diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-07-19 22:28:02 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-07-19 22:28:02 +0000 |
commit | 20aab260e2f7011523402464fb079f48e5899890 (patch) | |
tree | f7822e652f54884459d525f57f1ef18c03a126f7 | |
parent | 0382eb886529fc4dab170e7d66883c20fe0e2883 (diff) | |
download | busybox-w32-20aab260e2f7011523402464fb079f48e5899890.tar.gz busybox-w32-20aab260e2f7011523402464fb079f48e5899890.tar.bz2 busybox-w32-20aab260e2f7011523402464fb079f48e5899890.zip |
Some adjustments, mostly from David McCullough <davidm@lineo.com> to
make busybox be more uClinux friendly. I also adjusted Config.h for
uClinux so it will automagically disable apps the arn't going to
work without fork() and such.
-Erik
-rw-r--r-- | Config.h | 13 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | coreutils/ls.c | 2 | ||||
-rw-r--r-- | coreutils/uudecode.c | 15 | ||||
-rw-r--r-- | editors/vi.c | 4 | ||||
-rw-r--r-- | kill.c | 5 | ||||
-rw-r--r-- | libbb/gz_open.c | 4 | ||||
-rw-r--r-- | libbb/interface.c | 7 | ||||
-rw-r--r-- | logger.c | 26 | ||||
-rw-r--r-- | ls.c | 2 | ||||
-rw-r--r-- | miscutils/update.c | 60 | ||||
-rw-r--r-- | networking/wget.c | 4 | ||||
-rw-r--r-- | procps/kill.c | 5 | ||||
-rw-r--r-- | sysklogd/logger.c | 26 | ||||
-rw-r--r-- | update.c | 60 | ||||
-rw-r--r-- | uudecode.c | 15 | ||||
-rw-r--r-- | vi.c | 4 | ||||
-rw-r--r-- | wget.c | 4 |
18 files changed, 149 insertions, 109 deletions
@@ -417,6 +417,19 @@ | |||
417 | // Nothing beyond this point should ever be touched by | 417 | // Nothing beyond this point should ever be touched by |
418 | // mere mortals so leave this stuff alone. | 418 | // mere mortals so leave this stuff alone. |
419 | // | 419 | // |
420 | #include <features.h> | ||
421 | #if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__ | ||
422 | #undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */ | ||
423 | #undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */ | ||
424 | #undef BB_FEATURE_ASH /* Uses fork() */ | ||
425 | #undef BB_FEATURE_HUSH /* Uses fork() */ | ||
426 | #undef BB_FEATURE_LASH /* Uses fork() */ | ||
427 | #undef BB_INIT /* Uses fork() */ | ||
428 | #undef BB_FEATURE_TAR_GZIP /* Uses fork() */ | ||
429 | #undef BB_SYSLOGD /* Uses daemon() */ | ||
430 | #undef BB_KLOGD /* Uses daemon() */ | ||
431 | #undef BB_UPDATE /* Uses daemon() */ | ||
432 | #endif | ||
420 | #if defined BB_SH | 433 | #if defined BB_SH |
421 | #if defined BB_FEATURE_COMMAND_EDITING | 434 | #if defined BB_FEATURE_COMMAND_EDITING |
422 | #define BB_CMDEDIT | 435 | #define BB_CMDEDIT |
@@ -396,7 +396,7 @@ clean: | |||
396 | docs/busybox.lineo.com/BusyBox.html | 396 | docs/busybox.lineo.com/BusyBox.html |
397 | - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \ | 397 | - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \ |
398 | docs/busybox.pdf docs/busybox.lineo.com/busybox.html | 398 | docs/busybox.pdf docs/busybox.lineo.com/busybox.html |
399 | - rm -f multibuild.log Config.h.orig | 399 | - rm -f multibuild.log Config.h.orig *.gdb *.elf |
400 | - rm -rf docs/busybox _install libpwd.a libbb.a pod2htm* | 400 | - rm -rf docs/busybox _install libpwd.a libbb.a pod2htm* |
401 | - rm -f busybox.links libbb/loop.h *~ slist.mk core applet_source_list | 401 | - rm -f busybox.links libbb/loop.h *~ slist.mk core applet_source_list |
402 | - find -name \*.o -exec rm -f {} \; | 402 | - find -name \*.o -exec rm -f {} \; |
diff --git a/coreutils/ls.c b/coreutils/ls.c index bd79cc940..10191476e 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -303,6 +303,7 @@ static struct dnode **dnalloc(int num) | |||
303 | return(p); | 303 | return(p); |
304 | } | 304 | } |
305 | 305 | ||
306 | #ifdef BB_FEATURE_LS_RECURSIVE | ||
306 | static void dfree(struct dnode **dnp) | 307 | static void dfree(struct dnode **dnp) |
307 | { | 308 | { |
308 | struct dnode *cur, *next; | 309 | struct dnode *cur, *next; |
@@ -318,6 +319,7 @@ static void dfree(struct dnode **dnp) | |||
318 | } | 319 | } |
319 | free(dnp); /* free the array holding the dnode pointers */ | 320 | free(dnp); /* free the array holding the dnode pointers */ |
320 | } | 321 | } |
322 | #endif | ||
321 | 323 | ||
322 | static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which) | 324 | static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which) |
323 | { | 325 | { |
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 6a3f78a42..6ac9f1bf3 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -207,6 +207,8 @@ static int decode (const char *inname, | |||
207 | char buf[2 * BUFSIZ]; | 207 | char buf[2 * BUFSIZ]; |
208 | char *outname; | 208 | char *outname; |
209 | int do_base64 = 0; | 209 | int do_base64 = 0; |
210 | int res; | ||
211 | int dofre; | ||
210 | 212 | ||
211 | /* Search for header line. */ | 213 | /* Search for header line. */ |
212 | 214 | ||
@@ -226,6 +228,7 @@ static int decode (const char *inname, | |||
226 | } | 228 | } |
227 | 229 | ||
228 | /* If the output file name is given on the command line this rules. */ | 230 | /* If the output file name is given on the command line this rules. */ |
231 | dofre = FALSE; | ||
229 | if (forced_outname != NULL) | 232 | if (forced_outname != NULL) |
230 | outname = (char *) forced_outname; | 233 | outname = (char *) forced_outname; |
231 | else { | 234 | else { |
@@ -248,10 +251,11 @@ static int decode (const char *inname, | |||
248 | } | 251 | } |
249 | n = strlen (pw->pw_dir); | 252 | n = strlen (pw->pw_dir); |
250 | n1 = strlen (p); | 253 | n1 = strlen (p); |
251 | outname = (char *) alloca ((size_t) (n + n1 + 2)); | 254 | outname = (char *) xmalloc ((size_t) (n + n1 + 2)); |
252 | memcpy (outname + n + 1, p, (size_t) (n1 + 1)); | 255 | memcpy (outname + n + 1, p, (size_t) (n1 + 1)); |
253 | memcpy (outname, pw->pw_dir, (size_t) n); | 256 | memcpy (outname, pw->pw_dir, (size_t) n); |
254 | outname[n] = '/'; | 257 | outname[n] = '/'; |
258 | dofre = TRUE; | ||
255 | } | 259 | } |
256 | } | 260 | } |
257 | 261 | ||
@@ -261,6 +265,8 @@ static int decode (const char *inname, | |||
261 | || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) | 265 | || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) |
262 | )) { | 266 | )) { |
263 | perror_msg("%s", outname); /* */ | 267 | perror_msg("%s", outname); /* */ |
268 | if (dofre) | ||
269 | free(outname); | ||
264 | return FALSE; | 270 | return FALSE; |
265 | } | 271 | } |
266 | 272 | ||
@@ -269,9 +275,12 @@ static int decode (const char *inname, | |||
269 | 275 | ||
270 | /* For each input line: */ | 276 | /* For each input line: */ |
271 | if (do_base64) | 277 | if (do_base64) |
272 | return read_base64 (inname); | 278 | res = read_base64 (inname); |
273 | else | 279 | else |
274 | return read_stduu (inname); | 280 | res = read_stduu (inname); |
281 | if (dofre) | ||
282 | free(outname); | ||
283 | return res; | ||
275 | } | 284 | } |
276 | 285 | ||
277 | int uudecode_main (int argc, | 286 | int uudecode_main (int argc, |
diff --git a/editors/vi.c b/editors/vi.c index f75c884eb..cfdc29fcb 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | static const char vi_Version[] = | 21 | static const char vi_Version[] = |
22 | "$Id: vi.c,v 1.12 2001/07/17 01:12:36 andersen Exp $"; | 22 | "$Id: vi.c,v 1.13 2001/07/19 22:28:01 andersen Exp $"; |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * To compile for standalone use: | 25 | * To compile for standalone use: |
@@ -3554,7 +3554,7 @@ static int file_write(Byte * fn, Byte * first, Byte * last) | |||
3554 | } | 3554 | } |
3555 | charcnt = 0; | 3555 | charcnt = 0; |
3556 | // FIXIT- use the correct umask() | 3556 | // FIXIT- use the correct umask() |
3557 | fd = open((char *) fn, (O_RDWR | O_CREAT | O_TRUNC), 0664); | 3557 | fd = open((char *) fn, (O_WRONLY | O_CREAT | O_TRUNC), 0664); |
3558 | if (fd < 0) | 3558 | if (fd < 0) |
3559 | return (-1); | 3559 | return (-1); |
3560 | cnt = last - first + 1; | 3560 | cnt = last - first + 1; |
@@ -147,9 +147,8 @@ extern int kill_main(int argc, char **argv) | |||
147 | const struct signal_name *s = signames; | 147 | const struct signal_name *s = signames; |
148 | 148 | ||
149 | while (s->name != 0) { | 149 | while (s->name != 0) { |
150 | col += | 150 | col += fprintf(stderr, "%2d) %-8s", s->number, s->name); |
151 | fprintf(stderr, "%2d) %-8s", s->number, | 151 | s++; |
152 | (s++)->name); | ||
153 | if (col > 60) { | 152 | if (col > 60) { |
154 | fprintf(stderr, "\n"); | 153 | fprintf(stderr, "\n"); |
155 | col = 0; | 154 | col = 0; |
diff --git a/libbb/gz_open.c b/libbb/gz_open.c index b23920b16..ef30ff894 100644 --- a/libbb/gz_open.c +++ b/libbb/gz_open.c | |||
@@ -15,7 +15,7 @@ extern FILE *gz_open(FILE *compressed_file, int *pid) | |||
15 | return(NULL); | 15 | return(NULL); |
16 | } | 16 | } |
17 | if ((*pid = fork()) == -1) { | 17 | if ((*pid = fork()) == -1) { |
18 | error_msg("fork failured"); | 18 | error_msg("fork failed"); |
19 | return(NULL); | 19 | return(NULL); |
20 | } | 20 | } |
21 | if (*pid==0) { | 21 | if (*pid==0) { |
@@ -29,7 +29,7 @@ extern FILE *gz_open(FILE *compressed_file, int *pid) | |||
29 | } | 29 | } |
30 | close(unzip_pipe[1]); | 30 | close(unzip_pipe[1]); |
31 | if (unzip_pipe[0] == -1) { | 31 | if (unzip_pipe[0] == -1) { |
32 | error_msg("Couldnt initialise gzip stream"); | 32 | error_msg("gzip stream init failed"); |
33 | } | 33 | } |
34 | return(fdopen(unzip_pipe[0], "r")); | 34 | return(fdopen(unzip_pipe[0], "r")); |
35 | } | 35 | } |
diff --git a/libbb/interface.c b/libbb/interface.c index 8eb03a61c..484597c5f 100644 --- a/libbb/interface.c +++ b/libbb/interface.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * that either displays or sets the characteristics of | 3 | * that either displays or sets the characteristics of |
4 | * one or more of the system's networking interfaces. | 4 | * one or more of the system's networking interfaces. |
5 | * | 5 | * |
6 | * Version: $Id: interface.c,v 1.3 2001/06/01 21:47:15 andersen Exp $ | 6 | * Version: $Id: interface.c,v 1.4 2001/07/19 22:28:02 andersen Exp $ |
7 | * | 7 | * |
8 | * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> | 8 | * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> |
9 | * and others. Copyright 1993 MicroWalt Corporation | 9 | * and others. Copyright 1993 MicroWalt Corporation |
@@ -78,7 +78,9 @@ | |||
78 | #include <netdb.h> | 78 | #include <netdb.h> |
79 | #include <netinet/in.h> | 79 | #include <netinet/in.h> |
80 | #include <arpa/inet.h> | 80 | #include <arpa/inet.h> |
81 | #if 0 | ||
81 | #include <arpa/nameser.h> | 82 | #include <arpa/nameser.h> |
83 | #endif | ||
82 | #include "libbb.h" | 84 | #include "libbb.h" |
83 | 85 | ||
84 | #define _(x) x | 86 | #define _(x) x |
@@ -455,9 +457,11 @@ static int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, | |||
455 | #ifdef DEBUG | 457 | #ifdef DEBUG |
456 | fprintf (stderr, "getnetbyaddr (%08lx)\n", host_ad); | 458 | fprintf (stderr, "getnetbyaddr (%08lx)\n", host_ad); |
457 | #endif | 459 | #endif |
460 | #if 0 | ||
458 | np = getnetbyaddr(host_ad, AF_INET); | 461 | np = getnetbyaddr(host_ad, AF_INET); |
459 | if (np != NULL) | 462 | if (np != NULL) |
460 | safe_strncpy(name, np->n_name, len); | 463 | safe_strncpy(name, np->n_name, len); |
464 | #endif | ||
461 | } | 465 | } |
462 | if ((ent == NULL) && (np == NULL)) | 466 | if ((ent == NULL) && (np == NULL)) |
463 | safe_strncpy(name, inet_ntoa(s_in->sin_addr), len); | 467 | safe_strncpy(name, inet_ntoa(s_in->sin_addr), len); |
@@ -1068,7 +1072,6 @@ static int if_readconf(void) | |||
1068 | struct ifconf ifc; | 1072 | struct ifconf ifc; |
1069 | struct ifreq *ifr; | 1073 | struct ifreq *ifr; |
1070 | int n, err = -1; | 1074 | int n, err = -1; |
1071 | /* XXX Should this re-use the global skfd? */ | ||
1072 | int skfd2; | 1075 | int skfd2; |
1073 | 1076 | ||
1074 | /* SIOCGIFCONF currently seems to only work properly on AF_INET sockets | 1077 | /* SIOCGIFCONF currently seems to only work properly on AF_INET sockets |
@@ -127,14 +127,20 @@ extern int logger_main(int argc, char **argv) | |||
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | openlog(name, option, (pri | LOG_FACMASK)); | ||
130 | if (optind == argc) { | 131 | if (optind == argc) { |
131 | /* read from stdin */ | 132 | do { |
132 | i = 0; | 133 | /* read from stdin */ |
133 | while ((c = getc(stdin)) != EOF && i < sizeof(buf)) { | 134 | i = 0; |
134 | buf[i++] = c; | 135 | while ((c = getc(stdin)) != EOF && c != '\n' && |
135 | } | 136 | i < (sizeof(buf)-1)) { |
136 | buf[i++] = '\0'; | 137 | buf[i++] = c; |
137 | message = buf; | 138 | } |
139 | if (i > 0) { | ||
140 | buf[i++] = '\0'; | ||
141 | syslog(pri, "%s", buf); | ||
142 | } | ||
143 | } while (c != EOF); | ||
138 | } else { | 144 | } else { |
139 | len = 1; /* for the '\0' */ | 145 | len = 1; /* for the '\0' */ |
140 | message=xcalloc(1, 1); | 146 | message=xcalloc(1, 1); |
@@ -146,12 +152,10 @@ extern int logger_main(int argc, char **argv) | |||
146 | strcat(message, " "); | 152 | strcat(message, " "); |
147 | } | 153 | } |
148 | message[strlen(message)-1] = '\0'; | 154 | message[strlen(message)-1] = '\0'; |
155 | syslog(pri, "%s", message); | ||
149 | } | 156 | } |
150 | 157 | ||
151 | /*openlog(name, option, (pri | LOG_FACMASK)); | 158 | closelog(); |
152 | syslog(pri, "%s", message); | ||
153 | closelog();*/ | ||
154 | syslog_msg_with_name(name,(pri | LOG_FACMASK),pri,message); | ||
155 | return EXIT_SUCCESS; | 159 | return EXIT_SUCCESS; |
156 | } | 160 | } |
157 | 161 | ||
@@ -303,6 +303,7 @@ static struct dnode **dnalloc(int num) | |||
303 | return(p); | 303 | return(p); |
304 | } | 304 | } |
305 | 305 | ||
306 | #ifdef BB_FEATURE_LS_RECURSIVE | ||
306 | static void dfree(struct dnode **dnp) | 307 | static void dfree(struct dnode **dnp) |
307 | { | 308 | { |
308 | struct dnode *cur, *next; | 309 | struct dnode *cur, *next; |
@@ -318,6 +319,7 @@ static void dfree(struct dnode **dnp) | |||
318 | } | 319 | } |
319 | free(dnp); /* free the array holding the dnode pointers */ | 320 | free(dnp); /* free the array holding the dnode pointers */ |
320 | } | 321 | } |
322 | #endif | ||
321 | 323 | ||
322 | static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which) | 324 | static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which) |
323 | { | 325 | { |
diff --git a/miscutils/update.c b/miscutils/update.c index a6550b05c..603740e38 100644 --- a/miscutils/update.c +++ b/miscutils/update.c | |||
@@ -65,46 +65,44 @@ extern int update_main(int argc, char **argv) | |||
65 | show_usage(); | 65 | show_usage(); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | |||
69 | if (daemon(0, 1) < 0) | ||
70 | perror_msg_and_die("daemon"); | ||
68 | 71 | ||
69 | pid = fork(); | 72 | /* Become a proper daemon */ |
70 | if (pid < 0) | 73 | setsid(); |
71 | return EXIT_FAILURE; | 74 | chdir("/"); |
72 | else if (pid == 0) { | ||
73 | /* Become a proper daemon */ | ||
74 | setsid(); | ||
75 | chdir("/"); | ||
76 | #ifdef OPEN_MAX | 75 | #ifdef OPEN_MAX |
77 | for (pid = 0; pid < OPEN_MAX; pid++) close(pid); | 76 | for (pid = 0; pid < OPEN_MAX; pid++) close(pid); |
78 | #else | 77 | #else |
79 | /* glibc 2.1.92 requires using sysconf(_SC_OPEN_MAX) */ | 78 | /* glibc 2.1.92 requires using sysconf(_SC_OPEN_MAX) */ |
80 | for (pid = 0; pid < sysconf(_SC_OPEN_MAX); pid++) close(pid); | 79 | for (pid = 0; pid < sysconf(_SC_OPEN_MAX); pid++) close(pid); |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | /* | 82 | /* This is no longer necessary since 1.3.5x, but it will harmlessly |
84 | * This is no longer necessary since 1.3.5x, but it will harmlessly | 83 | * exit if that is the case. |
85 | * exit if that is the case. | 84 | */ |
86 | */ | ||
87 | 85 | ||
88 | /* set the program name that will show up in a 'ps' listing */ | 86 | /* set the program name that will show up in a 'ps' listing */ |
89 | argv[0] = "bdflush (update)"; | 87 | argv[0] = "bdflush (update)"; |
90 | argv[1] = NULL; | 88 | argv[1] = NULL; |
91 | argv[2] = NULL; | 89 | argv[2] = NULL; |
92 | for (;;) { | 90 | for (;;) { |
93 | if (use_sync) { | 91 | if (use_sync) { |
94 | sleep(sync_duration); | 92 | sleep(sync_duration); |
95 | sync(); | 93 | sync(); |
96 | } else { | 94 | } else { |
97 | sleep(flush_duration); | 95 | sleep(flush_duration); |
98 | if (bdflush(1, 0) < 0) { | 96 | if (bdflush(1, 0) < 0) { |
99 | openlog("update", LOG_CONS, LOG_DAEMON); | 97 | openlog("update", LOG_CONS, LOG_DAEMON); |
100 | syslog(LOG_INFO, | 98 | syslog(LOG_INFO, |
101 | "This kernel does not need update(8). Exiting."); | 99 | "This kernel does not need update(8). Exiting."); |
102 | closelog(); | 100 | closelog(); |
103 | return EXIT_SUCCESS; | 101 | return EXIT_SUCCESS; |
104 | } | ||
105 | } | 102 | } |
106 | } | 103 | } |
107 | } | 104 | } |
105 | |||
108 | return EXIT_SUCCESS; | 106 | return EXIT_SUCCESS; |
109 | } | 107 | } |
110 | 108 | ||
diff --git a/networking/wget.c b/networking/wget.c index 009e0c819..59373d1d9 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -56,12 +56,12 @@ static void parse_url(char *url, struct host_info *h); | |||
56 | static FILE *open_socket(char *host, int port); | 56 | static FILE *open_socket(char *host, int port); |
57 | static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc); | 57 | static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc); |
58 | static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); | 58 | static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); |
59 | static void progressmeter(int flag); | ||
60 | 59 | ||
61 | /* Globals (can be accessed from signal handlers */ | 60 | /* Globals (can be accessed from signal handlers */ |
62 | static off_t filesize = 0; /* content-length of the file */ | 61 | static off_t filesize = 0; /* content-length of the file */ |
63 | static int chunked = 0; /* chunked transfer encoding */ | 62 | static int chunked = 0; /* chunked transfer encoding */ |
64 | #ifdef BB_FEATURE_WGET_STATUSBAR | 63 | #ifdef BB_FEATURE_WGET_STATUSBAR |
64 | static void progressmeter(int flag); | ||
65 | static char *curfile; /* Name of current file being transferred. */ | 65 | static char *curfile; /* Name of current file being transferred. */ |
66 | static struct timeval start; /* Time a transfer started. */ | 66 | static struct timeval start; /* Time a transfer started. */ |
67 | static volatile unsigned long statbytes = 0; /* Number of bytes transferred so far. */ | 67 | static volatile unsigned long statbytes = 0; /* Number of bytes transferred so far. */ |
@@ -817,7 +817,7 @@ progressmeter(int flag) | |||
817 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 817 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
818 | * SUCH DAMAGE. | 818 | * SUCH DAMAGE. |
819 | * | 819 | * |
820 | * $Id: wget.c,v 1.44 2001/07/19 19:13:55 kraai Exp $ | 820 | * $Id: wget.c,v 1.45 2001/07/19 22:28:01 andersen Exp $ |
821 | */ | 821 | */ |
822 | 822 | ||
823 | 823 | ||
diff --git a/procps/kill.c b/procps/kill.c index 8745f63c1..34cbc4d6a 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -147,9 +147,8 @@ extern int kill_main(int argc, char **argv) | |||
147 | const struct signal_name *s = signames; | 147 | const struct signal_name *s = signames; |
148 | 148 | ||
149 | while (s->name != 0) { | 149 | while (s->name != 0) { |
150 | col += | 150 | col += fprintf(stderr, "%2d) %-8s", s->number, s->name); |
151 | fprintf(stderr, "%2d) %-8s", s->number, | 151 | s++; |
152 | (s++)->name); | ||
153 | if (col > 60) { | 152 | if (col > 60) { |
154 | fprintf(stderr, "\n"); | 153 | fprintf(stderr, "\n"); |
155 | col = 0; | 154 | col = 0; |
diff --git a/sysklogd/logger.c b/sysklogd/logger.c index b8aae3d28..623a4f9e5 100644 --- a/sysklogd/logger.c +++ b/sysklogd/logger.c | |||
@@ -127,14 +127,20 @@ extern int logger_main(int argc, char **argv) | |||
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | openlog(name, option, (pri | LOG_FACMASK)); | ||
130 | if (optind == argc) { | 131 | if (optind == argc) { |
131 | /* read from stdin */ | 132 | do { |
132 | i = 0; | 133 | /* read from stdin */ |
133 | while ((c = getc(stdin)) != EOF && i < sizeof(buf)) { | 134 | i = 0; |
134 | buf[i++] = c; | 135 | while ((c = getc(stdin)) != EOF && c != '\n' && |
135 | } | 136 | i < (sizeof(buf)-1)) { |
136 | buf[i++] = '\0'; | 137 | buf[i++] = c; |
137 | message = buf; | 138 | } |
139 | if (i > 0) { | ||
140 | buf[i++] = '\0'; | ||
141 | syslog(pri, "%s", buf); | ||
142 | } | ||
143 | } while (c != EOF); | ||
138 | } else { | 144 | } else { |
139 | len = 1; /* for the '\0' */ | 145 | len = 1; /* for the '\0' */ |
140 | message=xcalloc(1, 1); | 146 | message=xcalloc(1, 1); |
@@ -146,12 +152,10 @@ extern int logger_main(int argc, char **argv) | |||
146 | strcat(message, " "); | 152 | strcat(message, " "); |
147 | } | 153 | } |
148 | message[strlen(message)-1] = '\0'; | 154 | message[strlen(message)-1] = '\0'; |
155 | syslog(pri, "%s", message); | ||
149 | } | 156 | } |
150 | 157 | ||
151 | /*openlog(name, option, (pri | LOG_FACMASK)); | 158 | closelog(); |
152 | syslog(pri, "%s", message); | ||
153 | closelog();*/ | ||
154 | syslog_msg_with_name(name,(pri | LOG_FACMASK),pri,message); | ||
155 | return EXIT_SUCCESS; | 159 | return EXIT_SUCCESS; |
156 | } | 160 | } |
157 | 161 | ||
@@ -65,46 +65,44 @@ extern int update_main(int argc, char **argv) | |||
65 | show_usage(); | 65 | show_usage(); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | |||
69 | if (daemon(0, 1) < 0) | ||
70 | perror_msg_and_die("daemon"); | ||
68 | 71 | ||
69 | pid = fork(); | 72 | /* Become a proper daemon */ |
70 | if (pid < 0) | 73 | setsid(); |
71 | return EXIT_FAILURE; | 74 | chdir("/"); |
72 | else if (pid == 0) { | ||
73 | /* Become a proper daemon */ | ||
74 | setsid(); | ||
75 | chdir("/"); | ||
76 | #ifdef OPEN_MAX | 75 | #ifdef OPEN_MAX |
77 | for (pid = 0; pid < OPEN_MAX; pid++) close(pid); | 76 | for (pid = 0; pid < OPEN_MAX; pid++) close(pid); |
78 | #else | 77 | #else |
79 | /* glibc 2.1.92 requires using sysconf(_SC_OPEN_MAX) */ | 78 | /* glibc 2.1.92 requires using sysconf(_SC_OPEN_MAX) */ |
80 | for (pid = 0; pid < sysconf(_SC_OPEN_MAX); pid++) close(pid); | 79 | for (pid = 0; pid < sysconf(_SC_OPEN_MAX); pid++) close(pid); |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | /* | 82 | /* This is no longer necessary since 1.3.5x, but it will harmlessly |
84 | * This is no longer necessary since 1.3.5x, but it will harmlessly | 83 | * exit if that is the case. |
85 | * exit if that is the case. | 84 | */ |
86 | */ | ||
87 | 85 | ||
88 | /* set the program name that will show up in a 'ps' listing */ | 86 | /* set the program name that will show up in a 'ps' listing */ |
89 | argv[0] = "bdflush (update)"; | 87 | argv[0] = "bdflush (update)"; |
90 | argv[1] = NULL; | 88 | argv[1] = NULL; |
91 | argv[2] = NULL; | 89 | argv[2] = NULL; |
92 | for (;;) { | 90 | for (;;) { |
93 | if (use_sync) { | 91 | if (use_sync) { |
94 | sleep(sync_duration); | 92 | sleep(sync_duration); |
95 | sync(); | 93 | sync(); |
96 | } else { | 94 | } else { |
97 | sleep(flush_duration); | 95 | sleep(flush_duration); |
98 | if (bdflush(1, 0) < 0) { | 96 | if (bdflush(1, 0) < 0) { |
99 | openlog("update", LOG_CONS, LOG_DAEMON); | 97 | openlog("update", LOG_CONS, LOG_DAEMON); |
100 | syslog(LOG_INFO, | 98 | syslog(LOG_INFO, |
101 | "This kernel does not need update(8). Exiting."); | 99 | "This kernel does not need update(8). Exiting."); |
102 | closelog(); | 100 | closelog(); |
103 | return EXIT_SUCCESS; | 101 | return EXIT_SUCCESS; |
104 | } | ||
105 | } | 102 | } |
106 | } | 103 | } |
107 | } | 104 | } |
105 | |||
108 | return EXIT_SUCCESS; | 106 | return EXIT_SUCCESS; |
109 | } | 107 | } |
110 | 108 | ||
diff --git a/uudecode.c b/uudecode.c index 6a3f78a42..6ac9f1bf3 100644 --- a/uudecode.c +++ b/uudecode.c | |||
@@ -207,6 +207,8 @@ static int decode (const char *inname, | |||
207 | char buf[2 * BUFSIZ]; | 207 | char buf[2 * BUFSIZ]; |
208 | char *outname; | 208 | char *outname; |
209 | int do_base64 = 0; | 209 | int do_base64 = 0; |
210 | int res; | ||
211 | int dofre; | ||
210 | 212 | ||
211 | /* Search for header line. */ | 213 | /* Search for header line. */ |
212 | 214 | ||
@@ -226,6 +228,7 @@ static int decode (const char *inname, | |||
226 | } | 228 | } |
227 | 229 | ||
228 | /* If the output file name is given on the command line this rules. */ | 230 | /* If the output file name is given on the command line this rules. */ |
231 | dofre = FALSE; | ||
229 | if (forced_outname != NULL) | 232 | if (forced_outname != NULL) |
230 | outname = (char *) forced_outname; | 233 | outname = (char *) forced_outname; |
231 | else { | 234 | else { |
@@ -248,10 +251,11 @@ static int decode (const char *inname, | |||
248 | } | 251 | } |
249 | n = strlen (pw->pw_dir); | 252 | n = strlen (pw->pw_dir); |
250 | n1 = strlen (p); | 253 | n1 = strlen (p); |
251 | outname = (char *) alloca ((size_t) (n + n1 + 2)); | 254 | outname = (char *) xmalloc ((size_t) (n + n1 + 2)); |
252 | memcpy (outname + n + 1, p, (size_t) (n1 + 1)); | 255 | memcpy (outname + n + 1, p, (size_t) (n1 + 1)); |
253 | memcpy (outname, pw->pw_dir, (size_t) n); | 256 | memcpy (outname, pw->pw_dir, (size_t) n); |
254 | outname[n] = '/'; | 257 | outname[n] = '/'; |
258 | dofre = TRUE; | ||
255 | } | 259 | } |
256 | } | 260 | } |
257 | 261 | ||
@@ -261,6 +265,8 @@ static int decode (const char *inname, | |||
261 | || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) | 265 | || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) |
262 | )) { | 266 | )) { |
263 | perror_msg("%s", outname); /* */ | 267 | perror_msg("%s", outname); /* */ |
268 | if (dofre) | ||
269 | free(outname); | ||
264 | return FALSE; | 270 | return FALSE; |
265 | } | 271 | } |
266 | 272 | ||
@@ -269,9 +275,12 @@ static int decode (const char *inname, | |||
269 | 275 | ||
270 | /* For each input line: */ | 276 | /* For each input line: */ |
271 | if (do_base64) | 277 | if (do_base64) |
272 | return read_base64 (inname); | 278 | res = read_base64 (inname); |
273 | else | 279 | else |
274 | return read_stduu (inname); | 280 | res = read_stduu (inname); |
281 | if (dofre) | ||
282 | free(outname); | ||
283 | return res; | ||
275 | } | 284 | } |
276 | 285 | ||
277 | int uudecode_main (int argc, | 286 | int uudecode_main (int argc, |
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | static const char vi_Version[] = | 21 | static const char vi_Version[] = |
22 | "$Id: vi.c,v 1.12 2001/07/17 01:12:36 andersen Exp $"; | 22 | "$Id: vi.c,v 1.13 2001/07/19 22:28:01 andersen Exp $"; |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * To compile for standalone use: | 25 | * To compile for standalone use: |
@@ -3554,7 +3554,7 @@ static int file_write(Byte * fn, Byte * first, Byte * last) | |||
3554 | } | 3554 | } |
3555 | charcnt = 0; | 3555 | charcnt = 0; |
3556 | // FIXIT- use the correct umask() | 3556 | // FIXIT- use the correct umask() |
3557 | fd = open((char *) fn, (O_RDWR | O_CREAT | O_TRUNC), 0664); | 3557 | fd = open((char *) fn, (O_WRONLY | O_CREAT | O_TRUNC), 0664); |
3558 | if (fd < 0) | 3558 | if (fd < 0) |
3559 | return (-1); | 3559 | return (-1); |
3560 | cnt = last - first + 1; | 3560 | cnt = last - first + 1; |
@@ -56,12 +56,12 @@ static void parse_url(char *url, struct host_info *h); | |||
56 | static FILE *open_socket(char *host, int port); | 56 | static FILE *open_socket(char *host, int port); |
57 | static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc); | 57 | static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc); |
58 | static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); | 58 | static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); |
59 | static void progressmeter(int flag); | ||
60 | 59 | ||
61 | /* Globals (can be accessed from signal handlers */ | 60 | /* Globals (can be accessed from signal handlers */ |
62 | static off_t filesize = 0; /* content-length of the file */ | 61 | static off_t filesize = 0; /* content-length of the file */ |
63 | static int chunked = 0; /* chunked transfer encoding */ | 62 | static int chunked = 0; /* chunked transfer encoding */ |
64 | #ifdef BB_FEATURE_WGET_STATUSBAR | 63 | #ifdef BB_FEATURE_WGET_STATUSBAR |
64 | static void progressmeter(int flag); | ||
65 | static char *curfile; /* Name of current file being transferred. */ | 65 | static char *curfile; /* Name of current file being transferred. */ |
66 | static struct timeval start; /* Time a transfer started. */ | 66 | static struct timeval start; /* Time a transfer started. */ |
67 | static volatile unsigned long statbytes = 0; /* Number of bytes transferred so far. */ | 67 | static volatile unsigned long statbytes = 0; /* Number of bytes transferred so far. */ |
@@ -817,7 +817,7 @@ progressmeter(int flag) | |||
817 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 817 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
818 | * SUCH DAMAGE. | 818 | * SUCH DAMAGE. |
819 | * | 819 | * |
820 | * $Id: wget.c,v 1.44 2001/07/19 19:13:55 kraai Exp $ | 820 | * $Id: wget.c,v 1.45 2001/07/19 22:28:01 andersen Exp $ |
821 | */ | 821 | */ |
822 | 822 | ||
823 | 823 | ||