From fb74a4508876d4e11a5d3444fe74d083354d081a Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 18 Dec 2001 14:06:03 +0000 Subject: Vodz' last_patch31 Very minimal last corrections: 1) busybox.c: fix warining 2) docs/: add applets for list from pwd_grp 3) usage.h: add -n option for route 4) run_parts.c: many todo fix for busybox style 5) addgroup.c: add #ifdef CONFIG_FEATURE_SHADOWPASSWDS, reduce one perror_msg 6) adduser.c: fix bug "variable i not initialize" and add #ifdef CONFIG_FEATURE_SHADOWPASSWDS --- applets/busybox.c | 2 +- docs/busybox.sgml | 34 +++++++++++-------- docs/busybox_footer.pod | 4 +-- docs/busybox_header.pod | 27 +++++++-------- include/usage.h | 2 ++ init/run_parts.c | 89 +++++++++++++------------------------------------ 6 files changed, 63 insertions(+), 95 deletions(-) diff --git a/applets/busybox.c b/applets/busybox.c index e6e5eca2d..858358175 100644 --- a/applets/busybox.c +++ b/applets/busybox.c @@ -35,7 +35,7 @@ typedef int (*__link_f)(const char *, const char *); * malloc'd string w/ full pathname of busybox's location * NULL on failure */ -static char *busybox_fullpath() +static char *busybox_fullpath(void) { return xreadlink("/proc/self/exe"); } diff --git a/docs/busybox.sgml b/docs/busybox.sgml index 34559dab4..0a2683faf 100644 --- a/docs/busybox.sgml +++ b/docs/busybox.sgml @@ -136,19 +136,23 @@ - ar, basename, cat, chgrp, chmod, chown, chroot, chvt, clear, - cp, cut, date, dc, dd, deallocvt, df, dirname, dmesg, dpkg-deb, - du, dumpkmap, dutmp, echo, false, fbset, fdflush, find, free, - freeramdisk, fsck.minix, grep, gunzip, gzip, halt, head, - hostid, hostname, id, init, insmod, kill, killall, length, ln, - loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, - makedevs, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, - more, mount, mt, mv, nc, nslookup, ping, poweroff, printf, ps, - pwd, reboot, renice, reset, rm, rmdir, rmmod, run-parts, sed, setkeycodes, sh, sleep, - sort, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet, - test, touch, tr, true, tty, umount, uname, uniq, update, - uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, - zcat, [ + addgroup, adduser, adjtimex, ar, basename, busybox, cat, + chgrp, chmod, chown, chroot, chvt, clear, cmp, cp, cpio, cut, + date, dc, dd, deallocvt, deluser, df, dirname, dmesg, + dos2unix, dpkg, dpkg-deb, du, dumpkmap, dutmp, echo, expr, + false, fbset, fdflush, find, free, freeramdisk, fsck.minix, + getopt, getty, grep, gunzip, gzip, halt, head, hostid, + hostname, id, ifconfig, init, insmod, kill, killall, klogd, + length, ln, loadacm, loadfont, loadkmap, logger, logname, ls, + lsmod, makedevs, md5sum, mkdir, mkfifo, mkfs.minix, mknod, + mkswap, mktemp, more, mount, mt, mv, nc, nslookup, ping, + pivot_root, poweroff, printf, ps, pwd, rdate, readlink, + reboot, renice, reset, rm, rmdir, rmmod, route, rpm2cpio, + sed, setkeycodes, sh, sleep, sort, stty, swapoff, swapon, + sync, syslogd, tail, tar, tee, telnet, test, tftp, touch, tr, + true, tty, umount, uname, uniq, unix2dos, update, uptime, + usleep, uudecode, uuencode, watchdog, wc, wget, which, + whoami, xargs, yes, zcat, [ @@ -3996,6 +4000,10 @@ Enrique Zanardi <ezanardi@ull.es> + + Vladimir Oleynik <dzo@simtreas.ru> + + diff --git a/docs/busybox_footer.pod b/docs/busybox_footer.pod index 2ab4e166e..7c02003fc 100644 --- a/docs/busybox_footer.pod +++ b/docs/busybox_footer.pod @@ -113,7 +113,7 @@ Glenn McGrath Vladimir Oleynik - cmdedit, stty-port, locale, various fixes + cmdedit; ports: ash, stty, traceroute; locale, various fixes and irreconcilable critic of everything not perfect. =for html
@@ -166,4 +166,4 @@ Enrique Zanardi =cut -# $Id: busybox_footer.pod,v 1.4 2001/04/17 17:09:34 beppu Exp $ +# $Id: busybox_footer.pod,v 1.5 2001/12/18 14:06:01 andersen Exp $ diff --git a/docs/busybox_header.pod b/docs/busybox_header.pod index 764d6e35f..0ea7dbfe7 100644 --- a/docs/busybox_header.pod +++ b/docs/busybox_header.pod @@ -55,19 +55,20 @@ terse runtime description of their behavior. Currently defined functions include: -adjtimex, ar, basename, busybox, cat, chgrp, chmod, chown, chroot, chvt, clear, -cmp, cp, cpio, cut, date, dc, dd, deallocvt, df, dirname, dmesg, dos2unix, dpkg, -dpkg-deb, du, dumpkmap, dutmp, echo, expr, false, fbset, fdflush, find, free, -freeramdisk, fsck.minix, getopt, grep, gunzip, gzip, halt, head, hostid, -hostname, id, ifconfig, init, insmod, kill, killall, klogd, length, ln, -loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, md5sum, -mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, -nslookup, ping, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, reboot, -renice, reset, rm, rmdir, rmmod, route, rpm2cpio, sed, setkeycodes, -sh, sleep, sort, stty, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet, -test, tftp, touch, tr, true, tty, umount, uname, uniq, unix2dos, update, uptime, -usleep, uudecode, uuencode, watchdog, wc, wget, which, whoami, xargs, yes, zcat, -[ + addgroup, adduser, adjtimex, ar, basename, busybox, cat, chgrp, chmod, +chown, chroot, chvt, clear, cmp, cp, cpio, cut, date, dc, dd, deallocvt, +deluser, df, dirname, dmesg, dos2unix, dpkg, dpkg-deb, du, dumpkmap, dutmp, +echo, expr, false, fbset, fdflush, find, free, freeramdisk, fsck.minix, +getopt, getty, grep, gunzip, gzip, halt, head, hostid, hostname, id, +ifconfig, init, insmod, kill, killall, klogd, length, ln, loadacm, +loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, md5sum, mkdir, +mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, +nslookup, ping, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, +reboot, renice, reset, rm, rmdir, rmmod, route, rpm2cpio, sed, setkeycodes, +sh, sleep, sort, stty, swapoff, swapon, sync, syslogd, tail, tar, tee, +telnet, test, tftp, touch, tr, true, tty, umount, uname, uniq, unix2dos, +update, uptime, usleep, uudecode, uuencode, watchdog, wc, wget, which, +whoami, xargs, yes, zcat, [ =over 4 diff --git a/include/usage.h b/include/usage.h index a970c0f9c..20e2448fd 100644 --- a/include/usage.h +++ b/include/usage.h @@ -1432,6 +1432,8 @@ "[{add|del|flush}]" #define route_full_usage \ "Edit the kernel's routing tables" + "Options:\n" \ + "\t-n\tDont resolve names." #define rpm2cpio_trivial_usage \ "package.rpm" diff --git a/init/run_parts.c b/init/run_parts.c index 258afb4db..3ec4b9d10 100644 --- a/init/run_parts.c +++ b/init/run_parts.c @@ -45,9 +45,9 @@ * done - convert calls to error in perror... and remove error() * done - convert malloc/realloc to their x... counterparts * done - remove catch_sigchld - * use bb's isdirectory() ? It seems that no applet use it. * done - use bb's concat_path_file() - * declare run_parts_main() as extern and any other function as static? */ + * done - declare run_parts_main() as extern and any other function as static? + */ #include #include @@ -61,17 +61,14 @@ #include #include #include -/* #include - #include */ #include "busybox.h" -int test_mode = 0; -int verbose_mode = 0; -int exitstatus = 0; +static int test_mode = 0; +static int exitstatus = 0; -int argcount = 0, argsize = 0; -char **args = 0; +static int argcount = 0, argsize = 0; +static char **args = 0; /* set_umask */ @@ -80,7 +77,7 @@ char **args = 0; * 8 and 9 digits under some circumstances. We'll just have to live with it. */ -void set_umask (void) +static void set_umask (void) { int mask, result; @@ -97,14 +94,14 @@ void set_umask (void) /* add_argument */ /* Add an argument to the commands that we will call. Called once for every argument. */ -void add_argument (char *newarg) +static void add_argument (char *newarg) { if (argcount+1 >= argsize) { argsize = argsize ? argsize*2 : 4; /*TODO if we convert to xrealloc we lose the verbose error message */ args = realloc(args, argsize * (sizeof(char*))); if (!args) { - perror_msg_and_die ("failed to reallocate memory for arguments: %s", strerror(errno)); + perror_msg_and_die ("failed to reallocate memory for arguments"); } } args[argcount++] = newarg; @@ -116,7 +113,7 @@ void add_argument (char *newarg) * underscores, and hyphens only?) */ -int valid_name (const struct dirent *d) +static int valid_name (const struct dirent *d) { char *c = d->d_name; while (*c) { @@ -132,19 +129,19 @@ int valid_name (const struct dirent *d) /* run_part */ /* Execute a file */ -void run_part (char *progname) +static void run_part (char *progname) { int result; int pid; if ((pid=fork()) < 0) { - perror_msg_and_die ("failed to fork: %s", strerror(errno)); + perror_msg_and_die ("failed to fork"); } else if (!pid) { args[0] = progname; execv (progname, args); - perror_msg_and_die ("failed to exec %s: %s", progname, strerror (errno)); + perror_msg_and_die ("failed to exec %s", progname); } if (0) { @@ -168,70 +165,30 @@ void run_part (char *progname) /* run_parts */ /* Find the parts to run & call run_part() */ -void run_parts (char *dir_name) +static void run_parts (char *dir_name) { - struct dirent **namelist; - char *filename = NULL; - size_t filename_length, dir_name_length; - int entries, i, result; + struct dirent **namelist = 0; + char *filename; + int entries, i; struct stat st; - /* dir_name + "/" */ - dir_name_length = strlen(dir_name) + 1; - - /* dir_name + "/" + ".." + "\0" (This will save one realloc.) */ - filename_length = dir_name_length + 2 + 1; - - /* -- - * Removed this part because I want try to use concat_path_file() */ - -/* if (! (filename = malloc(filename_length))) { - error ("failed to allocate memory for path: %s", strerror(errno)); - exit (1); - } */ - /* -- */ /* scandir() isn't POSIX, but it makes things easy. */ entries = scandir (dir_name, &namelist, valid_name, alphasort); if (entries < 0) { - perror_msg_and_die ("failed to open directory %s: %s", dir_name, strerror (errno)); + perror_msg_and_die ("failed to open directory %s", dir_name); } for (i = 0; i < entries; i++) { - /* -- - * Removed this part because I want try to use concat_path_file() */ - - /* if (filename_length < dir_name_length + strlen(namelist[i]->d_name) + 1) { - filename_length = dir_name_length + strlen(namelist[i]->d_name) + 1; - if (!(filename = realloc(filename, filename_length))) { - error ("failed to reallocate memory for path: %s", strerror(errno)); - exit (1); - } - } - - */ - - /* -- */ - - - /* -- - * Removed for concat_path_file() */ - -/* strcpy (filename, dir_name); - strcat (filename, "/"); - strcat (filename, namelist[i]->d_name); */ - /* -- */ filename = concat_path_file (dir_name, namelist[i]->d_name); - result = stat (filename, &st); - if (result < 0) { - perror_msg_and_die ("failed to stat component %s: %s", filename, - strerror (errno)); + if (stat (filename, &st) < 0) { + perror_msg_and_die ("failed to stat component %s", filename); } if (S_ISREG(st.st_mode) && !access (filename, X_OK)) { if (test_mode) @@ -240,17 +197,17 @@ void run_parts (char *dir_name) run_part (filename); } } - /*TODO convert to isdirectory() */ + else if (!S_ISDIR(st.st_mode)) { - printf ("run-parts: component %s is not an executable plain file\n", + error_msg ("component %s is not an executable plain file", filename); exitstatus = 1; } free (namelist[i]); + free (filename); } free (namelist); - free (filename); } /* run_parts_main */ -- cgit v1.2.3