last_patch61 from vodz:
authorEric Andersen <andersen@codepoet.org>
Thu, 10 Oct 2002 04:20:21 +0000 (04:20 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 10 Oct 2002 04:20:21 +0000 (04:20 -0000)
    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.

12 files changed:
archival/libunarchive/data_extract_all.c
archival/tar.c
console-tools/dumpkmap.c
init/init.c
libbb/messages.c
libbb/obscure.c
loginutils/getty.c
loginutils/login.c
miscutils/dutmp.c
modutils/config.in
modutils/insmod.c
modutils/lsmod.c

index 39af2e3e7269123ecc1d8ec712ada4baa96a3c35..f839be35e9061fffefcfc77d1983d7e20aced163 100644 (file)
@@ -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);
        }                  
index e6c134e3be34bad946b98248b4d01808fc95131a..dba6bbcc4fcdbd1a66701adef5d1f4165a5b5a53 100644 (file)
@@ -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) {
index 22652a5e2b67167ce1ddc1cefd7da1b70e9607f2..d2bb6dcff10c772af7749f148d39b0c9db178eab 100644 (file)
@@ -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); 
index 3b0a66a247c78fd22c551841e256c097bd53b971..edbd90bfee9dd13b83a31ad96fffbd79ed2b0cb0 100644 (file)
@@ -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);
index 185c1ee917a08199569946e51e363fb016e88f10..cc7e2146c9a812d42daaf5075476529d4f2fb3a2 100644 (file)
@@ -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";
index dc7de751d7a4a7a6930a8a89865c7c693d0ee1ad..588ef5af6c18caf89714012f951fbebc5204d4a8 100644 (file)
@@ -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) {
index fec8ae8e505cbd7425c4b4fb5e90107a447bd504..0f0778caf9e085b905431f40ddc302b901758b8e 100644 (file)
@@ -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++;
                                        }
index 714829db1871aecc02eafec171f1318e245f4548..6b8f6c6510b4f179a5dbcfc1da828e182776488f 100644 (file)
 // 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
index cec5629c81d32799b34f272ef533baabdeda8178..19e09fbb0a178dbb5c79988b2449a828acf54a58 100644 (file)
@@ -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]);
                }
        }
 
index 7fe7ec1951e7fda99b5ea3f625b0d28c3d30edc0..10b0a9c33bc640487582be24805932255090ad1f 100644 (file)
@@ -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
 
index b246d90afef2d75ff7e794600410ce530a18291f..b367e84af1a8901dfe5e10a2ba9e0df24efcc0ac 100644 (file)
 #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)
 {
index a2a582389ca0860d23a5a2c2416655f30e452fc0..a03247f7381e7e3becdc47eb7f62b870db184dc6 100644 (file)
 #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 */