source: MondoRescue/branches/stable/mindi-busybox/sysklogd/logger.c@ 1842

Last change on this file since 1842 was 1842, checked in by Bruno Cornec, 16 years ago
  • Fix lack of /etc/raidtab at restore rime in the right place
  • Adds support for nls_utf8 and pata_serverworks Patches from Dirk Husung (husung_at_tu-harburg.de)
  • Add efibootmgr to deplist.txt in order to be able to modify EFI menu at restore time on ia64
  • Usage of the new testver param of pb 0.8.12 to deliver 2.2.5 packages in a test dir.
  • Update pbcl files for upcoming delivery of 2.2.5
  • Fix an issue on parted output (K instead of KB) in parted2fdisk at restore time
  • Adds support for alb/aft types of bonding on Intel cards (Mark Pinkerton <Mark.Pinkerton_at_emageon.com>)
  • Escape variables in a perl script like mindi-bkphw
  • Better Proliant support at restore time now.
  • Fix a label bug where the variable label should also be re-initialized at each loop
  • start-nfs should NOT do exit => kernel panix as init exits
  • some other fixes for init on denymods
  • Adds boot options denymods (for udev) and forcemods (if not udev)
  • kqemu is denied. Probably should also be done for kvm stuff
  • Fix again the bug on modules link at root of the initrd. Hopefully for good.
  • Wait more around the USB CD emulated by iLO as it takes up to 5 seconds to come up
  • Attempt to fix udev support for RHEL 5.1
  • Better support for automatic iLO Virtual Media with udev
  • Some VMWare support improvements (however, it seems that VMWare support won't be possible anytime soon)
  • during init at restore time, copy all static evices availble for udev, as some distro implementation are no

t yet supported correctly for udev. Not very elegant, but should solve our current issues

  • Fedora 8 now supported as a build target for pb
  • svn.log removed.
  • dependencies reviewd for rhel_3
  • Attempt to fix the lack of modules loaded at restore time - especially fs device drivers
  • removes bkphw dir before potential creation
  • render mount command more vebose at restore time
  • Should fix #217
  • Increase BOOT_SIZE and EXTRA_SIZE to support features such as HW recovery
  • Handles udev.files files which could be symlinks
  • Improve udev support for distro with compressed modules (mdv e.g.)
  • Fix modules.dep copy
  • /sbin/pam_console_apply is needed by mdv udev conf
  • Adds support for nohw boot option to avoid re-setuping the HW conf
  • Improved support for Proliant on cpqacuxe
  • RstHW should be called after driver initialization
  • For debian/ubuntu mindi dpends on mindi-busybox
  • Update mindi-busybox pbcl for correct debian changelog generation, and up2date infos
  • Should fix #215
  • Fix #214 (Thanks to xdelaruelle)
  • Fix again svn.log not used anymore with new pb version
  • Adaptation of build process to upcoming 0.8.12 version of pb
  • Remove MONOTONIC clock to continue to support 2.4 kernels (RHEL 3 e.g. or ESX)
  • Attempt to solve ia64 BMC access through the serial port
  • parted2fdisk binary no more generated
  • do not require perl modules (strict.pm) at restore time
  • try to avoid modprobe messages at restore time
  • on ia64 now use the perl script parted2fdisk at retore time also
  • Also modprobe modules for udev after decompressing the additional ones
  • replace gzip -v9 by gzip -c9. Fix a bug at least on ia64
  • For all modules supported, create symlinks under the mountpoint and extract dev files as some are not automat ically created at the moment
  • Support /vmfs/volumes for ESX
  • Finally do not use vdf for ESX. Only creates issues.
  • Avoids continuing hw support if no product name found
  • Improves ia64 support for bootable image build
  • Fix a potential problem with ramdisk_blocksize param
  • MAKEDEV should also be included in deplist.txt
  • More fixes for udev support for Debian
  • Do not mount /boot if it's already mounted - avoids ESX hang
  • Fix NICs renumbering on Debian at least
  • Udev startup improvement to support iLO + NFS so modprobing all modules seems required as of now
  • Update to version 1.7.3 of busybox for pb
  • Load USB earlier in order to support KBD such as with iLO
  • Do busybox ldd first in order to create a potential /lib64 link correctly and then use it later in the image
  • Use variable DF in mindi to be able to support the ESX vdf
  • Fix mindi for Debian x86_64 where /lib64 is a link
  • Fix issue at restore time for ext2fs params not reused (Fix from Klaus Ade Johnstad <klaus_at_skolelinux.no>)
  • Do not copy udev files if they do not exist In udev case do not insert modules at all (udev should do it alone) May avoid the issue with rhel4.5 kernel ? To be tested
  • Update dependencies for rpm base build as well
  • And also perl is a debian/ubuntu dep
  • Better debian/ubuntu dependecies requirements (mtools)
  • Fix modes on mindi-bkphw (Thanks Phil Walker phil.walker_at_hp.com)
  • Complete rev [1771] for upper case RESTORE cli with syslinux as well
  • Update mindi-busybox to 1.7.3
  • Use RESTORE consistently across mondo to restore without interaction (report from Takeshi Shoji t.shoji_at_tripodw.jp)

(merge -r1769:1841 $SVN_M/branches/2.2.5)

File size: 4.6 KB
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * Mini logger implementation for busybox
4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */
9
10#include "libbb.h"
11
12#if !defined CONFIG_SYSLOGD
13
14#define SYSLOG_NAMES
15#include <sys/syslog.h>
16
17#else
18#include <sys/syslog.h>
19# ifndef __dietlibc__
20 /* We have to do this since the header file defines static
21 * structures. Argh.... bad libc, bad, bad...
22 */
23 typedef struct _code {
24 char *c_name;
25 int c_val;
26 } CODE;
27 extern CODE prioritynames[];
28 extern CODE facilitynames[];
29# endif
30#endif
31
32/* Decode a symbolic name to a numeric value
33 * this function is based on code
34 * Copyright (c) 1983, 1993
35 * The Regents of the University of California. All rights reserved.
36 *
37 * Original copyright notice is retained at the end of this file.
38 */
39static int decode(char *name, CODE * codetab)
40{
41 CODE *c;
42
43 if (isdigit(*name))
44 return atoi(name);
45 for (c = codetab; c->c_name; c++) {
46 if (!strcasecmp(name, c->c_name)) {
47 return c->c_val;
48 }
49 }
50
51 return -1;
52}
53
54/* Decode a symbolic name to a numeric value
55 * this function is based on code
56 * Copyright (c) 1983, 1993
57 * The Regents of the University of California. All rights reserved.
58 *
59 * Original copyright notice is retained at the end of this file.
60 */
61static int pencode(char *s)
62{
63 char *save;
64 int lev, fac = LOG_USER;
65
66 for (save = s; *s && *s != '.'; ++s)
67 ;
68 if (*s) {
69 *s = '\0';
70 fac = decode(save, facilitynames);
71 if (fac < 0)
72 bb_error_msg_and_die("unknown %s name: %s", "facility", save);
73 *s++ = '.';
74 } else {
75 s = save;
76 }
77 lev = decode(s, prioritynames);
78 if (lev < 0)
79 bb_error_msg_and_die("unknown %s name: %s", "priority", save);
80 return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
81}
82
83
84int logger_main(int argc, char **argv);
85int logger_main(int argc, char **argv)
86{
87 char *str_p, *str_t;
88 int i = 0;
89 char name[80];
90
91 /* Fill out the name string early (may be overwritten later) */
92 bb_getpwuid(name, sizeof(name), geteuid());
93 str_t = name;
94
95 /* Parse any options */
96 getopt32(argv, "p:st:", &str_p, &str_t);
97
98 if (option_mask32 & 0x2) /* -s */
99 i |= LOG_PERROR;
100 //if (option_mask32 & 0x4) /* -t */
101 openlog(str_t, i, 0);
102 i = LOG_USER | LOG_NOTICE;
103 if (option_mask32 & 0x1) /* -p */
104 i = pencode(str_p);
105
106 argc -= optind;
107 argv += optind;
108 if (!argc) {
109#define strbuf bb_common_bufsiz1
110 while (fgets(strbuf, COMMON_BUFSIZE, stdin)) {
111 if (strbuf[0]
112 && NOT_LONE_CHAR(strbuf, '\n')
113 ) {
114 /* Neither "" nor "\n" */
115 syslog(i, "%s", strbuf);
116 }
117 }
118 } else {
119 char *message = NULL;
120 int len = 0;
121 int pos = 0;
122 do {
123 len += strlen(*argv) + 1;
124 message = xrealloc(message, len + 1);
125 sprintf(message + pos, " %s", *argv),
126 pos = len;
127 } while (*++argv);
128 syslog(i, "%s", message + 1); /* skip leading " " */
129 }
130
131 closelog();
132 return EXIT_SUCCESS;
133}
134
135
136/*-
137 * Copyright (c) 1983, 1993
138 * The Regents of the University of California. All rights reserved.
139 *
140 * This is the original license statement for the decode and pencode functions.
141 *
142 * Redistribution and use in source and binary forms, with or without
143 * modification, are permitted provided that the following conditions
144 * are met:
145 * 1. Redistributions of source code must retain the above copyright
146 * notice, this list of conditions and the following disclaimer.
147 * 2. Redistributions in binary form must reproduce the above copyright
148 * notice, this list of conditions and the following disclaimer in the
149 * documentation and/or other materials provided with the distribution.
150 *
151 * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
152 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
153 *
154 * 4. Neither the name of the University nor the names of its contributors
155 * may be used to endorse or promote products derived from this software
156 * without specific prior written permission.
157 *
158 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
159 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
160 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
161 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
162 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
163 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
164 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
165 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
166 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
167 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
168 * SUCH DAMAGE.
169 */
Note: See TracBrowser for help on using the repository browser.