From f23b96cebfe169eee7131efd8b879748587d1845 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 24 Aug 2006 03:06:55 +0000 Subject: tag busybox-1.2.1 --- Makefile | 7 +- Rules.mak | 26 +- archival/libunarchive/get_header_tar.c | 13 +- changelog | 598 +++++++++++++++++++++++++++++++++ include/libbb.h | 45 +-- libbb/obscure.c | 11 +- libbb/xfuncs.c | 139 +------- loginutils/passwd.c | 25 +- networking/arping.c | 12 + networking/inetd.c | 2 +- networking/traceroute.c | 10 +- shell/ash.c | 44 ++- shell/lash.c | 41 +++ util-linux/dmesg.c | 3 +- 14 files changed, 764 insertions(+), 212 deletions(-) create mode 100644 changelog diff --git a/Makefile b/Makefile index a705bac32..a14cbd00a 100644 --- a/Makefile +++ b/Makefile @@ -216,6 +216,8 @@ randconfig: scripts/config/conf allyesconfig: scripts/config/conf @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null + @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config + @./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null allnoconfig: scripts/config/conf @./scripts/config/conf -n $(CONFIG_CONFIG_IN) > /dev/null @@ -226,13 +228,13 @@ allnoconfig: scripts/config/conf defconfig: scripts/config/conf @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null - @$(SED) -i -r -e "s/^(CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config + @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config @./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null allbareconfig: scripts/config/conf @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null - @$(SED) -i -r -e "s/^(CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config + @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null @@ -483,7 +485,6 @@ distclean: clean rm -f scripts/bb_mkdep scripts/usage rm -r -f include/config include/config.h $(DEP_INCLUDES) find . -name .depend'*' -print0 | xargs -0 rm -f - find . -name '*.rej' -print0 | xargs -0 rm -f rm -f .hdepend rm -f .config .config.old .config.cmd diff --git a/Rules.mak b/Rules.mak index b7a91b63b..44c9f2374 100644 --- a/Rules.mak +++ b/Rules.mak @@ -14,7 +14,7 @@ endif PROG := busybox MAJOR_VERSION :=1 MINOR_VERSION :=2 -SUBLEVEL_VERSION:=0 +SUBLEVEL_VERSION:=1 EXTRAVERSION := VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION) BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z") @@ -24,20 +24,22 @@ BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z") # With a modern GNU make(1) (highly recommended, that's what all the # developers use), all of the following configuration values can be # overridden at the command line. For example: -# make CROSS_COMPILE=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app +# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app #-------------------------------------------------------- -# If you are running a cross compiler, you will want to set CROSS_COMPILE +# If you are running a cross compiler, you will want to set 'CROSS' # to something more interesting... Target architecture is determined # by asking the CC compiler what arch it compiles things for, so unless # your compiler is broken, you should not need to specify TARGET_ARCH -CC = $(CROSS_COMPILE)gcc -AR = $(CROSS_COMPILE)ar -AS = $(CROSS_COMPILE)as -LD = $(CROSS_COMPILE)ld -NM = $(CROSS_COMPILE)nm -STRIP = $(CROSS_COMPILE)strip -ELF2FLT = $(CROSS_COMPILE)elf2flt +CROSS =$(strip $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))) +# be gentle to vi coloring.. ")) +CC = $(CROSS)gcc +AR = $(CROSS)ar +AS = $(CROSS)as +LD = $(CROSS)ld +NM = $(CROSS)nm +STRIP = $(CROSS)strip +ELF2FLT = $(CROSS)elf2flt CPP = $(CC) -E SED ?= sed BZIP2 ?= bzip2 @@ -62,7 +64,7 @@ CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1)) #-------------------------------------------------------- -export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS_COMPILE CC AR AS LD NM STRIP CPP +export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP ifeq ($(strip $(TARGET_ARCH)),) TARGET_ARCH:=$(shell $(CC) -dumpmachine | $(SED) -e s'/-.*//' \ -e 's/i.86/i386/' \ @@ -169,13 +171,11 @@ CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,) # Pin CHECKED_CFLAGS with := so it's only evaluated once. CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,) -CHECKED_CFLAGS+=$(call check_cc,$(HOSTCC),-Werror,) CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,) CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,) CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,) CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,) CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen) -CHECKED_CFLAGS+=$(call check_cc,$(CC),-finline-limit=0) # Preemptively pin this too. PROG_CFLAGS:= diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index 4394d23ee..0f3196221 100644 --- a/archival/libunarchive/get_header_tar.c +++ b/archival/libunarchive/get_header_tar.c @@ -1,4 +1,3 @@ -/* vi: set sw=4 ts=4: */ /* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. * * FIXME: @@ -56,7 +55,11 @@ char get_header_tar(archive_handle_t *archive_handle) /* Align header */ data_align(archive_handle, 512); - xread(archive_handle->src_fd, tar.raw, 512); + if (bb_full_read(archive_handle->src_fd, tar.raw, 512) != 512) { + /* Assume end of file */ + bb_error_msg_and_die("Short header"); + //return(EXIT_FAILURE); + } archive_handle->offset += 512; /* If there is no filename its an empty header */ @@ -65,7 +68,7 @@ char get_header_tar(archive_handle_t *archive_handle) /* This is the second consecutive empty header! End of archive! * Read until the end to empty the pipe from gz or bz2 */ - while (full_read(archive_handle->src_fd, tar.raw, 512) == 512); + while (bb_full_read(archive_handle->src_fd, tar.raw, 512) == 512); return(EXIT_FAILURE); } end = 1; @@ -162,14 +165,14 @@ char get_header_tar(archive_handle_t *archive_handle) #ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS case 'L': { longname = xzalloc(file_header->size + 1); - xread(archive_handle->src_fd, longname, file_header->size); + archive_xread_all(archive_handle, longname, file_header->size); archive_handle->offset += file_header->size; return(get_header_tar(archive_handle)); } case 'K': { linkname = xzalloc(file_header->size + 1); - xread(archive_handle->src_fd, linkname, file_header->size); + archive_xread_all(archive_handle, linkname, file_header->size); archive_handle->offset += file_header->size; file_header->name = linkname; diff --git a/changelog b/changelog new file mode 100644 index 000000000..ace9acf93 --- /dev/null +++ b/changelog @@ -0,0 +1,598 @@ +Various bug fixes that apply to busybox 1.2.0, cherry-picked from the +ongoing development branch. This will form the basis for busybox 1.2.1. + +I'll append fixes to this as they come up. (Check the file date, or the bug +list below.) This file is basically a concatenation of the following: + +http://busybox.net/downloads/patches/svn-15575.patch +http://busybox.net/downloads/patches/svn-15653.patch +http://busybox.net/downloads/patches/svn-15656.patch +http://busybox.net/downloads/patches/svn-15658.patch +http://busybox.net/downloads/patches/svn-15659.patch +http://busybox.net/downloads/patches/svn-15660.patch +http://busybox.net/downloads/patches/svn-15670.patch +http://busybox.net/downloads/patches/svn-15698.patch +http://busybox.net/downloads/patches/svn-15700.patch +http://busybox.net/downloads/patches/svn-15702.patch +http://busybox.net/downloads/patches/svn-15705.patch +http://busybox.net/downloads/patches/svn-15727.patch + + ------------------------------------------------------------------------ +r15575 | landley | 2006-07-01 13:19:02 -0400 (Sat, 01 Jul 2006) | 2 lines +Changed paths: + M /trunk/busybox/shell/lash.c + +Patch from Shaun Jackman moving the var=value logic to where it can do some +good. + + ------------------------------------------------------------------------ +Index: shell/lash.c +=================================================================== +--- shell/lash.c (revision 15574) ++++ shell/lash.c (revision 15575) +@@ -1171,12 +1171,6 @@ + { + struct built_in_command *x; + +- /* Check if the command sets an environment variable. */ +- if( strchr(child->argv[0], '=') != NULL ) { +- child->argv[1] = child->argv[0]; +- _exit(builtin_export(child)); +- } +- + /* Check if the command matches any of the non-forking builtins. + * Depending on context, this might be redundant. But it's + * easier to waste a few CPU cycles than it is to figure out +@@ -1300,6 +1294,12 @@ + * is doomed to failure, and doesn't work on bash, either. + */ + if (newjob->num_progs == 1) { ++ /* Check if the command sets an environment variable. */ ++ if (strchr(child->argv[0], '=') != NULL) { ++ child->argv[1] = child->argv[0]; ++ return builtin_export(child); ++ } ++ + for (x = bltins; x->cmd; x++) { + if (strcmp(child->argv[0], x->cmd) == 0 ) { + int rcode; + ------------------------------------------------------------------------ +r15653 | landley | 2006-07-05 21:09:21 -0400 (Wed, 05 Jul 2006) | 6 lines +Changed paths: + M /trunk/busybox/shell/ash.c + +Bug fix from Vladimir Oleynic via Paul Fox for: +echo "+bond0" > /sys/class/net/bonding_masters +while true; do + echo hello +done + + ------------------------------------------------------------------------ +Index: shell/ash.c +=================================================================== +--- shell/ash.c (revision 15652) ++++ shell/ash.c (revision 15653) +@@ -3469,6 +3469,7 @@ + flushall(); + cmddone: + exitstatus |= ferror(stdout); ++ clearerr(stdout); + commandname = savecmdname; + exsig = 0; + handler = savehandler; + ------------------------------------------------------------------------ +r15656 | landley | 2006-07-06 12:41:56 -0400 (Thu, 06 Jul 2006) | 5 lines +Changed paths: + M /trunk/busybox/util-linux/dmesg.c + +Fix three embarassing thinkos in the new dmesg.c: +1) the c argument shouldn't have had a : after that, dunno how that got there. +2) the xgetlarg for level was using size +3) because xgetlarg's error message _SUCKS_ (it does a show_usage() rather than giving any specific info about the range that was violated) I dropped the range down to 2 bytes. (Which works fine, I dunno why we were nit-picking about that...) + + ------------------------------------------------------------------------ +Index: util-linux/dmesg.c +=================================================================== +--- util-linux/dmesg.c (revision 15655) ++++ util-linux/dmesg.c (revision 15656) +@@ -15,16 +15,16 @@ + int dmesg_main(int argc, char *argv[]) + { + char *size, *level; +- int flags = bb_getopt_ulflags(argc, argv, "c:s:n:", &size, &level); ++ int flags = bb_getopt_ulflags(argc, argv, "cs:n:", &size, &level); + + if (flags & 4) { +- if(klogctl(8, NULL, bb_xgetlarg(size, 10, 0, 10))) ++ if(klogctl(8, NULL, bb_xgetlarg(level, 10, 0, 10))) + bb_perror_msg_and_die("klogctl"); + } else { + int len; + char *buf; + +- len = (flags & 2) ? bb_xgetlarg(size, 10, 4096, INT_MAX) : 16384; ++ len = (flags & 2) ? bb_xgetlarg(size, 10, 2, INT_MAX) : 16384; + buf = xmalloc(len); + if (0 > (len = klogctl(3 + (flags & 1), buf, len))) + bb_perror_msg_and_die("klogctl"); + ------------------------------------------------------------------------ +r15658 | pgf | 2006-07-06 16:00:43 -0400 (Thu, 06 Jul 2006) | 4 lines +Changed paths: + M /trunk/busybox/Makefile + +fix dependencies so that compressed usage gets rebuilt if + a) include/usage.h is changed, and + b) after "make clean". + + ------------------------------------------------------------------------ +Index: Makefile +=================================================================== +--- Makefile (revision 15657) ++++ Makefile (revision 15658) +@@ -436,13 +436,16 @@ + + ifeq ($(strip $(CONFIG_FEATURE_COMPRESS_USAGE)),y) + USAGE_BIN:=scripts/usage +-$(USAGE_BIN): $(top_srcdir)/scripts/usage.c .config ++$(USAGE_BIN): $(top_srcdir)/scripts/usage.c .config \ ++ $(top_srcdir)/include/usage.h + $(do_link.h) + + DEP_INCLUDES += include/usage_compressed.h + +-include/usage_compressed.h: .config $(USAGE_BIN) $(top_srcdir)/scripts/usage_compressed +- $(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed "$(top_builddir)/scripts" > $@ ++include/usage_compressed.h: .config $(USAGE_BIN) \ ++ $(top_srcdir)/scripts/usage_compressed ++ $(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed \ ++ "$(top_builddir)/scripts" > $@ + endif # CONFIG_FEATURE_COMPRESS_USAGE + + # workaround alleged bug in make-3.80, make-3.81 +@@ -470,7 +473,8 @@ + docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \ + docs/busybox.net/BusyBox.html busybox.links \ + libbusybox.so* \ +- .config.old busybox busybox_unstripped ++ .config.old busybox busybox_unstripped \ ++ include/usage_compressed.h scripts/usage + - rm -r -f _install testsuite/links + - find . -name .\*.flags -o -name \*.o -o -name \*.om -o -name \*.syn \ + -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f + ------------------------------------------------------------------------ +r15659 | landley | 2006-07-06 16:02:47 -0400 (Thu, 06 Jul 2006) | 3 lines +Changed paths: + M /trunk/busybox/libbb/Makefile + +Attempt to address Shaun Jackman's problem adding "busybox: busybox.bflt" to +.config.mak. + + ------------------------------------------------------------------------ +Index: libbb/Makefile +=================================================================== +--- libbb/Makefile (revision 15658) ++++ libbb/Makefile (revision 15659) +@@ -12,6 +12,12 @@ + endif + srcdir=$(top_srcdir)/libbb + LIBBB_DIR:=./ ++ ++# Ensure "all" is still the default target when make is run by itself in ++# libbb, even if the files we include define rules for targets. ++ ++all: ++ + include $(top_srcdir)/Rules.mak + include $(top_builddir)/.config + include Makefile.in + ------------------------------------------------------------------------ +r15660 | landley | 2006-07-06 16:30:19 -0400 (Thu, 06 Jul 2006) | 3 lines +Changed paths: + M /trunk/busybox/archival/libunarchive/get_header_tar.c + +Fix tar so it can extract git-generated tarballs, based on a suggestion +from Erik Frederiksen. + + ------------------------------------------------------------------------ +Index: archival/libunarchive/get_header_tar.c +=================================================================== +--- archival/libunarchive/get_header_tar.c (revision 15659) ++++ archival/libunarchive/get_header_tar.c (revision 15660) +@@ -137,10 +137,6 @@ + case '1': + file_header->mode |= S_IFREG; + break; +- case 'x': +- case 'g': +- bb_error_msg_and_die("pax is not tar"); +- break; + case '7': + /* Reserved for high performance files, treat as normal file */ + case 0: +@@ -188,8 +184,11 @@ + case 'N': /* Old GNU for names > 100 characters */ + case 'S': /* Sparse file */ + case 'V': /* Volume header */ +- bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag); + #endif ++ case 'g': /* pax global header */ ++ case 'x': /* pax extended header */ ++ bb_error_msg("Ignoring extension type %c", tar.formated.typeflag); ++ break; + default: + bb_error_msg("Unknown typeflag: 0x%x", tar.formated.typeflag); + } + ------------------------------------------------------------------------ +r15670 | landley | 2006-07-09 13:03:07 -0400 (Sun, 09 Jul 2006) | 3 lines +Changed paths: + M /trunk/busybox/shell/lash.c + +Bugfix from Shaun Jackman (check that argv[optind] isn't null before +dereferencing it) plus a bunch of tweaks from me. + + ------------------------------------------------------------------------ +Index: shell/lash.c +=================================================================== +--- shell/lash.c (revision 15669) ++++ shell/lash.c (revision 15670) +@@ -1498,6 +1498,8 @@ + remove_job(&job_list, job_list.fg); + } + } ++#else ++void free_memory(void); + #endif + + #ifdef CONFIG_LASH_JOB_CONTROL +@@ -1528,7 +1530,7 @@ + /* Put ourselves in our own process group. */ + setsid(); + shell_pgrp = getpid (); +- setpgid (shell_pgrp, shell_pgrp); ++ setpgid(shell_pgrp, shell_pgrp); + + /* Grab control of the terminal. */ + tcsetpgrp(shell_terminal, shell_pgrp); +@@ -1577,7 +1579,7 @@ + argv = argv+optind; + break; + case 'i': +- interactive = TRUE; ++ interactive++; + break; + default: + bb_show_usage(); +@@ -1591,18 +1593,18 @@ + * standard output is a terminal + * Refer to Posix.2, the description of the `sh' utility. */ + if (argv[optind]==NULL && input==stdin && +- isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) { +- interactive=TRUE; ++ isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) ++ { ++ interactive++; + } + setup_job_control(); +- if (interactive==TRUE) { +- //printf( "optind=%d argv[optind]='%s'\n", optind, argv[optind]); ++ if (interactive) { + /* Looks like they want an interactive shell */ +-#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET +- printf( "\n\n%s Built-in shell (lash)\n", BB_BANNER); +- printf( "Enter 'help' for a list of built-in commands.\n\n"); +-#endif +- } else if (local_pending_command==NULL) { ++ if (!ENABLE_FEATURE_SH_EXTRA_QUIET) { ++ printf( "\n\n%s Built-in shell (lash)\n", BB_BANNER); ++ printf( "Enter 'help' for a list of built-in commands.\n\n"); ++ } ++ } else if (!local_pending_command && argv[optind]) { + //printf( "optind=%d argv[optind]='%s'\n", optind, argv[optind]); + input = bb_xfopen(argv[optind], "r"); + /* be lazy, never mark this closed */ +@@ -1614,15 +1616,10 @@ + if (!cwd) + cwd = bb_msg_unknown; + +-#ifdef CONFIG_FEATURE_CLEAN_UP +- atexit(free_memory); +-#endif ++ if (ENABLE_FEATURE_CLEAN_UP) atexit(free_memory); + +-#ifdef CONFIG_FEATURE_COMMAND_EDITING +- cmdedit_set_initial_prompt(); +-#else +- PS1 = NULL; +-#endif ++ if (ENABLE_FEATURE_COMMAND_EDITING) cmdedit_set_initial_prompt(); ++ else PS1 = NULL; + + return (busy_loop(input)); + } + ------------------------------------------------------------------------ +r15698 | vapier | 2006-07-14 23:59:00 -0400 (Fri, 14 Jul 2006) | 2 lines +Changed paths: + M /trunk/busybox/libbb/obscure.c + +Tito writes: If the gecos field of an user is empty, obscure reports a false "similar to gecos" error. + + ------------------------------------------------------------------------ +Index: libbb/obscure.c +=================================================================== +--- libbb/obscure.c (revision 15697) ++++ libbb/obscure.c (revision 15698) +@@ -109,7 +109,7 @@ + return "similar to username"; + } + /* no gecos as-is, as sub-string, reversed, capitalized, doubled */ +- if (string_checker(new_p, pw->pw_gecos)) { ++ if (*pw->pw_gecos && string_checker(new_p, pw->pw_gecos)) { + return "similar to gecos"; + } + /* hostname as-is, as sub-string, reversed, capitalized, doubled */ + ------------------------------------------------------------------------ +r15700 | landley | 2006-07-15 19:00:46 -0400 (Sat, 15 Jul 2006) | 4 lines +Changed paths: + M /trunk/busybox/include/libbb.h + M /trunk/busybox/libbb/xfuncs.c + +We need xsetuid() and xsetgid() because per-user process resource limits can +prevent a process from switching to a user that has too many processes, and +when that happens WE'RE STILL ROOT. See http://lwn.net/Articles/190331/ + + ------------------------------------------------------------------------ +Index: libbb/xfuncs.c +=================================================================== +--- libbb/xfuncs.c (revision 15699) ++++ libbb/xfuncs.c (revision 15700) +@@ -232,3 +232,15 @@ + return 0; + } + #endif ++ ++#ifdef L_setuid ++void xsetgid(gid_t gid) ++{ ++ if (setgid(gid)) bb_error_msg_and_die("setgid"); ++} ++ ++void xsetuid(uid_t uid) ++{ ++ if (setuid(uid)) bb_error_msg_and_die("setuid"); ++} ++#endif +Index: include/libbb.h +=================================================================== +--- include/libbb.h (revision 15699) ++++ include/libbb.h (revision 15700) +@@ -185,6 +185,8 @@ + extern bb_xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); + extern void bb_xlisten(int s, int backlog); + extern void bb_xchdir(const char *path); ++extern void xsetgid(gid_t gid); ++extern void xsetuid(uid_t uid); + + #define BB_GETOPT_ERROR 0x80000000UL + extern const char *bb_opt_complementally; + ------------------------------------------------------------------------ +r15702 | landley | 2006-07-16 04:06:34 -0400 (Sun, 16 Jul 2006) | 2 lines +Changed paths: + M /trunk/busybox/loginutils/passwd.c + M /trunk/busybox/networking/arping.c + M /trunk/busybox/networking/ether-wake.c + M /trunk/busybox/networking/fakeidentd.c + M /trunk/busybox/networking/inetd.c + M /trunk/busybox/networking/traceroute.c + +Convert setuid/setgid users to xsetuid/xsetgid. + + ------------------------------------------------------------------------ +Index: networking/fakeidentd.c +=================================================================== +--- networking/fakeidentd.c (revision 15701) ++++ networking/fakeidentd.c (revision 15702) +@@ -159,8 +159,8 @@ + + close(0); + inetbind(); +- if (setgid(nogrp)) bb_error_msg_and_die("Could not setgid()"); +- if (setuid(nobody)) bb_error_msg_and_die("Could not setuid()"); ++ xsetgid(nogrp); ++ xsetuid(nobody); + close(1); + close(2); + +Index: networking/ether-wake.c +=================================================================== +--- networking/ether-wake.c (revision 15701) ++++ networking/ether-wake.c (revision 15702) +@@ -145,7 +145,7 @@ + s = make_socket(); + + /* now that we have a raw socket we can drop root */ +- setuid(getuid()); ++ xsetuid(getuid()); + + /* look up the dest mac address */ + get_dest_addr(argv[optind], &eaddr); +Index: networking/inetd.c +=================================================================== +--- networking/inetd.c (revision 15701) ++++ networking/inetd.c (revision 15702) +@@ -1513,11 +1513,11 @@ + if (sep->se_group) { + pwd->pw_gid = grp->gr_gid; + } +- setgid ((gid_t) pwd->pw_gid); ++ xsetgid ((gid_t) pwd->pw_gid); + initgroups (pwd->pw_name, pwd->pw_gid); +- setuid ((uid_t) pwd->pw_uid); ++ xsetuid((uid_t) pwd->pw_uid); + } else if (sep->se_group) { +- setgid (grp->gr_gid); ++ xsetgid(grp->gr_gid); + setgroups (1, &grp->gr_gid); + } + dup2 (ctrl, 0); +Index: networking/traceroute.c +=================================================================== +--- networking/traceroute.c (revision 15701) ++++ networking/traceroute.c (revision 15702) +@@ -941,7 +941,6 @@ + #endif + u_short off = 0; + struct IFADDRLIST *al; +- int uid = getuid(); + char *device = NULL; + int max_ttl = 30; + char *max_ttl_str = NULL; +@@ -1010,8 +1009,7 @@ + * set the ip source address of the outbound + * probe (e.g., on a multi-homed host). + */ +- if (uid) +- bb_error_msg_and_die("-s %s: Permission denied", source); ++ if (getuid()) bb_error_msg_and_die("-s %s: Permission denied", source); + } + if(waittime_str) + waittime = str2val(waittime_str, "wait time", 2, 24 * 60 * 60); +@@ -1160,8 +1158,8 @@ + sizeof(on)); + + /* Revert to non-privileged user after opening sockets */ +- setgid(getgid()); +- setuid(uid); ++ xsetgid(getgid()); ++ xsetuid(getuid()); + + outip = (struct ip *)xcalloc(1, (unsigned)packlen); + +Index: networking/arping.c +=================================================================== +--- networking/arping.c (revision 15701) ++++ networking/arping.c (revision 15702) +@@ -262,7 +262,8 @@ + s = socket(PF_PACKET, SOCK_DGRAM, 0); + ifindex = errno; + +- setuid(getuid()); ++ // Drop suid root privileges ++ xsetuid(getuid()); + + { + unsigned long opt; +Index: loginutils/passwd.c +=================================================================== +--- loginutils/passwd.c (revision 15701) ++++ loginutils/passwd.c (revision 15702) +@@ -227,10 +227,7 @@ + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + umask(077); +- if (setuid(0)) { +- syslog(LOG_ERR, "can't setuid(0)"); +- bb_error_msg_and_die( "Cannot change ID to root.\n"); +- } ++ xsetuid(0); + if (!update_passwd(pw, crypt_passwd)) { + syslog(LOG_INFO, "password for `%s' changed by user `%s'", name, + myname); + ------------------------------------------------------------------------ +r15705 | landley | 2006-07-16 14:58:18 -0400 (Sun, 16 Jul 2006) | 2 lines +Changed paths: + M /trunk/busybox/loginutils/adduser.c + +Bugfix from Tito to make sure /etc/group gets updated. + + ------------------------------------------------------------------------ +Index: loginutils/adduser.c +=================================================================== +--- loginutils/adduser.c (revision 15704) ++++ loginutils/adduser.c (revision 15705) +@@ -96,6 +96,7 @@ + static int adduser(struct passwd *p, unsigned long flags) + { + FILE *file; ++ int addgroup = !p->pw_gid; + + /* make sure everything is kosher and setup uid && gid */ + file = bb_xfopen(bb_path_passwd_file, "a"); +@@ -132,9 +133,8 @@ + /* add to group */ + /* addgroup should be responsible for dealing w/ gshadow */ + /* if using a pre-existing group, don't create one */ +- if (p->pw_gid == 0) { +- addgroup_wrapper(p); +- } ++ if (addgroup) addgroup_wrapper(p); ++ + /* Clear the umask for this process so it doesn't + * * screw up the permissions on the mkdir and chown. */ + umask(0); + ------------------------------------------------------------------------ +r15727 | landley | 2006-07-19 17:33:42 -0400 (Wed, 19 Jul 2006) | 4 lines +Changed paths: + M /trunk/busybox/modutils/modprobe.c + +Patch from Yann Morin to look for modules.conf in the right place on 2.6. +Fixes http://bugs.busybox.net/view.php?id=942 + + + ------------------------------------------------------------------------ +Index: modutils/modprobe.c +=================================================================== +--- modutils/modprobe.c (revision 15726) ++++ modutils/modprobe.c (revision 15727) +@@ -545,29 +545,37 @@ + } + close ( fd ); + ++ /* ++ * First parse system-specific options and aliases ++ * as they take precedence over the kernel ones. ++ */ + if (!ENABLE_FEATURE_2_6_MODULES + || ( fd = open ( "/etc/modprobe.conf", O_RDONLY )) < 0 ) + if (( fd = open ( "/etc/modules.conf", O_RDONLY )) < 0 ) +- if (( fd = open ( "/etc/conf.modules", O_RDONLY )) < 0 ) +- return first; ++ fd = open ( "/etc/conf.modules", O_RDONLY ); + +- include_conf (&first, ¤t, buffer, sizeof(buffer), fd); +- close(fd); ++ if (fd >= 0) { ++ include_conf (&first, ¤t, buffer, sizeof(buffer), fd); ++ close(fd); ++ } + +- filename = bb_xasprintf("/lib/modules/%s/modules.alias", un.release); +- fd = open ( filename, O_RDONLY ); +- if (ENABLE_FEATURE_CLEAN_UP) +- free(filename); +- if (fd < 0) { +- /* Ok, that didn't work. Fall back to looking in /lib/modules */ +- if (( fd = open ( "/lib/modules/modules.alias", O_RDONLY )) < 0 ) { +- return first; ++ /* Only 2.6 has a modules.alias file */ ++ if (ENABLE_FEATURE_2_6_MODULES) { ++ /* Parse kernel-declared aliases */ ++ filename = bb_xasprintf("/lib/modules/%s/modules.alias", un.release); ++ if ((fd = open ( filename, O_RDONLY )) < 0) { ++ /* Ok, that didn't work. Fall back to looking in /lib/modules */ ++ fd = open ( "/lib/modules/modules.alias", O_RDONLY ); + } ++ if (ENABLE_FEATURE_CLEAN_UP) ++ free(filename); ++ ++ if (fd >= 0) { ++ include_conf (&first, ¤t, buffer, sizeof(buffer), fd); ++ close(fd); ++ } + } + +- include_conf (&first, ¤t, buffer, sizeof(buffer), fd); +- close(fd); +- + return first; + } + diff --git a/include/libbb.h b/include/libbb.h index ddf965fbf..6565760cf 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -16,22 +16,18 @@ #include #include -#include #include #include #include -#include #include #include #include #include #include -#include #include #include #include #include -#include #include #include @@ -41,7 +37,12 @@ #include "pwd_.h" #include "grp_.h" +#ifdef CONFIG_FEATURE_SHADOWPASSWDS #include "shadow_.h" +#endif +#ifdef CONFIG_FEATURE_SHA1_PASSWORDS +# include "sha1.h" +#endif /* Try to pull in PATH_MAX */ #include @@ -133,9 +134,9 @@ extern DIR *bb_xopendir(const char *path); extern int remove_file(const char *path, int flags); extern int copy_file(const char *source, const char *dest, int flags); extern ssize_t safe_read(int fd, void *buf, size_t count); -extern ssize_t full_read(int fd, void *buf, size_t len); +extern ssize_t bb_full_read(int fd, void *buf, size_t len); extern ssize_t safe_write(int fd, const void *buf, size_t count); -extern ssize_t full_write(int fd, const void *buf, size_t len); +extern ssize_t bb_full_write(int fd, const void *buf, size_t len); extern int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst, int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData), @@ -181,13 +182,8 @@ extern void bb_xdaemon(int nochdir, int noclose); extern void bb_xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); extern void bb_xlisten(int s, int backlog); extern void bb_xchdir(const char *path); -extern void utoa_to_buf(unsigned n, char *buf, unsigned buflen); -extern char *utoa(unsigned n); -extern void itoa_to_buf(int n, char *buf, unsigned buflen); -extern char *itoa(int n); extern void xsetgid(gid_t gid); extern void xsetuid(uid_t uid); -extern off_t fdlength(int fd); #define BB_GETOPT_ERROR 0x80000000UL extern const char *bb_opt_complementally; @@ -341,9 +337,7 @@ char *dirname (char *path); int bb_make_directory (char *path, long mode, int flags); -int get_signum(char *name); -char *get_signame(int number); - +const char *u_signal_names(const char *str_sig, int *signo, int startnum); char *bb_simplify_path(const char *path); enum { /* DO NOT CHANGE THESE VALUES! cp.c depends on them. */ @@ -474,14 +468,14 @@ extern int restricted_shell ( const char *shell ); extern void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw ); extern int correct_password ( const struct passwd *pw ); extern char *pw_encrypt(const char *clear, const char *salt); +extern struct spwd *pwd_to_spwd(const struct passwd *pw); extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); extern int bb_xopen(const char *pathname, int flags); extern int bb_xopen3(const char *pathname, int flags, int mode); -extern void xread(int fd, void *buf, size_t count); -extern unsigned char xread_char(int fd); -extern void xlseek(int fd, off_t offset, int whence); -extern void xwrite(int fd, void *buf, size_t count); +extern ssize_t bb_xread(int fd, void *buf, size_t count); +extern void bb_xread_all(int fd, void *buf, size_t count); +extern unsigned char bb_xread_char(int fd); #ifndef COMM_LEN #ifdef TASK_COMM_LEN @@ -559,19 +553,4 @@ extern uint32_t *bb_crc32_filltable (int endian); extern const char BB_BANNER[]; -// Make sure we call functions instead of macros. -#undef isalnum -#undef isalpha -#undef isascii -#undef isblank -#undef iscntrl -#undef isdigit -#undef isgraph -#undef islower -#undef isprint -#undef ispunct -#undef isspace -#undef isupper -#undef isxdigit - #endif /* __LIBBUSYBOX_H__ */ diff --git a/libbb/obscure.c b/libbb/obscure.c index 3353df949..464d3b5ab 100644 --- a/libbb/obscure.c +++ b/libbb/obscure.c @@ -46,6 +46,11 @@ #include "libbb.h" + +/* passwords should consist of 6 (to 8 characters) */ +#define MINLEN 6 + + static int string_checker_helper(const char *p1, const char *p2) __attribute__ ((__pure__)); static int string_checker_helper(const char *p1, const char *p2) @@ -95,13 +100,13 @@ static const char *obscure_msg(const char *old_p, const char *new_p, const struc int c; int length; int mixed = 0; - /* Add 2 for each type of characters to the minlen of password */ - int size = CONFIG_PASSWORD_MINLEN + 8; + /* Add 1 for each type of characters to the minlen of password */ + int size = MINLEN + 8; const char *p; char hostname[255]; /* size */ - if (!new_p || (length = strlen(new_p)) < CONFIG_PASSWORD_MINLEN) + if (!new_p || (length = strlen(new_p)) < MINLEN) return("too short"); /* no username as-is, as sub-string, reversed, capitalized, doubled */ diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 8562a4fcb..e5f471cc6 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -120,55 +120,40 @@ int bb_xopen3(const char *pathname, int flags, int mode) #endif #ifdef L_xread - -// Die with an error message if we can't read the entire buffer. - -void xread(int fd, void *buf, size_t count) +ssize_t bb_xread(int fd, void *buf, size_t count) { - while (count) { - ssize_t size; + ssize_t size; - if ((size = safe_read(fd, buf, count)) < 1) - bb_error_msg_and_die("Short read"); - count -= size; - buf = ((char *) buf) + size; + size = read(fd, buf, count); + if (size < 0) { + bb_perror_msg_and_die(bb_msg_read_error); } + return(size); } #endif -#ifdef L_xwrite - -// Die with an error message if we can't write the entire buffer. - -void xwrite(int fd, void *buf, size_t count) +#ifdef L_xread_all +void bb_xread_all(int fd, void *buf, size_t count) { - while (count) { - ssize_t size; + ssize_t size; - if ((size = safe_write(fd, buf, count)) < 1) - bb_error_msg_and_die("Short write"); + while (count) { + if ((size = bb_xread(fd, buf, count)) == 0) { /* EOF */ + bb_error_msg_and_die("Short read"); + } count -= size; buf = ((char *) buf) + size; } -} -#endif - -#ifdef L_xlseek - -// Die if we can't lseek to the right spot. - -void xlseek(int fd, off_t offset, int whence) -{ - if (whence != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek"); + return; } #endif #ifdef L_xread_char -unsigned char xread_char(int fd) +unsigned char bb_xread_char(int fd) { char tmp; - xread(fd, &tmp, 1); + bb_xread_all(fd, &tmp, 1); return(tmp); } @@ -244,59 +229,7 @@ int wait4pid(int pid) if (WIFSIGNALED(status)) return WTERMSIG(status); return 0; } -#endif - -#ifdef L_itoa -// Largest 32 bit integer is -2 billion plus null terminator. -// Int should always be 32 bits on a Unix-oid system, see -// http://www.unix.org/whitepapers/64bit.html -static char local_buf[12]; - -void utoa_to_buf(unsigned n, char *buf, unsigned buflen) -{ - int i, out = 0; - if (buflen) { - for (i=1000000000; i; i/=10) { - int res = n/i; - - if ((res || out || i == 1) && --buflen>0) { - out++; - n -= res*i; - *buf++ = '0' + res; - } - } - *buf = 0; - } -} - -// Note: uses static buffer, calling it twice in a row will overwrite. - -char *utoa(unsigned n) -{ - utoa_to_buf(n, local_buf, sizeof(local_buf)); - - return local_buf; -} - -void itoa_to_buf(int n, char *buf, unsigned buflen) -{ - if (buflen && n<0) { - n = -n; - *buf++ = '-'; - buflen--; - } - utoa_to_buf((unsigned)n, buf, buflen); -} - -// Note: uses static buffer, calling it twice in a row will overwrite. - -char *itoa(int n) -{ - itoa_to_buf(n, local_buf, sizeof(local_buf)); - - return local_buf; -} -#endif +#endif #ifdef L_setuid void xsetgid(gid_t gid) @@ -309,41 +242,3 @@ void xsetuid(uid_t uid) if (setuid(uid)) bb_error_msg_and_die("setuid"); } #endif - -#ifdef L_fdlength -off_t fdlength(int fd) -{ - off_t bottom = 0, top = 0, pos; - long size; - - // If the ioctl works for this, return it. - - if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512; - - // If not, do a binary search for the last location we can read. - - do { - char temp; - - pos = bottom + (top - bottom) / 2;; - - // If we can read from the current location, it's bigger. - - if (lseek(fd, pos, 0)>=0 && safe_read(fd, &temp, 1)==1) { - if (bottom == top) bottom = top = (top+1) * 2; - else bottom = pos; - - // If we can't, it's smaller. - - } else { - if (bottom == top) { - if (!top) return 0; - bottom = top/2; - } - else top = pos; - } - } while (bottom + 1 != top); - - return pos + 1; -} -#endif diff --git a/loginutils/passwd.c b/loginutils/passwd.c index 7745444c0..92cddc182 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c @@ -1,8 +1,4 @@ /* vi: set sw=4 ts=4: */ -/* - * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. - */ - #include #include #include @@ -150,6 +146,9 @@ int passwd_main(int argc, char **argv) int dflg = 0; /* -d - delete password */ const struct passwd *pw; +#if ENABLE_FEATURE_SHADOWPASSWDS + const struct spwd *sp; +#endif amroot = (getuid() == 0); openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); while ((flag = getopt(argc, argv, "a:dlu")) != EOF) { @@ -188,13 +187,18 @@ int passwd_main(int argc, char **argv) syslog(LOG_WARNING, "can't change pwd for `%s'", name); bb_error_msg_and_die("Permission denied.\n"); } - if (ENABLE_FEATURE_SHADOWPASSWDS) { - struct spwd *sp = getspnam(name); - if (!sp) bb_error_msg_and_die("Unknown user %s", name); - cp = sp->sp_pwdp; - } else cp = pw->pw_passwd; - +#if ENABLE_FEATURE_SHADOWPASSWDS + sp = getspnam(name); + if (!sp) { + sp = (struct spwd *) pwd_to_spwd(pw); + } + cp = sp->sp_pwdp; + np = sp->sp_namp; +#else + cp = pw->pw_passwd; np = name; +#endif + safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); if (!(dflg || lflg || uflg)) { if (!amroot) { @@ -236,7 +240,6 @@ int passwd_main(int argc, char **argv) syslog(LOG_WARNING, "an error occurred updating the password file"); bb_error_msg_and_die("An error occurred updating the password file.\n"); } - if (ENABLE_FEATURE_CLEAN_UP) free(myname); return (0); } diff --git a/networking/arping.c b/networking/arping.c index 5665ddb2b..04eb728a7 100644 --- a/networking/arping.c +++ b/networking/arping.c @@ -52,6 +52,18 @@ static int req_recv; #define MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \ ((tv1).tv_usec-(tv2).tv_usec)/1000 ) +#if 0 +static void set_signal(int signo, void (*handler) (void)) +{ + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = (void (*)(int)) handler; + sa.sa_flags = SA_RESTART; + sigaction(signo, &sa, NULL); +} +#endif + static int send_pack(int sock, struct in_addr *src_addr, struct in_addr *dst_addr, struct sockaddr_ll *ME, struct sockaddr_ll *HE) diff --git a/networking/inetd.c b/networking/inetd.c index 54294b635..d3d2cca20 100644 --- a/networking/inetd.c +++ b/networking/inetd.c @@ -1,4 +1,3 @@ -/* vi: set sw=4 ts=4: */ /* $Slackware: inetd.c 1.79s 2001/02/06 13:18:00 volkerdi Exp $ */ /* $OpenBSD: inetd.c,v 1.79 2001/01/30 08:30:57 deraadt Exp $ */ /* $NetBSD: inetd.c,v 1.11 1996/02/22 11:14:41 mycroft Exp $ */ @@ -1802,3 +1801,4 @@ daytime_dg (int s, servtab_t *sep ATTRIBUTE_UNUSED) (void) sendto (s, buffer, strlen (buffer), 0, &sa, sizeof (sa)); } #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME */ +/* vi: set sw=4 ts=4: */ diff --git a/networking/traceroute.c b/networking/traceroute.c index c2084fc1e..b7046a054 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -548,7 +548,7 @@ static int wait_for_reply(int sock, struct sockaddr_in *fromp, const struct timeval *tp) { fd_set fds; - struct timeval now, tvwait; + struct timeval now, wait; struct timezone tz; int cc = 0; socklen_t fromlen = sizeof(*fromp); @@ -556,12 +556,12 @@ wait_for_reply(int sock, struct sockaddr_in *fromp, const struct timeval *tp) FD_ZERO(&fds); FD_SET(sock, &fds); - tvwait.tv_sec = tp->tv_sec + waittime; - tvwait.tv_usec = tp->tv_usec; + wait.tv_sec = tp->tv_sec + waittime; + wait.tv_usec = tp->tv_usec; (void)gettimeofday(&now, &tz); - tvsub(&tvwait, &now); + tvsub(&wait, &now); - if (select(sock + 1, &fds, NULL, NULL, &tvwait) > 0) + if (select(sock + 1, &fds, NULL, NULL, &wait) > 0) cc = recvfrom(sock, (char *)packet, sizeof(packet), 0, (struct sockaddr *)fromp, &fromlen); diff --git a/shell/ash.c b/shell/ash.c index 5031ae153..6011448d3 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -2035,6 +2035,7 @@ static void onsig(int); static int dotrap(void); static void setinteractive(int); static void exitshell(void) ATTRIBUTE_NORETURN; +static int decode_signal(const char *, int); /* * This routine is called when an error or an interrupt occurs in an @@ -2546,6 +2547,11 @@ onint(void) { int i; intpending = 0; +#if 0 + /* comment by vodz: its strange for me, this programm don`t use other + signal block */ + sigsetmask(0); +#endif i = EXSIG; if (gotsig[SIGINT - 1] && !trap[SIGINT]) { if (!(rootshell && iflag)) { @@ -3322,7 +3328,7 @@ evalcommand(union node *cmd, int flags) } sp = arglist.list; } - full_write(preverrout_fd, "\n", 1); + bb_full_write(preverrout_fd, "\n", 1); } cmd_is_exec = 0; @@ -4559,7 +4565,7 @@ expandhere(union node *arg, int fd) { herefd = fd; expandarg(arg, (struct arglist *)NULL, 0); - full_write(fd, stackblock(), expdest - (char *)stackblock()); + bb_full_write(fd, stackblock(), expdest - (char *)stackblock()); } @@ -6547,7 +6553,7 @@ usage: } if (**++argv == '-') { - signo = get_signum(*argv + 1); + signo = decode_signal(*argv + 1, 1); if (signo < 0) { int c; @@ -6561,7 +6567,7 @@ usage: list = 1; break; case 's': - signo = get_signum(optionarg); + signo = decode_signal(optionarg, 1); if (signo < 0) { sh_error( "invalid signal number or name: %s", @@ -6587,14 +6593,14 @@ usage: if (!*argv) { for (i = 1; i < NSIG; i++) { - name = get_signame(i); - if (isdigit(*name)) + name = u_signal_names(0, &i, 1); + if (name) out1fmt(snlfmt, name); } return 0; } - name = get_signame(signo); - if (isdigit(*name)) + name = u_signal_names(*argptr, &signo, -1); + if (name) out1fmt(snlfmt, name); else sh_error("invalid signal number or exit status: %s", *argptr); @@ -8378,7 +8384,7 @@ growstackstr(void) { size_t len = stackblocksize(); if (herefd >= 0 && len >= 1024) { - full_write(herefd, stackblock(), len); + bb_full_write(herefd, stackblock(), len); return stackblock(); } growstackblock(); @@ -10973,7 +10979,7 @@ openhere(union node *redir) if (redir->type == NHERE) { len = strlen(redir->nhere.doc->narg.text); if (len <= PIPESIZE) { - full_write(pip[1], redir->nhere.doc->narg.text, len); + bb_full_write(pip[1], redir->nhere.doc->narg.text, len); goto out; } } @@ -10987,7 +10993,7 @@ openhere(union node *redir) #endif signal(SIGPIPE, SIG_DFL); if (redir->type == NHERE) - full_write(pip[1], redir->nhere.doc->narg.text, len); + bb_full_write(pip[1], redir->nhere.doc->narg.text, len); else expandhere(redir->nhere.doc, pip[1]); _exit(0); @@ -11616,7 +11622,9 @@ trapcmd(int argc, char **argv) if (trap[signo] != NULL) { const char *sn; - sn = get_signame(signo); + sn = u_signal_names(0, &signo, 0); + if (sn == NULL) + sn = "???"; out1fmt("trap -- %s %s\n", single_quote(trap[signo]), sn); } @@ -11628,7 +11636,7 @@ trapcmd(int argc, char **argv) else action = *ap++; while (*ap) { - if ((signo = get_signum(*ap)) < 0) + if ((signo = decode_signal(*ap, 0)) < 0) sh_error("%s: bad trap", *ap); INTOFF; if (action) { @@ -11931,6 +11939,14 @@ out: /* NOTREACHED */ } +static int decode_signal(const char *string, int minsig) +{ + int signo; + const char *name = u_signal_names(string, &signo, minsig); + + return name ? signo : -1; +} + /* var.c */ static struct var *vartab[VTABSIZE]; @@ -13457,7 +13473,7 @@ static const char op_tokens[] = { static arith_t arith (const char *expr, int *perrcode) { - char arithval; /* Current character under analysis */ + register char arithval; /* Current character under analysis */ operator lasttok, op; operator prec; diff --git a/shell/lash.c b/shell/lash.c index 92c24d1c2..be2f364e0 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -22,7 +22,18 @@ #include "busybox.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include "cmdedit.h" #ifdef CONFIG_LOCALE_SUPPORT @@ -532,6 +543,16 @@ static void checkjobs(struct jobset *j_list) /* child stopped */ job->stopped_progs++; job->progs[prognum].is_stopped = 1; + +#if 0 + /* Printing this stuff is a pain, since it tends to + * overwrite the prompt an inconveinient moments. So + * don't do that. */ + if (job->stopped_progs == job->num_progs) { + printf(JOB_STATUS_FORMAT, job->jobid, "Stopped", + job->text); + } +#endif } } @@ -686,6 +707,26 @@ static int get_command(FILE * source, char *command) return 0; } +static char* itoa(register int i) +{ + static char a[7]; /* Max 7 ints */ + register char *b = a + sizeof(a) - 1; + int sign = (i < 0); + + if (sign) + i = -i; + *b = 0; + do + { + *--b = '0' + (i % 10); + i /= 10; + } + while (i); + if (sign) + *--b = '-'; + return b; +} + static char * strsep_space( char *string, int * ix) { char *token; diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index de9c3700f..f0d440d2b 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c @@ -1,5 +1,4 @@ -/* vi: set sw=4 ts=4: */ -/* +/* vi: set ts=4: * * dmesg - display/control kernel ring buffer. * -- cgit v1.2.3