From 71ae64bdc6b044eef0a9f3bebd85cc4a6b67362f Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 10 Oct 2002 04:20:21 +0000 Subject: [PATCH] last_patch61 from vodz: New complex patch for decrease size devel version. Requires previous patch. Also removed small problems from dutmp and tar applets. Also includes vodz' last_patch61_2: Last patch correcting comment for #endif and more integrated with libbb (very reduce size if used "cat" applet also). Requires last_patch61 for modutils/config.in. --- archival/libunarchive/data_extract_all.c | 2 +- archival/tar.c | 12 +++---- console-tools/dumpkmap.c | 2 +- init/init.c | 7 ++-- libbb/messages.c | 2 +- libbb/obscure.c | 62 ++++++++++++++++---------------- loginutils/getty.c | 24 +++---------- loginutils/login.c | 14 ++++---- miscutils/dutmp.c | 2 +- modutils/config.in | 4 +++ modutils/insmod.c | 8 +++-- modutils/lsmod.c | 26 ++++++-------- 12 files changed, 76 insertions(+), 89 deletions(-) diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c index 39af2e3e7..f839be35e 100644 --- a/archival/libunarchive/data_extract_all.c +++ b/archival/libunarchive/data_extract_all.c @@ -16,7 +16,7 @@ extern void data_extract_all(archive_handle_t *archive_handle) int res; if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) { - char *name = strdup(file_header->name); + char *name = xstrdup(file_header->name); make_directory (dirname(name), 0777, FILEUTILS_RECUR); free(name); } diff --git a/archival/tar.c b/archival/tar.c index e6c134e3b..dba6bbcc4 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -302,7 +302,7 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo, if ((size = full_write(tbInfo->tarFd, (char *) &header, sizeof(struct TarHeader))) < 0) { - error_msg(io_error, real_name, strerror(errno)); + error_msg(io_error, real_name); return (FALSE); } /* Pad the header up to the tar block size */ @@ -426,7 +426,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, /* open the file we want to archive, and make sure all is well */ if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { - error_msg("%s: Cannot open: %s", fileName, strerror(errno)); + perror_msg("%s: Cannot open", fileName); return (FALSE); } @@ -434,13 +434,13 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, while ((size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0) { if (full_write(tbInfo->tarFd, buffer, size) != size) { /* Output file seems to have a problem */ - error_msg(io_error, fileName, strerror(errno)); + error_msg(io_error, fileName); return (FALSE); } readSize += size; } if (size == -1) { - error_msg(io_error, fileName, strerror(errno)); + error_msg(io_error, fileName); return (FALSE); } /* Pad the file up to the tar block size */ @@ -483,7 +483,7 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag, } if (tbInfo.tarFd < 0) { - perror_msg("Error opening '%s'", tarName); + perror_msg("%s: Cannot open", tarName); freeHardLinkInfo(&tbInfo.hlInfoHead); return (FALSE); } @@ -491,7 +491,7 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag, /* Store the stat info for the tarball's file, so * can avoid including the tarball into itself.... */ if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0) - error_msg_and_die(io_error, tarName, strerror(errno)); + error_msg_and_die(io_error, tarName); #ifdef CONFIG_FEATURE_TAR_GZIP if (gzip) { diff --git a/console-tools/dumpkmap.c b/console-tools/dumpkmap.c index 22652a5e2..d2bb6dcff 100644 --- a/console-tools/dumpkmap.c +++ b/console-tools/dumpkmap.c @@ -81,7 +81,7 @@ int dumpkmap_main(int argc, char **argv) ke.kb_table = i; if (ioctl(fd, KDGKBENT, &ke) < 0) { - error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value); + error_msg("ioctl returned: %m, %s, %s, %xqq", (char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value); } else { write(1,(void*)&ke.kb_value,2); diff --git a/init/init.c b/init/init.c index 3b0a66a24..edbd90bfe 100644 --- a/init/init.c +++ b/init/init.c @@ -660,8 +660,7 @@ static pid_t run(struct init_action *a) execve(cmdpath, cmd, environment); /* We're still here? Some error happened. */ - message(LOG | CONSOLE, "\rBummer, could not run '%s': %s\n", cmdpath, - strerror(errno)); + message(LOG | CONSOLE, "\rBummer, could not run '%s': %m\n", cmdpath); _exit(-1); } sigprocmask(SIG_SETMASK, &omask, NULL); @@ -785,8 +784,8 @@ static void exec_signal(int sig) message(CONSOLE | LOG, "\rTrying to re-exec %s\n", a->command); execl(a->command, a->command, NULL); - message(CONSOLE | LOG, "\rexec of '%s' failed: %s\n", - a->command, strerror(errno)); + message(CONSOLE | LOG, "\rexec of '%s' failed: %m\n", + a->command); sync(); sleep(2); init_reboot(RB_HALT_SYSTEM); diff --git a/libbb/messages.c b/libbb/messages.c index 185c1ee91..cc7e2146c 100644 --- a/libbb/messages.c +++ b/libbb/messages.c @@ -45,7 +45,7 @@ const char * const invalid_option = "invalid option -- %c"; #endif #ifdef L_io_error - const char * const io_error = "%s: input/output error -- %s"; + const char * const io_error = "%s: input/output error -- %m"; #endif #ifdef L_dash_dash_help const char * const dash_dash_help = "--help"; diff --git a/libbb/obscure.c b/libbb/obscure.c index dc7de751d..588ef5af6 100644 --- a/libbb/obscure.c +++ b/libbb/obscure.c @@ -44,7 +44,7 @@ * can't be a palindrome - like `R A D A R' or `M A D A M' */ -static int palindrome(const char *old, const char *newval) +static int palindrome(const char *newval) { int i, j; @@ -79,24 +79,25 @@ static int similiar(const char *old, const char *newval) * a nice mix of characters. */ -static int simple(const char *old, const char *newval) +static int simple(const char *newval) { int digits = 0; int uppers = 0; int lowers = 0; int others = 0; + int c; int size; int i; - for (i = 0; newval[i]; i++) { - if (isdigit(newval[i])) - digits++; - else if (isupper(newval[i])) - uppers++; - else if (islower(newval[i])) - lowers++; + for (i = 0; (c = *newval++) != 0; i++) { + if (isdigit(c)) + digits = c; + else if (isupper(c)) + uppers = c; + else if (islower(c)) + lowers = c; else - others++; + others = c; } /* @@ -129,49 +130,50 @@ static char *str_lower(char *string) return string; } -static char *password_check(const char *old, const char *newval, const struct passwd *pwdp) +static const char * +password_check(const char *old, const char *newval, const struct passwd *pwdp) { - char *msg = NULL; - char *oldmono, *newmono, *wrapped; + const char *msg; + char *newmono, *wrapped; + int lenwrap; if (strcmp(newval, old) == 0) return "no change"; + if (simple(newval)) + return "too simple"; + msg = NULL; newmono = str_lower(xstrdup(newval)); - oldmono = str_lower(xstrdup(old)); - wrapped = (char *) xmalloc(strlen(oldmono) * 2 + 1); - strcpy(wrapped, oldmono); - strcat(wrapped, oldmono); + lenwrap = strlen(old) * 2 + 1; + wrapped = (char *) xmalloc(lenwrap); + str_lower(strcpy(wrapped, old)); - if (palindrome(oldmono, newmono)) + if (palindrome(newmono)) msg = "a palindrome"; - if (!msg && strcmp(oldmono, newmono) == 0) + else if (strcmp(wrapped, newmono) == 0) msg = "case changes only"; - if (!msg && similiar(oldmono, newmono)) + else if (similiar(wrapped, newmono)) msg = "too similiar"; - if (!msg && simple(old, newval)) - msg = "too simple"; - - if (!msg && strstr(wrapped, newmono)) + else if (strstr(strcat(wrapped, wrapped), newmono)) msg = "rotated"; bzero(newmono, strlen(newmono)); - bzero(oldmono, strlen(oldmono)); - bzero(wrapped, strlen(wrapped)); + bzero(wrapped, lenwrap); free(newmono); - free(oldmono); free(wrapped); return msg; } -static char *obscure_msg(const char *old, const char *newval, const struct passwd *pwdp) +static const char * +obscure_msg(const char *old, const char *newval, const struct passwd *pwdp) { int maxlen, oldlen, newlen; - char *new1, *old1, *msg; + char *new1, *old1; + const char *msg; oldlen = strlen(old); newlen = strlen(newval); @@ -233,7 +235,7 @@ static char *obscure_msg(const char *old, const char *newval, const struct passw extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) { - char *msg = obscure_msg(old, newval, pwdp); + const char *msg = obscure_msg(old, newval, pwdp); /* if (msg) { */ if (msg != NULL) { diff --git a/loginutils/getty.c b/loginutils/getty.c index fec8ae8e5..0f0778caf 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -388,34 +388,20 @@ static void parse_args(int argc, char **argv, struct options *op) switch (c) { case 'I': if (!(op->initstring = strdup(optarg))) - error("can't malloc initstring"); + error(memory_exhausted); { - char ch, *p, *q; - int i; + const char *p; + char *q; /* copy optarg into op->initstring decoding \ddd octal codes into chars */ q = op->initstring; p = optarg; while (*p) { - if (*p == '\\') { /* know \\ means \ */ + if (*p == '\\') { p++; - if (*p == '\\') { - ch = '\\'; - p++; - } else { /* handle \000 - \177 */ - ch = 0; - for (i = 1; i <= 3; i++) { - if (*p >= '0' && *p <= '7') { - ch <<= 3; - ch += *p - '0'; - p++; - } else - break; - } - } - *q++ = ch; + *q++ = process_escape_sequence(&p); } else { *q++ = *p++; } diff --git a/loginutils/login.c b/loginutils/login.c index 714829db1..6b8f6c651 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -22,20 +22,15 @@ // import from utmp.c static void checkutmp(int picky); static void setutmp(const char *name, const char *line); +/* Stuff global to this file */ +struct utmp utent; #endif -// import from encrypt.c -extern char *pw_encrypt(const char *clear, const char *salt); - - // login defines #define TIMEOUT 60 #define EMPTY_USERNAME_COUNT 10 #define USERNAME_SIZE 32 -/* Stuff global to this file */ -struct utmp utent; - static int check_nologin ( int amroot ); @@ -131,12 +126,15 @@ extern int login_main(int argc, char **argv) else safe_strncpy ( tty, "UNKNOWN", sizeof( tty )); +#ifdef CONFIG_FEATURE_U_W_TMP if ( amroot ) memset ( utent.ut_host, 0, sizeof utent.ut_host ); +#endif if ( opt_host ) { +#ifdef CONFIG_FEATURE_U_W_TMP safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); - +#endif snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host ); } else diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c index cec5629c8..19e09fbb0 100644 --- a/miscutils/dutmp.c +++ b/miscutils/dutmp.c @@ -34,7 +34,7 @@ extern int dutmp_main(int argc, char **argv) } else { file = open(argv[1], O_RDONLY); if (file < 0) { - perror_msg_and_die(io_error, argv[1]); + error_msg_and_die(io_error, argv[1]); } } diff --git a/modutils/config.in b/modutils/config.in index 7fe7ec195..10b0a9c33 100644 --- a/modutils/config.in +++ b/modutils/config.in @@ -29,5 +29,9 @@ if [ "$CONFIG_LSMOD" = "y" ]; then fi fi +if [ "$CONFIG_INSMOD" = "y" -o "$CONFIG_LSMOD" = "y" ]; then + bool 'Support tainted module checking with new kernels' CONFIG_FEATURE_CHECK_TAINTED_MODULE +fi + endmenu diff --git a/modutils/insmod.c b/modutils/insmod.c index b246d90af..b367e84af 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -234,7 +234,7 @@ #ifndef MODUTILS_MODULE_H static const int MODUTILS_MODULE_H = 1; -#ident "$Id: insmod.c,v 1.90 2002/09/16 05:30:24 andersen Exp $" +#ident "$Id: insmod.c,v 1.91 2002/10/10 04:20:21 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 @@ -455,7 +455,7 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H static const int MODUTILS_OBJ_H = 1; -#ident "$Id: insmod.c,v 1.90 2002/09/16 05:30:24 andersen Exp $" +#ident "$Id: insmod.c,v 1.91 2002/10/10 04:20:21 andersen Exp $" /* The relocatable object is manipulated using elfin types. */ @@ -3422,6 +3422,7 @@ static void hide_special_symbols(struct obj_file *f) ELFW(ST_INFO) (STB_LOCAL, ELFW(ST_TYPE) (sym->info)); } +#ifdef CONFIG_FEATURE_CHECK_TAINTED_MODULE static int obj_gpl_license(struct obj_file *f, const char **license) { struct obj_section *sec; @@ -3533,6 +3534,9 @@ static void check_tainted_module(struct obj_file *f, char *m_name) if (fd >= 0) close(fd); } +#else /* CONFIG_FEATURE_CHECK_TAINTED_MODULE */ +#define check_tainted_module(x, y) do { } while(0); +#endif /* CONFIG_FEATURE_CHECK_TAINTED_MODULE */ extern int insmod_main( int argc, char **argv) { diff --git a/modutils/lsmod.c b/modutils/lsmod.c index a2a582389..a03247f73 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -40,13 +40,15 @@ #include "busybox.h" - +#ifndef CONFIG_FEATURE_CHECK_TAINTED_MODULE +static inline void check_tainted(void) { printf("\n"); } +#else #define TAINT_FILENAME "/proc/sys/kernel/tainted" #define TAINT_PROPRIETORY_MODULE (1<<0) #define TAINT_FORCED_MODULE (1<<1) #define TAINT_UNSAFE_SMP (1<<2) -void check_tainted(void) +static void check_tainted(void) { int tainted; FILE *f; @@ -66,6 +68,7 @@ void check_tainted(void) printf(" Not tainted\n"); } } +#endif #ifdef CONFIG_FEATURE_QUERY_MODULE_INTERFACE @@ -111,6 +114,7 @@ static int my_query_module(const char *name, int which, void **buf, return my_ret; } +#endif extern int lsmod_main(int argc, char **argv) { @@ -170,26 +174,16 @@ extern int lsmod_main(int argc, char **argv) return( 0); } -#else /*CONFIG_FEATURE_OLD_MODULE_INTERFACE*/ +#else /* CONFIG_FEATURE_QUERY_MODULE_INTERFACE */ extern int lsmod_main(int argc, char **argv) { - int fd, i; - char line[128]; - printf("Module Size Used by"); check_tainted(); - fflush(stdout); - if ((fd = open("/proc/modules", O_RDONLY)) >= 0 ) { - while ((i = read(fd, line, sizeof(line))) > 0) { - write(fileno(stdout), line, i); - } - close(fd); - return 0; - } - perror_msg_and_die("/proc/modules"); + if(print_file_by_name("/proc/modules") == FALSE) return 1; + return 0; } -#endif /*CONFIG_FEATURE_OLD_MODULE_INTERFACE*/ +#endif /* CONFIG_FEATURE_QUERY_MODULE_INTERFACE */ -- 2.11.0