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.
This commit is contained in:
Eric Andersen 2002-10-10 04:20:21 +00:00
parent fdfe298a96
commit 71ae64bdc6
12 changed files with 76 additions and 89 deletions

View File

@ -16,7 +16,7 @@ extern void data_extract_all(archive_handle_t *archive_handle)
int res; int res;
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) { 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); make_directory (dirname(name), 0777, FILEUTILS_RECUR);
free(name); free(name);
} }

View File

@ -302,7 +302,7 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
if ((size = if ((size =
full_write(tbInfo->tarFd, (char *) &header, full_write(tbInfo->tarFd, (char *) &header,
sizeof(struct TarHeader))) < 0) { sizeof(struct TarHeader))) < 0) {
error_msg(io_error, real_name, strerror(errno)); error_msg(io_error, real_name);
return (FALSE); return (FALSE);
} }
/* Pad the header up to the tar block size */ /* 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 */ /* open the file we want to archive, and make sure all is well */
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
error_msg("%s: Cannot open: %s", fileName, strerror(errno)); perror_msg("%s: Cannot open", fileName);
return (FALSE); return (FALSE);
} }
@ -434,13 +434,13 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
while ((size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0) { while ((size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0) {
if (full_write(tbInfo->tarFd, buffer, size) != size) { if (full_write(tbInfo->tarFd, buffer, size) != size) {
/* Output file seems to have a problem */ /* Output file seems to have a problem */
error_msg(io_error, fileName, strerror(errno)); error_msg(io_error, fileName);
return (FALSE); return (FALSE);
} }
readSize += size; readSize += size;
} }
if (size == -1) { if (size == -1) {
error_msg(io_error, fileName, strerror(errno)); error_msg(io_error, fileName);
return (FALSE); return (FALSE);
} }
/* Pad the file up to the tar block size */ /* 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) { if (tbInfo.tarFd < 0) {
perror_msg("Error opening '%s'", tarName); perror_msg("%s: Cannot open", tarName);
freeHardLinkInfo(&tbInfo.hlInfoHead); freeHardLinkInfo(&tbInfo.hlInfoHead);
return (FALSE); 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 /* Store the stat info for the tarball's file, so
* can avoid including the tarball into itself.... */ * can avoid including the tarball into itself.... */
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0) 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 #ifdef CONFIG_FEATURE_TAR_GZIP
if (gzip) { if (gzip) {

View File

@ -81,7 +81,7 @@ int dumpkmap_main(int argc, char **argv)
ke.kb_table = i; ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) { 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 { else {
write(1,(void*)&ke.kb_value,2); write(1,(void*)&ke.kb_value,2);

View File

@ -660,8 +660,7 @@ static pid_t run(struct init_action *a)
execve(cmdpath, cmd, environment); execve(cmdpath, cmd, environment);
/* We're still here? Some error happened. */ /* We're still here? Some error happened. */
message(LOG | CONSOLE, "\rBummer, could not run '%s': %s\n", cmdpath, message(LOG | CONSOLE, "\rBummer, could not run '%s': %m\n", cmdpath);
strerror(errno));
_exit(-1); _exit(-1);
} }
sigprocmask(SIG_SETMASK, &omask, NULL); 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); message(CONSOLE | LOG, "\rTrying to re-exec %s\n", a->command);
execl(a->command, a->command, NULL); execl(a->command, a->command, NULL);
message(CONSOLE | LOG, "\rexec of '%s' failed: %s\n", message(CONSOLE | LOG, "\rexec of '%s' failed: %m\n",
a->command, strerror(errno)); a->command);
sync(); sync();
sleep(2); sleep(2);
init_reboot(RB_HALT_SYSTEM); init_reboot(RB_HALT_SYSTEM);

View File

@ -45,7 +45,7 @@
const char * const invalid_option = "invalid option -- %c"; const char * const invalid_option = "invalid option -- %c";
#endif #endif
#ifdef L_io_error #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 #endif
#ifdef L_dash_dash_help #ifdef L_dash_dash_help
const char * const dash_dash_help = "--help"; const char * const dash_dash_help = "--help";

View File

@ -44,7 +44,7 @@
* can't be a palindrome - like `R A D A R' or `M A D A M' * 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; int i, j;
@ -79,24 +79,25 @@ static int similiar(const char *old, const char *newval)
* a nice mix of characters. * a nice mix of characters.
*/ */
static int simple(const char *old, const char *newval) static int simple(const char *newval)
{ {
int digits = 0; int digits = 0;
int uppers = 0; int uppers = 0;
int lowers = 0; int lowers = 0;
int others = 0; int others = 0;
int c;
int size; int size;
int i; int i;
for (i = 0; newval[i]; i++) { for (i = 0; (c = *newval++) != 0; i++) {
if (isdigit(newval[i])) if (isdigit(c))
digits++; digits = c;
else if (isupper(newval[i])) else if (isupper(c))
uppers++; uppers = c;
else if (islower(newval[i])) else if (islower(c))
lowers++; lowers = c;
else else
others++; others = c;
} }
/* /*
@ -129,49 +130,50 @@ static char *str_lower(char *string)
return 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; const char *msg;
char *oldmono, *newmono, *wrapped; char *newmono, *wrapped;
int lenwrap;
if (strcmp(newval, old) == 0) if (strcmp(newval, old) == 0)
return "no change"; return "no change";
if (simple(newval))
return "too simple";
msg = NULL;
newmono = str_lower(xstrdup(newval)); newmono = str_lower(xstrdup(newval));
oldmono = str_lower(xstrdup(old)); lenwrap = strlen(old) * 2 + 1;
wrapped = (char *) xmalloc(strlen(oldmono) * 2 + 1); wrapped = (char *) xmalloc(lenwrap);
strcpy(wrapped, oldmono); str_lower(strcpy(wrapped, old));
strcat(wrapped, oldmono);
if (palindrome(oldmono, newmono)) if (palindrome(newmono))
msg = "a palindrome"; msg = "a palindrome";
if (!msg && strcmp(oldmono, newmono) == 0) else if (strcmp(wrapped, newmono) == 0)
msg = "case changes only"; msg = "case changes only";
if (!msg && similiar(oldmono, newmono)) else if (similiar(wrapped, newmono))
msg = "too similiar"; msg = "too similiar";
if (!msg && simple(old, newval)) else if (strstr(strcat(wrapped, wrapped), newmono))
msg = "too simple";
if (!msg && strstr(wrapped, newmono))
msg = "rotated"; msg = "rotated";
bzero(newmono, strlen(newmono)); bzero(newmono, strlen(newmono));
bzero(oldmono, strlen(oldmono)); bzero(wrapped, lenwrap);
bzero(wrapped, strlen(wrapped));
free(newmono); free(newmono);
free(oldmono);
free(wrapped); free(wrapped);
return msg; 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; int maxlen, oldlen, newlen;
char *new1, *old1, *msg; char *new1, *old1;
const char *msg;
oldlen = strlen(old); oldlen = strlen(old);
newlen = strlen(newval); 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) 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) { */
if (msg != NULL) { if (msg != NULL) {

View File

@ -388,34 +388,20 @@ static void parse_args(int argc, char **argv, struct options *op)
switch (c) { switch (c) {
case 'I': case 'I':
if (!(op->initstring = strdup(optarg))) if (!(op->initstring = strdup(optarg)))
error("can't malloc initstring"); error(memory_exhausted);
{ {
char ch, *p, *q; const char *p;
int i; char *q;
/* copy optarg into op->initstring decoding \ddd /* copy optarg into op->initstring decoding \ddd
octal codes into chars */ octal codes into chars */
q = op->initstring; q = op->initstring;
p = optarg; p = optarg;
while (*p) { while (*p) {
if (*p == '\\') { /* know \\ means \ */
p++;
if (*p == '\\') { if (*p == '\\') {
ch = '\\';
p++; p++;
} else { /* handle \000 - \177 */ *q++ = process_escape_sequence(&p);
ch = 0;
for (i = 1; i <= 3; i++) {
if (*p >= '0' && *p <= '7') {
ch <<= 3;
ch += *p - '0';
p++;
} else
break;
}
}
*q++ = ch;
} else { } else {
*q++ = *p++; *q++ = *p++;
} }

View File

@ -22,20 +22,15 @@
// import from utmp.c // import from utmp.c
static void checkutmp(int picky); static void checkutmp(int picky);
static void setutmp(const char *name, const char *line); static void setutmp(const char *name, const char *line);
/* Stuff global to this file */
struct utmp utent;
#endif #endif
// import from encrypt.c
extern char *pw_encrypt(const char *clear, const char *salt);
// login defines // login defines
#define TIMEOUT 60 #define TIMEOUT 60
#define EMPTY_USERNAME_COUNT 10 #define EMPTY_USERNAME_COUNT 10
#define USERNAME_SIZE 32 #define USERNAME_SIZE 32
/* Stuff global to this file */
struct utmp utent;
static int check_nologin ( int amroot ); static int check_nologin ( int amroot );
@ -131,12 +126,15 @@ extern int login_main(int argc, char **argv)
else else
safe_strncpy ( tty, "UNKNOWN", sizeof( tty )); safe_strncpy ( tty, "UNKNOWN", sizeof( tty ));
#ifdef CONFIG_FEATURE_U_W_TMP
if ( amroot ) if ( amroot )
memset ( utent.ut_host, 0, sizeof utent.ut_host ); memset ( utent.ut_host, 0, sizeof utent.ut_host );
#endif
if ( opt_host ) { if ( opt_host ) {
#ifdef CONFIG_FEATURE_U_W_TMP
safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host ));
#endif
snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host ); snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host );
} }
else else

View File

@ -34,7 +34,7 @@ extern int dutmp_main(int argc, char **argv)
} else { } else {
file = open(argv[1], O_RDONLY); file = open(argv[1], O_RDONLY);
if (file < 0) { if (file < 0) {
perror_msg_and_die(io_error, argv[1]); error_msg_and_die(io_error, argv[1]);
} }
} }

View File

@ -29,5 +29,9 @@ if [ "$CONFIG_LSMOD" = "y" ]; then
fi fi
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 endmenu

View File

@ -234,7 +234,7 @@
#ifndef MODUTILS_MODULE_H #ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1; 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. /* 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 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 #ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1; 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. */ /* 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)); 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) static int obj_gpl_license(struct obj_file *f, const char **license)
{ {
struct obj_section *sec; struct obj_section *sec;
@ -3533,6 +3534,9 @@ static void check_tainted_module(struct obj_file *f, char *m_name)
if (fd >= 0) if (fd >= 0)
close(fd); 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) extern int insmod_main( int argc, char **argv)
{ {

View File

@ -40,13 +40,15 @@
#include "busybox.h" #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_FILENAME "/proc/sys/kernel/tainted"
#define TAINT_PROPRIETORY_MODULE (1<<0) #define TAINT_PROPRIETORY_MODULE (1<<0)
#define TAINT_FORCED_MODULE (1<<1) #define TAINT_FORCED_MODULE (1<<1)
#define TAINT_UNSAFE_SMP (1<<2) #define TAINT_UNSAFE_SMP (1<<2)
void check_tainted(void) static void check_tainted(void)
{ {
int tainted; int tainted;
FILE *f; FILE *f;
@ -66,6 +68,7 @@ void check_tainted(void)
printf(" Not tainted\n"); printf(" Not tainted\n");
} }
} }
#endif
#ifdef CONFIG_FEATURE_QUERY_MODULE_INTERFACE #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; return my_ret;
} }
#endif
extern int lsmod_main(int argc, char **argv) extern int lsmod_main(int argc, char **argv)
{ {
@ -170,26 +174,16 @@ extern int lsmod_main(int argc, char **argv)
return( 0); return( 0);
} }
#else /*CONFIG_FEATURE_OLD_MODULE_INTERFACE*/ #else /* CONFIG_FEATURE_QUERY_MODULE_INTERFACE */
extern int lsmod_main(int argc, char **argv) extern int lsmod_main(int argc, char **argv)
{ {
int fd, i;
char line[128];
printf("Module Size Used by"); printf("Module Size Used by");
check_tainted(); check_tainted();
fflush(stdout);
if ((fd = open("/proc/modules", O_RDONLY)) >= 0 ) { if(print_file_by_name("/proc/modules") == FALSE)
while ((i = read(fd, line, sizeof(line))) > 0) { return 1;
write(fileno(stdout), line, i);
}
close(fd);
return 0; return 0;
} }
perror_msg_and_die("/proc/modules");
return 1;
}
#endif /*CONFIG_FEATURE_OLD_MODULE_INTERFACE*/ #endif /* CONFIG_FEATURE_QUERY_MODULE_INTERFACE */