From: Eric Andersen Date: Fri, 10 Aug 2001 18:22:16 +0000 (-0000) Subject: Merge the CVS changes so far into the stable branch. X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6c8c51a4706a2e58bb43ebc73cbd59f052c54be5;p=oweals%2Fbusybox.git Merge the CVS changes so far into the stable branch. --- diff --git a/busybox/Config.h b/busybox/Config.h index b0b57b04e..c46e2d282 100644 --- a/busybox/Config.h +++ b/busybox/Config.h @@ -239,6 +239,9 @@ // Enable support for mounting remote NFS volumes. // You may need to mount with "-o nolock" if you are // not running a local portmapper daemon... +// +// If you are using uClibc, be sure that you've already compiled +// uClibc with INCLUDE_RPC=true (contained in the Config file) //#define BB_FEATURE_NFSMOUNT // // Enable support forced filesystem unmounting @@ -316,7 +319,7 @@ // Support for Minix filesystem, version 2 //#define BB_FEATURE_MINIX2 // -// Enable ifconfig status reporting output -- this feature adds 12k. +// Enable ifconfig status reporting output -- this feature adds 7k. //#define BB_FEATURE_IFCONFIG_STATUS // // Enable ifconfig slip-specific options "keepalive" and "outfill" @@ -328,6 +331,10 @@ // Enable ifconfig option "hw". Currently works for only with "ether". //#define BB_FEATURE_IFCONFIG_HW // +// Allows "broadcast +" to set broadcast automatically based on hostaddr +// and netmask, at a cost of about 100 bytes of code (i386). +//#define BB_FEATURE_IFCONFIG_BROADCAST_PLUS +// // Enable busybox --install [-s] // to create links (or symlinks) for all the commands that are // compiled into the binary. (needs /proc filesystem) @@ -462,15 +469,11 @@ #endif // #if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH -# define BB_SH # define shell_main ash_main #elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH -# define BB_SH # define shell_main hush_main #elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH -# define BB_SH # define shell_main lash_main #elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH -# define BB_SH # define shell_main msh_main #endif diff --git a/busybox/Makefile b/busybox/Makefile index 44d5b5e93..242dac4b9 100644 --- a/busybox/Makefile +++ b/busybox/Makefile @@ -250,7 +250,8 @@ safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \ trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \ xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \ copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \ -dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c +dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c \ +simplify_path.c LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC)) ifeq ($(strip $(BB_SRC_DIR)),) LIBBB_CFLAGS += -I$(LIBBB) diff --git a/busybox/ash.c b/busybox/ash.c index bcd12f106..914458451 100644 --- a/busybox/ash.c +++ b/busybox/ash.c @@ -58,7 +58,7 @@ /* Getopts is used by shell procedures to parse positional parameters. * You probably want to leave this disabled, and use the busybox getopt * applet if you want to do this sort of thing. There are some scripts - * out there that use it, so it you need it, enable. Most people will + * out there that use it, so if you need it, enable it. Most people will * leave this disabled. This adds 1k on an x86 system. */ #undef ASH_GETOPTS @@ -12785,7 +12785,7 @@ findvar(struct var **vpp, const char *name) /* * Copyright (c) 1999 Herbert Xu * This file contains code for the times builtin. - * $Id: ash.c,v 1.17 2001/08/02 05:02:45 andersen Exp $ + * $Id: ash.c,v 1.17.2.1 2001/08/10 18:22:14 andersen Exp $ */ static int timescmd (int argc, char **argv) { diff --git a/busybox/chroot.c b/busybox/chroot.c index 0440e46b9..de6a2ea50 100644 --- a/busybox/chroot.c +++ b/busybox/chroot.c @@ -48,7 +48,7 @@ int chroot_main(int argc, char **argv) prog = *argv; execvp(*argv, argv); } else { -#if defined(BB_SH) && defined BB_FEATURE_SH_STANDALONE_SHELL +#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL char shell[] = "/bin/sh"; char *shell_argv[2] = { shell, NULL }; applet_name = shell; diff --git a/busybox/coreutils/chroot.c b/busybox/coreutils/chroot.c index 0440e46b9..de6a2ea50 100644 --- a/busybox/coreutils/chroot.c +++ b/busybox/coreutils/chroot.c @@ -48,7 +48,7 @@ int chroot_main(int argc, char **argv) prog = *argv; execvp(*argv, argv); } else { -#if defined(BB_SH) && defined BB_FEATURE_SH_STANDALONE_SHELL +#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL char shell[] = "/bin/sh"; char *shell_argv[2] = { shell, NULL }; applet_name = shell; diff --git a/busybox/coreutils/head.c b/busybox/coreutils/head.c index 0c8ef3d59..688c250b1 100644 --- a/busybox/coreutils/head.c +++ b/busybox/coreutils/head.c @@ -22,7 +22,6 @@ * */ -#include #include #include #include @@ -82,10 +81,9 @@ int head_main(int argc, char **argv) printf("==> %s <==\n", argv[optind]); } head(len, fp); - if (errno) { + if (ferror(fp)) { perror_msg("%s", argv[optind]); status = EXIT_FAILURE; - errno = 0; } if (optind < argc - 1) putchar('\n'); diff --git a/busybox/debian/Config.h-deb b/busybox/debian/Config.h-deb index 892ce1303..fd848e192 100644 --- a/busybox/debian/Config.h-deb +++ b/busybox/debian/Config.h-deb @@ -459,15 +459,11 @@ #endif // #if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH -# define BB_SH # define shell_main ash_main #elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH -# define BB_SH # define shell_main hush_main #elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH -# define BB_SH # define shell_main lash_main #elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH -# define BB_SH # define shell_main msh_main #endif diff --git a/busybox/debian/Config.h-static b/busybox/debian/Config.h-static index 71f6df0d0..094b1f9b4 100644 --- a/busybox/debian/Config.h-static +++ b/busybox/debian/Config.h-static @@ -459,15 +459,11 @@ #endif // #if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH -# define BB_SH # define shell_main ash_main #elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH -# define BB_SH # define shell_main hush_main #elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH -# define BB_SH # define shell_main lash_main #elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH -# define BB_SH # define shell_main msh_main #endif diff --git a/busybox/debian/Config.h-udeb b/busybox/debian/Config.h-udeb index 51446ff89..8e7594dc4 100644 --- a/busybox/debian/Config.h-udeb +++ b/busybox/debian/Config.h-udeb @@ -459,15 +459,11 @@ #endif // #if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH -# define BB_SH # define shell_main ash_main #elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH -# define BB_SH # define shell_main hush_main #elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH -# define BB_SH # define shell_main lash_main #elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH -# define BB_SH # define shell_main msh_main #endif diff --git a/busybox/head.c b/busybox/head.c index 0c8ef3d59..688c250b1 100644 --- a/busybox/head.c +++ b/busybox/head.c @@ -22,7 +22,6 @@ * */ -#include #include #include #include @@ -82,10 +81,9 @@ int head_main(int argc, char **argv) printf("==> %s <==\n", argv[optind]); } head(len, fp); - if (errno) { + if (ferror(fp)) { perror_msg("%s", argv[optind]); status = EXIT_FAILURE; - errno = 0; } if (optind < argc - 1) putchar('\n'); diff --git a/busybox/ifconfig.c b/busybox/ifconfig.c index 7f3978a4a..5f8b0eed6 100644 --- a/busybox/ifconfig.c +++ b/busybox/ifconfig.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: ifconfig.c,v 1.11 2001/07/07 05:19:52 andersen Exp $ + * $Id: ifconfig.c,v 1.11.2.1 2001/08/10 18:22:15 andersen Exp $ * */ @@ -110,8 +110,6 @@ #define A_NETMASK 0x20 /* Set if netmask (check for multiple sets). */ #define A_SET_AFTER 0x40 /* Set a flag at the end. */ #define A_COLON_CHK 0x80 /* Is this needed? See below. */ -#define A_HOSTNAME 0x100 /* Set if it is ip addr. */ -#define A_BROADCAST 0x200 /* Set if it is broadcast addr. */ /* * These defines are for dealing with the A_CAST_TYPE field. @@ -141,12 +139,12 @@ #define ARG_IRQ (A_ARG_REQ | A_MAP_UCHAR) #define ARG_DSTADDR (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE) #define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK) -#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_BROADCAST) +#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) #define ARG_HW (A_ARG_REQ | A_CAST_HOST_COPY_IN_ETHER) #define ARG_POINTOPOINT (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) #define ARG_KEEPALIVE (A_ARG_REQ | A_CAST_CHAR_PTR) #define ARG_OUTFILL (A_ARG_REQ | A_CAST_CHAR_PTR) -#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK | A_HOSTNAME) +#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK) /* @@ -162,7 +160,7 @@ struct arg1opt { struct options { const char *name; const unsigned char flags; - const unsigned int arg_flags; + const unsigned char arg_flags; const unsigned short selector; }; @@ -248,7 +246,6 @@ int ifconfig_main(int argc, char **argv) { struct ifreq ifr; struct sockaddr_in sai; - struct sockaddr_in sai_hostname, sai_netmask; #ifdef BB_FEATURE_IFCONFIG_HW struct sockaddr sa; #endif @@ -259,8 +256,8 @@ int ifconfig_main(int argc, char **argv) int selector; char *p; char host[128]; - unsigned int mask; - unsigned int did_flags; + unsigned char mask; + unsigned char did_flags; goterr = 0; did_flags = 0; @@ -334,7 +331,7 @@ int ifconfig_main(int argc, char **argv) } } else { /* got an arg so process it */ HOSTNAME: - did_flags |= (mask & (A_NETMASK|A_HOSTNAME)); + did_flags |= (mask & A_NETMASK); if (mask & A_CAST_HOST_COPY) { #ifdef BB_FEATURE_IFCONFIG_HW if (mask & A_CAST_RESOLVE) { @@ -345,20 +342,11 @@ int ifconfig_main(int argc, char **argv) if (!strcmp(host, "default")) { /* Default is special, meaning 0.0.0.0. */ sai.sin_addr.s_addr = INADDR_ANY; - } else if ((!strcmp(host, "+")) && (mask & A_BROADCAST) && - (did_flags & (A_NETMASK|A_HOSTNAME))) { - /* + is special, meaning broadcast is derived. */ - sai.sin_addr.s_addr = (~sai_netmask.sin_addr.s_addr) | - (sai_hostname.sin_addr.s_addr & sai_netmask.sin_addr.s_addr); } else if (inet_aton(host, &sai.sin_addr) == 0) { /* It's not a dotted quad. */ ++goterr; continue; } - if(mask & A_HOSTNAME) - sai_hostname = sai; - if(mask & A_NETMASK) - sai_netmask = sai; p = (char *) &sai; #ifdef BB_FEATURE_IFCONFIG_HW } else { /* A_CAST_HOST_COPY_IN_ETHER */ diff --git a/busybox/include/libbb.h b/busybox/include/libbb.h index 04ed2ae82..a7e38325b 100644 --- a/busybox/include/libbb.h +++ b/busybox/include/libbb.h @@ -264,6 +264,7 @@ char *dirname (const char *path); int make_directory (char *path, long mode, int flags); const char *u_signal_names(const char *str_sig, int *signo, int startnum); +char *simplify_path(const char *path); #define CT_AUTO 0 #define CT_UNIX2DOS 1 diff --git a/busybox/insmod.c b/busybox/insmod.c index 1a63ecb2a..013715278 100644 --- a/busybox/insmod.c +++ b/busybox/insmod.c @@ -133,7 +133,7 @@ #ifndef MODUTILS_MODULE_H static const int MODUTILS_MODULE_H = 1; -#ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $" +#ident "$Id: insmod.c,v 1.70.2.1 2001/08/10 18:22:15 andersen Exp $" /* This file contains the structures used by the 2.0 and 2.1 kernels. We do not use the kernel headers directly because we do not wish @@ -350,7 +350,7 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H static const int MODUTILS_OBJ_H = 1; -#ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $" +#ident "$Id: insmod.c,v 1.70.2.1 2001/08/10 18:22:15 andersen Exp $" /* The relocatable object is manipulated using elfin types. */ @@ -1304,22 +1304,6 @@ static unsigned long obj_elf_hash(const char *name) } #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING -/* Get the kernel version in the canonical integer form. */ - -static int get_kernel_version(char str[STRVERSIONLEN]) -{ - struct utsname uts_info; - int kv; - - if (uname(&uts_info) < 0) - return -1; - strncpy(str, uts_info.release, STRVERSIONLEN); - - kv = get_kernel_revision(); - if(kv==0) - return -1; -} - /* String comparison for non-co-versioned kernel and module. */ static int ncv_strcmp(const char *a, const char *b) @@ -3239,8 +3223,7 @@ extern int insmod_main( int argc, char **argv) int exit_status = EXIT_FAILURE; int m_has_modinfo; #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING - int k_version; - char k_strversion[STRVERSIONLEN]; + struct utsname uts_info; char m_strversion[STRVERSIONLEN]; int m_version; int m_crcs; @@ -3355,7 +3338,8 @@ extern int insmod_main( int argc, char **argv) #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING /* Version correspondence? */ - k_version = get_kernel_version(k_strversion); + if (uname(&uts_info) < 0) + uts_info.release[0] = '\0'; if (m_has_modinfo) { m_version = new_get_module_version(f, m_strversion); } else { @@ -3367,17 +3351,17 @@ extern int insmod_main( int argc, char **argv) } } - if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { + if (strncmp(uts_info.release, m_strversion, STRVERSIONLEN) != 0) { if (flag_force_load) { error_msg("Warning: kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" "\twhile this kernel is version %s", - m_filename, m_strversion, k_strversion); + m_filename, m_strversion, uts_info.release); } else { error_msg("kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" "\twhile this kernel is version %s.", - m_filename, m_strversion, k_strversion); + m_filename, m_strversion, uts_info.release); goto out; } } diff --git a/busybox/libbb/libbb.h b/busybox/libbb/libbb.h index 04ed2ae82..a7e38325b 100644 --- a/busybox/libbb/libbb.h +++ b/busybox/libbb/libbb.h @@ -264,6 +264,7 @@ char *dirname (const char *path); int make_directory (char *path, long mode, int flags); const char *u_signal_names(const char *str_sig, int *signo, int startnum); +char *simplify_path(const char *path); #define CT_AUTO 0 #define CT_UNIX2DOS 1 diff --git a/busybox/libbb/unarchive.c b/busybox/libbb/unarchive.c index 91db2e3b1..0d414a3a8 100644 --- a/busybox/libbb/unarchive.c +++ b/busybox/libbb/unarchive.c @@ -230,24 +230,35 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers const int extract_function, const char *prefix, char **extract_names) { file_header_t *file_entry; - int found; + int extract_flag; int i; char *buffer = NULL; archive_offset = 0; while ((file_entry = get_headers(src_stream)) != NULL) { - found = FALSE; - if (extract_names == NULL) { - found = TRUE; - } else { + extract_flag = TRUE; + if (extract_names != NULL) { + int found_flag = FALSE; for(i = 0; extract_names[i] != 0; i++) { if (strcmp(extract_names[i], file_entry->name) == 0) { - found = TRUE; + found_flag = TRUE; + break; + } + } + if (extract_function & extract_exclude_list) { + if (found_flag == TRUE) { + extract_flag = FALSE; + } + } else { + /* If its not found in the include list dont extract it */ + if (found_flag == FALSE) { + extract_flag = FALSE; } } + } - if (found) { + if (extract_flag == TRUE) { buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix); } else { /* seek past the data entry */ diff --git a/busybox/modutils/insmod.c b/busybox/modutils/insmod.c index 1a63ecb2a..013715278 100644 --- a/busybox/modutils/insmod.c +++ b/busybox/modutils/insmod.c @@ -133,7 +133,7 @@ #ifndef MODUTILS_MODULE_H static const int MODUTILS_MODULE_H = 1; -#ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $" +#ident "$Id: insmod.c,v 1.70.2.1 2001/08/10 18:22:15 andersen Exp $" /* This file contains the structures used by the 2.0 and 2.1 kernels. We do not use the kernel headers directly because we do not wish @@ -350,7 +350,7 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H static const int MODUTILS_OBJ_H = 1; -#ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $" +#ident "$Id: insmod.c,v 1.70.2.1 2001/08/10 18:22:15 andersen Exp $" /* The relocatable object is manipulated using elfin types. */ @@ -1304,22 +1304,6 @@ static unsigned long obj_elf_hash(const char *name) } #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING -/* Get the kernel version in the canonical integer form. */ - -static int get_kernel_version(char str[STRVERSIONLEN]) -{ - struct utsname uts_info; - int kv; - - if (uname(&uts_info) < 0) - return -1; - strncpy(str, uts_info.release, STRVERSIONLEN); - - kv = get_kernel_revision(); - if(kv==0) - return -1; -} - /* String comparison for non-co-versioned kernel and module. */ static int ncv_strcmp(const char *a, const char *b) @@ -3239,8 +3223,7 @@ extern int insmod_main( int argc, char **argv) int exit_status = EXIT_FAILURE; int m_has_modinfo; #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING - int k_version; - char k_strversion[STRVERSIONLEN]; + struct utsname uts_info; char m_strversion[STRVERSIONLEN]; int m_version; int m_crcs; @@ -3355,7 +3338,8 @@ extern int insmod_main( int argc, char **argv) #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING /* Version correspondence? */ - k_version = get_kernel_version(k_strversion); + if (uname(&uts_info) < 0) + uts_info.release[0] = '\0'; if (m_has_modinfo) { m_version = new_get_module_version(f, m_strversion); } else { @@ -3367,17 +3351,17 @@ extern int insmod_main( int argc, char **argv) } } - if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { + if (strncmp(uts_info.release, m_strversion, STRVERSIONLEN) != 0) { if (flag_force_load) { error_msg("Warning: kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" "\twhile this kernel is version %s", - m_filename, m_strversion, k_strversion); + m_filename, m_strversion, uts_info.release); } else { error_msg("kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" "\twhile this kernel is version %s.", - m_filename, m_strversion, k_strversion); + m_filename, m_strversion, uts_info.release); goto out; } } diff --git a/busybox/mount.c b/busybox/mount.c index eb6091f30..6ffce2bf1 100644 --- a/busybox/mount.c +++ b/busybox/mount.c @@ -395,18 +395,15 @@ extern int mount_main(int argc, char **argv) if (optind < argc) { /* if device is a filename get its real path */ if (stat(argv[optind], &statbuf) == 0) { - realpath(argv[optind], device); + device = simplify_path(argv[optind]); } else { safe_strncpy(device, argv[optind], PATH_MAX); } } - if (optind + 1 < argc) { - if (realpath(argv[optind + 1], directory) == NULL) { - perror_msg_and_die("%s", directory); - } - } - + if (optind + 1 < argc) + directory = simplify_path(argv[optind + 1]); + if (all == TRUE || optind + 1 == argc) { struct mntent *m = NULL; FILE *f = setmntent("/etc/fstab", "r"); diff --git a/busybox/msh.c b/busybox/msh.c index 92a0f8536..e16d6f304 100644 --- a/busybox/msh.c +++ b/busybox/msh.c @@ -1261,7 +1261,7 @@ static void ronly(vp) struct var *vp; { - if (isalpha(vp->name[0])) /* not an internal symbol ($# etc) */ + if (isalpha(vp->name[0]) || vp->name[0] == '_') /* not an internal symbol */ vp->status |= RONLY; } @@ -1269,10 +1269,10 @@ static int isassign(s) register char *s; { - if (!isalpha((int)*s)) + if (!isalpha((int)*s) && *s != '_') return(0); for (; *s != '='; s++) - if (*s == 0 || !isalnum(*s)) + if (*s == 0 || (!isalnum(*s) && *s != '_')) return(0); return(1); } @@ -1285,10 +1285,10 @@ int cf; register char *cp; struct var *vp; - if (!isalpha(*s)) + if (!isalpha(*s) && *s != '_') return(0); for (cp = s; *cp != '='; cp++) - if (*cp == 0 || !isalnum(*cp)) + if (*cp == 0 || (!isalnum(*cp) && *cp != '_')) return(0); vp = lookup(s); nameval(vp, ++cp, cf == COPYV? (char *)NULL: s); @@ -1301,10 +1301,10 @@ static int checkname(cp) register char *cp; { - if (!isalpha(*cp++)) + if (!isalpha(*cp++) && *(cp-1) != '_') return(0); while (*cp) - if (!isalnum(*cp++)) + if (!isalnum(*cp++) && *(cp-1) != '_') return(0); return(1); } @@ -1316,7 +1316,7 @@ register int f, out; register struct var *vp; for (vp = vlist; vp; vp = vp->next) - if (vp->status & f && isalpha(*vp->name)) { + if (vp->status & f && (isalpha(*vp->name) || *vp->name == '_')) { if (vp->status & EXPORT) write(out, "export ", 7); if (vp->status & RONLY) @@ -3406,7 +3406,7 @@ varput(s, out) register char *s; int out; { - if (isalnum(*s)) { + if (isalnum(*s) || *s == '_') { write(out, s, strlen(s)); write(out, "\n", 1); } @@ -3613,7 +3613,7 @@ loop: c = 0; } unget(c); - if (!isalpha(c)) + if (!isalpha(c) && c != '_') scanequals = 0; for (;;) { c = subgetc('"', foundequals); @@ -3631,7 +3631,7 @@ loop: foundequals = 1; scanequals = 0; } - else if (!isalnum(c)) + else if (!isalnum(c) && c != '_') scanequals = 0; } *e.linep++ = c; @@ -3684,8 +3684,8 @@ int quoted; s = e.linep; if (c != '{') { *e.linep++ = c; - if (isalpha(c)) { - while ((c = readc())!=0 && isalnum(c)) + if (isalpha(c) || c == '_') { + while ((c = readc())!=0 && (isalnum(c) || c == '_')) if (e.linep < elinep) *e.linep++ = c; unget(c); diff --git a/busybox/networking/ifconfig.c b/busybox/networking/ifconfig.c index 7f3978a4a..5f8b0eed6 100644 --- a/busybox/networking/ifconfig.c +++ b/busybox/networking/ifconfig.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: ifconfig.c,v 1.11 2001/07/07 05:19:52 andersen Exp $ + * $Id: ifconfig.c,v 1.11.2.1 2001/08/10 18:22:15 andersen Exp $ * */ @@ -110,8 +110,6 @@ #define A_NETMASK 0x20 /* Set if netmask (check for multiple sets). */ #define A_SET_AFTER 0x40 /* Set a flag at the end. */ #define A_COLON_CHK 0x80 /* Is this needed? See below. */ -#define A_HOSTNAME 0x100 /* Set if it is ip addr. */ -#define A_BROADCAST 0x200 /* Set if it is broadcast addr. */ /* * These defines are for dealing with the A_CAST_TYPE field. @@ -141,12 +139,12 @@ #define ARG_IRQ (A_ARG_REQ | A_MAP_UCHAR) #define ARG_DSTADDR (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE) #define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK) -#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_BROADCAST) +#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) #define ARG_HW (A_ARG_REQ | A_CAST_HOST_COPY_IN_ETHER) #define ARG_POINTOPOINT (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) #define ARG_KEEPALIVE (A_ARG_REQ | A_CAST_CHAR_PTR) #define ARG_OUTFILL (A_ARG_REQ | A_CAST_CHAR_PTR) -#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK | A_HOSTNAME) +#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK) /* @@ -162,7 +160,7 @@ struct arg1opt { struct options { const char *name; const unsigned char flags; - const unsigned int arg_flags; + const unsigned char arg_flags; const unsigned short selector; }; @@ -248,7 +246,6 @@ int ifconfig_main(int argc, char **argv) { struct ifreq ifr; struct sockaddr_in sai; - struct sockaddr_in sai_hostname, sai_netmask; #ifdef BB_FEATURE_IFCONFIG_HW struct sockaddr sa; #endif @@ -259,8 +256,8 @@ int ifconfig_main(int argc, char **argv) int selector; char *p; char host[128]; - unsigned int mask; - unsigned int did_flags; + unsigned char mask; + unsigned char did_flags; goterr = 0; did_flags = 0; @@ -334,7 +331,7 @@ int ifconfig_main(int argc, char **argv) } } else { /* got an arg so process it */ HOSTNAME: - did_flags |= (mask & (A_NETMASK|A_HOSTNAME)); + did_flags |= (mask & A_NETMASK); if (mask & A_CAST_HOST_COPY) { #ifdef BB_FEATURE_IFCONFIG_HW if (mask & A_CAST_RESOLVE) { @@ -345,20 +342,11 @@ int ifconfig_main(int argc, char **argv) if (!strcmp(host, "default")) { /* Default is special, meaning 0.0.0.0. */ sai.sin_addr.s_addr = INADDR_ANY; - } else if ((!strcmp(host, "+")) && (mask & A_BROADCAST) && - (did_flags & (A_NETMASK|A_HOSTNAME))) { - /* + is special, meaning broadcast is derived. */ - sai.sin_addr.s_addr = (~sai_netmask.sin_addr.s_addr) | - (sai_hostname.sin_addr.s_addr & sai_netmask.sin_addr.s_addr); } else if (inet_aton(host, &sai.sin_addr) == 0) { /* It's not a dotted quad. */ ++goterr; continue; } - if(mask & A_HOSTNAME) - sai_hostname = sai; - if(mask & A_NETMASK) - sai_netmask = sai; p = (char *) &sai; #ifdef BB_FEATURE_IFCONFIG_HW } else { /* A_CAST_HOST_COPY_IN_ETHER */ diff --git a/busybox/shell/ash.c b/busybox/shell/ash.c index bcd12f106..914458451 100644 --- a/busybox/shell/ash.c +++ b/busybox/shell/ash.c @@ -58,7 +58,7 @@ /* Getopts is used by shell procedures to parse positional parameters. * You probably want to leave this disabled, and use the busybox getopt * applet if you want to do this sort of thing. There are some scripts - * out there that use it, so it you need it, enable. Most people will + * out there that use it, so if you need it, enable it. Most people will * leave this disabled. This adds 1k on an x86 system. */ #undef ASH_GETOPTS @@ -12785,7 +12785,7 @@ findvar(struct var **vpp, const char *name) /* * Copyright (c) 1999 Herbert Xu * This file contains code for the times builtin. - * $Id: ash.c,v 1.17 2001/08/02 05:02:45 andersen Exp $ + * $Id: ash.c,v 1.17.2.1 2001/08/10 18:22:14 andersen Exp $ */ static int timescmd (int argc, char **argv) { diff --git a/busybox/shell/msh.c b/busybox/shell/msh.c index 92a0f8536..e16d6f304 100644 --- a/busybox/shell/msh.c +++ b/busybox/shell/msh.c @@ -1261,7 +1261,7 @@ static void ronly(vp) struct var *vp; { - if (isalpha(vp->name[0])) /* not an internal symbol ($# etc) */ + if (isalpha(vp->name[0]) || vp->name[0] == '_') /* not an internal symbol */ vp->status |= RONLY; } @@ -1269,10 +1269,10 @@ static int isassign(s) register char *s; { - if (!isalpha((int)*s)) + if (!isalpha((int)*s) && *s != '_') return(0); for (; *s != '='; s++) - if (*s == 0 || !isalnum(*s)) + if (*s == 0 || (!isalnum(*s) && *s != '_')) return(0); return(1); } @@ -1285,10 +1285,10 @@ int cf; register char *cp; struct var *vp; - if (!isalpha(*s)) + if (!isalpha(*s) && *s != '_') return(0); for (cp = s; *cp != '='; cp++) - if (*cp == 0 || !isalnum(*cp)) + if (*cp == 0 || (!isalnum(*cp) && *cp != '_')) return(0); vp = lookup(s); nameval(vp, ++cp, cf == COPYV? (char *)NULL: s); @@ -1301,10 +1301,10 @@ static int checkname(cp) register char *cp; { - if (!isalpha(*cp++)) + if (!isalpha(*cp++) && *(cp-1) != '_') return(0); while (*cp) - if (!isalnum(*cp++)) + if (!isalnum(*cp++) && *(cp-1) != '_') return(0); return(1); } @@ -1316,7 +1316,7 @@ register int f, out; register struct var *vp; for (vp = vlist; vp; vp = vp->next) - if (vp->status & f && isalpha(*vp->name)) { + if (vp->status & f && (isalpha(*vp->name) || *vp->name == '_')) { if (vp->status & EXPORT) write(out, "export ", 7); if (vp->status & RONLY) @@ -3406,7 +3406,7 @@ varput(s, out) register char *s; int out; { - if (isalnum(*s)) { + if (isalnum(*s) || *s == '_') { write(out, s, strlen(s)); write(out, "\n", 1); } @@ -3613,7 +3613,7 @@ loop: c = 0; } unget(c); - if (!isalpha(c)) + if (!isalpha(c) && c != '_') scanequals = 0; for (;;) { c = subgetc('"', foundequals); @@ -3631,7 +3631,7 @@ loop: foundequals = 1; scanequals = 0; } - else if (!isalnum(c)) + else if (!isalnum(c) && c != '_') scanequals = 0; } *e.linep++ = c; @@ -3684,8 +3684,8 @@ int quoted; s = e.linep; if (c != '{') { *e.linep++ = c; - if (isalpha(c)) { - while ((c = readc())!=0 && isalnum(c)) + if (isalpha(c) || c == '_') { + while ((c = readc())!=0 && (isalnum(c) || c == '_')) if (e.linep < elinep) *e.linep++ = c; unget(c); diff --git a/busybox/util-linux/mount.c b/busybox/util-linux/mount.c index eb6091f30..6ffce2bf1 100644 --- a/busybox/util-linux/mount.c +++ b/busybox/util-linux/mount.c @@ -395,18 +395,15 @@ extern int mount_main(int argc, char **argv) if (optind < argc) { /* if device is a filename get its real path */ if (stat(argv[optind], &statbuf) == 0) { - realpath(argv[optind], device); + device = simplify_path(argv[optind]); } else { safe_strncpy(device, argv[optind], PATH_MAX); } } - if (optind + 1 < argc) { - if (realpath(argv[optind + 1], directory) == NULL) { - perror_msg_and_die("%s", directory); - } - } - + if (optind + 1 < argc) + directory = simplify_path(argv[optind + 1]); + if (all == TRUE || optind + 1 == argc) { struct mntent *m = NULL; FILE *f = setmntent("/etc/fstab", "r");