From e66a212081bcca521760ccff3a2da0deccd99340 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 5 Jan 2011 11:45:44 +0100 Subject: mkswap: selinux build fix Signed-off-by: Denys Vlasenko --- util-linux/mkswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 53537fcd9..2e9662b2b 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c @@ -15,7 +15,7 @@ static void mkswap_selinux_setcontext(int fd, const char *path) if (!is_selinux_enabled()) return; - xfstat(fd, &stbuf, argv[0]); + xfstat(fd, &stbuf, path); if (S_ISREG(stbuf.st_mode)) { security_context_t newcon; security_context_t oldcon = NULL; -- cgit v1.2.3-55-g6feb From f42c7b8fc161f5b3eb4e9c13f392daf7a11760c8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 7 Jan 2011 13:51:16 +0100 Subject: suppress "'fast_strtol_10' defined but not used" warning Signed-off-by: Denys Vlasenko --- libbb/procps.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libbb/procps.c b/libbb/procps.c index f22a55d15..fb4c32001 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -154,6 +154,7 @@ static unsigned long fast_strtoul_10(char **endptr) return n; } +# if ENABLE_FEATURE_FAST_TOP static long fast_strtol_10(char **endptr) { if (**endptr != '-') @@ -162,6 +163,7 @@ static long fast_strtol_10(char **endptr) (*endptr)++; return - (long)fast_strtoul_10(endptr); } +# endif static char *skip_fields(char *str, int count) { @@ -450,7 +452,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags) //FIXME: is it safe to assume this field exists? sp->last_seen_on_cpu = fast_strtoul_10(&cp); # endif -#endif /* end of !ENABLE_FEATURE_TOP_SMP_PROCESS */ +#endif /* FEATURE_FAST_TOP */ #if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS sp->niceness = tasknice; -- cgit v1.2.3-55-g6feb From 642e71a789156a96bcb18e6c5a0f52416c49d3b5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 7 Jan 2011 15:16:05 +0100 Subject: hush: fix wrong prompt problem on empty interactive commants Signed-off-by: Denys Vlasenko --- shell/hush.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shell/hush.c b/shell/hush.c index a771e9cd9..24b9e6efe 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -4140,7 +4140,16 @@ static struct pipe *parse_stream(char **pstring, if (IS_NULL_CMD(ctx.command) && dest.length == 0 && !dest.has_quoted_part ) { - continue; + /* This newline can be ignored. But... + * without the below check, interactive shell + * will ignore even lines with bare , + * and show the continuation prompt: + * ps1_prompt$ + * ps2> _ <=== wrong prompt, should be ps1 + */ + struct pipe *pi = ctx.list_head; + if (pi->num_cmds != 0) + continue; } /* Treat newline as a command separator. */ done_pipe(&ctx, PIPE_SEQ); -- cgit v1.2.3-55-g6feb From e9d12b57bfb941e754d09a7d5f54c183ca7dbb25 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 9 Jan 2011 20:57:52 +0100 Subject: modprobe-small: support compressed modules in insmod Signed-off-by: Denys Vlasenko --- modutils/modprobe-small.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index ec3ddfb8f..f4f17e766 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -844,13 +844,15 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) void *map; len = MAXINT(ssize_t); - map = xmalloc_xopen_read_close(*argv, &len); + map = xmalloc_open_zipped_read_close(*argv, &len); if (init_module(map, len, IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : "") IF_NOT_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE("") - ) != 0) + ) != 0 + ) { bb_error_msg_and_die("can't insert '%s': %s", *argv, moderror(errno)); + } return 0; } -- cgit v1.2.3-55-g6feb From bcdb9b8762d14634afb570fe48db9fa62d8c0109 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 9 Jan 2011 21:44:51 +0100 Subject: getty: fix -i (was ignored) Signed-off-by: Denys Vlasenko --- include/usage.src.h | 17 ------- loginutils/getty.c | 135 ++++++++++++++++++++++++++-------------------------- 2 files changed, 67 insertions(+), 85 deletions(-) diff --git a/include/usage.src.h b/include/usage.src.h index ea0e6a452..ef2bebd8b 100644 --- a/include/usage.src.h +++ b/include/usage.src.h @@ -1394,23 +1394,6 @@ INSERT #define getsebool_full_usage "\n\n" \ " -a Show all selinux booleans" -#define getty_trivial_usage \ - "[OPTIONS] BAUD_RATE TTY [TERMTYPE]" -#define getty_full_usage "\n\n" \ - "Open a tty, prompt for a login name, then invoke /bin/login\n" \ - "\nOptions:" \ - "\n -h Enable hardware (RTS/CTS) flow control" \ - "\n -i Don't display /etc/issue before running login" \ - "\n -L Local line, don't do carrier detect" \ - "\n -m Get baud rate from modem's CONNECT status message" \ - "\n -w Wait for a CR or LF before sending /etc/issue" \ - "\n -n Don't prompt the user for a login name" \ - "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue" \ - "\n -l LOGIN Invoke LOGIN instead of /bin/login" \ - "\n -t SEC Terminate after SEC if no username is read" \ - "\n -I INITSTR Send INITSTR before anything else" \ - "\n -H HOST Log HOST into the utmp file as the hostname" \ - #define gunzip_trivial_usage \ "[-cft] [FILE]..." #define gunzip_full_usage "\n\n" \ diff --git a/loginutils/getty.c b/loginutils/getty.c index 76b0de449..0f5e333a7 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -31,14 +31,25 @@ * System V, assume it is SunOS 4. */ #ifdef LOGIN_PROCESS /* defined in System V utmp.h */ -#include +# include #else /* if !sysV style, wtmp/utmp code is off */ -#undef ENABLE_FEATURE_UTMP -#undef ENABLE_FEATURE_WTMP -#define ENABLE_FEATURE_UTMP 0 -#define ENABLE_FEATURE_WTMP 0 +# undef ENABLE_FEATURE_UTMP +# undef ENABLE_FEATURE_WTMP +# define ENABLE_FEATURE_UTMP 0 +# define ENABLE_FEATURE_WTMP 0 #endif /* LOGIN_PROCESS */ + +/* The following is used for understandable diagnostics. */ +#ifdef DEBUGGING +static FILE *dbf; +# define DEBUGTERM "/dev/ttyp0" +# define debug(...) do { fprintf(dbf, __VA_ARGS__); fflush(dbf); } while (0) +#else +# define debug(...) ((void)0) +#endif + + /* * Things you may want to modify. * @@ -51,13 +62,15 @@ #undef HANDLE_ALLCAPS #undef ANCIENT_BS_KILL_CHARS +#undef _PATH_LOGIN #define _PATH_LOGIN "/bin/login" -/* If ISSUE is not defined, getty will never display the contents of the +/* Displayed before the login prompt. + * If ISSUE is not defined, getty will never display the contents of the * /etc/issue file. You will not want to spit out large "issue" files at the * wrong baud rate. */ -#define ISSUE "/etc/issue" /* displayed before the login prompt */ +#define ISSUE "/etc/issue" /* Some shorthands for control characters. */ #define CTL(x) ((x) ^ 0100) /* Assumes ASCII dialect */ @@ -83,7 +96,6 @@ /* Storage for command-line options. */ struct options { - int flags; /* toggle switches, see below */ unsigned timeout; /* time-out period */ const char *login; /* login program */ const char *tty; /* name of tty */ @@ -111,7 +123,6 @@ struct chardata { #endif }; - /* Initial values for the above. */ static const struct chardata init_chardata = { DEF_ERASE, /* default erase character */ @@ -123,30 +134,37 @@ static const struct chardata init_chardata = { #endif }; -static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:wn"; -#define F_INITSTRING (1 << 0) /* -I initstring is set */ -#define F_LOCAL (1 << 1) /* -L force local */ -#define F_FAKEHOST (1 << 2) /* -H fake hostname */ -#define F_CUSTISSUE (1 << 3) /* -f give alternative issue file */ -#define F_RTSCTS (1 << 4) /* -h enable RTS/CTS flow control */ -#define F_ISSUE (1 << 5) /* -i display /etc/issue */ -#define F_LOGIN (1 << 6) /* -l non-default login program */ -#define F_PARSE (1 << 7) /* -m process modem status messages */ -#define F_TIMEOUT (1 << 8) /* -t time out */ -#define F_WAITCRLF (1 << 9) /* -w wait for CR or LF */ -#define F_NOPROMPT (1 << 10) /* -n don't ask for login name */ - - #define line_buf bb_common_bufsiz1 -/* The following is used for understandable diagnostics. */ -#ifdef DEBUGGING -static FILE *dbf; -#define DEBUGTERM "/dev/ttyp0" -#define debug(...) do { fprintf(dbf, __VA_ARGS__); fflush(dbf); } while (0) -#else -#define debug(...) ((void)0) -#endif +//usage:#define getty_trivial_usage +//usage: "[OPTIONS] BAUD_RATE TTY [TERMTYPE]" +//usage:#define getty_full_usage "\n\n" +//usage: "Open a tty, prompt for a login name, then invoke /bin/login\n" +//usage: "\nOptions:" +//usage: "\n -h Enable hardware (RTS/CTS) flow control" +//usage: "\n -i Don't display /etc/issue" +//usage: "\n -L Local line, don't do carrier detect" +//usage: "\n -m Get baud rate from modem's CONNECT status message" +//usage: "\n -w Wait for a CR or LF before sending /etc/issue" +//usage: "\n -n Don't prompt the user for a login name" +//usage: "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue" +//usage: "\n -l LOGIN Invoke LOGIN instead of /bin/login" +//usage: "\n -t SEC Terminate after SEC if no username is read" +//usage: "\n -I INITSTR Send INITSTR before anything else" +//usage: "\n -H HOST Log HOST into the utmp file as the hostname" + +static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:wn"; +#define F_INITSTRING (1 << 0) /* -I */ +#define F_LOCAL (1 << 1) /* -L */ +#define F_FAKEHOST (1 << 2) /* -H */ +#define F_CUSTISSUE (1 << 3) /* -f */ +#define F_RTSCTS (1 << 4) /* -h */ +#define F_NOISSUE (1 << 5) /* -i */ +#define F_LOGIN (1 << 6) /* -l */ +#define F_PARSE (1 << 7) /* -m */ +#define F_TIMEOUT (1 << 8) /* -t */ +#define F_WAITCRLF (1 << 9) /* -w */ +#define F_NOPROMPT (1 << 10) /* -n */ /* bcode - convert speed string to speed code; return <= 0 on failure */ @@ -181,18 +199,18 @@ static void parse_speeds(struct options *op, char *arg) static void parse_args(char **argv, struct options *op, char **fakehost_p) { char *ts; + int flags; opt_complementary = "-2:t+"; /* at least 2 args; -t N */ - op->flags = getopt32(argv, opt_string, + flags = getopt32(argv, opt_string, &(op->initstring), fakehost_p, &(op->issue), &(op->login), &op->timeout); - argv += optind; - if (op->flags & F_INITSTRING) { + if (flags & F_INITSTRING) { op->initstring = xstrdup(op->initstring); /* decode \ddd octal codes into chars */ strcpy_and_process_escape_sequences((char*)op->initstring, op->initstring); } - op->flags ^= F_ISSUE; /* invert flag "show /etc/issue" */ + argv += optind; debug("after getopt\n"); /* we loosen up a bit and accept both "baudrate tty" and "tty baudrate" */ @@ -217,17 +235,6 @@ static void open_tty(const char *tty) { /* Set up new standard input, unless we are given an already opened port. */ if (NOT_LONE_DASH(tty)) { -// struct stat st; -// int cur_dir_fd; -// int fd; - - /* Sanity checks... */ -// cur_dir_fd = xopen(".", O_DIRECTORY | O_NONBLOCK); -// xchdir("/dev"); -// xstat(tty, &st); -// if (!S_ISCHR(st.st_mode)) -// bb_error_msg_and_die("not a character device"); - if (tty[0] != '/') tty = xasprintf("/dev/%s", tty); /* will leak it */ @@ -236,15 +243,6 @@ static void open_tty(const char *tty) close(0); /*fd =*/ xopen(tty, O_RDWR | O_NONBLOCK); /* uses fd 0 */ -// /* Restore current directory */ -// fchdir(cur_dir_fd); - - /* Open the tty as standard input, continued */ -// xmove_fd(fd, 0); -// /* fd is >= cur_dir_fd, and cur_dir_fd gets closed too here: */ -// while (fd > 2) -// close(fd--); - /* Set proper protections and ownership. */ fchown(0, 0, 0); /* 0:0 */ fchmod(0, 0620); /* crw--w---- */ @@ -259,7 +257,7 @@ static void open_tty(const char *tty) } /* termios_init - initialize termios settings */ -static void termios_init(struct termios *tp, int speed, struct options *op) +static void termios_init(struct termios *tp, int speed) { speed_t ispeed, ospeed; /* @@ -278,7 +276,7 @@ static void termios_init(struct termios *tp, int speed, struct options *op) ospeed = cfgetospeed(tp); } tp->c_cflag = CS8 | HUPCL | CREAD; - if (op->flags & F_LOCAL) + if (option_mask32 & F_LOCAL) tp->c_cflag |= CLOCAL; cfsetispeed(tp, ispeed); cfsetospeed(tp, ospeed); @@ -293,7 +291,7 @@ static void termios_init(struct termios *tp, int speed, struct options *op) /* Optionally enable hardware flow control */ #ifdef CRTSCTS - if (op->flags & F_RTSCTS) + if (option_mask32 & F_RTSCTS) tp->c_cflag |= CRTSCTS; #endif @@ -364,7 +362,8 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) static void do_prompt(struct options *op) { #ifdef ISSUE - print_login_issue(op->issue, op->tty); + if (!(option_mask32 & F_NOISSUE)) + print_login_issue(op->issue, op->tty); #endif print_login_prompt(); } @@ -429,7 +428,7 @@ static char *get_logname(char *logname, unsigned size_logname, return NULL; /* Do parity bit handling. */ - if (!(op->flags & F_LOCAL) && (c & 0x80)) { /* "parity" bit on? */ + if (!(option_mask32 & F_LOCAL) && (c & 0x80)) { /* "parity" bit on? */ bits = 1; mask = 1; while (mask & 0x7f) { @@ -499,7 +498,7 @@ static char *get_logname(char *logname, unsigned size_logname, } /* termios_final - set the final tty mode bits */ -static void termios_final(struct options *op, struct termios *tp, struct chardata *cp) +static void termios_final(struct termios *tp, struct chardata *cp) { /* General terminal-independent stuff. */ tp->c_iflag |= IXON | IXOFF; /* 2-way flow control */ @@ -554,7 +553,7 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat #endif /* Optionally enable hardware flow control */ #ifdef CRTSCTS - if (op->flags & F_RTSCTS) + if (option_mask32 & F_RTSCTS) tp->c_cflag |= CRTSCTS; #endif @@ -655,24 +654,24 @@ int getty_main(int argc UNUSED_PARAM, char **argv) /* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */ debug("calling termios_init\n"); - termios_init(&termios, options.speeds[0], &options); + termios_init(&termios, options.speeds[0]); /* Write the modem init string and DON'T flush the buffers */ - if (options.flags & F_INITSTRING) { + if (option_mask32 & F_INITSTRING) { debug("writing init string\n"); full_write1_str(options.initstring); } /* Optionally detect the baud rate from the modem status message */ debug("before autobaud\n"); - if (options.flags & F_PARSE) + if (option_mask32 & F_PARSE) auto_baud(line_buf, sizeof(line_buf), &termios); /* Set the optional timer */ alarm(options.timeout); /* if 0, alarm is not set */ /* Optionally wait for CR or LF before writing /etc/issue */ - if (options.flags & F_WAITCRLF) { + if (option_mask32 & F_WAITCRLF) { char ch; debug("waiting for cr-lf\n"); @@ -685,7 +684,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) } logname = NULL; - if (!(options.flags & F_NOPROMPT)) { + if (!(option_mask32 & F_NOPROMPT)) { /* NB:termios_init already set line speed * to options.speeds[0] */ int baud_index = 0; @@ -709,7 +708,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) alarm(0); /* Finalize the termios settings. */ - termios_final(&options, &termios, &chardata); + termios_final(&termios, &chardata); /* Now the newline character should be properly written. */ full_write(STDOUT_FILENO, "\n", 1); -- cgit v1.2.3-55-g6feb From 7b305646e12536e9aa62d2768d48bf2d2d78caa5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 9 Jan 2011 21:54:50 +0100 Subject: stop giving root rights to dnsd, ipcrm, ipcs Signed-off-by: Denys Vlasenko --- include/applets.src.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/include/applets.src.h b/include/applets.src.h index 261ef2333..691e097c1 100644 --- a/include/applets.src.h +++ b/include/applets.src.h @@ -118,8 +118,7 @@ IF_DHCPRELAY(APPLET(dhcprelay, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) IF_DIFF(APPLET(diff, _BB_DIR_USR_BIN, _BB_SUID_DROP)) IF_DIRNAME(APPLET_NOFORK(dirname, dirname, _BB_DIR_USR_BIN, _BB_SUID_DROP, dirname)) IF_DMESG(APPLET(dmesg, _BB_DIR_BIN, _BB_SUID_DROP)) -/* Why _BB_SUID_REQUIRE? */ -IF_DNSD(APPLET(dnsd, _BB_DIR_USR_SBIN, _BB_SUID_REQUIRE)) +IF_DNSD(APPLET(dnsd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) IF_HOSTNAME(APPLET_ODDNAME(dnsdomainname, hostname, _BB_DIR_BIN, _BB_SUID_DROP, dnsdomainname)) IF_DOS2UNIX(APPLET_NOEXEC(dos2unix, dos2unix, _BB_DIR_USR_BIN, _BB_SUID_DROP, dos2unix)) IF_DPKG(APPLET(dpkg, _BB_DIR_USR_BIN, _BB_SUID_DROP)) @@ -198,10 +197,8 @@ IF_IP(APPLET(ip, _BB_DIR_BIN, _BB_SUID_DROP)) #endif IF_IPADDR(APPLET(ipaddr, _BB_DIR_BIN, _BB_SUID_DROP)) IF_IPCALC(APPLET(ipcalc, _BB_DIR_BIN, _BB_SUID_DROP)) -/* Why _BB_SUID_REQUIRE? On Fedora, it isn't suid root */ -IF_IPCRM(APPLET(ipcrm, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) -/* Why _BB_SUID_REQUIRE? On Fedora, it isn't suid root */ -IF_IPCS(APPLET(ipcs, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) +IF_IPCRM(APPLET(ipcrm, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +IF_IPCS(APPLET(ipcs, _BB_DIR_USR_BIN, _BB_SUID_DROP)) IF_IPLINK(APPLET(iplink, _BB_DIR_BIN, _BB_SUID_DROP)) IF_IPROUTE(APPLET(iproute, _BB_DIR_BIN, _BB_SUID_DROP)) IF_IPRULE(APPLET(iprule, _BB_DIR_BIN, _BB_SUID_DROP)) -- cgit v1.2.3-55-g6feb From 84dba9c5bbd99cb80c0e201bbffa27a51766c63f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 10 Jan 2011 12:51:44 +0100 Subject: tftp: fix bad interaction betweel poll() and alarm(). Closes bug 3061 This was breaking timeout handling. function old new delta tftp_progress_update - 45 +45 tftp_progress_done - 32 +32 tftp_protocol 1839 1858 +19 tftp_progress_init 9 15 +6 tftp_main 298 286 -12 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/1 up/down: 102/-12) Total: 90 bytes Signed-off-by: Denys Vlasenko --- libbb/progress.c | 2 +- networking/tftp.c | 39 ++++++++++++--------------------------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/libbb/progress.c b/libbb/progress.c index 4c2763c53..74e80a39e 100644 --- a/libbb/progress.c +++ b/libbb/progress.c @@ -78,7 +78,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, /* Do not update on every call * (we can be called on every network read!) */ if (since_last_update == 0 && !totalsize) - return; + return; beg_and_transferred = beg_range + transferred; ratio = 100; diff --git a/networking/tftp.c b/networking/tftp.c index 04c8f0ebb..fcd933f6a 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -105,39 +105,22 @@ struct BUG_G_too_big { #define error_pkt_str (error_pkt + 4) #if ENABLE_FEATURE_TFTP_PROGRESS_BAR -/* SIGALRM logic nicked from the wget applet */ -static void progress_meter(int flag) +static void tftp_progress_update(void) { - /* We can be called from signal handler */ - int save_errno = errno; - - if (flag == -1) { /* first call to progress_meter */ - bb_progress_init(&G.pmt); - } - bb_progress_update(&G.pmt, G.file, 0, G.pos, G.size); - - if (flag == 0) { - /* last call to progress_meter */ - alarm(0); - bb_putchar_stderr('\n'); - } else { - if (flag == -1) { /* first call to progress_meter */ - signal_SA_RESTART_empty_mask(SIGALRM, progress_meter); - } - alarm(1); - } - - errno = save_errno; } static void tftp_progress_init(void) { - progress_meter(-1); + bb_progress_init(&G.pmt); + tftp_progress_update(); } static void tftp_progress_done(void) { - if (G.pmt.inited) - progress_meter(0); + if (G.pmt.inited) { + tftp_progress_update(); + bb_putchar_stderr('\n'); + G.pmt.inited = 0; + } } #else # define tftp_progress_init() ((void)0) @@ -460,9 +443,10 @@ static int tftp_protocol( xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); #if ENABLE_FEATURE_TFTP_PROGRESS_BAR - if (ENABLE_TFTP && remote_file) { /* tftp */ + if (ENABLE_TFTP && remote_file) /* tftp */ G.pos = (block_nr - 1) * (uoff_t)blksize; - } + if (G.pmt.inited) + tftp_progress_update(); #endif /* Was it final ACK? then exit */ if (finished && (opcode == TFTP_ACK)) @@ -479,6 +463,7 @@ static int tftp_protocol( case 0: retries--; if (retries == 0) { + tftp_progress_done(); bb_error_msg("timeout"); goto ret; /* no err packet sent */ } -- cgit v1.2.3-55-g6feb From 0f44c08560a5287fb927c15a3cce54302a0b80e5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 10 Jan 2011 16:10:29 +0100 Subject: libbb: progress indicator: use unicode support funcs instead of open-coding it function old new delta bb_progress_update 729 641 -88 Signed-off-by: Denys Vlasenko --- libbb/progress.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/libbb/progress.c b/libbb/progress.c index 74e80a39e..3c7355fee 100644 --- a/libbb/progress.c +++ b/libbb/progress.c @@ -93,22 +93,9 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, #if ENABLE_UNICODE_SUPPORT init_unicode(); - /* libbb candidate? */ { - wchar_t wbuf21[21]; - char *buf = xstrdup(curfile); - unsigned len; - - /* trim to 20 wide chars max (sets wbuf21[20] to 0) - * also, in case mbstowcs fails, we at least - * dont get garbage */ - memset(wbuf21, 0, sizeof(wbuf21)); - /* convert to wide chars, no more than 20 */ - len = mbstowcs(wbuf21, curfile, 20); /* NB: may return -1 */ - /* back to multibyte; cant overflow */ - wcstombs(buf, wbuf21, INT_MAX); - len = (len > 20) ? 0 : 20 - len; - fprintf(stderr, "\r%s%*s%4u%% ", buf, len, "", ratio); + char *buf = unicode_conv_to_printable_fixedwidth(NULL, curfile, 20); + fprintf(stderr, "\r%s%4u%% ", buf, ratio); free(buf); } #else @@ -158,7 +145,8 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, /* (long long helps to have working ETA even if !LFS) */ unsigned eta = (unsigned long long)to_download*elapsed/(uoff_t)transferred - elapsed; unsigned secs = eta % 3600; - fprintf(stderr, "%02u:%02u:%02u ETA", eta / 3600, secs / 60, secs % 60); + unsigned hours = eta / 3600; + fprintf(stderr, "%02u:%02u:%02u ETA", hours, secs / 60, secs % 60); } } } -- cgit v1.2.3-55-g6feb From 5a163b26451c591187482f99659e5fe639a0616a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 11 Jan 2011 13:07:22 +0100 Subject: lsmod: fox unsafe usage of strlen() - 1 Signed-off-by: Denys Vlasenko --- modutils/lsmod.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modutils/lsmod.c b/modutils/lsmod.c index ab7c11f2a..d7e16689b 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -87,7 +87,8 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) // N.B. token[3] is either '-' (module is not used by others) // or comma-separated list ended by comma // so trimming the trailing char is just what we need! - token[3][strlen(token[3])-1] = '\0'; + if (token[3][0]) + token[3][strlen(token[3]) - 1] = '\0'; # if ENABLE_UNICODE_SUPPORT { uni_stat_t uni_stat; -- cgit v1.2.3-55-g6feb From dc7e5c46b0204bc3489ee961a631fb00533ae597 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 11 Jan 2011 13:08:28 +0100 Subject: libbb unicode: comment out usused function and unused parameter Signed-off-by: Denys Vlasenko --- coreutils/cal.c | 2 +- include/unicode.h | 4 ++-- libbb/progress.c | 2 +- libbb/unicode.c | 11 ++++++----- networking/udhcp/dumpleases.c | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/coreutils/cal.c b/coreutils/cal.c index ef5dbeadb..f18c16120 100644 --- a/coreutils/cal.c +++ b/coreutils/cal.c @@ -138,7 +138,7 @@ int cal_main(int argc UNUSED_PARAM, char **argv) if (julian) *hp++ = ' '; { - char *two_wchars = unicode_conv_to_printable_fixedwidth(NULL, buf, 2); + char *two_wchars = unicode_conv_to_printable_fixedwidth(/*NULL,*/ buf, 2); strcpy(hp, two_wchars); free(two_wchars); } diff --git a/include/unicode.h b/include/unicode.h index 1dd55e67d..dee02e777 100644 --- a/include/unicode.h +++ b/include/unicode.h @@ -60,8 +60,8 @@ enum { //UNUSED: unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src); //UNUSED: char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char *src, unsigned width, int flags); char* FAST_FUNC unicode_conv_to_printable(uni_stat_t *stats, const char *src); -char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth); -char* FAST_FUNC unicode_conv_to_printable_fixedwidth(uni_stat_t *stats, const char *src, unsigned width); +//UNUSED: char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth); +char* FAST_FUNC unicode_conv_to_printable_fixedwidth(/*uni_stat_t *stats,*/ const char *src, unsigned width); # if ENABLE_UNICODE_USING_LOCALE diff --git a/libbb/progress.c b/libbb/progress.c index 3c7355fee..40608b047 100644 --- a/libbb/progress.c +++ b/libbb/progress.c @@ -94,7 +94,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, #if ENABLE_UNICODE_SUPPORT init_unicode(); { - char *buf = unicode_conv_to_printable_fixedwidth(NULL, curfile, 20); + char *buf = unicode_conv_to_printable_fixedwidth(/*NULL,*/ curfile, 20); fprintf(stderr, "\r%s%4u%% ", buf, ratio); free(buf); } diff --git a/libbb/unicode.c b/libbb/unicode.c index cf0c6bed9..08a4c7427 100644 --- a/libbb/unicode.c +++ b/libbb/unicode.c @@ -1107,16 +1107,17 @@ char* FAST_FUNC unicode_conv_to_printable(uni_stat_t *stats, const char *src) { return unicode_conv_to_printable2(stats, src, INT_MAX, 0); } -char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth) +char* FAST_FUNC unicode_conv_to_printable_fixedwidth(/*uni_stat_t *stats,*/ const char *src, unsigned width) { - return unicode_conv_to_printable2(stats, src, maxwidth, 0); + return unicode_conv_to_printable2(/*stats:*/ NULL, src, width, UNI_FLAG_PAD); } -char* FAST_FUNC unicode_conv_to_printable_fixedwidth(uni_stat_t *stats, const char *src, unsigned width) + +#ifdef UNUSED +char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth) { - return unicode_conv_to_printable2(stats, src, width, UNI_FLAG_PAD); + return unicode_conv_to_printable2(stats, src, maxwidth, 0); } -#ifdef UNUSED unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src) { if (unicode_status != UNICODE_ON) { diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index a15e409cc..21d62a2d2 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c @@ -57,7 +57,7 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv) addr.s_addr = lease.lease_nip; #if ENABLE_UNICODE_SUPPORT { - char *uni_name = unicode_conv_to_printable_fixedwidth(NULL, lease.hostname, 19); + char *uni_name = unicode_conv_to_printable_fixedwidth(/*NULL,*/ lease.hostname, 19); printf(" %-16s%s ", inet_ntoa(addr), uni_name); free(uni_name); } -- cgit v1.2.3-55-g6feb From 8030a1484917d5b71d5ccd1a1d28a29da7a3d7f0 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 11 Jan 2011 17:59:45 +0100 Subject: httpd: send correct mtime for .gz files Signed-off-by: Denys Vlasenko --- networking/httpd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/networking/httpd.c b/networking/httpd.c index fa42d9850..b8113a843 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -1522,6 +1522,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what) struct stat sb; fstat(fd, &sb); file_size = sb.st_size; + last_mod = sb.st_mtime; } else { IF_FEATURE_HTTPD_GZIP(content_gzip = 0;) fd = open(url, O_RDONLY); -- cgit v1.2.3-55-g6feb From 068444629fbcf59dd8165a63885f8e69fd5cb474 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 13 Jan 2011 16:07:51 +0100 Subject: top: add keyboard commands to --help Signed-off-by: Denys Vlasenko --- include/usage.src.h | 8 -------- procps/top.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/usage.src.h b/include/usage.src.h index ef2bebd8b..a4776a2d6 100644 --- a/include/usage.src.h +++ b/include/usage.src.h @@ -3826,14 +3826,6 @@ INSERT "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n" \ "Defaults: SECS: 10, SIG: TERM." \ -#define top_trivial_usage \ - "[-b] [-nCOUNT] [-dSECONDS]" IF_FEATURE_TOPMEM(" [-m]") -#define top_full_usage "\n\n" \ - "Provide a view of process activity in real time.\n" \ - "Read the status of all processes from /proc each SECONDS\n" \ - "and display a screenful of them." \ -//TODO: add options and keyboard commands - #define tr_trivial_usage \ "[-cds] STRING1 [STRING2]" #define tr_full_usage "\n\n" \ diff --git a/procps/top.c b/procps/top.c index f9106fac7..1eb33dc5d 100644 --- a/procps/top.c +++ b/procps/top.c @@ -833,6 +833,35 @@ enum { | PSSCAN_COMM, }; +//usage:#if ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_TOP_SMP_CPU +//usage:# define IF_SHOW_THREADS_OR_TOP_SMP(...) __VA_ARGS__ +//usage:#else +//usage:# define IF_SHOW_THREADS_OR_TOP_SMP(...) +//usage:#endif +//usage:#define top_trivial_usage +//usage: "[-b] [-nCOUNT] [-dSECONDS]" IF_FEATURE_TOPMEM(" [-m]") +//usage:#define top_full_usage "\n\n" +//usage: "Provide a view of process activity in real time." +//usage: "\n""Read the status of all processes from /proc each SECONDS" +//usage: "\n""and display a screenful of them." +//usage: "\n""Keys:" +//usage: "\n"" N/M" +//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P") +//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/T") +//usage: ": " IF_FEATURE_TOPMEM("show CPU usage, ") "sort by pid/mem" +//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/cpu") +//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/time") +//usage: IF_FEATURE_TOPMEM( +//usage: "\n"" S: show memory, R: reverse memory sort" +//usage: ) +//usage: IF_SHOW_THREADS_OR_TOP_SMP( +//usage: "\n"" " +//usage: IF_FEATURE_SHOW_THREADS("H: toggle threads") +//usage: IF_FEATURE_SHOW_THREADS(IF_FEATURE_TOP_SMP_CPU(", ")) +//usage: IF_FEATURE_TOP_SMP_CPU("1: toggle SMP") +//usage: ) +//usage: "\n"" Q,^C: exit" + int top_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int top_main(int argc UNUSED_PARAM, char **argv) { -- cgit v1.2.3-55-g6feb From df1689138e71fa3648209db28146a595c4e63c26 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 16 Jan 2011 01:25:34 +0100 Subject: remove a few aliasing warnings Signed-off-by: Denys Vlasenko --- archival/libarchive/get_header_tar.c | 2 +- networking/udhcp/dhcprelay.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c index 78b0ae25f..2e0332792 100644 --- a/archival/libarchive/get_header_tar.c +++ b/archival/libarchive/get_header_tar.c @@ -199,7 +199,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) uint16_t magic2; autodetect: - magic2 = *(uint16_t*)tar.name; + magic2 = *(bb__aliased_uint16_t*)tar.name; /* tar gz/bz autodetect: check for gz/bz2 magic. * If we see the magic, and it is the very first block, * we can switch to get_header_tar_gz/bz2/lzma(). diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index 759a4ba03..86ef04a62 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c @@ -25,7 +25,7 @@ struct xid_item { uint32_t xid; struct sockaddr_in ip; struct xid_item *next; -}; +} FIX_ALIASING; #define dhcprelay_xid_list (*(struct xid_item*)&bb_common_bufsiz1) -- cgit v1.2.3-55-g6feb From e8d0a1450a04d83b540f1f58297e79c2cf0f5b4f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 16 Jan 2011 11:21:15 +0100 Subject: remove a few aliasing warnings Signed-off-by: Denys Vlasenko --- procps/free.c | 2 +- procps/fuser.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/procps/free.c b/procps/free.c index efbac5ba6..ad8711f8a 100644 --- a/procps/free.c +++ b/procps/free.c @@ -19,7 +19,7 @@ struct globals { #else # define G_unit_steps 10 #endif -}; +} FIX_ALIASING; #define G (*(struct globals*)&bb_common_bufsiz1) #define INIT_G() do { } while (0) diff --git a/procps/fuser.c b/procps/fuser.c index addf1a7d8..a1b93d77f 100644 --- a/procps/fuser.c +++ b/procps/fuser.c @@ -35,7 +35,7 @@ typedef struct pid_list { struct globals { pid_list *pid_list_head; inode_list *inode_list_head; -}; +} FIX_ALIASING; #define G (*(struct globals*)&bb_common_bufsiz1) #define INIT_G() do { } while (0) -- cgit v1.2.3-55-g6feb From ad3d72f082cbdb152837ae87d1d285cbbf67913a Mon Sep 17 00:00:00 2001 From: Tito Ragusa Date: Sun, 16 Jan 2011 23:39:45 +0100 Subject: move passwd, shadow, group and gshadow path definitions to libbb.h ...and define them only if the used libc doesn't. Signed-off-by: Tito Ragusa Signed-off-by: Denys Vlasenko --- include/libbb.h | 21 +++++++++++++++++---- include/shadow_.h | 5 ----- libpwdgrp/pwd_grp.c | 10 ---------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index d3ad6e294..67dfbc361 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -68,6 +68,19 @@ # include # endif #endif +/* Just in case libc doesn't define some of these... */ +#ifndef _PATH_PASSWD +#define _PATH_PASSWD "/etc/passwd" +#endif +#ifndef _PATH_GROUP +#define _PATH_GROUP "/etc/group" +#endif +#ifndef _PATH_SHADOW +#define _PATH_SHADOW "/etc/shadow" +#endif +#ifndef _PATH_GSHADOW +#define _PATH_GSHADOW "/etc/gshadow" +#endif #if defined __FreeBSD__ || defined __OpenBSD__ # include # include @@ -1604,10 +1617,10 @@ extern const char bb_path_wtmp_file[]; * get the list of currently mounted filesystems */ #define bb_path_mtab_file IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/proc/mounts") -#define bb_path_passwd_file "/etc/passwd" -#define bb_path_shadow_file "/etc/shadow" -#define bb_path_gshadow_file "/etc/gshadow" -#define bb_path_group_file "/etc/group" +#define bb_path_passwd_file _PATH_PASSWD +#define bb_path_group_file _PATH_GROUP +#define bb_path_shadow_file _PATH_SHADOW +#define bb_path_gshadow_file _PATH_GSHADOW #define bb_path_motd_file "/etc/motd" diff --git a/include/shadow_.h b/include/shadow_.h index de126ddec..648a62ab3 100644 --- a/include/shadow_.h +++ b/include/shadow_.h @@ -37,11 +37,6 @@ struct spwd { unsigned long sp_flag; /* Reserved */ }; -/* Paths to the user database files */ -#ifndef _PATH_SHADOW -#define _PATH_SHADOW "/etc/shadow" -#endif - #define setspent bb_internal_setspent #define endspent bb_internal_endspent #define getspent bb_internal_getspent diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index abb6f189a..2eb9d9dd1 100644 --- a/libpwdgrp/pwd_grp.c +++ b/libpwdgrp/pwd_grp.c @@ -20,16 +20,6 @@ #include "libbb.h" #include -#ifndef _PATH_SHADOW -#define _PATH_SHADOW "/etc/shadow" -#endif -#ifndef _PATH_PASSWD -#define _PATH_PASSWD "/etc/passwd" -#endif -#ifndef _PATH_GROUP -#define _PATH_GROUP "/etc/group" -#endif - /**********************************************************************/ /* Sizes for statically allocated buffers. */ -- cgit v1.2.3-55-g6feb From 10ee20b58b77bdfb941480fdf4b95347c2b2ea79 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 17 Jan 2011 14:23:42 +0100 Subject: libbb: better comment in parse_date Signed-off-by: Denys Vlasenko --- libbb/time.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libbb/time.c b/libbb/time.c index 1eb2d75c2..e2b938471 100644 --- a/libbb/time.c +++ b/libbb/time.c @@ -91,7 +91,13 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) * .SS Seconds, a number from 0 to 61 (with leap seconds) * Everything but the minutes is optional * - * This coincides with the format of "touch -t TIME" + * "touch -t DATETIME" format: [[[[[YY]YY]MM]DD]hh]mm[.ss] + * Some, but not all, Unix "date DATETIME" commands + * move [[YY]YY] past minutes mm field (!). + * Coreutils date does it, and SUS mandates it. + * (date -s DATETIME does not support this format. lovely!) + * In bbox, this format is special-cased in date applet + * (IOW: this function assumes "touch -t" format). */ unsigned cur_year = ptm->tm_year; int len = strchrnul(date_str, '.') - date_str; -- cgit v1.2.3-55-g6feb From 094cc51e50bdb877fa4c245dbde47e4dfbf94387 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 17 Jan 2011 14:58:27 +0100 Subject: insmod: check for module read errors Signed-off-by: Denys Vlasenko --- include/libbb.h | 4 ++-- modutils/modprobe-small.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 67dfbc361..55510316b 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -674,6 +674,8 @@ extern char *xmalloc_reads(int fd, char *pfx, size_t *maxsz_p) FAST_FUNC; extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; /* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */ extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; +/* Never returns NULL */ +extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; /* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */ #if ENABLE_FEATURE_SEAMLESS_LZMA \ || ENABLE_FEATURE_SEAMLESS_BZ2 \ @@ -686,8 +688,6 @@ extern void setup_unzip_on_fd(int fd /*, int fail_if_not_detected*/) FAST_FUNC; /* Autodetects .gz etc */ extern int open_zipped(const char *fname) FAST_FUNC; extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; -/* Never returns NULL */ -extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC; // NB: will return short write on error, not -1, diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index f4f17e766..188a7f229 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -205,6 +205,7 @@ static void parse_module(module_info *info, const char *pathname) /* Read (possibly compressed) module */ len = 64 * 1024 * 1024; /* 64 Mb at most */ module_image = xmalloc_open_zipped_read_close(pathname, &len); + /* module_image == NULL is ok here, find_keyword handles it */ //TODO: optimize redundant module body reads /* "alias1 symbol:sym1 alias2 symbol:sym2" */ @@ -845,6 +846,8 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) len = MAXINT(ssize_t); map = xmalloc_open_zipped_read_close(*argv, &len); + if (!map) + bb_perror_msg_and_die("can't read '%s'", *argv); if (init_module(map, len, IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : "") IF_NOT_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE("") -- cgit v1.2.3-55-g6feb From 3b5acaa4323bd165077e60098af94ad9750d62fd Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 18 Jan 2011 13:52:48 +0100 Subject: disable automatic selection of FEATURE_SUID; improve its help text Signed-off-by: Denys Vlasenko --- Config.in | 16 ++++++++++++---- include/applets.src.h | 2 ++ loginutils/Config.src | 4 ---- miscutils/Config.src | 1 - util-linux/Config.src | 2 -- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Config.in b/Config.in index 140572e2d..1109b1016 100644 --- a/Config.in +++ b/Config.in @@ -328,10 +328,18 @@ config FEATURE_SUID symlinks pointing to each binary), and only set the suid bit on the one that needs it. - The applets currently marked to need the suid bit are: - - crontab, dnsd, findfs, ipcrm, ipcs, login, passwd, ping, su, - traceroute, vlock. + The applets which require root rights (need suid bit or + to be run by root) and will refuse to execute otherwise: + crontab, login, passwd, su, vlock, wall. + + The applets which will use root rights if they have them + (via suid bit, or because run by root), but would try to work + without root right nevertheless: + findfs, ping[6], traceroute[6], mount. + + Note that if you DONT select this option, but DO make busybox + suid root, ALL applets will run under root, which is a huge + security hole (think "cp /some/file /etc/passwd"). config FEATURE_SUID_CONFIG bool "Runtime SUID/SGID configuration via /etc/busybox.conf" diff --git a/include/applets.src.h b/include/applets.src.h index 691e097c1..2481fe67f 100644 --- a/include/applets.src.h +++ b/include/applets.src.h @@ -18,6 +18,8 @@ s - suid type: _BB_SUID_MAYBE: neither of the above (every instance of _BB_SUID_REQUIRE and _BB_SUID_MAYBE needs to be justified in comment) + NB: please update FEATURE_SUID help text whenever you add/remove + _BB_SUID_REQUIRE or _BB_SUID_MAYBE applet. */ #if defined(PROTOTYPES) diff --git a/loginutils/Config.src b/loginutils/Config.src index 8158bce74..4c771bbc4 100644 --- a/loginutils/Config.src +++ b/loginutils/Config.src @@ -186,7 +186,6 @@ config GETTY config LOGIN bool "login" default y - select FEATURE_SUID select FEATURE_SYSLOG help login is used when signing onto a system. @@ -229,7 +228,6 @@ config FEATURE_SECURETTY config PASSWD bool "passwd" default y - select FEATURE_SUID select FEATURE_SYSLOG help passwd changes passwords for user and group accounts. A normal user @@ -265,7 +263,6 @@ config CHPASSWD config SU bool "su" default y - select FEATURE_SUID select FEATURE_SYSLOG help su is used to become another user during a login session. @@ -295,7 +292,6 @@ config SULOGIN config VLOCK bool "vlock" default y - select FEATURE_SUID help Build the "vlock" applet which allows you to lock (virtual) terminals. diff --git a/miscutils/Config.src b/miscutils/Config.src index 4912daf88..da52e14c6 100644 --- a/miscutils/Config.src +++ b/miscutils/Config.src @@ -170,7 +170,6 @@ config FEATURE_CROND_DIR config CRONTAB bool "crontab" default y - select FEATURE_SUID help Crontab manipulates the crontab for a particular user. Only the superuser may specify a different user and/or crontab directory. diff --git a/util-linux/Config.src b/util-linux/Config.src index dbf2b0d85..941a47f90 100644 --- a/util-linux/Config.src +++ b/util-linux/Config.src @@ -361,7 +361,6 @@ config FEATURE_HWCLOCK_ADJTIME_FHS config IPCRM bool "ipcrm" default y - select FEATURE_SUID help The ipcrm utility allows the removal of System V interprocess communication (IPC) objects and the associated data structures @@ -371,7 +370,6 @@ config IPCS bool "ipcs" default y depends on PLATFORM_LINUX - select FEATURE_SUID help The ipcs utility is used to provide information on the currently allocated System V interprocess (IPC) objects in the system. -- cgit v1.2.3-55-g6feb From b9f2d9f7d9b4a9b6fbb6a28a8c0bcf8e0e3b1704 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 18 Jan 2011 13:58:01 +0100 Subject: mass removal of underscores from _BB_DIR_foo and _BB_SUID_foo Signed-off-by: Denys Vlasenko --- archival/bbunzip.c | 4 +- coreutils/date.c | 2 +- coreutils/touch.c | 2 +- coreutils/uudecode.c | 2 +- docs/new-applet-HOWTO.txt | 2 +- editors/patch.c | 2 +- findutils/find.c | 2 +- findutils/grep.c | 6 +- findutils/xargs.c | 2 +- include/applets.src.h | 678 +++++++++++++++++++++--------------------- include/busybox.h | 20 +- init/bootchartd.c | 2 +- init/halt.c | 6 +- init/init.c | 4 +- init/mesg.c | 2 +- libbb/appletlib.c | 4 +- loginutils/add-remove-shell.c | 4 +- miscutils/conspy.c | 2 +- miscutils/nandwrite.c | 4 +- miscutils/ubi_attach_detach.c | 4 +- modutils/depmod.c | 2 +- modutils/insmod.c | 2 +- modutils/lsmod.c | 2 +- modutils/modinfo.c | 2 +- modutils/modprobe-small.c | 10 +- modutils/modprobe.c | 2 +- modutils/rmmod.c | 2 +- networking/nbd-client.c | 2 +- networking/ping.c | 6 +- procps/iostat.c | 2 +- procps/mpstat.c | 2 +- procps/nmeter.c | 2 +- procps/pmap.c | 2 +- procps/powertop.c | 2 +- procps/pstree.c | 2 +- procps/smemcap.c | 2 +- shell/ash.c | 6 +- shell/cttyhack.c | 2 +- shell/hush.c | 8 +- util-linux/blockdev.c | 2 +- util-linux/rev.c | 2 +- 41 files changed, 409 insertions(+), 409 deletions(-) diff --git a/archival/bbunzip.c b/archival/bbunzip.c index a69e1b3ca..c4cc5d821 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -315,8 +315,8 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) //usage: "FILE" //usage:#define bzcat_full_usage "\n\n" //usage: "Decompress to stdout" -//applet:IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat)) +//applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) +//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) #if ENABLE_BUNZIP2 static IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(unpack_info_t *info UNUSED_PARAM) diff --git a/coreutils/date.c b/coreutils/date.c index 6ad5f1bb6..05b4f6eed 100644 --- a/coreutils/date.c +++ b/coreutils/date.c @@ -19,7 +19,7 @@ /* Input parsing code is always bulky - used heavy duty libc stuff as much as possible, missed out a lot of bounds checking */ -//applet:IF_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_DROP)) +//applet:IF_DATE(APPLET(date, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_DATE) += date.o diff --git a/coreutils/touch.c b/coreutils/touch.c index 6c2b948e6..c51fb70ca 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -26,7 +26,7 @@ //config: touch is used to create or change the access and/or //config: modification timestamp of specified files. -//applet:IF_TOUCH(APPLET_NOFORK(touch, touch, _BB_DIR_BIN, _BB_SUID_DROP, touch)) +//applet:IF_TOUCH(APPLET_NOFORK(touch, touch, BB_DIR_BIN, BB_SUID_DROP, touch)) //kbuild:lib-$(CONFIG_TOUCH) += touch.o diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 0c4311f24..56ed254e5 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c @@ -132,7 +132,7 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv) } #endif -//applet:IF_BASE64(APPLET(base64, _BB_DIR_BIN, _BB_SUID_DROP)) +//applet:IF_BASE64(APPLET(base64, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_BASE64) += uudecode.o diff --git a/docs/new-applet-HOWTO.txt b/docs/new-applet-HOWTO.txt index bb29999cf..6a8054d0e 100644 --- a/docs/new-applet-HOWTO.txt +++ b/docs/new-applet-HOWTO.txt @@ -161,7 +161,7 @@ algorithm in busybox.c and the Gods of BusyBox smite you. Yea, verily: Be sure to read the top of applets.src.h before adding your applet. /* all programs above here are alphabetically "less than" 'mu' */ - IF_MU(APPLET(mu, _BB_DIR_USR_BIN, _BB_SUID_DROP)) + IF_MU(APPLET(mu, BB_DIR_USR_BIN, BB_SUID_DROP)) /* all programs below here are alphabetically "greater than" 'mu' */ diff --git a/editors/patch.c b/editors/patch.c index 9c6d967b9..a90252a03 100644 --- a/editors/patch.c +++ b/editors/patch.c @@ -21,7 +21,7 @@ * [file] which file to patch */ -//applet:IF_PATCH(APPLET(patch, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +//applet:IF_PATCH(APPLET(patch, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_PATCH) += patch.o diff --git a/findutils/find.c b/findutils/find.c index dd00f37ea..f85381b47 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -53,7 +53,7 @@ * diff -u /tmp/std_find /tmp/bb_find && echo Identical */ -//applet:IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_DROP, find)) +//applet:IF_FIND(APPLET_NOEXEC(find, find, BB_DIR_USR_BIN, BB_SUID_DROP, find)) //kbuild:lib-$(CONFIG_FIND) += find.o diff --git a/findutils/grep.c b/findutils/grep.c index ff6742a69..e7116e4c9 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -18,9 +18,9 @@ * (C) 2006 Jac Goudsmit added -o option */ -//applet:IF_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_DROP)) -//applet:IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, egrep)) -//applet:IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep)) +//applet:IF_GREP(APPLET(grep, BB_DIR_BIN, BB_SUID_DROP)) +//applet:IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, BB_DIR_BIN, BB_SUID_DROP, egrep)) +//applet:IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, BB_DIR_BIN, BB_SUID_DROP, fgrep)) //kbuild:lib-$(CONFIG_GREP) += grep.o diff --git a/findutils/xargs.c b/findutils/xargs.c index d73fad9de..0ec80f809 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c @@ -15,7 +15,7 @@ * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html */ -//applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_DROP, xargs)) +//applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, BB_DIR_USR_BIN, BB_SUID_DROP, xargs)) //kbuild:lib-$(CONFIG_XARGS) += xargs.o diff --git a/include/applets.src.h b/include/applets.src.h index 2481fe67f..fa7d0cc55 100644 --- a/include/applets.src.h +++ b/include/applets.src.h @@ -12,14 +12,14 @@ name2 - applet name, converted to C (ether-wake: name2 = ether_wake) main - corresponding _main to call (bzcat: main = bunzip2) l - location to install link to: [/usr]/[s]bin s - suid type: - _BB_SUID_REQUIRE: will complain if busybox isn't suid + BB_SUID_REQUIRE: will complain if busybox isn't suid and is run by non-root (applet_main() will not be called at all) - _BB_SUID_DROP: will drop suid prior to applet_main() - _BB_SUID_MAYBE: neither of the above - (every instance of _BB_SUID_REQUIRE and _BB_SUID_MAYBE + BB_SUID_DROP: will drop suid prior to applet_main() + BB_SUID_MAYBE: neither of the above + (every instance of BB_SUID_REQUIRE and BB_SUID_MAYBE needs to be justified in comment) NB: please update FEATURE_SUID help text whenever you add/remove - _BB_SUID_REQUIRE or _BB_SUID_MAYBE applet. + BB_SUID_REQUIRE or BB_SUID_MAYBE applet. */ #if defined(PROTOTYPES) @@ -61,363 +61,363 @@ s - suid type: #endif #if ENABLE_INSTALL_NO_USR -# define _BB_DIR_USR_BIN _BB_DIR_BIN -# define _BB_DIR_USR_SBIN _BB_DIR_SBIN +# define BB_DIR_USR_BIN BB_DIR_BIN +# define BB_DIR_USR_SBIN BB_DIR_SBIN #endif INSERT -IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) -IF_TEST(APPLET_NOFORK([[, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) -IF_ACPID(APPLET(acpid, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_ADDGROUP(APPLET(addgroup, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_ADDUSER(APPLET(adduser, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_ADJTIMEX(APPLET(adjtimex, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_AR(APPLET(ar, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_ARP(APPLET(arp, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_AWK(APPLET_NOEXEC(awk, awk, _BB_DIR_USR_BIN, _BB_SUID_DROP, awk)) -IF_BASENAME(APPLET_NOFORK(basename, basename, _BB_DIR_USR_BIN, _BB_SUID_DROP, basename)) -IF_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_BEEP(APPLET(beep, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CAT(APPLET_NOFORK(cat, cat, _BB_DIR_BIN, _BB_SUID_DROP, cat)) -IF_CATV(APPLET(catv, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_CHAT(APPLET(chat, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CHATTR(APPLET(chattr, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_CHCON(APPLET(chcon, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, _BB_DIR_BIN, _BB_SUID_DROP, chgrp)) -IF_CHMOD(APPLET_NOEXEC(chmod, chmod, _BB_DIR_BIN, _BB_SUID_DROP, chmod)) -IF_CHOWN(APPLET_NOEXEC(chown, chown, _BB_DIR_BIN, _BB_SUID_DROP, chown)) -IF_CHPASSWD(APPLET(chpasswd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CHROOT(APPLET(chroot, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_CHRT(APPLET(chrt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CHVT(APPLET(chvt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CKSUM(APPLET_NOEXEC(cksum, cksum, _BB_DIR_USR_BIN, _BB_SUID_DROP, cksum)) -IF_CLEAR(APPLET(clear, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CMP(APPLET(cmp, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_COMM(APPLET(comm, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CP(APPLET_NOEXEC(cp, cp, _BB_DIR_BIN, _BB_SUID_DROP, cp)) -IF_CPIO(APPLET(cpio, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_CROND(APPLET(crond, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) +IF_TEST(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) +IF_TEST(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) +IF_ACPID(APPLET(acpid, BB_DIR_SBIN, BB_SUID_DROP)) +IF_ADDGROUP(APPLET(addgroup, BB_DIR_BIN, BB_SUID_DROP)) +IF_ADDUSER(APPLET(adduser, BB_DIR_BIN, BB_SUID_DROP)) +IF_ADJTIMEX(APPLET(adjtimex, BB_DIR_SBIN, BB_SUID_DROP)) +IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_ARP(APPLET(arp, BB_DIR_SBIN, BB_SUID_DROP)) +IF_ARPING(APPLET(arping, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_AWK(APPLET_NOEXEC(awk, awk, BB_DIR_USR_BIN, BB_SUID_DROP, awk)) +IF_BASENAME(APPLET_NOFORK(basename, basename, BB_DIR_USR_BIN, BB_SUID_DROP, basename)) +IF_BBCONFIG(APPLET(bbconfig, BB_DIR_BIN, BB_SUID_DROP)) +IF_BEEP(APPLET(beep, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_BLKID(APPLET(blkid, BB_DIR_SBIN, BB_SUID_DROP)) +IF_BRCTL(APPLET(brctl, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CAL(APPLET(cal, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat)) +IF_CATV(APPLET(catv, BB_DIR_BIN, BB_SUID_DROP)) +IF_CHAT(APPLET(chat, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CHATTR(APPLET(chattr, BB_DIR_BIN, BB_SUID_DROP)) +IF_CHCON(APPLET(chcon, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, BB_DIR_BIN, BB_SUID_DROP, chgrp)) +IF_CHMOD(APPLET_NOEXEC(chmod, chmod, BB_DIR_BIN, BB_SUID_DROP, chmod)) +IF_CHOWN(APPLET_NOEXEC(chown, chown, BB_DIR_BIN, BB_SUID_DROP, chown)) +IF_CHPASSWD(APPLET(chpasswd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_CHPST(APPLET(chpst, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CHROOT(APPLET(chroot, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_CHRT(APPLET(chrt, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CHVT(APPLET(chvt, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CKSUM(APPLET_NOEXEC(cksum, cksum, BB_DIR_USR_BIN, BB_SUID_DROP, cksum)) +IF_CLEAR(APPLET(clear, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CMP(APPLET(cmp, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_COMM(APPLET(comm, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp)) +IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP)) +IF_CROND(APPLET(crond, BB_DIR_USR_SBIN, BB_SUID_DROP)) /* Needs to be run by root or be suid root - needs to change /var/spool/cron* files: */ -IF_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) -IF_CRYPTPW(APPLET(cryptpw, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_CUT(APPLET_NOEXEC(cut, cut, _BB_DIR_USR_BIN, _BB_SUID_DROP, cut)) -IF_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_DD(APPLET_NOEXEC(dd, dd, _BB_DIR_BIN, _BB_SUID_DROP, dd)) -IF_DEALLOCVT(APPLET(deallocvt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, _BB_DIR_BIN, _BB_SUID_DROP, delgroup)) -IF_DELUSER(APPLET(deluser, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_DEVFSD(APPLET(devfsd, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_DEVMEM(APPLET(devmem, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_DF(APPLET(df, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_DHCPRELAY(APPLET(dhcprelay, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_DIFF(APPLET(diff, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_DIRNAME(APPLET_NOFORK(dirname, dirname, _BB_DIR_USR_BIN, _BB_SUID_DROP, dirname)) -IF_DMESG(APPLET(dmesg, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_DNSD(APPLET(dnsd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_HOSTNAME(APPLET_ODDNAME(dnsdomainname, hostname, _BB_DIR_BIN, _BB_SUID_DROP, dnsdomainname)) -IF_DOS2UNIX(APPLET_NOEXEC(dos2unix, dos2unix, _BB_DIR_USR_BIN, _BB_SUID_DROP, dos2unix)) -IF_DPKG(APPLET(dpkg, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, _BB_DIR_USR_BIN, _BB_SUID_DROP, dpkg_deb)) -IF_DU(APPLET(du, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_DUMPKMAP(APPLET(dumpkmap, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_DUMPLEASES(APPLET(dumpleases, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -//IF_E2FSCK(APPLET(e2fsck, _BB_DIR_SBIN, _BB_SUID_DROP)) -//IF_E2LABEL(APPLET_ODDNAME(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_DROP, e2label)) -IF_ECHO(APPLET_NOFORK(echo, echo, _BB_DIR_BIN, _BB_SUID_DROP, echo)) -IF_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_DROP, env)) -IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, envdir)) -IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, envuidgid)) -IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_DROP, ether_wake)) -IF_EXPAND(APPLET(expand, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_EXPR(APPLET(expr, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_FAKEIDENTD(APPLET(fakeidentd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_FALSE(APPLET_NOFORK(false, false, _BB_DIR_BIN, _BB_SUID_DROP, false)) -IF_FBSET(APPLET(fbset, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_FBSPLASH(APPLET(fbsplash, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_DROP, fdflush)) -IF_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_FGCONSOLE(APPLET(fgconsole, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +IF_CRONTAB(APPLET(crontab, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) +IF_CRYPTPW(APPLET(cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_CUT(APPLET_NOEXEC(cut, cut, BB_DIR_USR_BIN, BB_SUID_DROP, cut)) +IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_DD(APPLET_NOEXEC(dd, dd, BB_DIR_BIN, BB_SUID_DROP, dd)) +IF_DEALLOCVT(APPLET(deallocvt, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, BB_DIR_BIN, BB_SUID_DROP, delgroup)) +IF_DELUSER(APPLET(deluser, BB_DIR_BIN, BB_SUID_DROP)) +IF_DEVFSD(APPLET(devfsd, BB_DIR_SBIN, BB_SUID_DROP)) +IF_DEVMEM(APPLET(devmem, BB_DIR_SBIN, BB_SUID_DROP)) +IF_DF(APPLET(df, BB_DIR_BIN, BB_SUID_DROP)) +IF_DHCPRELAY(APPLET(dhcprelay, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_DIFF(APPLET(diff, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_DIRNAME(APPLET_NOFORK(dirname, dirname, BB_DIR_USR_BIN, BB_SUID_DROP, dirname)) +IF_DMESG(APPLET(dmesg, BB_DIR_BIN, BB_SUID_DROP)) +IF_DNSD(APPLET(dnsd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_HOSTNAME(APPLET_ODDNAME(dnsdomainname, hostname, BB_DIR_BIN, BB_SUID_DROP, dnsdomainname)) +IF_DOS2UNIX(APPLET_NOEXEC(dos2unix, dos2unix, BB_DIR_USR_BIN, BB_SUID_DROP, dos2unix)) +IF_DPKG(APPLET(dpkg, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, BB_DIR_USR_BIN, BB_SUID_DROP, dpkg_deb)) +IF_DU(APPLET(du, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_DUMPKMAP(APPLET(dumpkmap, BB_DIR_BIN, BB_SUID_DROP)) +IF_DUMPLEASES(APPLET(dumpleases, BB_DIR_USR_BIN, BB_SUID_DROP)) +//IF_E2FSCK(APPLET(e2fsck, BB_DIR_SBIN, BB_SUID_DROP)) +//IF_E2LABEL(APPLET_ODDNAME(e2label, tune2fs, BB_DIR_SBIN, BB_SUID_DROP, e2label)) +IF_ECHO(APPLET_NOFORK(echo, echo, BB_DIR_BIN, BB_SUID_DROP, echo)) +IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP)) +IF_EJECT(APPLET(eject, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_ENV(APPLET_NOEXEC(env, env, BB_DIR_USR_BIN, BB_SUID_DROP, env)) +IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir)) +IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid)) +IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_BIN, BB_SUID_DROP, ether_wake)) +IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_EXPR(APPLET(expr, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_FAKEIDENTD(APPLET(fakeidentd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_FALSE(APPLET_NOFORK(false, false, BB_DIR_BIN, BB_SUID_DROP, false)) +IF_FBSET(APPLET(fbset, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_FBSPLASH(APPLET(fbsplash, BB_DIR_SBIN, BB_SUID_DROP)) +IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, BB_DIR_BIN, BB_SUID_DROP, fdflush)) +IF_FDFORMAT(APPLET(fdformat, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_FDISK(APPLET(fdisk, BB_DIR_SBIN, BB_SUID_DROP)) +IF_FGCONSOLE(APPLET(fgconsole, BB_DIR_USR_BIN, BB_SUID_DROP)) /* Benefits from suid root: better access to /dev/BLOCKDEVs: */ -IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE)) -IF_FLASH_ERASEALL(APPLET(flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_DROP, flash_lock)) -IF_FLASH_UNLOCK(APPLET_ODDNAME(flash_unlock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_DROP, flash_unlock)) -IF_FLASHCP(APPLET(flashcp, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_FLOCK(APPLET(flock, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_FOLD(APPLET_NOEXEC(fold, fold, _BB_DIR_USR_BIN, _BB_SUID_DROP, fold)) -IF_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_FSCK(APPLET(fsck, _BB_DIR_SBIN, _BB_SUID_DROP)) -//IF_E2FSCK(APPLET_ODDNAME(fsck.ext2, e2fsck, _BB_DIR_SBIN, _BB_SUID_DROP, fsck_ext2)) -//IF_E2FSCK(APPLET_ODDNAME(fsck.ext3, e2fsck, _BB_DIR_SBIN, _BB_SUID_DROP, fsck_ext3)) -IF_FSCK_MINIX(APPLET_ODDNAME(fsck.minix, fsck_minix, _BB_DIR_SBIN, _BB_SUID_DROP, fsck_minix)) -IF_FSYNC(APPLET_NOFORK(fsync, fsync, _BB_DIR_BIN, _BB_SUID_DROP, fsync)) -IF_FTPD(APPLET(ftpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, _BB_DIR_USR_BIN, _BB_SUID_DROP, ftpget)) -IF_FTPPUT(APPLET_ODDNAME(ftpput, ftpgetput, _BB_DIR_USR_BIN, _BB_SUID_DROP, ftpput)) -IF_FUSER(APPLET(fuser, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_GETENFORCE(APPLET(getenforce, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_GETOPT(APPLET(getopt, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_GETSEBOOL(APPLET(getsebool, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_GETTY(APPLET(getty, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_DROP, hd)) -IF_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_HEAD(APPLET_NOEXEC(head, head, _BB_DIR_USR_BIN, _BB_SUID_DROP, head)) -IF_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_DROP, hexdump)) -IF_HOSTID(APPLET_NOFORK(hostid, hostid, _BB_DIR_USR_BIN, _BB_SUID_DROP, hostid)) -IF_HOSTNAME(APPLET(hostname, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_HTTPD(APPLET(httpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_HWCLOCK(APPLET(hwclock, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_ID(APPLET_NOEXEC(id, id, _BB_DIR_USR_BIN, _BB_SUID_DROP, id)) -IF_IFCONFIG(APPLET(ifconfig, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, _BB_DIR_SBIN, _BB_SUID_DROP, ifdown)) -IF_IFENSLAVE(APPLET(ifenslave, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_IFPLUGD(APPLET(ifplugd, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, _BB_DIR_SBIN, _BB_SUID_DROP, ifup)) -IF_INETD(APPLET(inetd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_INOTIFYD(APPLET(inotifyd, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_INSTALL(APPLET(install, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_IONICE(APPLET(ionice, _BB_DIR_BIN, _BB_SUID_DROP)) +IF_FINDFS(APPLET(findfs, BB_DIR_SBIN, BB_SUID_MAYBE)) +IF_FLASH_ERASEALL(APPLET(flash_eraseall, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, BB_DIR_USR_SBIN, BB_SUID_DROP, flash_lock)) +IF_FLASH_UNLOCK(APPLET_ODDNAME(flash_unlock, flash_lock_unlock, BB_DIR_USR_SBIN, BB_SUID_DROP, flash_unlock)) +IF_FLASHCP(APPLET(flashcp, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_FLOCK(APPLET(flock, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_FOLD(APPLET_NOEXEC(fold, fold, BB_DIR_USR_BIN, BB_SUID_DROP, fold)) +IF_FREE(APPLET(free, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_FREERAMDISK(APPLET(freeramdisk, BB_DIR_SBIN, BB_SUID_DROP)) +IF_FSCK(APPLET(fsck, BB_DIR_SBIN, BB_SUID_DROP)) +//IF_E2FSCK(APPLET_ODDNAME(fsck.ext2, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext2)) +//IF_E2FSCK(APPLET_ODDNAME(fsck.ext3, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext3)) +IF_FSCK_MINIX(APPLET_ODDNAME(fsck.minix, fsck_minix, BB_DIR_SBIN, BB_SUID_DROP, fsck_minix)) +IF_FSYNC(APPLET_NOFORK(fsync, fsync, BB_DIR_BIN, BB_SUID_DROP, fsync)) +IF_FTPD(APPLET(ftpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpget)) +IF_FTPPUT(APPLET_ODDNAME(ftpput, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpput)) +IF_FUSER(APPLET(fuser, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_GETENFORCE(APPLET(getenforce, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_GETOPT(APPLET(getopt, BB_DIR_BIN, BB_SUID_DROP)) +IF_GETSEBOOL(APPLET(getsebool, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_GETTY(APPLET(getty, BB_DIR_SBIN, BB_SUID_DROP)) +IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP)) +IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP)) +IF_HD(APPLET_NOEXEC(hd, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hd)) +IF_HDPARM(APPLET(hdparm, BB_DIR_SBIN, BB_SUID_DROP)) +IF_HEAD(APPLET_NOEXEC(head, head, BB_DIR_USR_BIN, BB_SUID_DROP, head)) +IF_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hexdump)) +IF_HOSTID(APPLET_NOFORK(hostid, hostid, BB_DIR_USR_BIN, BB_SUID_DROP, hostid)) +IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP)) +IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP)) +IF_ID(APPLET_NOEXEC(id, id, BB_DIR_USR_BIN, BB_SUID_DROP, id)) +IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP)) +IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown)) +IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP)) +IF_IFPLUGD(APPLET(ifplugd, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup)) +IF_INETD(APPLET(inetd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_INOTIFYD(APPLET(inotifyd, BB_DIR_SBIN, BB_SUID_DROP)) +IF_INSTALL(APPLET(install, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_IONICE(APPLET(ionice, BB_DIR_BIN, BB_SUID_DROP)) #if ENABLE_FEATURE_IP_ADDRESS \ || ENABLE_FEATURE_IP_ROUTE \ || ENABLE_FEATURE_IP_LINK \ || ENABLE_FEATURE_IP_TUNNEL \ || ENABLE_FEATURE_IP_RULE -IF_IP(APPLET(ip, _BB_DIR_BIN, _BB_SUID_DROP)) +IF_IP(APPLET(ip, BB_DIR_BIN, BB_SUID_DROP)) #endif -IF_IPADDR(APPLET(ipaddr, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_IPCALC(APPLET(ipcalc, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_IPCRM(APPLET(ipcrm, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_IPCS(APPLET(ipcs, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_IPLINK(APPLET(iplink, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_IPROUTE(APPLET(iproute, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_IPRULE(APPLET(iprule, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_IPTUNNEL(APPLET(iptunnel, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_KBD_MODE(APPLET(kbd_mode, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_KILL(APPLET(kill, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_KILLALL(APPLET_ODDNAME(killall, kill, _BB_DIR_USR_BIN, _BB_SUID_DROP, killall)) -IF_KILLALL5(APPLET_ODDNAME(killall5, kill, _BB_DIR_USR_BIN, _BB_SUID_DROP, killall5)) -IF_KLOGD(APPLET(klogd, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_LAST(APPLET(last, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_LENGTH(APPLET_NOFORK(length, length, _BB_DIR_USR_BIN, _BB_SUID_DROP, length)) -IF_LESS(APPLET(less, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_SETARCH(APPLET_ODDNAME(linux32, setarch, _BB_DIR_BIN, _BB_SUID_DROP, linux32)) -IF_SETARCH(APPLET_ODDNAME(linux64, setarch, _BB_DIR_BIN, _BB_SUID_DROP, linux64)) -IF_LN(APPLET_NOEXEC(ln, ln, _BB_DIR_BIN, _BB_SUID_DROP, ln)) -IF_LOAD_POLICY(APPLET(load_policy, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_LOADFONT(APPLET(loadfont, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_LOGGER(APPLET(logger, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +IF_IPADDR(APPLET(ipaddr, BB_DIR_BIN, BB_SUID_DROP)) +IF_IPCALC(APPLET(ipcalc, BB_DIR_BIN, BB_SUID_DROP)) +IF_IPCRM(APPLET(ipcrm, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_IPCS(APPLET(ipcs, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_IPLINK(APPLET(iplink, BB_DIR_BIN, BB_SUID_DROP)) +IF_IPROUTE(APPLET(iproute, BB_DIR_BIN, BB_SUID_DROP)) +IF_IPRULE(APPLET(iprule, BB_DIR_BIN, BB_SUID_DROP)) +IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_BIN, BB_SUID_DROP)) +IF_KBD_MODE(APPLET(kbd_mode, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_KILL(APPLET(kill, BB_DIR_BIN, BB_SUID_DROP)) +IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall)) +IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall5)) +IF_KLOGD(APPLET(klogd, BB_DIR_SBIN, BB_SUID_DROP)) +IF_LAST(APPLET(last, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_LENGTH(APPLET_NOFORK(length, length, BB_DIR_USR_BIN, BB_SUID_DROP, length)) +IF_LESS(APPLET(less, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_SETARCH(APPLET_ODDNAME(linux32, setarch, BB_DIR_BIN, BB_SUID_DROP, linux32)) +IF_SETARCH(APPLET_ODDNAME(linux64, setarch, BB_DIR_BIN, BB_SUID_DROP, linux64)) +IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN, BB_SUID_DROP, ln)) +IF_LOAD_POLICY(APPLET(load_policy, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_LOADKMAP(APPLET(loadkmap, BB_DIR_SBIN, BB_SUID_DROP)) +IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP)) /* Needs to be run by root or be suid root - needs to change uid and gid: */ -IF_LOGIN(APPLET(login, _BB_DIR_BIN, _BB_SUID_REQUIRE)) -IF_LOGNAME(APPLET_NOFORK(logname, logname, _BB_DIR_USR_BIN, _BB_SUID_DROP, logname)) -IF_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_LPD(APPLET(lpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_LPQ(APPLET_ODDNAME(lpq, lpqr, _BB_DIR_USR_BIN, _BB_SUID_DROP, lpq)) -IF_LPR(APPLET_ODDNAME(lpr, lpqr, _BB_DIR_USR_BIN, _BB_SUID_DROP, lpr)) -IF_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_DROP, ls)) -IF_LSATTR(APPLET(lsattr, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_LSPCI(APPLET(lspci, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_LSUSB(APPLET(lsusb, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzcat)) -IF_LZMA(APPLET_ODDNAME(lzma, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzma)) -IF_LZOP(APPLET(lzop, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzopcat)) -IF_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_MAKEMIME(APPLET(makemime, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_MAN(APPLET(man, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_MATCHPATHCON(APPLET(matchpathcon, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, md5sum)) -IF_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_MICROCOM(APPLET(microcom, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_DROP, mkdir)) -IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_vfat)) -IF_MKFS_EXT2(APPLET_ODDNAME(mke2fs, mkfs_ext2, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_ext2)) -IF_MKFIFO(APPLET_NOEXEC(mkfifo, mkfifo, _BB_DIR_USR_BIN, _BB_SUID_DROP, mkfifo)) -IF_MKFS_EXT2(APPLET_ODDNAME(mkfs.ext2, mkfs_ext2, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_ext2)) -//IF_MKE2FS(APPLET_ODDNAME(mkfs.ext3, mke2fs, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_ext3)) -IF_MKFS_MINIX(APPLET_ODDNAME(mkfs.minix, mkfs_minix, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_minix)) -IF_MKFS_REISER(APPLET_ODDNAME(mkfs.reiser, mkfs_reiser, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_reiser)) -IF_MKFS_VFAT(APPLET_ODDNAME(mkfs.vfat, mkfs_vfat, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_vfat)) -IF_MKNOD(APPLET_NOEXEC(mknod, mknod, _BB_DIR_BIN, _BB_SUID_DROP, mknod)) -IF_CRYPTPW(APPLET_ODDNAME(mkpasswd, cryptpw, _BB_DIR_USR_BIN, _BB_SUID_DROP, mkpasswd)) -IF_MKSWAP(APPLET(mkswap, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_MKTEMP(APPLET(mktemp, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_MORE(APPLET(more, _BB_DIR_BIN, _BB_SUID_DROP)) +IF_LOGIN(APPLET(login, BB_DIR_BIN, BB_SUID_REQUIRE)) +IF_LOGNAME(APPLET_NOFORK(logname, logname, BB_DIR_USR_BIN, BB_SUID_DROP, logname)) +IF_LOGREAD(APPLET(logread, BB_DIR_SBIN, BB_SUID_DROP)) +IF_LOSETUP(APPLET(losetup, BB_DIR_SBIN, BB_SUID_DROP)) +IF_LPD(APPLET(lpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_LPQ(APPLET_ODDNAME(lpq, lpqr, BB_DIR_USR_BIN, BB_SUID_DROP, lpq)) +IF_LPR(APPLET_ODDNAME(lpr, lpqr, BB_DIR_USR_BIN, BB_SUID_DROP, lpr)) +IF_LS(APPLET_NOEXEC(ls, ls, BB_DIR_BIN, BB_SUID_DROP, ls)) +IF_LSATTR(APPLET(lsattr, BB_DIR_BIN, BB_SUID_DROP)) +IF_LSPCI(APPLET(lspci, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_LSUSB(APPLET(lsusb, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat)) +IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma)) +IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP)) +IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat)) +IF_MAKEDEVS(APPLET(makedevs, BB_DIR_SBIN, BB_SUID_DROP)) +IF_MAKEMIME(APPLET(makemime, BB_DIR_BIN, BB_SUID_DROP)) +IF_MAN(APPLET(man, BB_DIR_SBIN, BB_SUID_DROP)) +IF_MATCHPATHCON(APPLET(matchpathcon, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum)) +IF_MDEV(APPLET(mdev, BB_DIR_SBIN, BB_SUID_DROP)) +IF_MICROCOM(APPLET(microcom, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, BB_DIR_BIN, BB_SUID_DROP, mkdir)) +IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) +IF_MKFS_EXT2(APPLET_ODDNAME(mke2fs, mkfs_ext2, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext2)) +IF_MKFIFO(APPLET_NOEXEC(mkfifo, mkfifo, BB_DIR_USR_BIN, BB_SUID_DROP, mkfifo)) +IF_MKFS_EXT2(APPLET_ODDNAME(mkfs.ext2, mkfs_ext2, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext2)) +//IF_MKE2FS(APPLET_ODDNAME(mkfs.ext3, mke2fs, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext3)) +IF_MKFS_MINIX(APPLET_ODDNAME(mkfs.minix, mkfs_minix, BB_DIR_SBIN, BB_SUID_DROP, mkfs_minix)) +IF_MKFS_REISER(APPLET_ODDNAME(mkfs.reiser, mkfs_reiser, BB_DIR_SBIN, BB_SUID_DROP, mkfs_reiser)) +IF_MKFS_VFAT(APPLET_ODDNAME(mkfs.vfat, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) +IF_MKNOD(APPLET_NOEXEC(mknod, mknod, BB_DIR_BIN, BB_SUID_DROP, mknod)) +IF_CRYPTPW(APPLET_ODDNAME(mkpasswd, cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP, mkpasswd)) +IF_MKSWAP(APPLET(mkswap, BB_DIR_SBIN, BB_SUID_DROP)) +IF_MKTEMP(APPLET(mktemp, BB_DIR_BIN, BB_SUID_DROP)) +IF_MORE(APPLET(more, BB_DIR_BIN, BB_SUID_DROP)) /* On full-blown systems, requires suid for user mounts. * But it's not unthinkable to have it available in non-suid flavor on some systems, * for viewing mount table. - * Therefore we use _BB_SUID_MAYBE instead of _BB_SUID_REQUIRE: */ -IF_MOUNT(APPLET(mount, _BB_DIR_BIN, IF_DESKTOP(_BB_SUID_MAYBE) IF_NOT_DESKTOP(_BB_SUID_DROP))) -IF_MOUNTPOINT(APPLET(mountpoint, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_MT(APPLET(mt, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_MV(APPLET(mv, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_NAMEIF(APPLET(nameif, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_NC(APPLET(nc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_NETSTAT(APPLET(netstat, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_NICE(APPLET(nice, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_NOHUP(APPLET(nohup, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_NSLOOKUP(APPLET(nslookup, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_NTPD(APPLET(ntpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_OD(APPLET(od, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_OPENVT(APPLET(openvt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -//IF_PARSE(APPLET(parse, _BB_DIR_USR_BIN, _BB_SUID_DROP)) + * Therefore we use BB_SUID_MAYBE instead of BB_SUID_REQUIRE: */ +IF_MOUNT(APPLET(mount, BB_DIR_BIN, IF_DESKTOP(BB_SUID_MAYBE) IF_NOT_DESKTOP(BB_SUID_DROP))) +IF_MOUNTPOINT(APPLET(mountpoint, BB_DIR_BIN, BB_SUID_DROP)) +IF_MT(APPLET(mt, BB_DIR_BIN, BB_SUID_DROP)) +IF_MV(APPLET(mv, BB_DIR_BIN, BB_SUID_DROP)) +IF_NAMEIF(APPLET(nameif, BB_DIR_SBIN, BB_SUID_DROP)) +IF_NC(APPLET(nc, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_NETSTAT(APPLET(netstat, BB_DIR_BIN, BB_SUID_DROP)) +IF_NICE(APPLET(nice, BB_DIR_BIN, BB_SUID_DROP)) +IF_NOHUP(APPLET(nohup, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_NSLOOKUP(APPLET(nslookup, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_NTPD(APPLET(ntpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_OD(APPLET(od, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_OPENVT(APPLET(openvt, BB_DIR_USR_BIN, BB_SUID_DROP)) +//IF_PARSE(APPLET(parse, BB_DIR_USR_BIN, BB_SUID_DROP)) /* Needs to be run by root or be suid root - needs to change /etc/{passwd,shadow}: */ -IF_PASSWD(APPLET(passwd, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) -IF_PGREP(APPLET(pgrep, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_PIDOF(APPLET(pidof, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_PIPE_PROGRESS(APPLET(pipe_progress, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_PIVOT_ROOT(APPLET(pivot_root, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_PKILL(APPLET_ODDNAME(pkill, pgrep, _BB_DIR_USR_BIN, _BB_SUID_DROP, pkill)) -IF_POPMAILDIR(APPLET(popmaildir, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_PRINTENV(APPLET_NOFORK(printenv, printenv, _BB_DIR_BIN, _BB_SUID_DROP, printenv)) -IF_PRINTF(APPLET_NOFORK(printf, printf, _BB_DIR_USR_BIN, _BB_SUID_DROP, printf)) -IF_PS(APPLET(ps, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_PSCAN(APPLET(pscan, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_PWD(APPLET_NOFORK(pwd, pwd, _BB_DIR_BIN, _BB_SUID_DROP, pwd)) -IF_RAIDAUTORUN(APPLET(raidautorun, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_RDATE(APPLET(rdate, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_RDEV(APPLET(rdev, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_READAHEAD(APPLET(readahead, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_READLINK(APPLET(readlink, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_READPROFILE(APPLET(readprofile, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_REALPATH(APPLET(realpath, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_REFORMIME(APPLET(reformime, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_RESTORECON(APPLET_ODDNAME(restorecon, setfiles, _BB_DIR_SBIN, _BB_SUID_DROP, restorecon)) -IF_RFKILL(APPLET(rfkill, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_RM(APPLET_NOFORK(rm, rm, _BB_DIR_BIN, _BB_SUID_DROP, rm)) -IF_RMDIR(APPLET_NOFORK(rmdir, rmdir, _BB_DIR_BIN, _BB_SUID_DROP, rmdir)) -IF_ROUTE(APPLET(route, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_RPM(APPLET(rpm, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_RPM2CPIO(APPLET(rpm2cpio, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_RTCWAKE(APPLET(rtcwake, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_RUN_PARTS(APPLET_ODDNAME(run-parts, run_parts, _BB_DIR_BIN, _BB_SUID_DROP, run_parts)) -IF_RUNCON(APPLET(runcon, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_RUNLEVEL(APPLET(runlevel, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_RUNSV(APPLET(runsv, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_RUNSVDIR(APPLET(runsvdir, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_RX(APPLET(rx, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_SCRIPT(APPLET(script, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_SCRIPTREPLAY(APPLET(scriptreplay, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_SED(APPLET(sed, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_SELINUXENABLED(APPLET(selinuxenabled, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_SENDMAIL(APPLET(sendmail, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_SEQ(APPLET_NOFORK(seq, seq, _BB_DIR_USR_BIN, _BB_SUID_DROP, seq)) -IF_SESTATUS(APPLET(sestatus, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_SETARCH(APPLET(setarch, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_SETCONSOLE(APPLET(setconsole, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_SETENFORCE(APPLET(setenforce, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_SETFILES(APPLET(setfiles, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_SETFONT(APPLET(setfont, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_SETKEYCODES(APPLET(setkeycodes, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_SETLOGCONS(APPLET(setlogcons, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_SETSEBOOL(APPLET(setsebool, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_SETSID(APPLET(setsid, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, setuidgid)) -IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, sha1sum)) -IF_SHA256SUM(APPLET_NOEXEC(sha256sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, sha256sum)) -IF_SHA512SUM(APPLET_NOEXEC(sha512sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, sha512sum)) -IF_SHOWKEY(APPLET(showkey, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_SLATTACH(APPLET(slattach, _BB_DIR_SBIN, _BB_SUID_DROP)) +IF_PASSWD(APPLET(passwd, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) +IF_PGREP(APPLET(pgrep, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_PIDOF(APPLET(pidof, BB_DIR_BIN, BB_SUID_DROP)) +IF_PIPE_PROGRESS(APPLET(pipe_progress, BB_DIR_BIN, BB_SUID_DROP)) +IF_PIVOT_ROOT(APPLET(pivot_root, BB_DIR_SBIN, BB_SUID_DROP)) +IF_PKILL(APPLET_ODDNAME(pkill, pgrep, BB_DIR_USR_BIN, BB_SUID_DROP, pkill)) +IF_POPMAILDIR(APPLET(popmaildir, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_PRINTENV(APPLET_NOFORK(printenv, printenv, BB_DIR_BIN, BB_SUID_DROP, printenv)) +IF_PRINTF(APPLET_NOFORK(printf, printf, BB_DIR_USR_BIN, BB_SUID_DROP, printf)) +IF_PS(APPLET(ps, BB_DIR_BIN, BB_SUID_DROP)) +IF_PSCAN(APPLET(pscan, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_PWD(APPLET_NOFORK(pwd, pwd, BB_DIR_BIN, BB_SUID_DROP, pwd)) +IF_RAIDAUTORUN(APPLET(raidautorun, BB_DIR_SBIN, BB_SUID_DROP)) +IF_RDATE(APPLET(rdate, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_RDEV(APPLET(rdev, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_READAHEAD(APPLET(readahead, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_READLINK(APPLET(readlink, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_READPROFILE(APPLET(readprofile, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_REALPATH(APPLET(realpath, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_REFORMIME(APPLET(reformime, BB_DIR_BIN, BB_SUID_DROP)) +IF_RENICE(APPLET(renice, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_RESET(APPLET(reset, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_RESIZE(APPLET(resize, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_RESTORECON(APPLET_ODDNAME(restorecon, setfiles, BB_DIR_SBIN, BB_SUID_DROP, restorecon)) +IF_RFKILL(APPLET(rfkill, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_RM(APPLET_NOFORK(rm, rm, BB_DIR_BIN, BB_SUID_DROP, rm)) +IF_RMDIR(APPLET_NOFORK(rmdir, rmdir, BB_DIR_BIN, BB_SUID_DROP, rmdir)) +IF_ROUTE(APPLET(route, BB_DIR_SBIN, BB_SUID_DROP)) +IF_RPM(APPLET(rpm, BB_DIR_BIN, BB_SUID_DROP)) +IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_RTCWAKE(APPLET(rtcwake, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_RUN_PARTS(APPLET_ODDNAME(run-parts, run_parts, BB_DIR_BIN, BB_SUID_DROP, run_parts)) +IF_RUNCON(APPLET(runcon, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_RUNLEVEL(APPLET(runlevel, BB_DIR_SBIN, BB_SUID_DROP)) +IF_RUNSV(APPLET(runsv, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_RUNSVDIR(APPLET(runsvdir, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_RX(APPLET(rx, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_SCRIPT(APPLET(script, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_SCRIPTREPLAY(APPLET(scriptreplay, BB_DIR_BIN, BB_SUID_DROP)) +IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP)) +IF_SELINUXENABLED(APPLET(selinuxenabled, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_SENDMAIL(APPLET(sendmail, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_SEQ(APPLET_NOFORK(seq, seq, BB_DIR_USR_BIN, BB_SUID_DROP, seq)) +IF_SESTATUS(APPLET(sestatus, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_SETARCH(APPLET(setarch, BB_DIR_BIN, BB_SUID_DROP)) +IF_SETCONSOLE(APPLET(setconsole, BB_DIR_SBIN, BB_SUID_DROP)) +IF_SETENFORCE(APPLET(setenforce, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_SETFILES(APPLET(setfiles, BB_DIR_SBIN, BB_SUID_DROP)) +IF_SETFONT(APPLET(setfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_SETKEYCODES(APPLET(setkeycodes, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_SETLOGCONS(APPLET(setlogcons, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_SETSEBOOL(APPLET(setsebool, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_SETSID(APPLET(setsid, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid)) +IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha1sum)) +IF_SHA256SUM(APPLET_NOEXEC(sha256sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha256sum)) +IF_SHA512SUM(APPLET_NOEXEC(sha512sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha512sum)) +IF_SHOWKEY(APPLET(showkey, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_SLATTACH(APPLET(slattach, BB_DIR_SBIN, BB_SUID_DROP)) /* Do not make this applet NOFORK. It breaks ^C-ing of pauses in shells: */ -IF_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, softlimit)) -IF_SORT(APPLET_NOEXEC(sort, sort, _BB_DIR_USR_BIN, _BB_SUID_DROP, sort)) -IF_SPLIT(APPLET(split, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_DROP, start_stop_daemon)) -IF_STAT(APPLET(stat, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_STRINGS(APPLET(strings, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_STTY(APPLET(stty, _BB_DIR_BIN, _BB_SUID_DROP)) +IF_SLEEP(APPLET(sleep, BB_DIR_BIN, BB_SUID_DROP)) +IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, softlimit)) +IF_SORT(APPLET_NOEXEC(sort, sort, BB_DIR_USR_BIN, BB_SUID_DROP, sort)) +IF_SPLIT(APPLET(split, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, BB_DIR_SBIN, BB_SUID_DROP, start_stop_daemon)) +IF_STAT(APPLET(stat, BB_DIR_BIN, BB_SUID_DROP)) +IF_STRINGS(APPLET(strings, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_STTY(APPLET(stty, BB_DIR_BIN, BB_SUID_DROP)) /* Needs to be run by root or be suid root - needs to change uid and gid: */ -IF_SU(APPLET(su, _BB_DIR_BIN, _BB_SUID_REQUIRE)) -IF_SULOGIN(APPLET(sulogin, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_SUM(APPLET(sum, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_SV(APPLET(sv, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_SVLOGD(APPLET(svlogd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, _BB_DIR_SBIN, _BB_SUID_DROP, swapoff)) -IF_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, _BB_DIR_SBIN, _BB_SUID_DROP, swapon)) -IF_SWITCH_ROOT(APPLET(switch_root, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_SYNC(APPLET_NOFORK(sync, sync, _BB_DIR_BIN, _BB_SUID_DROP, sync)) -IF_BB_SYSCTL(APPLET(sysctl, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_SYSLOGD(APPLET(syslogd, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_TAC(APPLET_NOEXEC(tac, tac, _BB_DIR_USR_BIN, _BB_SUID_DROP, tac)) -IF_TAIL(APPLET(tail, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TAR(APPLET(tar, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_TASKSET(APPLET(taskset, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -/* IF_TC(APPLET(tc, _BB_DIR_SBIN, _BB_SUID_DROP)) */ -IF_TCPSVD(APPLET_ODDNAME(tcpsvd, tcpudpsvd, _BB_DIR_USR_BIN, _BB_SUID_DROP, tcpsvd)) -IF_TEE(APPLET(tee, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TELNET(APPLET(telnet, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TELNETD(APPLET(telnetd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_TEST(APPLET_NOFORK(test, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) +IF_SU(APPLET(su, BB_DIR_BIN, BB_SUID_REQUIRE)) +IF_SULOGIN(APPLET(sulogin, BB_DIR_SBIN, BB_SUID_DROP)) +IF_SUM(APPLET(sum, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_SV(APPLET(sv, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_SVLOGD(APPLET(svlogd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapoff)) +IF_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapon)) +IF_SWITCH_ROOT(APPLET(switch_root, BB_DIR_SBIN, BB_SUID_DROP)) +IF_SYNC(APPLET_NOFORK(sync, sync, BB_DIR_BIN, BB_SUID_DROP, sync)) +IF_BB_SYSCTL(APPLET(sysctl, BB_DIR_SBIN, BB_SUID_DROP)) +IF_SYSLOGD(APPLET(syslogd, BB_DIR_SBIN, BB_SUID_DROP)) +IF_TAC(APPLET_NOEXEC(tac, tac, BB_DIR_USR_BIN, BB_SUID_DROP, tac)) +IF_TAIL(APPLET(tail, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TAR(APPLET(tar, BB_DIR_BIN, BB_SUID_DROP)) +IF_TASKSET(APPLET(taskset, BB_DIR_USR_BIN, BB_SUID_DROP)) +/* IF_TC(APPLET(tc, BB_DIR_SBIN, BB_SUID_DROP)) */ +IF_TCPSVD(APPLET_ODDNAME(tcpsvd, tcpudpsvd, BB_DIR_USR_BIN, BB_SUID_DROP, tcpsvd)) +IF_TEE(APPLET(tee, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TELNET(APPLET(telnet, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TELNETD(APPLET(telnetd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_TEST(APPLET_NOFORK(test, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT -IF_TFTP(APPLET(tftp, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TFTPD(APPLET(tftpd, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +IF_TFTP(APPLET(tftp, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TFTPD(APPLET(tftpd, BB_DIR_USR_BIN, BB_SUID_DROP)) #endif -IF_TIME(APPLET(time, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TIMEOUT(APPLET(timeout, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TOP(APPLET(top, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TR(APPLET(tr, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -/* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore _BB_SUID_MAYBE: */ -IF_TRACEROUTE(APPLET(traceroute, _BB_DIR_USR_BIN, _BB_SUID_MAYBE)) -IF_TRACEROUTE6(APPLET(traceroute6, _BB_DIR_USR_BIN, _BB_SUID_MAYBE)) -IF_TRUE(APPLET_NOFORK(true, true, _BB_DIR_BIN, _BB_SUID_DROP, true)) -IF_TTY(APPLET(tty, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TTYSIZE(APPLET(ttysize, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_TUNCTL(APPLET(tunctl, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_TUNE2FS(APPLET(tune2fs, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_UDHCPC(APPLET(udhcpc, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_UDHCPD(APPLET(udhcpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -IF_UDPSVD(APPLET_ODDNAME(udpsvd, tcpudpsvd, _BB_DIR_USR_BIN, _BB_SUID_DROP, udpsvd)) -IF_UMOUNT(APPLET(umount, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_UNAME(APPLET(uname, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_UNCOMPRESS(APPLET(uncompress, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, _BB_DIR_USR_BIN, _BB_SUID_DROP, unexpand)) -IF_UNIQ(APPLET(uniq, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_UNIX2DOS(APPLET_NOEXEC(unix2dos, dos2unix, _BB_DIR_USR_BIN, _BB_SUID_DROP, unix2dos)) -IF_UNXZ(APPLET(unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_UNLZMA(APPLET(unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_LZOP(APPLET_ODDNAME(unlzop, lzop, _BB_DIR_USR_BIN, _BB_SUID_DROP, unlzop)) -IF_UNZIP(APPLET(unzip, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_UPTIME(APPLET(uptime, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_USLEEP(APPLET_NOFORK(usleep, usleep, _BB_DIR_BIN, _BB_SUID_DROP, usleep)) -IF_UUDECODE(APPLET(uudecode, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_UUENCODE(APPLET(uuencode, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_DROP)) +IF_TIME(APPLET(time, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TIMEOUT(APPLET(timeout, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TOP(APPLET(top, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TR(APPLET(tr, BB_DIR_USR_BIN, BB_SUID_DROP)) +/* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore BB_SUID_MAYBE: */ +IF_TRACEROUTE(APPLET(traceroute, BB_DIR_USR_BIN, BB_SUID_MAYBE)) +IF_TRACEROUTE6(APPLET(traceroute6, BB_DIR_USR_BIN, BB_SUID_MAYBE)) +IF_TRUE(APPLET_NOFORK(true, true, BB_DIR_BIN, BB_SUID_DROP, true)) +IF_TTY(APPLET(tty, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TTYSIZE(APPLET(ttysize, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_TUNCTL(APPLET(tunctl, BB_DIR_SBIN, BB_SUID_DROP)) +IF_TUNE2FS(APPLET(tune2fs, BB_DIR_SBIN, BB_SUID_DROP)) +IF_UDHCPC(APPLET(udhcpc, BB_DIR_SBIN, BB_SUID_DROP)) +IF_UDHCPD(APPLET(udhcpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) +IF_UDPSVD(APPLET_ODDNAME(udpsvd, tcpudpsvd, BB_DIR_USR_BIN, BB_SUID_DROP, udpsvd)) +IF_UMOUNT(APPLET(umount, BB_DIR_BIN, BB_SUID_DROP)) +IF_UNAME(APPLET(uname, BB_DIR_BIN, BB_SUID_DROP)) +IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP)) +IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, BB_DIR_USR_BIN, BB_SUID_DROP, unexpand)) +IF_UNIQ(APPLET(uniq, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_UNIX2DOS(APPLET_NOEXEC(unix2dos, dos2unix, BB_DIR_USR_BIN, BB_SUID_DROP, unix2dos)) +IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_LZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop)) +IF_UNZIP(APPLET(unzip, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_UPTIME(APPLET(uptime, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_USLEEP(APPLET_NOFORK(usleep, usleep, BB_DIR_BIN, BB_SUID_DROP, usleep)) +IF_UUDECODE(APPLET(uudecode, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_UUENCODE(APPLET(uuencode, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_VCONFIG(APPLET(vconfig, BB_DIR_SBIN, BB_SUID_DROP)) +IF_VI(APPLET(vi, BB_DIR_BIN, BB_SUID_DROP)) /* Needs to be run by root or be suid root - needs to change uid and gid: */ -IF_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) -IF_VOLNAME(APPLET(volname, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +IF_VLOCK(APPLET(vlock, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) +IF_VOLNAME(APPLET(volname, BB_DIR_USR_BIN, BB_SUID_DROP)) /* Needs to be run by root or be suid root - needs to write to /dev/TTY: */ -IF_WALL(APPLET(wall, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) -IF_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_DROP)) -IF_WATCHDOG(APPLET(watchdog, _BB_DIR_SBIN, _BB_SUID_DROP)) -IF_WC(APPLET(wc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_WGET(APPLET(wget, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_DROP)) -IF_WHOAMI(APPLET_NOFORK(whoami, whoami, _BB_DIR_USR_BIN, _BB_SUID_DROP, whoami)) -IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP, xzcat)) -IF_XZ(APPLET_ODDNAME(xz, unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP, xz)) -IF_YES(APPLET_NOFORK(yes, yes, _BB_DIR_USR_BIN, _BB_SUID_DROP, yes)) -IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, _BB_DIR_BIN, _BB_SUID_DROP, zcat)) -IF_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_DROP)) +IF_WALL(APPLET(wall, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) +IF_WATCH(APPLET(watch, BB_DIR_BIN, BB_SUID_DROP)) +IF_WATCHDOG(APPLET(watchdog, BB_DIR_SBIN, BB_SUID_DROP)) +IF_WC(APPLET(wc, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_WGET(APPLET(wget, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_WHICH(APPLET(which, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_WHO(APPLET(who, BB_DIR_USR_BIN, BB_SUID_DROP)) +IF_WHOAMI(APPLET_NOFORK(whoami, whoami, BB_DIR_USR_BIN, BB_SUID_DROP, whoami)) +IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat)) +IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz)) +IF_YES(APPLET_NOFORK(yes, yes, BB_DIR_USR_BIN, BB_SUID_DROP, yes)) +IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) +IF_ZCIP(APPLET(zcip, BB_DIR_SBIN, BB_SUID_DROP)) #if !defined(PROTOTYPES) && !defined(NAME_MAIN_CNAME) && !defined(MAKE_USAGE) }; diff --git a/include/busybox.h b/include/busybox.h index 757317fc7..be06817e3 100644 --- a/include/busybox.h +++ b/include/busybox.h @@ -13,22 +13,22 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN /* order matters: used as index into "install_dir[]" in appletlib.c */ typedef enum bb_install_loc_t { - _BB_DIR_ROOT = 0, - _BB_DIR_BIN, - _BB_DIR_SBIN, + BB_DIR_ROOT = 0, + BB_DIR_BIN, + BB_DIR_SBIN, #if ENABLE_INSTALL_NO_USR - _BB_DIR_USR_BIN = _BB_DIR_BIN, - _BB_DIR_USR_SBIN = _BB_DIR_SBIN, + BB_DIR_USR_BIN = BB_DIR_BIN, + BB_DIR_USR_SBIN = BB_DIR_SBIN, #else - _BB_DIR_USR_BIN, - _BB_DIR_USR_SBIN, + BB_DIR_USR_BIN, + BB_DIR_USR_SBIN, #endif } bb_install_loc_t; typedef enum bb_suid_t { - _BB_SUID_DROP = 0, - _BB_SUID_MAYBE, - _BB_SUID_REQUIRE + BB_SUID_DROP = 0, + BB_SUID_MAYBE, + BB_SUID_REQUIRE } bb_suid_t; diff --git a/init/bootchartd.c b/init/bootchartd.c index ac3f261c8..009e2690c 100644 --- a/init/bootchartd.c +++ b/init/bootchartd.c @@ -3,7 +3,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP)) +//applet:IF_BOOTCHARTD(APPLET(bootchartd, BB_DIR_SBIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_BOOTCHARTD) += bootchartd.o diff --git a/init/halt.c b/init/halt.c index 47f1ef7b2..f853ba4a1 100644 --- a/init/halt.c +++ b/init/halt.c @@ -7,9 +7,9 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ -//applet:IF_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_DROP)) -//applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, _BB_DIR_SBIN, _BB_SUID_DROP, poweroff)) -//applet:IF_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_DROP, reboot)) +//applet:IF_HALT(APPLET(halt, BB_DIR_SBIN, BB_SUID_DROP)) +//applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff)) +//applet:IF_HALT(APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot)) //kbuild:lib-$(CONFIG_HALT) += halt.o diff --git a/init/init.c b/init/init.c index a2cc3b5f5..d8e180746 100644 --- a/init/init.c +++ b/init/init.c @@ -9,8 +9,8 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_INIT(APPLET(init, _BB_DIR_SBIN, _BB_SUID_DROP)) -//applet:IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, _BB_DIR_ROOT, _BB_SUID_DROP, linuxrc)) +//applet:IF_INIT(APPLET(init, BB_DIR_SBIN, BB_SUID_DROP)) +//applet:IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, BB_DIR_ROOT, BB_SUID_DROP, linuxrc)) //kbuild:lib-$(CONFIG_INIT) += init.o diff --git a/init/mesg.c b/init/mesg.c index b6fd070e1..676ca2e24 100644 --- a/init/mesg.c +++ b/init/mesg.c @@ -7,7 +7,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +//applet:IF_MESG(APPLET(mesg, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_MESG) += mesg.o diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 3e32fa1ef..fc3e962d5 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -574,12 +574,12 @@ static void check_suid(int applet_no) # endif check_need_suid: # endif - if (APPLET_SUID(applet_no) == _BB_SUID_REQUIRE) { + if (APPLET_SUID(applet_no) == BB_SUID_REQUIRE) { /* Real uid is not 0. If euid isn't 0 too, suid bit * is most probably not set on our executable */ if (geteuid()) bb_error_msg_and_die("must be suid to work properly"); - } else if (APPLET_SUID(applet_no) == _BB_SUID_DROP) { + } else if (APPLET_SUID(applet_no) == BB_SUID_DROP) { xsetgid(rgid); /* drop all privileges */ xsetuid(ruid); } diff --git a/loginutils/add-remove-shell.c b/loginutils/add-remove-shell.c index 757e50503..9a1454430 100644 --- a/loginutils/add-remove-shell.c +++ b/loginutils/add-remove-shell.c @@ -8,8 +8,8 @@ * for details. */ -//applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, _BB_DIR_USR_BIN, _BB_SUID_DROP, add_shell )) -//applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, _BB_DIR_USR_BIN, _BB_SUID_DROP, remove_shell)) +//applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, BB_DIR_USR_BIN, BB_SUID_DROP, add_shell )) +//applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, BB_DIR_USR_BIN, BB_SUID_DROP, remove_shell)) //kbuild:lib-$(CONFIG_ADD_SHELL) += add-remove-shell.o //kbuild:lib-$(CONFIG_REMOVE_SHELL) += add-remove-shell.o diff --git a/miscutils/conspy.c b/miscutils/conspy.c index 723b4208a..721eb6d59 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c @@ -10,7 +10,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_CONSPY(APPLET(conspy, _BB_DIR_BIN, _BB_SUID_DROP)) +//applet:IF_CONSPY(APPLET(conspy, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_CONSPY) += conspy.o diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c index 831d2f76b..c5e2fb841 100644 --- a/miscutils/nandwrite.c +++ b/miscutils/nandwrite.c @@ -8,8 +8,8 @@ * TODO: add support for large (>4GB) MTD devices */ -//applet:IF_NANDWRITE(APPLET(nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) -//applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP, nanddump)) +//applet:IF_NANDWRITE(APPLET(nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP)) +//applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP, nanddump)) //kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o diff --git a/miscutils/ubi_attach_detach.c b/miscutils/ubi_attach_detach.c index b74d97b68..aa8a5171a 100644 --- a/miscutils/ubi_attach_detach.c +++ b/miscutils/ubi_attach_detach.c @@ -3,8 +3,8 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ -//applet:IF_UBIATTACH(APPLET_ODDNAME(ubiattach, ubi_attach_detach, _BB_DIR_USR_SBIN, _BB_SUID_DROP, ubiattach)) -//applet:IF_UBIDETACH(APPLET_ODDNAME(ubidetach, ubi_attach_detach, _BB_DIR_USR_SBIN, _BB_SUID_DROP, ubidetach)) +//applet:IF_UBIATTACH(APPLET_ODDNAME(ubiattach, ubi_attach_detach, BB_DIR_USR_SBIN, BB_SUID_DROP, ubiattach)) +//applet:IF_UBIDETACH(APPLET_ODDNAME(ubidetach, ubi_attach_detach, BB_DIR_USR_SBIN, BB_SUID_DROP, ubidetach)) //kbuild:lib-$(CONFIG_UBIATTACH) += ubi_attach_detach.o //kbuild:lib-$(CONFIG_UBIDETACH) += ubi_attach_detach.o diff --git a/modutils/depmod.c b/modutils/depmod.c index 85b64a229..f6c0bf33a 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c @@ -8,7 +8,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_DEPMOD(APPLET(depmod, _BB_DIR_SBIN, _BB_SUID_DROP)) +//applet:IF_DEPMOD(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)) //usage:#if !ENABLE_MODPROBE_SMALL //usage:#define depmod_trivial_usage NOUSAGE_STR diff --git a/modutils/insmod.c b/modutils/insmod.c index 7ec3cae47..e5b46f402 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -7,7 +7,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_DROP)) +//applet:IF_INSMOD(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP)) #include "libbb.h" #include "modutils.h" diff --git a/modutils/lsmod.c b/modutils/lsmod.c index d7e16689b..3b3c166b9 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -8,7 +8,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_DROP)) +//applet:IF_LSMOD(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP)) //usage:#if !ENABLE_MODPROBE_SMALL //usage:#define lsmod_trivial_usage diff --git a/modutils/modinfo.c b/modutils/modinfo.c index 37ba77edf..731fc0553 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c @@ -6,7 +6,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_MODINFO(APPLET(modinfo, _BB_DIR_SBIN, _BB_SUID_DROP)) +//applet:IF_MODINFO(APPLET(modinfo, BB_DIR_SBIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_MODINFO) += modinfo.o modutils.o diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 188a7f229..2a69eb513 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -8,11 +8,11 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ -//applet:IF_MODPROBE_SMALL(APPLET(modprobe, _BB_DIR_SBIN, _BB_SUID_DROP)) -//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) -//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) -//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) -//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) +//applet:IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) +//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) +//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) +//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) +//applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) #include "libbb.h" /* After libbb.h, since it needs sys/types.h on some systems */ diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 73df39c6c..e3bacac56 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -8,7 +8,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_MODPROBE(APPLET(modprobe, _BB_DIR_SBIN, _BB_SUID_DROP)) +//applet:IF_MODPROBE(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) #include "libbb.h" #include "modutils.h" diff --git a/modutils/rmmod.c b/modutils/rmmod.c index 2486511d7..65a4911cd 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c @@ -8,7 +8,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ -//applet:IF_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_DROP)) +//applet:IF_RMMOD(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP)) //usage:#if !ENABLE_MODPROBE_SMALL //usage:#define rmmod_trivial_usage diff --git a/networking/nbd-client.c b/networking/nbd-client.c index 8b856eda7..cadda5261 100644 --- a/networking/nbd-client.c +++ b/networking/nbd-client.c @@ -7,7 +7,7 @@ #include #include -//applet:IF_NBDCLIENT(APPLET_ODDNAME(nbd-client, nbdclient, _BB_DIR_USR_SBIN, _BB_SUID_DROP, nbdclient)) +//applet:IF_NBDCLIENT(APPLET_ODDNAME(nbd-client, nbdclient, BB_DIR_USR_SBIN, BB_SUID_DROP, nbdclient)) //kbuild:lib-$(CONFIG_NBDCLIENT) += nbd-client.o diff --git a/networking/ping.c b/networking/ping.c index 366a98668..11ce24eb5 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -52,9 +52,9 @@ //config: Make the output from the ping applet include statistics, and at the //config: same time provide full support for ICMP packets. -/* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore _BB_SUID_MAYBE: */ -//applet:IF_PING(APPLET(ping, _BB_DIR_BIN, _BB_SUID_MAYBE)) -//applet:IF_PING6(APPLET(ping6, _BB_DIR_BIN, _BB_SUID_MAYBE)) +/* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore BB_SUID_MAYBE: */ +//applet:IF_PING(APPLET(ping, BB_DIR_BIN, BB_SUID_MAYBE)) +//applet:IF_PING6(APPLET(ping6, BB_DIR_BIN, BB_SUID_MAYBE)) //kbuild:lib-$(CONFIG_PING) += ping.o //kbuild:lib-$(CONFIG_PING6) += ping.o diff --git a/procps/iostat.c b/procps/iostat.c index a9ff13a05..06a33eb1d 100644 --- a/procps/iostat.c +++ b/procps/iostat.c @@ -7,7 +7,7 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ -//applet:IF_IOSTAT(APPLET(iostat, _BB_DIR_BIN, _BB_SUID_DROP)) +//applet:IF_IOSTAT(APPLET(iostat, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_IOSTAT) += iostat.o diff --git a/procps/mpstat.c b/procps/mpstat.c index 25efedf62..d643c999f 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c @@ -7,7 +7,7 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ -//applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP)) +//applet:IF_MPSTAT(APPLET(mpstat, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o diff --git a/procps/nmeter.c b/procps/nmeter.c index ac019eb53..48b56a399 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c @@ -12,7 +12,7 @@ //config: help //config: Prints selected system stats continuously, one line per update. -//applet:IF_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +//applet:IF_NMETER(APPLET(nmeter, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_NMETER) += nmeter.o diff --git a/procps/pmap.c b/procps/pmap.c index bb5f9e7c2..7f7f391b9 100644 --- a/procps/pmap.c +++ b/procps/pmap.c @@ -8,7 +8,7 @@ * for details. */ -//applet:IF_PMAP(APPLET(pmap, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +//applet:IF_PMAP(APPLET(pmap, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_PMAP) += pmap.o //config:config PMAP diff --git a/procps/powertop.c b/procps/powertop.c index 2f977a03b..bfe5a9568 100644 --- a/procps/powertop.c +++ b/procps/powertop.c @@ -9,7 +9,7 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ -//applet:IF_POWERTOP(APPLET(powertop, _BB_DIR_BIN, _BB_SUID_DROP)) +//applet:IF_POWERTOP(APPLET(powertop, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_POWERTOP) += powertop.o diff --git a/procps/pstree.c b/procps/pstree.c index 180d0939a..ddf5dba59 100644 --- a/procps/pstree.c +++ b/procps/pstree.c @@ -16,7 +16,7 @@ //config: help //config: Display a tree of processes. -//applet:IF_PSTREE(APPLET(pstree, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +//applet:IF_PSTREE(APPLET(pstree, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_PSTREE) += pstree.o diff --git a/procps/smemcap.c b/procps/smemcap.c index 200df6795..e108d88ad 100644 --- a/procps/smemcap.c +++ b/procps/smemcap.c @@ -8,7 +8,7 @@ herein by reference. */ -//applet:IF_SMEMCAP(APPLET(smemcap, _BB_DIR_USR_BIN, _BB_SUID_DROP)) +//applet:IF_SMEMCAP(APPLET(smemcap, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_SMEMCAP) += smemcap.o diff --git a/shell/ash.c b/shell/ash.c index 6f03ac1c6..298ba3558 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -72,9 +72,9 @@ # error "Do not even bother, ash will not run on NOMMU machine" #endif -//applet:IF_ASH(APPLET(ash, _BB_DIR_BIN, _BB_SUID_DROP)) -//applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, _BB_DIR_BIN, _BB_SUID_DROP, sh)) -//applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, _BB_DIR_BIN, _BB_SUID_DROP, bash)) +//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) +//applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh)) +//applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash)) //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o diff --git a/shell/cttyhack.c b/shell/cttyhack.c index d1cb7fcc3..d1ac2cd23 100644 --- a/shell/cttyhack.c +++ b/shell/cttyhack.c @@ -6,7 +6,7 @@ */ #include "libbb.h" -//applet:IF_CTTYHACK(APPLET(cttyhack, _BB_DIR_BIN, _BB_SUID_DROP)) +//applet:IF_CTTYHACK(APPLET(cttyhack, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_CTTYHACK) += cttyhack.o diff --git a/shell/hush.c b/shell/hush.c index 24b9e6efe..6970c50c4 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -105,10 +105,10 @@ # define PIPE_BUF 4096 /* amount of buffering in a pipe */ #endif -//applet:IF_HUSH(APPLET(hush, _BB_DIR_BIN, _BB_SUID_DROP)) -//applet:IF_MSH(APPLET(msh, _BB_DIR_BIN, _BB_SUID_DROP)) -//applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, _BB_DIR_BIN, _BB_SUID_DROP, sh)) -//applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, _BB_DIR_BIN, _BB_SUID_DROP, bash)) +//applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP)) +//applet:IF_MSH(APPLET(msh, BB_DIR_BIN, BB_SUID_DROP)) +//applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, sh)) +//applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, bash)) //kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o diff --git a/util-linux/blockdev.c b/util-linux/blockdev.c index c61116df9..c2fcaee88 100644 --- a/util-linux/blockdev.c +++ b/util-linux/blockdev.c @@ -6,7 +6,7 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ -//applet:IF_BLOCKDEV(APPLET(blockdev, _BB_DIR_SBIN, _BB_SUID_DROP)) +//applet:IF_BLOCKDEV(APPLET(blockdev, BB_DIR_SBIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_BLOCKDEV) += blockdev.o diff --git a/util-linux/rev.c b/util-linux/rev.c index e1e004437..3c1b22f09 100644 --- a/util-linux/rev.c +++ b/util-linux/rev.c @@ -6,7 +6,7 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ -//applet:IF_REV(APPLET(rev, _BB_DIR_BIN, _BB_SUID_DROP)) +//applet:IF_REV(APPLET(rev, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_REV) += rev.o -- cgit v1.2.3-55-g6feb From 98c46d10ee81f206f274da312086a3f0533582af Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 18 Jan 2011 17:30:07 +0100 Subject: hush: fix "cmd & " problem Signed-off-by: Denys Vlasenko --- shell/hush.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 6970c50c4..3581ba119 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -4141,15 +4141,26 @@ static struct pipe *parse_stream(char **pstring, && dest.length == 0 && !dest.has_quoted_part ) { /* This newline can be ignored. But... - * without the below check, interactive shell - * will ignore even lines with bare , - * and show the continuation prompt: + * Without check #1, interactive shell + * ignores even bare , + * and shows the continuation prompt: * ps1_prompt$ - * ps2> _ <=== wrong prompt, should be ps1 + * ps2> _ <=== wrong, should be ps1 + * Without check #2, "cmd & " + * is similarly mistreated. + * (BTW, this makes "cmd & cmd" + * and "cmd && cmd" non-orthogonal. + * Really, ask yourself, why + * "cmd && " doesn't start + * cmd but waits for more input? + * No reason...) */ struct pipe *pi = ctx.list_head; - if (pi->num_cmds != 0) + if (pi->num_cmds != 0 /* check #1 */ + && pi->followup != PIPE_BG /* check #2 */ + ) { continue; + } } /* Treat newline as a command separator. */ done_pipe(&ctx, PIPE_SEQ); -- cgit v1.2.3-55-g6feb From a14631917363aa96943e46090773c15ac1b0f995 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 18 Jan 2011 17:55:04 +0100 Subject: hush: improve prompt in nested {}s, remove unused in_str->promptme member function old new delta setup_string_in_str 29 38 +9 parse_and_run_stream 79 88 +9 setup_file_in_str 32 39 +7 parse_stream 2430 2422 -8 file_get 262 235 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 25/-35) Total: -10 bytes Signed-off-by: Denys Vlasenko --- shell/hush.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 3581ba119..1709fd9d1 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -445,7 +445,6 @@ typedef struct in_str { char eof_flag; /* meaningless if ->p == NULL */ char peek_buf[2]; #if ENABLE_HUSH_INTERACTIVE - smallint promptme; smallint promptmode; /* 0: PS1, 1: PS2 */ #endif FILE *file; @@ -1946,22 +1945,17 @@ static int FAST_FUNC file_get(struct in_str *i) /* need to double check i->file because we might be doing something * more complicated by now, like sourcing or substituting. */ #if ENABLE_HUSH_INTERACTIVE - if (G_interactive_fd && i->promptme && i->file == stdin) { + if (G_interactive_fd && i->file == stdin) { do { get_user_input(i); } while (!*i->p); /* need non-empty line */ i->promptmode = 1; /* PS2 */ - i->promptme = 0; goto take_cached; } #endif do ch = fgetc(i->file); while (ch == '\0'); } debug_printf("file_get: got '%c' %d\n", ch, ch); -#if ENABLE_HUSH_INTERACTIVE - if (ch == '\n') - i->promptme = 1; -#endif return ch; } @@ -1988,26 +1982,22 @@ static int FAST_FUNC file_peek(struct in_str *i) static void setup_file_in_str(struct in_str *i, FILE *f) { + memset(i, 0, sizeof(*i)); i->peek = file_peek; i->get = file_get; -#if ENABLE_HUSH_INTERACTIVE - i->promptme = 1; - i->promptmode = 0; /* PS1 */ -#endif + /* i->promptmode = 0; - PS1 (memset did it) */ i->file = f; - i->p = NULL; + /* i->p = NULL; */ } static void setup_string_in_str(struct in_str *i, const char *s) { + memset(i, 0, sizeof(*i)); i->peek = static_peek; i->get = static_get; -#if ENABLE_HUSH_INTERACTIVE - i->promptme = 1; - i->promptmode = 0; /* PS1 */ -#endif + /* i->promptmode = 0; - PS1 (memset did it) */ i->p = s; - i->eof_flag = 0; + /* i->eof_flag = 0; */ } @@ -4031,9 +4021,6 @@ static struct pipe *parse_stream(char **pstring, reset: /* we come back here only on syntax errors in interactive shell */ -#if ENABLE_HUSH_INTERACTIVE - input->promptmode = 0; /* PS1 */ -#endif if (MAYBE_ASSIGNMENT != 0) dest.o_assignment = MAYBE_ASSIGNMENT; initialize_context(&ctx); @@ -4539,7 +4526,6 @@ static struct pipe *parse_stream(char **pstring, } /* Discard cached input, force prompt */ input->p = NULL; - IF_HUSH_INTERACTIVE(input->promptme = 1;) goto reset; } } @@ -5539,6 +5525,10 @@ static void parse_and_run_stream(struct in_str *inp, int end_trigger) while (1) { struct pipe *pipe_list; +#if ENABLE_HUSH_INTERACTIVE + if (end_trigger == ';') + inp->promptmode = 0; /* PS1 */ +#endif pipe_list = parse_stream(NULL, inp, end_trigger); if (!pipe_list) { /* EOF */ if (empty) -- cgit v1.2.3-55-g6feb From 9ad97d504146db2ea6b6a1a23c96ca052c50e270 Mon Sep 17 00:00:00 2001 From: Chris Rees Date: Thu, 20 Jan 2011 00:51:52 +0100 Subject: sighandler_t definition for BSD Signed-off-by: Chris Rees Signed-off-by: Denys Vlasenko --- include/platform.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/platform.h b/include/platform.h index 2666eebee..6328ff6ad 100644 --- a/include/platform.h +++ b/include/platform.h @@ -14,6 +14,7 @@ #define HAVE_MEMRCHR 1 #define HAVE_MKDTEMP 1 #define HAVE_SETBIT 1 +#define HAVE_SIGHANDLER_T 1 #define HAVE_STRCASESTR 1 #define HAVE_STRCHRNUL 1 #define HAVE_STRSEP 1 @@ -253,6 +254,7 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ # undef HAVE_MNTENT_H # undef HAVE_SYS_STATFS_H +# undef HAVE_SIGHANDLER_T #else # define HAVE_MNTENT_H 1 # define HAVE_SYS_STATFS_H 1 @@ -396,6 +398,10 @@ extern char *mkdtemp(char *template) FAST_FUNC; # define clrbit(a, b) ((a)[(b) >> 3] &= ~(1 << ((b) & 7))) #endif +#ifndef HAVE_SIGHANDLER_T +typedef void (*sighandler_t)(int); +#endif + #ifndef HAVE_STRCASESTR extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; #endif -- cgit v1.2.3-55-g6feb From 53f30b41ec252d9973719b349a644477e72e1a09 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 01:20:36 +0100 Subject: ifplugd: eliminate aliasing warnings Signed-off-by: Denys Vlasenko --- networking/ifplugd.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/networking/ifplugd.c b/networking/ifplugd.c index 58f56dbf1..3b59a63ff 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c @@ -131,18 +131,20 @@ static int network_ioctl(int request, void* data, const char *errmsg) static smallint detect_link_mii(void) { - struct ifreq ifreq; - struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; + /* char buffer instead of bona-fide struct avoids aliasing warning */ + char buf[sizeof(struct ifreq)]; + struct ifreq *ifreq = (void *)buf; + struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data; - set_ifreq_to_ifname(&ifreq); + set_ifreq_to_ifname(ifreq); - if (network_ioctl(SIOCGMIIPHY, &ifreq, "SIOCGMIIPHY") < 0) { + if (network_ioctl(SIOCGMIIPHY, ifreq, "SIOCGMIIPHY") < 0) { return IFSTATUS_ERR; } mii->reg_num = 1; - if (network_ioctl(SIOCGMIIREG, &ifreq, "SIOCGMIIREG") < 0) { + if (network_ioctl(SIOCGMIIREG, ifreq, "SIOCGMIIREG") < 0) { return IFSTATUS_ERR; } @@ -151,18 +153,20 @@ static smallint detect_link_mii(void) static smallint detect_link_priv(void) { - struct ifreq ifreq; - struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; + /* char buffer instead of bona-fide struct avoids aliasing warning */ + char buf[sizeof(struct ifreq)]; + struct ifreq *ifreq = (void *)buf; + struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data; - set_ifreq_to_ifname(&ifreq); + set_ifreq_to_ifname(ifreq); - if (network_ioctl(SIOCDEVPRIVATE, &ifreq, "SIOCDEVPRIVATE") < 0) { + if (network_ioctl(SIOCDEVPRIVATE, ifreq, "SIOCDEVPRIVATE") < 0) { return IFSTATUS_ERR; } mii->reg_num = 1; - if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq, "SIOCDEVPRIVATE+1") < 0) { + if (network_ioctl(SIOCDEVPRIVATE+1, ifreq, "SIOCDEVPRIVATE+1") < 0) { return IFSTATUS_ERR; } -- cgit v1.2.3-55-g6feb From b3b6c8bdf23d30c57d92458f1aac93ce84bf81a7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 11:29:00 +0100 Subject: eliminate aliasing warning in networking/route.c Signed-off-by: Denys Vlasenko --- networking/ifplugd.c | 6 +++-- networking/route.c | 71 +++++++++++++++++++++++++++------------------------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/networking/ifplugd.c b/networking/ifplugd.c index 3b59a63ff..8dd0a5bd8 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c @@ -133,7 +133,8 @@ static smallint detect_link_mii(void) { /* char buffer instead of bona-fide struct avoids aliasing warning */ char buf[sizeof(struct ifreq)]; - struct ifreq *ifreq = (void *)buf; + struct ifreq *const ifreq = (void *)buf; + struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data; set_ifreq_to_ifname(ifreq); @@ -155,7 +156,8 @@ static smallint detect_link_priv(void) { /* char buffer instead of bona-fide struct avoids aliasing warning */ char buf[sizeof(struct ifreq)]; - struct ifreq *ifreq = (void *)buf; + struct ifreq *const ifreq = (void *)buf; + struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data; set_ifreq_to_ifname(ifreq); diff --git a/networking/route.c b/networking/route.c index 98567aaee..b7d08dd63 100644 --- a/networking/route.c +++ b/networking/route.c @@ -153,7 +153,10 @@ static int kw_lookup(const char *kwtbl, char ***pargs) static NOINLINE void INET_setroute(int action, char **args) { - struct rtentry rt; + /* char buffer instead of bona-fide struct avoids aliasing warning */ + char rt_buf[sizeof(struct rtentry)]; + struct rtentry *const rt = (void *)rt_buf; + const char *netmask = NULL; int skfd, isnet, xflag; @@ -166,7 +169,7 @@ static NOINLINE void INET_setroute(int action, char **args) } /* Clean out the RTREQ structure. */ - memset(&rt, 0, sizeof(rt)); + memset(rt, 0, sizeof(*rt)); { const char *target = *args++; @@ -178,17 +181,17 @@ static NOINLINE void INET_setroute(int action, char **args) int prefix_len; prefix_len = xatoul_range(prefix+1, 0, 32); - mask_in_addr(rt) = htonl( ~(0xffffffffUL >> prefix_len)); + mask_in_addr(*rt) = htonl( ~(0xffffffffUL >> prefix_len)); *prefix = '\0'; #if HAVE_NEW_ADDRT - rt.rt_genmask.sa_family = AF_INET; + rt->rt_genmask.sa_family = AF_INET; #endif } else { /* Default netmask. */ netmask = "default"; } /* Prefer hostname lookup is -host flag (xflag==1) was given. */ - isnet = INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst, + isnet = INET_resolve(target, (struct sockaddr_in *) &rt->rt_dst, (xflag & HOST_FLAG)); if (isnet < 0) { bb_error_msg_and_die("resolving %s", target); @@ -204,20 +207,20 @@ static NOINLINE void INET_setroute(int action, char **args) } /* Fill in the other fields. */ - rt.rt_flags = ((isnet) ? RTF_UP : (RTF_UP | RTF_HOST)); + rt->rt_flags = ((isnet) ? RTF_UP : (RTF_UP | RTF_HOST)); while (*args) { int k = kw_lookup(tbl_ipvx, &args); const char *args_m1 = args[-1]; if (k & KW_IPVx_FLAG_ONLY) { - rt.rt_flags |= flags_ipvx[k & 3]; + rt->rt_flags |= flags_ipvx[k & 3]; continue; } #if HAVE_NEW_ADDRT if (k == KW_IPVx_METRIC) { - rt.rt_metric = xatoul(args_m1) + 1; + rt->rt_metric = xatoul(args_m1) + 1; continue; } #endif @@ -225,7 +228,7 @@ static NOINLINE void INET_setroute(int action, char **args) if (k == KW_IPVx_NETMASK) { struct sockaddr mask; - if (mask_in_addr(rt)) { + if (mask_in_addr(*rt)) { bb_show_usage(); } @@ -234,18 +237,18 @@ static NOINLINE void INET_setroute(int action, char **args) if (isnet < 0) { bb_error_msg_and_die("resolving %s", netmask); } - rt.rt_genmask = full_mask(mask); + rt->rt_genmask = full_mask(mask); continue; } if (k == KW_IPVx_GATEWAY) { - if (rt.rt_flags & RTF_GATEWAY) { + if (rt->rt_flags & RTF_GATEWAY) { bb_show_usage(); } isnet = INET_resolve(args_m1, - (struct sockaddr_in *) &rt.rt_gateway, 1); - rt.rt_flags |= RTF_GATEWAY; + (struct sockaddr_in *) &rt->rt_gateway, 1); + rt->rt_flags |= RTF_GATEWAY; if (isnet) { if (isnet < 0) { @@ -257,24 +260,24 @@ static NOINLINE void INET_setroute(int action, char **args) } if (k == KW_IPVx_MSS) { /* Check valid MSS bounds. */ - rt.rt_flags |= RTF_MSS; - rt.rt_mss = xatoul_range(args_m1, 64, 32768); + rt->rt_flags |= RTF_MSS; + rt->rt_mss = xatoul_range(args_m1, 64, 32768); continue; } if (k == KW_IPVx_WINDOW) { /* Check valid window bounds. */ - rt.rt_flags |= RTF_WINDOW; - rt.rt_window = xatoul_range(args_m1, 128, INT_MAX); + rt->rt_flags |= RTF_WINDOW; + rt->rt_window = xatoul_range(args_m1, 128, INT_MAX); continue; } #ifdef RTF_IRTT if (k == KW_IPVx_IRTT) { - rt.rt_flags |= RTF_IRTT; - rt.rt_irtt = xatoul(args_m1); - rt.rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ + rt->rt_flags |= RTF_IRTT; + rt->rt_irtt = xatoul(args_m1); + rt->rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ #if 0 /* FIXME: do we need to check anything of this? */ - if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) { + if (rt->rt_irtt < 1 || rt->rt_irtt > (120 * HZ)) { bb_error_msg_and_die("bad irtt"); } #endif @@ -284,9 +287,9 @@ static NOINLINE void INET_setroute(int action, char **args) /* Device is special in that it can be the last arg specified * and doesn't requre the dev/device keyword in that case. */ - if (!rt.rt_dev && ((k == KW_IPVx_DEVICE) || (!k && !*++args))) { + if (!rt->rt_dev && ((k == KW_IPVx_DEVICE) || (!k && !*++args))) { /* Don't use args_m1 here since args may have changed! */ - rt.rt_dev = args[-1]; + rt->rt_dev = args[-1]; continue; } @@ -295,41 +298,41 @@ static NOINLINE void INET_setroute(int action, char **args) } #ifdef RTF_REJECT - if ((rt.rt_flags & RTF_REJECT) && !rt.rt_dev) { - rt.rt_dev = (char*)"lo"; + if ((rt->rt_flags & RTF_REJECT) && !rt->rt_dev) { + rt->rt_dev = (char*)"lo"; } #endif /* sanity checks.. */ - if (mask_in_addr(rt)) { - uint32_t mask = mask_in_addr(rt); + if (mask_in_addr(*rt)) { + uint32_t mask = mask_in_addr(*rt); mask = ~ntohl(mask); - if ((rt.rt_flags & RTF_HOST) && mask != 0xffffffff) { + if ((rt->rt_flags & RTF_HOST) && mask != 0xffffffff) { bb_error_msg_and_die("netmask %.8x and host route conflict", (unsigned int) mask); } if (mask & (mask + 1)) { bb_error_msg_and_die("bogus netmask %s", netmask); } - mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr; - if (mask & ~(uint32_t)mask_in_addr(rt)) { + mask = ((struct sockaddr_in *) &rt->rt_dst)->sin_addr.s_addr; + if (mask & ~(uint32_t)mask_in_addr(*rt)) { bb_error_msg_and_die("netmask and route address conflict"); } } /* Fill out netmask if still unset */ - if ((action == RTACTION_ADD) && (rt.rt_flags & RTF_HOST)) { - mask_in_addr(rt) = 0xffffffff; + if ((action == RTACTION_ADD) && (rt->rt_flags & RTF_HOST)) { + mask_in_addr(*rt) = 0xffffffff; } /* Create a socket to the INET kernel. */ skfd = xsocket(AF_INET, SOCK_DGRAM, 0); if (action == RTACTION_ADD) - xioctl(skfd, SIOCADDRT, &rt); + xioctl(skfd, SIOCADDRT, rt); else - xioctl(skfd, SIOCDELRT, &rt); + xioctl(skfd, SIOCDELRT, rt); if (ENABLE_FEATURE_CLEAN_UP) close(skfd); } -- cgit v1.2.3-55-g6feb From dd169e84683aa7be3604d491f1c34ab657973365 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 12:13:23 +0100 Subject: eliminate aliasing warnings in traceroute.c and udhcp/socket.c Signed-off-by: Denys Vlasenko --- networking/traceroute.c | 3 ++- networking/udhcp/socket.c | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/networking/traceroute.c b/networking/traceroute.c index c18fba8d0..82bb0118c 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -751,7 +751,8 @@ print(int read_len, const struct sockaddr *from, const struct sockaddr *to) } else #endif { - read_len -= ((struct ip*)recv_pkt)->ip_hl << 2; + struct ip *ip4packet = (struct ip*)recv_pkt; + read_len -= ip4packet->ip_hl << 2; } printf(" %d bytes to %s", read_len, ina); free(ina); diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c index 0ed7ad1c6..39f1cec54 100644 --- a/networking/udhcp/socket.c +++ b/networking/udhcp/socket.c @@ -36,42 +36,45 @@ int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac) { + /* char buffer instead of bona-fide struct avoids aliasing warning */ + char ifr_buf[sizeof(struct ifreq)]; + struct ifreq *const ifr = (void *)ifr_buf; + int fd; - struct ifreq ifr; struct sockaddr_in *our_ip; - memset(&ifr, 0, sizeof(ifr)); + memset(ifr, 0, sizeof(*ifr)); fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); - ifr.ifr_addr.sa_family = AF_INET; - strncpy_IFNAMSIZ(ifr.ifr_name, interface); + ifr->ifr_addr.sa_family = AF_INET; + strncpy_IFNAMSIZ(ifr->ifr_name, interface); if (nip) { - if (ioctl_or_perror(fd, SIOCGIFADDR, &ifr, + if (ioctl_or_perror(fd, SIOCGIFADDR, ifr, "is interface %s up and configured?", interface) ) { close(fd); return -1; } - our_ip = (struct sockaddr_in *) &ifr.ifr_addr; + our_ip = (struct sockaddr_in *) &ifr->ifr_addr; *nip = our_ip->sin_addr.s_addr; log1("IP %s", inet_ntoa(our_ip->sin_addr)); } if (ifindex) { - if (ioctl_or_warn(fd, SIOCGIFINDEX, &ifr) != 0) { + if (ioctl_or_warn(fd, SIOCGIFINDEX, ifr) != 0) { close(fd); return -1; } - log1("Adapter index %d", ifr.ifr_ifindex); - *ifindex = ifr.ifr_ifindex; + log1("Adapter index %d", ifr->ifr_ifindex); + *ifindex = ifr->ifr_ifindex; } if (mac) { - if (ioctl_or_warn(fd, SIOCGIFHWADDR, &ifr) != 0) { + if (ioctl_or_warn(fd, SIOCGIFHWADDR, ifr) != 0) { close(fd); return -1; } - memcpy(mac, ifr.ifr_hwaddr.sa_data, 6); + memcpy(mac, ifr->ifr_hwaddr.sa_data, 6); log1("MAC %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } -- cgit v1.2.3-55-g6feb From b40da22357563bf53fa93823342f8ab59899222d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 21 Jan 2011 01:16:09 +0100 Subject: fix compile error on non-x86 architectures Signed-off-by: Denys Vlasenko --- include/platform.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/platform.h b/include/platform.h index 6328ff6ad..cbde7bc7b 100644 --- a/include/platform.h +++ b/include/platform.h @@ -218,14 +218,15 @@ /* ---- Unaligned access ------------------------------------ */ +typedef int bb__aliased_int FIX_ALIASING; +typedef uint16_t bb__aliased_uint16_t FIX_ALIASING; +typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; + /* NB: unaligned parameter should be a pointer, aligned one - * a lvalue. This makes it more likely to not swap them by mistake */ #if defined(i386) || defined(__x86_64__) || defined(__powerpc__) # include -typedef int bb__aliased_int FIX_ALIASING; -typedef uint16_t bb__aliased_uint16_t FIX_ALIASING; -typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; # define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp)) # define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p)) # define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p)) -- cgit v1.2.3-55-g6feb From 3a0f690dcd06ff693a0b76d764739425600ec1f1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 22 Jan 2011 00:38:24 +0100 Subject: svlogd: extend usage text. +70 bytes Signed-off-by: Denys Vlasenko --- include/usage.src.h | 7 ------- runit/svlogd.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/usage.src.h b/include/usage.src.h index a4776a2d6..9300b3ce8 100644 --- a/include/usage.src.h +++ b/include/usage.src.h @@ -3538,13 +3538,6 @@ INSERT "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n" \ "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service" \ -#define svlogd_trivial_usage \ - "[-ttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..." -#define svlogd_full_usage "\n\n" \ - "Continuously read log data from stdin, optionally\n" \ - "filter log messages, and write the data to one or more automatically\n" \ - "rotated logs" \ - #define swapoff_trivial_usage \ "[-a] [DEVICE]" #define swapoff_full_usage "\n\n" \ diff --git a/runit/svlogd.c b/runit/svlogd.c index c3ff4e9c1..cfa20a773 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c @@ -125,6 +125,23 @@ log message, you can use a pattern like this instead -*: *: pid * */ +//usage:#define svlogd_trivial_usage +//usage: "[-ttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..." +//usage:#define svlogd_full_usage "\n\n" +//usage: "Continuously read log data from stdin and write to rotated log files in DIRs" +//usage: "\n" +//usage: "\n""DIR/config file modifies behavior:" +//usage: "\n""sSIZE - when to rotate logs" +//usage: "\n""nNUM - number of files to retain" +/*usage: "\n""NNUM - min number files to retain" - confusing */ +/*usage: "\n""tSEC - rotate file if it get SEC seconds old" - confusing */ +//usage: "\n""!PROG - process rotated log with PROG" +/*usage: "\n""uIPADDR - send log over UDP" - unsupported */ +/*usage: "\n""UIPADDR - send log over UDP and DONT log" - unsupported */ +/*usage: "\n""pPFX - prefix each line with PFX" - unsupported */ +//usage: "\n""+,-PATTERN - (de)select line for logging" +//usage: "\n""E,ePATTERN - (de)select line for stderr" + #include #include #include "libbb.h" -- cgit v1.2.3-55-g6feb From 2b57b6cd43211e2430c78caa0895f41376f29dc1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 22 Jan 2011 03:06:40 +0100 Subject: getty: comment out parity detection code; improve usage text function old new delta packed_usage 28155 28191 +36 static.erase 12 - -12 getty_main 1847 1621 -226 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 36/-238) Total: -202 bytes Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 112 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 40 deletions(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index 0f5e333a7..94c9147ab 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -58,9 +58,16 @@ static FILE *dbf; * and for line editing at the same time. */ -/* I doubt there are systems which still need this */ +/* I doubt there are systems which still... */ +/* ...have only uppercase: */ #undef HANDLE_ALLCAPS +/* ...use # and @ for backspace and line erase: */ #undef ANCIENT_BS_KILL_CHARS +/* It actually makes sense (tries to guess parity by looking at 7th bit) + * but it's broken, and interferes with non-ASCII login names + * (yes, I did receive complains from real users): + */ +#undef BROKEN_PARITY_DETECTION_CODE #undef _PATH_LOGIN #define _PATH_LOGIN "/bin/login" @@ -108,8 +115,11 @@ struct options { /* Storage for things detected while the login name was read. */ struct chardata { unsigned char erase; /* erase character */ +#ifdef ANCIENT_BS_KILL_CHARS unsigned char kill; /* kill character */ +#endif unsigned char eol; /* end-of-line character */ +#ifdef BROKEN_PARITY_DETECTION_CODE unsigned char parity; /* what parity did we see */ /* (parity & 1): saw odd parity char with 7th bit set */ /* (parity & 2): saw even parity char with 7th bit set */ @@ -117,7 +127,8 @@ struct chardata { /* parity == 1: probably 7-bit, odd parity? */ /* parity == 2: probably 7-bit, even parity? */ /* parity == 3: definitely 8 bit, no parity! */ - /* Hmm... with any value of "parity" 8 bit, no parity is possible */ + /* Hmm... with any value of parity "8 bit, no parity" is possible */ +#endif #ifdef HANDLE_ALLCAPS unsigned char capslock; /* upper case without lower case */ #endif @@ -126,9 +137,13 @@ struct chardata { /* Initial values for the above. */ static const struct chardata init_chardata = { DEF_ERASE, /* default erase character */ +#ifdef ANCIENT_BS_KILL_CHARS DEF_KILL, /* default kill character */ +#endif 13, /* default eol char */ +#ifdef BROKEN_PARITY_DETECTION_CODE 0, /* space parity */ +#endif #ifdef HANDLE_ALLCAPS 0, /* no capslock */ #endif @@ -137,21 +152,23 @@ static const struct chardata init_chardata = { #define line_buf bb_common_bufsiz1 //usage:#define getty_trivial_usage -//usage: "[OPTIONS] BAUD_RATE TTY [TERMTYPE]" +//usage: "[OPTIONS] BAUD_RATE[,BAUD_RATE]... TTY [TERMTYPE]" //usage:#define getty_full_usage "\n\n" //usage: "Open a tty, prompt for a login name, then invoke /bin/login\n" //usage: "\nOptions:" //usage: "\n -h Enable hardware (RTS/CTS) flow control" //usage: "\n -i Don't display /etc/issue" -//usage: "\n -L Local line, don't do carrier detect" +//usage: "\n -L Local line, set CLOCAL on it" //usage: "\n -m Get baud rate from modem's CONNECT status message" -//usage: "\n -w Wait for a CR or LF before sending /etc/issue" -//usage: "\n -n Don't prompt the user for a login name" +//usage: "\n -w Wait for CR or LF before sending /etc/issue" +//usage: "\n -n Don't prompt for a login name" //usage: "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue" //usage: "\n -l LOGIN Invoke LOGIN instead of /bin/login" //usage: "\n -t SEC Terminate after SEC if no username is read" //usage: "\n -I INITSTR Send INITSTR before anything else" //usage: "\n -H HOST Log HOST into the utmp file as the hostname" +//usage: "\n" +//usage: "\nBAUD_RATE of 0 leaves it unchanged" static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:wn"; #define F_INITSTRING (1 << 0) /* -I */ @@ -259,29 +276,27 @@ static void open_tty(const char *tty) /* termios_init - initialize termios settings */ static void termios_init(struct termios *tp, int speed) { - speed_t ispeed, ospeed; + /* Flush input and output queues, important for modems! */ + /* TODO: sleep(1)? Users report lost chars, and I hesitate + * to use tcdrain here instead of tcflush */ + tcflush(0, TCIOFLUSH); + + /* Set speed if it wasn't specified as "0" on command line. */ + if (speed != B0) { + cfsetispeed(tp, speed); + cfsetospeed(tp, speed); + } /* * Initial termios settings: 8-bit characters, raw-mode, blocking i/o. * Special characters are set after we have read the login name; all * reads will be done in raw mode anyway. Errors will be dealt with * later on. */ - /* flush input and output queues, important for modems! */ - tcflush(0, TCIOFLUSH); - ispeed = ospeed = speed; - if (speed == B0) { - /* Speed was specified as "0" on command line. - * Just leave it unchanged */ - ispeed = cfgetispeed(tp); - ospeed = cfgetospeed(tp); - } tp->c_cflag = CS8 | HUPCL | CREAD; if (option_mask32 & F_LOCAL) tp->c_cflag |= CLOCAL; - cfsetispeed(tp, ispeed); - cfsetospeed(tp, ospeed); - - tp->c_iflag = tp->c_lflag = 0; + tp->c_iflag = 0; + tp->c_lflag = 0; tp->c_oflag = OPOST | ONLCR; tp->c_cc[VMIN] = 1; tp->c_cc[VTIME] = 0; @@ -388,14 +403,14 @@ static char *get_logname(char *logname, unsigned size_logname, char *bp; char c; /* input character, full eight bits */ char ascval; /* low 7 bits of input character */ - int bits; /* # of "1" bits per character */ - int mask; /* mask with 1 bit up */ +#ifdef BROKEN_PARITY_DETECTION_CODE static const char erase[][3] = {/* backspace-space-backspace */ "\010\040\010", /* space parity */ "\010\040\010", /* odd parity */ "\210\240\210", /* even parity */ "\010\040\010", /* 8 bit no parity */ }; +#endif /* NB: *cp is pre-initialized with init_chardata */ @@ -406,14 +421,13 @@ static char *get_logname(char *logname, unsigned size_logname, /* Prompt for and read a login name. */ logname[0] = '\0'; while (!logname[0]) { - /* Write issue file and prompt, with "parity" bit == 0. */ + /* Write issue file and prompt. */ do_prompt(op); /* Read name, watch for break, parity, erase, kill, end-of-line. */ bp = logname; cp->eol = '\0'; - while (cp->eol == '\0') { - + while (1) { /* Do not report trivial EINTR/EIO errors. */ errno = EINTR; /* make read of 0 bytes be silent too */ if (read(STDIN_FILENO, &c, 1) < 1) { @@ -427,10 +441,11 @@ static char *get_logname(char *logname, unsigned size_logname, if (c == '\0' && op->numspeed > 1) return NULL; +#ifdef BROKEN_PARITY_DETECTION_CODE /* Do parity bit handling. */ - if (!(option_mask32 & F_LOCAL) && (c & 0x80)) { /* "parity" bit on? */ - bits = 1; - mask = 1; + if (!(option_mask32 & F_LOCAL) && (c & 0x80)) { /* "parity" bit on? */ + int bits = 1; + int mask = 1; while (mask & 0x7f) { if (mask & c) bits++; /* count "1" bits */ @@ -439,15 +454,18 @@ static char *get_logname(char *logname, unsigned size_logname, /* ... |= 2 - even, 1 - odd */ cp->parity |= 2 - (bits & 1); } + ascval = c & 0x7f; +#else + ascval = c; +#endif /* Do erase, kill and end-of-line processing. */ - ascval = c & 0x7f; switch (ascval) { case CR: case NL: *bp = '\0'; /* terminate logname */ cp->eol = ascval; /* set end-of-line char */ - break; + goto got_logname; case BS: case DEL: #ifdef ANCIENT_BS_KILL_CHARS @@ -455,17 +473,25 @@ static char *get_logname(char *logname, unsigned size_logname, #endif cp->erase = ascval; /* set erase character */ if (bp > logname) { +#ifdef BROKEN_PARITY_DETECTION_CODE full_write(STDOUT_FILENO, erase[cp->parity], 3); +#else + full_write(STDOUT_FILENO, "\010 \010", 3); +#endif bp--; } break; case CTL('U'): #ifdef ANCIENT_BS_KILL_CHARS case '@': -#endif cp->kill = ascval; /* set kill character */ +#endif while (bp > logname) { +#ifdef BROKEN_PARITY_DETECTION_CODE full_write(STDOUT_FILENO, erase[cp->parity], 3); +#else + full_write(STDOUT_FILENO, "\010 \010", 3); +#endif bp--; } break; @@ -474,19 +500,18 @@ static char *get_logname(char *logname, unsigned size_logname, default: if (ascval < ' ') { /* ignore garbage characters */ - } else if ((int)(bp - logname) >= size_logname - 1) { - bb_error_msg_and_die("input overrun"); - } else { + } else if ((int)(bp - logname) < size_logname - 1) { full_write(STDOUT_FILENO, &c, 1); /* echo the character */ *bp++ = ascval; /* and store it */ } break; } - } - } - /* Handle names with upper case and no lower case. */ + } /* end of get char loop */ + got_logname: ; + } /* while logname is empty */ #ifdef HANDLE_ALLCAPS + /* Handle names with upper case and no lower case. */ cp->capslock = all_is_upcase(logname); if (cp->capslock) { for (bp = logname; *bp; bp++) @@ -520,8 +545,13 @@ static void termios_final(struct termios *tp, struct chardata *cp) tp->c_oflag |= ONLCR; /* map NL in output to CR-NL */ } tp->c_cc[VERASE] = cp->erase; /* set erase character */ +#ifdef ANCIENT_BS_KILL_CHARS tp->c_cc[VKILL] = cp->kill; /* set kill character */ +#else + tp->c_cc[VKILL] = DEF_KILL; /* set kill character */ +#endif +#ifdef BROKEN_PARITY_DETECTION_CODE /* Account for the presence or absence of parity bits in input. */ switch (cp->parity) { case 0: /* space (always 0) parity */ @@ -542,17 +572,19 @@ static void termios_final(struct termios *tp, struct chardata *cp) // Entire parity detection madness here just begs for deletion... break; } +#endif - /* Account for upper case without lower case. */ #ifdef HANDLE_ALLCAPS + /* Account for upper case without lower case. */ if (cp->capslock) { tp->c_iflag |= IUCLC; tp->c_lflag |= XCASE; tp->c_oflag |= OLCUC; } #endif - /* Optionally enable hardware flow control */ + #ifdef CRTSCTS + /* Optionally enable hardware flow control */ if (option_mask32 & F_RTSCTS) tp->c_cflag |= CRTSCTS; #endif @@ -685,7 +717,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) logname = NULL; if (!(option_mask32 & F_NOPROMPT)) { - /* NB:termios_init already set line speed + /* NB: termios_init already set line speed * to options.speeds[0] */ int baud_index = 0; -- cgit v1.2.3-55-g6feb From 006416e8fe63996b86bf614496ce71d83d9b9057 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 22 Jan 2011 17:29:53 +0100 Subject: getty: more correct check for O_RDWR Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index 94c9147ab..015f077d6 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -268,7 +268,7 @@ static void open_tty(const char *tty) * Standard input should already be connected to an open port. Make * sure it is open for read/write. */ - if ((fcntl(0, F_GETFL) & O_RDWR) != O_RDWR) + if ((fcntl(0, F_GETFL) & (O_RDWR|O_RDONLY|O_WRONLY)) != O_RDWR) bb_error_msg_and_die("stdin is not open for read/write"); } } -- cgit v1.2.3-55-g6feb From 1f4a987d477c89e63928fd23fd4b168d0bef07f6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 22 Jan 2011 17:31:35 +0100 Subject: pltaform.h: move include of stdint.h before uint16_t is used Signed-off-by: Denys Vlasenko --- include/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/platform.h b/include/platform.h index cbde7bc7b..bbbc0a9b6 100644 --- a/include/platform.h +++ b/include/platform.h @@ -218,6 +218,7 @@ /* ---- Unaligned access ------------------------------------ */ +#include typedef int bb__aliased_int FIX_ALIASING; typedef uint16_t bb__aliased_uint16_t FIX_ALIASING; typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; @@ -226,7 +227,6 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; * a lvalue. This makes it more likely to not swap them by mistake */ #if defined(i386) || defined(__x86_64__) || defined(__powerpc__) -# include # define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp)) # define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p)) # define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p)) -- cgit v1.2.3-55-g6feb From 1336f89d59fc571ef19f3cb74ced0580b3331a96 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 22 Jan 2011 17:57:01 +0100 Subject: wc: fix swapped -c and -m Signed-off-by: Denys Vlasenko --- coreutils/wc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/coreutils/wc.c b/coreutils/wc.c index fe3f274f8..6e22c66c8 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c @@ -81,11 +81,11 @@ * column order in "wc -cmlwL" output: */ enum { - WC_LINES = 0, - WC_WORDS = 1, - WC_UNICHARS = 2, - WC_CHARS = 3, - WC_LENGTH = 4, + WC_LINES = 0, /* -l */ + WC_WORDS = 1, /* -w */ + WC_UNICHARS = 2, /* -m */ + WC_BYTES = 3, /* -c */ + WC_LENGTH = 4, /* -L */ NUM_WCS = 5, }; @@ -104,10 +104,10 @@ int wc_main(int argc UNUSED_PARAM, char **argv) init_unicode(); - print_type = getopt32(argv, "lwcmL"); + print_type = getopt32(argv, "lwmcL"); if (print_type == 0) { - print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS); + print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_BYTES); } argv += optind; @@ -157,7 +157,7 @@ int wc_main(int argc UNUSED_PARAM, char **argv) } /* Cater for -c and -m */ - ++counts[WC_CHARS]; + ++counts[WC_BYTES]; if (unicode_status != UNICODE_ON /* every byte is a new char */ || (c & 0xc0) != 0x80 /* it isn't a 2nd+ byte of a Unicode char */ ) { -- cgit v1.2.3-55-g6feb From 658a437d4bd97d4897a9d0183570634a90ae6773 Mon Sep 17 00:00:00 2001 From: Davide Cavalca Date: Sat, 22 Jan 2011 18:55:32 +0100 Subject: hwclock: implement --systz function old new delta hwclock_main 324 434 +110 packed_usage 28220 28259 +39 static.hwclock_longopts 53 60 +7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 156/0) Total: 156 bytes Signed-off-by: Davide Cavalca Signed-off-by: Denys Vlasenko --- include/usage.src.h | 19 ---------------- util-linux/hwclock.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 24 deletions(-) diff --git a/include/usage.src.h b/include/usage.src.h index 9300b3ce8..ebe80f8e1 100644 --- a/include/usage.src.h +++ b/include/usage.src.h @@ -1595,25 +1595,6 @@ INSERT "\n -e STRING HTML encode STRING" \ "\n -d STRING URL decode STRING" \ -#define hwclock_trivial_usage \ - IF_FEATURE_HWCLOCK_LONG_OPTIONS( \ - "[-r|--show] [-s|--hctosys] [-w|--systohc]" \ - " [-l|--localtime] [-u|--utc]" \ - " [-f FILE]" \ - ) \ - IF_NOT_FEATURE_HWCLOCK_LONG_OPTIONS( \ - "[-r] [-s] [-w] [-l] [-u] [-f FILE]" \ - ) -#define hwclock_full_usage "\n\n" \ - "Query and set hardware clock (RTC)\n" \ - "\nOptions:" \ - "\n -r Show hardware clock time" \ - "\n -s Set system time from hardware clock" \ - "\n -w Set hardware clock to system time" \ - "\n -u Hardware clock is in UTC" \ - "\n -l Hardware clock is in local time" \ - "\n -f FILE Use specified device (e.g. /dev/rtc2)" \ - #define id_trivial_usage \ "[OPTIONS] [USER]" #define id_full_usage "\n\n" \ diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 922dd0578..54e97e5bb 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -223,12 +223,63 @@ static void from_sys_clock(const char **pp_rtcname, int utc) close(rtc); } +/* + * At system boot, kernel may set system time from RTC, + * but it knows nothing about timezones. If RTC is in local time, + * then system time is wrong - it is offset by timezone. + * This option corrects system time if RTC is in local time, + * and (always) sets in-kernel timezone. + * + * This is an alternate option to --hctosys that does not read the + * hardware clock. + */ +static void set_system_clock_timezone(int utc) +{ + struct timeval tv; + struct tm *broken; + struct timezone tz; + + gettimeofday(&tv, NULL); + broken = localtime(&tv.tv_sec); + tz.tz_minuteswest = timezone / 60; + if (broken->tm_isdst) + tz.tz_minuteswest -= 60; + tz.tz_dsttime = 0; + gettimeofday(&tv, NULL); + if (!utc) + tv.tv_sec += tz.tz_minuteswest * 60; + if (settimeofday(&tv, &tz)) + bb_perror_msg_and_die("settimeofday"); +} + +//usage:#define hwclock_trivial_usage +//usage: IF_FEATURE_HWCLOCK_LONG_OPTIONS( +//usage: "[-r|--show] [-s|--hctosys] [-w|--systohc] [-t|--systz]" +//usage: " [-l|--localtime] [-u|--utc]" +//usage: " [-f|--rtc FILE]" +//usage: ) +//usage: IF_NOT_FEATURE_HWCLOCK_LONG_OPTIONS( +//usage: "[-r] [-s] [-w] [-t] [-l] [-u] [-f FILE]" +//usage: ) +//usage:#define hwclock_full_usage "\n\n" +//usage: "Query and set hardware clock (RTC)\n" +//usage: "\nOptions:" +//usage: "\n -r Show hardware clock time" +//usage: "\n -s Set system time from hardware clock" +//usage: "\n -w Set hardware clock from system time" +//usage: "\n -t Set in-kernel timezone, correct system time" +//usage: "\n if hardware clock is in local time" +//usage: "\n -u Hardware clock is in UTC" +//usage: "\n -l Hardware clock is in local time" +//usage: "\n -f FILE Use specified device (e.g. /dev/rtc2)" + #define HWCLOCK_OPT_LOCALTIME 0x01 #define HWCLOCK_OPT_UTC 0x02 #define HWCLOCK_OPT_SHOW 0x04 #define HWCLOCK_OPT_HCTOSYS 0x08 #define HWCLOCK_OPT_SYSTOHC 0x10 -#define HWCLOCK_OPT_RTCFILE 0x20 +#define HWCLOCK_OPT_SYSTZ 0x20 +#define HWCLOCK_OPT_RTCFILE 0x40 int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int hwclock_main(int argc UNUSED_PARAM, char **argv) @@ -239,17 +290,18 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv) #if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS static const char hwclock_longopts[] ALIGN1 = - "localtime\0" No_argument "l" + "localtime\0" No_argument "l" /* short opt is non-standard */ "utc\0" No_argument "u" "show\0" No_argument "r" "hctosys\0" No_argument "s" "systohc\0" No_argument "w" - "file\0" Required_argument "f" + "systz\0" No_argument "t" /* short opt is non-standard */ + "rtc\0" Required_argument "f" ; applet_long_options = hwclock_longopts; #endif - opt_complementary = "r--ws:w--rs:s--wr:l--u:u--l"; - opt = getopt32(argv, "lurswf:", &rtcname); + opt_complementary = "r--wst:w--rst:s--wrt:t--rsw:l--u:u--l"; + opt = getopt32(argv, "lurswtf:", &rtcname); /* If -u or -l wasn't given check if we are using utc */ if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) @@ -261,6 +313,8 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv) to_sys_clock(&rtcname, utc); else if (opt & HWCLOCK_OPT_SYSTOHC) from_sys_clock(&rtcname, utc); + else if (opt & HWCLOCK_OPT_SYSTZ) + set_system_clock_timezone(utc); else /* default HWCLOCK_OPT_SHOW */ show_clock(&rtcname, utc); -- cgit v1.2.3-55-g6feb From 1f0840450e3934cc65520ee6605b9b72df2d53f5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 00:16:50 +0100 Subject: getty: use cfsetspeed to save some bytes; cosmetic fixes Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index 015f077d6..e60af3aa3 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -1,8 +1,7 @@ /* vi: set sw=4 ts=4: */ -/* agetty.c - another getty program for Linux. By W. Z. Venema 1989 +/* Based on agetty - another getty program for Linux. By W. Z. Venema 1989 * Ported to Linux by Peter Orbaek - * This program is freely distributable. The entire man-page used to - * be here. Now read the real man-page agetty.8 instead. + * This program is freely distributable. * * option added by Eric Rasmussen - 12/28/95 * @@ -184,7 +183,7 @@ static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:wn"; #define F_NOPROMPT (1 << 10) /* -n */ -/* bcode - convert speed string to speed code; return <= 0 on failure */ +/* convert speed string to speed code; return <= 0 on failure */ static int bcode(const char *s) { int value = bb_strtou(s, NULL, 10); /* yes, int is intended! */ @@ -193,7 +192,7 @@ static int bcode(const char *s) return tty_value_to_baud(value); } -/* parse_speeds - parse alternate baud rates */ +/* parse alternate baud rates */ static void parse_speeds(struct options *op, char *arg) { char *cp; @@ -212,7 +211,7 @@ static void parse_speeds(struct options *op, char *arg) debug("exiting parse_speeds\n"); } -/* parse_args - parse command-line arguments */ +/* parse command-line arguments */ static void parse_args(char **argv, struct options *op, char **fakehost_p) { char *ts; @@ -247,7 +246,7 @@ static void parse_args(char **argv, struct options *op, char **fakehost_p) debug("exiting parse_args\n"); } -/* open_tty - set up tty as standard { input, output, error } */ +/* set up tty as standard input, output, error */ static void open_tty(const char *tty) { /* Set up new standard input, unless we are given an already opened port. */ @@ -273,7 +272,7 @@ static void open_tty(const char *tty) } } -/* termios_init - initialize termios settings */ +/* initialize termios settings */ static void termios_init(struct termios *tp, int speed) { /* Flush input and output queues, important for modems! */ @@ -282,10 +281,9 @@ static void termios_init(struct termios *tp, int speed) tcflush(0, TCIOFLUSH); /* Set speed if it wasn't specified as "0" on command line. */ - if (speed != B0) { - cfsetispeed(tp, speed); - cfsetospeed(tp, speed); - } + if (speed != B0) + cfsetspeed(tp, speed); + /* * Initial termios settings: 8-bit characters, raw-mode, blocking i/o. * Special characters are set after we have read the login name; all @@ -315,7 +313,7 @@ static void termios_init(struct termios *tp, int speed) debug("term_io 2\n"); } -/* auto_baud - extract baud rate from modem status message */ +/* extract baud rate from modem status message */ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) { int speed; @@ -373,19 +371,8 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) tcsetattr_stdin_TCSANOW(tp); } -/* do_prompt - show login prompt, optionally preceded by /etc/issue contents */ -static void do_prompt(struct options *op) -{ -#ifdef ISSUE - if (!(option_mask32 & F_NOISSUE)) - print_login_issue(op->issue, op->tty); -#endif - print_login_prompt(); -} - #ifdef HANDLE_ALLCAPS -/* all_is_upcase - string contains upper case without lower case */ -/* returns 1 if true, 0 if false */ +/* does string contain upper case without lower case? */ static int all_is_upcase(const char *s) { while (*s) @@ -395,7 +382,7 @@ static int all_is_upcase(const char *s) } #endif -/* get_logname - get user name, establish parity, speed, erase, kill, eol; +/* get user name, establish parity, speed, erase, kill, eol; * return NULL on BREAK, logname on success */ static char *get_logname(char *logname, unsigned size_logname, struct options *op, struct chardata *cp) @@ -422,7 +409,11 @@ static char *get_logname(char *logname, unsigned size_logname, logname[0] = '\0'; while (!logname[0]) { /* Write issue file and prompt. */ - do_prompt(op); +#ifdef ISSUE + if (!(option_mask32 & F_NOISSUE)) + print_login_issue(op->issue, op->tty); +#endif + print_login_prompt(); /* Read name, watch for break, parity, erase, kill, end-of-line. */ bp = logname; @@ -522,7 +513,7 @@ static char *get_logname(char *logname, unsigned size_logname, return logname; } -/* termios_final - set the final tty mode bits */ +/* set the final tty mode bits */ static void termios_final(struct termios *tp, struct chardata *cp) { /* General terminal-independent stuff. */ @@ -730,8 +721,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) break; /* we are here only if options.numspeed > 1 */ baud_index = (baud_index + 1) % options.numspeed; - cfsetispeed(&termios, options.speeds[baud_index]); - cfsetospeed(&termios, options.speeds[baud_index]); + cfsetspeed(&termios, options.speeds[baud_index]); tcsetattr_stdin_TCSANOW(&termios); } } -- cgit v1.2.3-55-g6feb From dc6cd12569e6ac3775b11f6285ccc1bb81b13af0 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 00:28:43 +0100 Subject: getty: add sleep before initial tcdrain; reduce another sleep from 1 to 0.1s Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index e60af3aa3..13b341db5 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -275,10 +275,13 @@ static void open_tty(const char *tty) /* initialize termios settings */ static void termios_init(struct termios *tp, int speed) { - /* Flush input and output queues, important for modems! */ - /* TODO: sleep(1)? Users report lost chars, and I hesitate - * to use tcdrain here instead of tcflush */ - tcflush(0, TCIOFLUSH); + /* Flush input and output queues, important for modems! + * Users report losing previously queued output chars, and I hesitate + * to use tcdrain here instead of tcflush - I imagine it can block. + * Using small sleep instead. + */ + usleep(100*1000); /* 0.1 sec */ + tcflush(STDIN_FILENO, TCIOFLUSH); /* Set speed if it wasn't specified as "0" on command line. */ if (speed != B0) @@ -402,8 +405,8 @@ static char *get_logname(char *logname, unsigned size_logname, /* NB: *cp is pre-initialized with init_chardata */ /* Flush pending input (esp. after parsing or switching the baud rate). */ - sleep(1); - tcflush(0, TCIOFLUSH); + usleep(100*1000); /* 0.1 sec */ + tcflush(STDIN_FILENO, TCIOFLUSH); /* Prompt for and read a login name. */ logname[0] = '\0'; @@ -659,7 +662,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) * by patching the SunOS kernel variable "zsadtrlow" to a larger value; * 5 seconds seems to be a good value. */ - if (tcgetattr(0, &termios) < 0) + if (tcgetattr(STDIN_FILENO, &termios) < 0) bb_perror_msg_and_die("tcgetattr"); pid = getpid(); @@ -667,9 +670,9 @@ int getty_main(int argc UNUSED_PARAM, char **argv) // FIXME: do we need this? Otherwise "-" case seems to be broken... // /* Forcibly make fd 0 our controlling tty, even if another session // * has it as a ctty. (Another session loses ctty). */ - // ioctl(0, TIOCSCTTY, (void*)1); + // ioctl(STDIN_FILENO, TIOCSCTTY, (void*)1); /* Make ourself a foreground process group within our session */ - tcsetpgrp(0, pid); + tcsetpgrp(STDIN_FILENO, pid); #endif /* Update the utmp file. This tty is ours now! */ -- cgit v1.2.3-55-g6feb From e9a40e3b91f699c08053d7307bf50b0764811b8e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 00:29:55 +0100 Subject: libbb: make ndelay_no/off a bit more clever. +14 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 6 +++--- libbb/xfuncs.c | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 55510316b..6e37b8d04 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -348,9 +348,9 @@ extern char *bb_get_last_path_component_strip(char *path) FAST_FUNC; /* "abc/def/" -> "" and it never modifies 'path' */ extern char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC; -int ndelay_on(int fd) FAST_FUNC; -int ndelay_off(int fd) FAST_FUNC; -int close_on_exec_on(int fd) FAST_FUNC; +void ndelay_on(int fd) FAST_FUNC; +void ndelay_off(int fd) FAST_FUNC; +void close_on_exec_on(int fd) FAST_FUNC; void xdup2(int, int) FAST_FUNC; void xmove_fd(int, int) FAST_FUNC; diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index a02a504b0..23f27516f 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -25,19 +25,25 @@ #include "libbb.h" /* Turn on nonblocking I/O on a fd */ -int FAST_FUNC ndelay_on(int fd) +void FAST_FUNC ndelay_on(int fd) { - return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); + int flags = fcntl(fd, F_GETFL); + if (flags & O_NONBLOCK) + return; + fcntl(fd, F_SETFL, flags | O_NONBLOCK); } -int FAST_FUNC ndelay_off(int fd) +void FAST_FUNC ndelay_off(int fd) { - return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK); + int flags = fcntl(fd, F_GETFL); + if (!(flags & O_NONBLOCK)) + return; + fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); } -int FAST_FUNC close_on_exec_on(int fd) +void FAST_FUNC close_on_exec_on(int fd) { - return fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(fd, F_SETFD, FD_CLOEXEC); } char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) -- cgit v1.2.3-55-g6feb From 6596380f52cd48b8b44443bb5677ec8caf538761 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 04:43:04 +0100 Subject: getty: simplify code by going to more straignforward G trick function old new delta getty_main 1615 1475 -140 Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 396 ++++++++++++++++------------------------------------- 1 file changed, 121 insertions(+), 275 deletions(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index 13b341db5..bf66f2287 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -16,11 +16,9 @@ #include "libbb.h" #include - #if ENABLE_FEATURE_UTMP # include /* LOGIN_PROCESS */ #endif - #ifndef IUCLC # define IUCLC 0 #endif @@ -36,7 +34,7 @@ # undef ENABLE_FEATURE_WTMP # define ENABLE_FEATURE_UTMP 0 # define ENABLE_FEATURE_WTMP 0 -#endif /* LOGIN_PROCESS */ +#endif /* The following is used for understandable diagnostics. */ @@ -56,18 +54,6 @@ static FILE *dbf; * below. Note, however, that DEL cannot be used for interrupt generation * and for line editing at the same time. */ - -/* I doubt there are systems which still... */ -/* ...have only uppercase: */ -#undef HANDLE_ALLCAPS -/* ...use # and @ for backspace and line erase: */ -#undef ANCIENT_BS_KILL_CHARS -/* It actually makes sense (tries to guess parity by looking at 7th bit) - * but it's broken, and interferes with non-ASCII login names - * (yes, I did receive complains from real users): - */ -#undef BROKEN_PARITY_DETECTION_CODE - #undef _PATH_LOGIN #define _PATH_LOGIN "/bin/login" @@ -100,8 +86,7 @@ static FILE *dbf; */ #define MAX_SPEED 10 /* max. nr. of baud rates */ -/* Storage for command-line options. */ -struct options { +struct globals { unsigned timeout; /* time-out period */ const char *login; /* login program */ const char *tty; /* name of tty */ @@ -109,46 +94,17 @@ struct options { const char *issue; /* alternative issue file */ int numspeed; /* number of baud rates to try */ int speeds[MAX_SPEED]; /* baud rates to be tried */ + struct termios termios; /* terminal mode bits */ + /* Storage for things detected while the login name was read. */ + unsigned char erase; /* erase character */ + unsigned char eol; /* end-of-line character */ + char line_buf[128]; }; -/* Storage for things detected while the login name was read. */ -struct chardata { - unsigned char erase; /* erase character */ -#ifdef ANCIENT_BS_KILL_CHARS - unsigned char kill; /* kill character */ -#endif - unsigned char eol; /* end-of-line character */ -#ifdef BROKEN_PARITY_DETECTION_CODE - unsigned char parity; /* what parity did we see */ - /* (parity & 1): saw odd parity char with 7th bit set */ - /* (parity & 2): saw even parity char with 7th bit set */ - /* parity == 0: probably 7-bit, space parity? */ - /* parity == 1: probably 7-bit, odd parity? */ - /* parity == 2: probably 7-bit, even parity? */ - /* parity == 3: definitely 8 bit, no parity! */ - /* Hmm... with any value of parity "8 bit, no parity" is possible */ -#endif -#ifdef HANDLE_ALLCAPS - unsigned char capslock; /* upper case without lower case */ -#endif -}; - -/* Initial values for the above. */ -static const struct chardata init_chardata = { - DEF_ERASE, /* default erase character */ -#ifdef ANCIENT_BS_KILL_CHARS - DEF_KILL, /* default kill character */ -#endif - 13, /* default eol char */ -#ifdef BROKEN_PARITY_DETECTION_CODE - 0, /* space parity */ -#endif -#ifdef HANDLE_ALLCAPS - 0, /* no capslock */ -#endif -}; - -#define line_buf bb_common_bufsiz1 +#define G (*ptr_to_globals) +#define INIT_G() do { \ + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ +} while (0) //usage:#define getty_trivial_usage //usage: "[OPTIONS] BAUD_RATE[,BAUD_RATE]... TTY [TERMTYPE]" @@ -193,52 +149,53 @@ static int bcode(const char *s) } /* parse alternate baud rates */ -static void parse_speeds(struct options *op, char *arg) +static void parse_speeds(char *arg) { char *cp; /* NB: at least one iteration is always done */ debug("entered parse_speeds\n"); while ((cp = strsep(&arg, ",")) != NULL) { - op->speeds[op->numspeed] = bcode(cp); - if (op->speeds[op->numspeed] < 0) + G.speeds[G.numspeed] = bcode(cp); + if (G.speeds[G.numspeed] < 0) bb_error_msg_and_die("bad speed: %s", cp); /* note: arg "0" turns into speed B0 */ - op->numspeed++; - if (op->numspeed > MAX_SPEED) + G.numspeed++; + if (G.numspeed > MAX_SPEED) bb_error_msg_and_die("too many alternate speeds"); } debug("exiting parse_speeds\n"); } /* parse command-line arguments */ -static void parse_args(char **argv, struct options *op, char **fakehost_p) +static void parse_args(char **argv, char **fakehost_p) { char *ts; int flags; opt_complementary = "-2:t+"; /* at least 2 args; -t N */ flags = getopt32(argv, opt_string, - &(op->initstring), fakehost_p, &(op->issue), - &(op->login), &op->timeout); + &G.initstring, fakehost_p, &G.issue, + &G.login, &G.timeout + ); if (flags & F_INITSTRING) { - op->initstring = xstrdup(op->initstring); + G.initstring = xstrdup(G.initstring); /* decode \ddd octal codes into chars */ - strcpy_and_process_escape_sequences((char*)op->initstring, op->initstring); + strcpy_and_process_escape_sequences((char*)G.initstring, G.initstring); } argv += optind; debug("after getopt\n"); - /* we loosen up a bit and accept both "baudrate tty" and "tty baudrate" */ - op->tty = argv[0]; /* tty name */ + /* We loosen up a bit and accept both "baudrate tty" and "tty baudrate" */ + G.tty = argv[0]; /* tty name */ ts = argv[1]; /* baud rate(s) */ if (isdigit(argv[0][0])) { - /* a number first, assume it's a speed (BSD style) */ - op->tty = ts; /* tty name is in argv[1] */ + /* A number first, assume it's a speed (BSD style) */ + G.tty = ts; /* tty name is in argv[1] */ ts = argv[0]; /* baud rate(s) */ } - parse_speeds(op, ts); - applet_name = xasprintf("getty: %s", op->tty); + parse_speeds(ts); + applet_name = xasprintf("getty: %s", G.tty); if (argv[2]) xsetenv("TERM", argv[2]); @@ -247,17 +204,17 @@ static void parse_args(char **argv, struct options *op, char **fakehost_p) } /* set up tty as standard input, output, error */ -static void open_tty(const char *tty) +static void open_tty(void) { /* Set up new standard input, unless we are given an already opened port. */ - if (NOT_LONE_DASH(tty)) { - if (tty[0] != '/') - tty = xasprintf("/dev/%s", tty); /* will leak it */ + if (NOT_LONE_DASH(G.tty)) { + if (G.tty[0] != '/') + G.tty = xasprintf("/dev/%s", G.tty); /* will leak it */ /* Open the tty as standard input. */ debug("open(2)\n"); close(0); - /*fd =*/ xopen(tty, O_RDWR | O_NONBLOCK); /* uses fd 0 */ + xopen(G.tty, O_RDWR | O_NONBLOCK); /* uses fd 0 */ /* Set proper protections and ownership. */ fchown(0, 0, 0); /* 0:0 */ @@ -273,7 +230,7 @@ static void open_tty(const char *tty) } /* initialize termios settings */ -static void termios_init(struct termios *tp, int speed) +static void termios_init(int speed) { /* Flush input and output queues, important for modems! * Users report losing previously queued output chars, and I hesitate @@ -285,7 +242,7 @@ static void termios_init(struct termios *tp, int speed) /* Set speed if it wasn't specified as "0" on command line. */ if (speed != B0) - cfsetspeed(tp, speed); + cfsetspeed(&G.termios, speed); /* * Initial termios settings: 8-bit characters, raw-mode, blocking i/o. @@ -293,31 +250,29 @@ static void termios_init(struct termios *tp, int speed) * reads will be done in raw mode anyway. Errors will be dealt with * later on. */ - tp->c_cflag = CS8 | HUPCL | CREAD; + G.termios.c_cflag = CS8 | HUPCL | CREAD; if (option_mask32 & F_LOCAL) - tp->c_cflag |= CLOCAL; - tp->c_iflag = 0; - tp->c_lflag = 0; - tp->c_oflag = OPOST | ONLCR; - tp->c_cc[VMIN] = 1; - tp->c_cc[VTIME] = 0; + G.termios.c_cflag |= CLOCAL; + G.termios.c_iflag = 0; + G.termios.c_lflag = 0; + G.termios.c_oflag = OPOST | ONLCR; + G.termios.c_cc[VMIN] = 1; + G.termios.c_cc[VTIME] = 0; #ifdef __linux__ - tp->c_line = 0; + G.termios.c_line = 0; #endif - - /* Optionally enable hardware flow control */ #ifdef CRTSCTS if (option_mask32 & F_RTSCTS) - tp->c_cflag |= CRTSCTS; + G.termios.c_cflag |= CRTSCTS; #endif - tcsetattr_stdin_TCSANOW(tp); + tcsetattr_stdin_TCSANOW(&G.termios); debug("term_io 2\n"); } /* extract baud rate from modem status message */ -static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) +static void auto_baud(void) { int speed; int vmin; @@ -344,83 +299,60 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) * Use 7-bit characters, don't block if input queue is empty. Errors will * be dealt with later on. */ - iflag = tp->c_iflag; - tp->c_iflag |= ISTRIP; /* enable 8th-bit stripping */ - vmin = tp->c_cc[VMIN]; - tp->c_cc[VMIN] = 0; /* don't block if queue empty */ - tcsetattr_stdin_TCSANOW(tp); + iflag = G.termios.c_iflag; + G.termios.c_iflag |= ISTRIP; /* enable 8th-bit stripping */ + vmin = G.termios.c_cc[VMIN]; + G.termios.c_cc[VMIN] = 0; /* don't block if queue empty */ + tcsetattr_stdin_TCSANOW(&G.termios); /* * Wait for a while, then read everything the modem has said so far and * try to extract the speed of the dial-in call. */ sleep(1); - nread = safe_read(STDIN_FILENO, buf, size_buf - 1); + nread = safe_read(STDIN_FILENO, G.line_buf, sizeof(G.line_buf) - 1); if (nread > 0) { - buf[nread] = '\0'; - for (bp = buf; bp < buf + nread; bp++) { + G.line_buf[nread] = '\0'; + for (bp = G.line_buf; bp < G.line_buf + nread; bp++) { if (isdigit(*bp)) { speed = bcode(bp); if (speed > 0) - cfsetspeed(tp, speed); + cfsetspeed(&G.termios, speed); break; } } } /* Restore terminal settings. Errors will be dealt with later on. */ - tp->c_iflag = iflag; - tp->c_cc[VMIN] = vmin; - tcsetattr_stdin_TCSANOW(tp); -} - -#ifdef HANDLE_ALLCAPS -/* does string contain upper case without lower case? */ -static int all_is_upcase(const char *s) -{ - while (*s) - if (islower(*s++)) - return 0; - return 1; + G.termios.c_iflag = iflag; + G.termios.c_cc[VMIN] = vmin; + tcsetattr_stdin_TCSANOW(&G.termios); } -#endif /* get user name, establish parity, speed, erase, kill, eol; * return NULL on BREAK, logname on success */ -static char *get_logname(char *logname, unsigned size_logname, - struct options *op, struct chardata *cp) +static char *get_logname(void) { char *bp; - char c; /* input character, full eight bits */ - char ascval; /* low 7 bits of input character */ -#ifdef BROKEN_PARITY_DETECTION_CODE - static const char erase[][3] = {/* backspace-space-backspace */ - "\010\040\010", /* space parity */ - "\010\040\010", /* odd parity */ - "\210\240\210", /* even parity */ - "\010\040\010", /* 8 bit no parity */ - }; -#endif - - /* NB: *cp is pre-initialized with init_chardata */ + char c; /* Flush pending input (esp. after parsing or switching the baud rate). */ usleep(100*1000); /* 0.1 sec */ tcflush(STDIN_FILENO, TCIOFLUSH); /* Prompt for and read a login name. */ - logname[0] = '\0'; - while (!logname[0]) { + G.line_buf[0] = '\0'; + while (!G.line_buf[0]) { /* Write issue file and prompt. */ #ifdef ISSUE if (!(option_mask32 & F_NOISSUE)) - print_login_issue(op->issue, op->tty); + print_login_issue(G.issue, G.tty); #endif print_login_prompt(); /* Read name, watch for break, parity, erase, kill, end-of-line. */ - bp = logname; - cp->eol = '\0'; + bp = G.line_buf; + G.eol = '\0'; while (1) { /* Do not report trivial EINTR/EIO errors. */ errno = EINTR; /* make read of 0 bytes be silent too */ @@ -432,71 +364,39 @@ static char *get_logname(char *logname, unsigned size_logname, /* BREAK. If we have speeds to try, * return NULL (will switch speeds and return here) */ - if (c == '\0' && op->numspeed > 1) + if (c == '\0' && G.numspeed > 1) return NULL; -#ifdef BROKEN_PARITY_DETECTION_CODE - /* Do parity bit handling. */ - if (!(option_mask32 & F_LOCAL) && (c & 0x80)) { /* "parity" bit on? */ - int bits = 1; - int mask = 1; - while (mask & 0x7f) { - if (mask & c) - bits++; /* count "1" bits */ - mask <<= 1; - } - /* ... |= 2 - even, 1 - odd */ - cp->parity |= 2 - (bits & 1); - } - ascval = c & 0x7f; -#else - ascval = c; -#endif - /* Do erase, kill and end-of-line processing. */ - switch (ascval) { + switch (c) { case CR: case NL: - *bp = '\0'; /* terminate logname */ - cp->eol = ascval; /* set end-of-line char */ + *bp = '\0'; + G.eol = c; goto got_logname; case BS: case DEL: -#ifdef ANCIENT_BS_KILL_CHARS - case '#': -#endif - cp->erase = ascval; /* set erase character */ - if (bp > logname) { -#ifdef BROKEN_PARITY_DETECTION_CODE - full_write(STDOUT_FILENO, erase[cp->parity], 3); -#else + G.erase = c; + if (bp > G.line_buf) { full_write(STDOUT_FILENO, "\010 \010", 3); -#endif bp--; } break; case CTL('U'): -#ifdef ANCIENT_BS_KILL_CHARS - case '@': - cp->kill = ascval; /* set kill character */ -#endif - while (bp > logname) { -#ifdef BROKEN_PARITY_DETECTION_CODE - full_write(STDOUT_FILENO, erase[cp->parity], 3); -#else + while (bp > G.line_buf) { full_write(STDOUT_FILENO, "\010 \010", 3); -#endif bp--; } break; case CTL('D'): exit(EXIT_SUCCESS); default: - if (ascval < ' ') { + if ((unsigned char)c < ' ') { /* ignore garbage characters */ - } else if ((int)(bp - logname) < size_logname - 1) { - full_write(STDOUT_FILENO, &c, 1); /* echo the character */ - *bp++ = ascval; /* and store it */ + } else if ((int)(bp - G.line_buf) < sizeof(G.line_buf) - 1) { + /* echo and store the character */ + full_write(STDOUT_FILENO, &c, 1); + *bp++ = c; } break; } @@ -504,87 +404,42 @@ static char *get_logname(char *logname, unsigned size_logname, got_logname: ; } /* while logname is empty */ -#ifdef HANDLE_ALLCAPS - /* Handle names with upper case and no lower case. */ - cp->capslock = all_is_upcase(logname); - if (cp->capslock) { - for (bp = logname; *bp; bp++) - if (isupper(*bp)) - *bp = tolower(*bp); /* map name to lower case */ - } -#endif - return logname; + return G.line_buf; } /* set the final tty mode bits */ -static void termios_final(struct termios *tp, struct chardata *cp) +static void termios_final(void) { /* General terminal-independent stuff. */ - tp->c_iflag |= IXON | IXOFF; /* 2-way flow control */ - tp->c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE; - /* no longer| ECHOCTL | ECHOPRT */ - tp->c_oflag |= OPOST; - /* tp->c_cflag = 0; */ - tp->c_cc[VINTR] = DEF_INTR; /* default interrupt */ - tp->c_cc[VQUIT] = DEF_QUIT; /* default quit */ - tp->c_cc[VEOF] = DEF_EOF; /* default EOF character */ - tp->c_cc[VEOL] = DEF_EOL; + G.termios.c_iflag |= IXON | IXOFF; /* 2-way flow control */ + G.termios.c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE; + /* no longer in lflag: | ECHOCTL | ECHOPRT */ + G.termios.c_oflag |= OPOST; + /* G.termios.c_cflag = 0; */ + G.termios.c_cc[VINTR] = DEF_INTR; /* default interrupt */ + G.termios.c_cc[VQUIT] = DEF_QUIT; /* default quit */ + G.termios.c_cc[VEOF] = DEF_EOF; /* default EOF character */ + G.termios.c_cc[VEOL] = DEF_EOL; #ifdef VSWTC - tp->c_cc[VSWTC] = DEF_SWITCH; /* default switch character */ + G.termios.c_cc[VSWTC] = DEF_SWITCH; /* default switch character */ #endif /* Account for special characters seen in input. */ - if (cp->eol == CR) { - tp->c_iflag |= ICRNL; /* map CR in input to NL */ - tp->c_oflag |= ONLCR; /* map NL in output to CR-NL */ - } - tp->c_cc[VERASE] = cp->erase; /* set erase character */ -#ifdef ANCIENT_BS_KILL_CHARS - tp->c_cc[VKILL] = cp->kill; /* set kill character */ -#else - tp->c_cc[VKILL] = DEF_KILL; /* set kill character */ -#endif - -#ifdef BROKEN_PARITY_DETECTION_CODE - /* Account for the presence or absence of parity bits in input. */ - switch (cp->parity) { - case 0: /* space (always 0) parity */ -// I bet most people go here - they use only 7-bit chars in usernames.... - break; - case 1: /* odd parity */ - tp->c_cflag |= PARODD; - /* FALLTHROUGH */ - case 2: /* even parity */ - tp->c_cflag |= PARENB; - tp->c_iflag |= INPCK | ISTRIP; - /* FALLTHROUGH */ - case (1 | 2): /* no parity bit */ - tp->c_cflag &= ~CSIZE; - tp->c_cflag |= CS7; -// FIXME: wtf? case 3: we saw both even and odd 8-bit bytes - -// it's probably some umlauts etc, but definitely NOT 7-bit!!! -// Entire parity detection madness here just begs for deletion... - break; + if (G.eol == CR) { + G.termios.c_iflag |= ICRNL; /* map CR in input to NL */ + G.termios.c_oflag |= ONLCR; /* map NL in output to CR-NL */ } -#endif - -#ifdef HANDLE_ALLCAPS - /* Account for upper case without lower case. */ - if (cp->capslock) { - tp->c_iflag |= IUCLC; - tp->c_lflag |= XCASE; - tp->c_oflag |= OLCUC; - } -#endif + G.termios.c_cc[VERASE] = G.erase; /* set erase character */ + G.termios.c_cc[VKILL] = DEF_KILL; /* set kill character */ #ifdef CRTSCTS /* Optionally enable hardware flow control */ if (option_mask32 & F_RTSCTS) - tp->c_cflag |= CRTSCTS; + G.termios.c_cflag |= CRTSCTS; #endif /* Finally, make the new settings effective */ - if (tcsetattr_stdin_TCSANOW(tp) < 0) + if (tcsetattr_stdin_TCSANOW(&G.termios) < 0) bb_perror_msg_and_die("tcsetattr"); } @@ -593,27 +448,20 @@ int getty_main(int argc UNUSED_PARAM, char **argv) { int n; pid_t pid; - char *fakehost = NULL; /* Fake hostname for ut_host */ - char *logname; /* login name, given to /bin/login */ - /* Merging these into "struct local" may _seem_ to reduce - * parameter passing, but today's gcc will inline - * statics which are called once anyway, so don't do that */ - struct chardata chardata; /* set by get_logname() */ - struct termios termios; /* terminal mode bits */ - struct options options; - - chardata = init_chardata; + char *fakehost = NULL; /* Fake hostname for ut_host */ + char *logname; - memset(&options, 0, sizeof(options)); - options.login = _PATH_LOGIN; /* default login program */ - options.tty = "tty1"; /* default tty line */ - options.initstring = ""; /* modem init string */ + INIT_G(); + G.login = _PATH_LOGIN; /* default login program */ + G.initstring = ""; /* modem init string */ #ifdef ISSUE - options.issue = ISSUE; /* default issue file */ + G.issue = ISSUE; /* default issue file */ #endif + G.erase = DEF_ERASE; + G.eol = CR; /* Parse command-line arguments. */ - parse_args(argv, &options, &fakehost); + parse_args(argv, &fakehost); logmode = LOGMODE_NONE; @@ -648,7 +496,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) /* Open the tty as standard input, if it is not "-" */ /* If it's not "-" and not taken yet, it will become our ctty */ debug("calling open_tty\n"); - open_tty(options.tty); + open_tty(); ndelay_off(0); debug("duping\n"); xdup2(0, 1); @@ -662,7 +510,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) * by patching the SunOS kernel variable "zsadtrlow" to a larger value; * 5 seconds seems to be a good value. */ - if (tcgetattr(STDIN_FILENO, &termios) < 0) + if (tcgetattr(STDIN_FILENO, &G.termios) < 0) bb_perror_msg_and_die("tcgetattr"); pid = getpid(); @@ -676,25 +524,25 @@ int getty_main(int argc UNUSED_PARAM, char **argv) #endif /* Update the utmp file. This tty is ours now! */ - update_utmp(pid, LOGIN_PROCESS, options.tty, "LOGIN", fakehost); + update_utmp(pid, LOGIN_PROCESS, G.tty, "LOGIN", fakehost); /* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */ debug("calling termios_init\n"); - termios_init(&termios, options.speeds[0]); + termios_init(G.speeds[0]); /* Write the modem init string and DON'T flush the buffers */ if (option_mask32 & F_INITSTRING) { debug("writing init string\n"); - full_write1_str(options.initstring); + full_write1_str(G.initstring); } /* Optionally detect the baud rate from the modem status message */ debug("before autobaud\n"); if (option_mask32 & F_PARSE) - auto_baud(line_buf, sizeof(line_buf), &termios); + auto_baud(); /* Set the optional timer */ - alarm(options.timeout); /* if 0, alarm is not set */ + alarm(G.timeout); /* if 0, alarm is not set */ /* Optionally wait for CR or LF before writing /etc/issue */ if (option_mask32 & F_WAITCRLF) { @@ -703,7 +551,6 @@ int getty_main(int argc UNUSED_PARAM, char **argv) debug("waiting for cr-lf\n"); while (safe_read(STDIN_FILENO, &ch, 1) == 1) { debug("read %x\n", (unsigned char)ch); - ch &= 0x7f; /* strip "parity bit" */ if (ch == '\n' || ch == '\r') break; } @@ -712,20 +559,19 @@ int getty_main(int argc UNUSED_PARAM, char **argv) logname = NULL; if (!(option_mask32 & F_NOPROMPT)) { /* NB: termios_init already set line speed - * to options.speeds[0] */ + * to G.speeds[0] */ int baud_index = 0; while (1) { /* Read the login name. */ debug("reading login name\n"); - logname = get_logname(line_buf, sizeof(line_buf), - &options, &chardata); + logname = get_logname(); if (logname) break; - /* we are here only if options.numspeed > 1 */ - baud_index = (baud_index + 1) % options.numspeed; - cfsetspeed(&termios, options.speeds[baud_index]); - tcsetattr_stdin_TCSANOW(&termios); + /* We are here only if G.numspeed > 1. */ + baud_index = (baud_index + 1) % G.numspeed; + cfsetspeed(&G.termios, G.speeds[baud_index]); + tcsetattr_stdin_TCSANOW(&G.termios); } } @@ -733,7 +579,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) alarm(0); /* Finalize the termios settings. */ - termios_final(&termios, &chardata); + termios_final(); /* Now the newline character should be properly written. */ full_write(STDOUT_FILENO, "\n", 1); @@ -742,6 +588,6 @@ int getty_main(int argc UNUSED_PARAM, char **argv) /* We use PATH because we trust that root doesn't set "bad" PATH, * and getty is not suid-root applet. */ /* With -n, logname == NULL, and login will ask for username instead */ - BB_EXECLP(options.login, options.login, "--", logname, NULL); - bb_error_msg_and_die("can't execute '%s'", options.login); + BB_EXECLP(G.login, G.login, "--", logname, NULL); + bb_error_msg_and_die("can't execute '%s'", G.login); } -- cgit v1.2.3-55-g6feb From faaf8cb3faf413485f2ea1bb3656ac40cb48b785 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 14:35:09 +0100 Subject: getty: more simplifications; explain how we treat parity now function old new delta getty_main 1471 1434 -37 Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 188 ++++++++++++++++++++++++++--------------------------- 1 file changed, 93 insertions(+), 95 deletions(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index bf66f2287..402e1c097 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -1,15 +1,23 @@ /* vi: set sw=4 ts=4: */ -/* Based on agetty - another getty program for Linux. By W. Z. Venema 1989 +/* + * Based on agetty - another getty program for Linux. By W. Z. Venema 1989 * Ported to Linux by Peter Orbaek * This program is freely distributable. * * option added by Eric Rasmussen - 12/28/95 * * 1999-02-22 Arkadiusz Mickiewicz - * - added Native Language Support + * - Added Native Language Support * * 1999-05-05 Thorsten Kranzkowski - * - enable hardware flow control before displaying /etc/issue + * - Enabled hardware flow control before displaying /etc/issue + * + * 2011-01 Venys Vlasenko + * - Removed parity detection code. It can't work reliably: + * if all chars received have bit 7 cleared and odd (or even) parity, + * it is impossible to determine whether other side is 8-bit,no-parity + * or 7-bit,odd(even)-parity. It also interferes with non-ASCII usernames. + * - From now on, we assume that parity is correctly set. * * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ @@ -23,13 +31,7 @@ # define IUCLC 0 #endif -/* - * Some heuristics to find out what environment we are in: if it is not - * System V, assume it is SunOS 4. - */ -#ifdef LOGIN_PROCESS /* defined in System V utmp.h */ -# include -#else /* if !sysV style, wtmp/utmp code is off */ +#ifndef LOGIN_PROCESS # undef ENABLE_FEATURE_UTMP # undef ENABLE_FEATURE_WTMP # define ENABLE_FEATURE_UTMP 0 @@ -37,7 +39,7 @@ #endif -/* The following is used for understandable diagnostics. */ +/* The following is used for understandable diagnostics */ #ifdef DEBUGGING static FILE *dbf; # define DEBUGTERM "/dev/ttyp0" @@ -64,14 +66,14 @@ static FILE *dbf; */ #define ISSUE "/etc/issue" -/* Some shorthands for control characters. */ +/* Some shorthands for control characters */ #define CTL(x) ((x) ^ 0100) /* Assumes ASCII dialect */ #define CR CTL('M') /* carriage return */ #define NL CTL('J') /* line feed */ #define BS CTL('H') /* back space */ #define DEL CTL('?') /* delete */ -/* Defaults for line-editing etc. characters; you may want to change this. */ +/* Defaults for line-editing etc. characters; you may want to change this */ #define DEF_ERASE DEL /* default erase character */ #define DEF_INTR CTL('C') /* default interrupt character */ #define DEF_QUIT CTL('\\') /* default quit char */ @@ -81,23 +83,22 @@ static FILE *dbf; #define DEF_SWITCH 0 /* default switch char */ /* - * When multiple baud rates are specified on the command line, the first one - * we will try is the first one specified. + * When multiple baud rates are specified on the command line, + * the first one we will try is the first one specified. */ #define MAX_SPEED 10 /* max. nr. of baud rates */ struct globals { unsigned timeout; /* time-out period */ const char *login; /* login program */ + const char *fakehost; const char *tty; /* name of tty */ const char *initstring; /* modem init string */ const char *issue; /* alternative issue file */ int numspeed; /* number of baud rates to try */ int speeds[MAX_SPEED]; /* baud rates to be tried */ + unsigned char eol; /* end-of-line char seen (CR or NL) */ struct termios termios; /* terminal mode bits */ - /* Storage for things detected while the login name was read. */ - unsigned char erase; /* erase character */ - unsigned char eol; /* end-of-line character */ char line_buf[128]; }; @@ -168,14 +169,14 @@ static void parse_speeds(char *arg) } /* parse command-line arguments */ -static void parse_args(char **argv, char **fakehost_p) +static void parse_args(char **argv) { char *ts; int flags; opt_complementary = "-2:t+"; /* at least 2 args; -t N */ flags = getopt32(argv, opt_string, - &G.initstring, fakehost_p, &G.issue, + &G.initstring, &G.fakehost, &G.issue, &G.login, &G.timeout ); if (flags & F_INITSTRING) { @@ -206,17 +207,17 @@ static void parse_args(char **argv, char **fakehost_p) /* set up tty as standard input, output, error */ static void open_tty(void) { - /* Set up new standard input, unless we are given an already opened port. */ + /* Set up new standard input, unless we are given an already opened port */ if (NOT_LONE_DASH(G.tty)) { if (G.tty[0] != '/') G.tty = xasprintf("/dev/%s", G.tty); /* will leak it */ - /* Open the tty as standard input. */ + /* Open the tty as standard input */ debug("open(2)\n"); close(0); xopen(G.tty, O_RDWR | O_NONBLOCK); /* uses fd 0 */ - /* Set proper protections and ownership. */ + /* Set proper protections and ownership */ fchown(0, 0, 0); /* 0:0 */ fchmod(0, 0620); /* crw--w---- */ } else { @@ -229,7 +230,13 @@ static void open_tty(void) } } -/* initialize termios settings */ +/* We manipulate termios this way: + * - first, we read existing termios settings + * - termios_init modifies some parts and sets it + * - auto_baud and/or BREAK processing can set different speed and set termios + * - termios_final again modifies some parts and sets termios before + * execing login + */ static void termios_init(int speed) { /* Flush input and output queues, important for modems! @@ -240,7 +247,7 @@ static void termios_init(int speed) usleep(100*1000); /* 0.1 sec */ tcflush(STDIN_FILENO, TCIOFLUSH); - /* Set speed if it wasn't specified as "0" on command line. */ + /* Set speed if it wasn't specified as "0" on command line */ if (speed != B0) cfsetspeed(&G.termios, speed); @@ -271,13 +278,44 @@ static void termios_init(int speed) debug("term_io 2\n"); } +static void termios_final(void) +{ + /* General terminal-independent stuff */ + G.termios.c_iflag |= IXON | IXOFF; /* 2-way flow control */ + G.termios.c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE; + /* no longer in lflag: | ECHOCTL | ECHOPRT */ + G.termios.c_oflag |= OPOST; + /* G.termios.c_cflag = 0; */ + G.termios.c_cc[VINTR] = DEF_INTR; + G.termios.c_cc[VQUIT] = DEF_QUIT; + G.termios.c_cc[VEOF] = DEF_EOF; + G.termios.c_cc[VEOL] = DEF_EOL; +#ifdef VSWTC + G.termios.c_cc[VSWTC] = DEF_SWITCH; +#endif + + /* Account for special characters seen in input */ + if (G.eol == CR) { + G.termios.c_iflag |= ICRNL; /* map CR in input to NL */ + /* already done by termios_init */ + /* G.termios.c_oflag |= ONLCR; map NL in output to CR-NL */ + } + G.termios.c_cc[VKILL] = DEF_KILL; + +#ifdef CRTSCTS + /* Optionally enable hardware flow control */ + if (option_mask32 & F_RTSCTS) + G.termios.c_cflag |= CRTSCTS; +#endif + + /* Finally, make the new settings effective */ + if (tcsetattr_stdin_TCSANOW(&G.termios) < 0) + bb_perror_msg_and_die("tcsetattr"); +} + /* extract baud rate from modem status message */ static void auto_baud(void) { - int speed; - int vmin; - unsigned iflag; - char *bp; int nread; /* @@ -296,12 +334,9 @@ static void auto_baud(void) */ /* - * Use 7-bit characters, don't block if input queue is empty. Errors will - * be dealt with later on. + * Don't block if input queue is empty. + * Errors will be dealt with later on. */ - iflag = G.termios.c_iflag; - G.termios.c_iflag |= ISTRIP; /* enable 8th-bit stripping */ - vmin = G.termios.c_cc[VMIN]; G.termios.c_cc[VMIN] = 0; /* don't block if queue empty */ tcsetattr_stdin_TCSANOW(&G.termios); @@ -312,6 +347,8 @@ static void auto_baud(void) sleep(1); nread = safe_read(STDIN_FILENO, G.line_buf, sizeof(G.line_buf) - 1); if (nread > 0) { + int speed; + char *bp; G.line_buf[nread] = '\0'; for (bp = G.line_buf; bp < G.line_buf + nread; bp++) { if (isdigit(*bp)) { @@ -323,38 +360,38 @@ static void auto_baud(void) } } - /* Restore terminal settings. Errors will be dealt with later on. */ - G.termios.c_iflag = iflag; - G.termios.c_cc[VMIN] = vmin; + /* Restore terminal settings. Errors will be dealt with later on */ + G.termios.c_cc[VMIN] = 1; /* restore to value set by termios_init */ tcsetattr_stdin_TCSANOW(&G.termios); } /* get user name, establish parity, speed, erase, kill, eol; - * return NULL on BREAK, logname on success */ + * return NULL on BREAK, logname on success + */ static char *get_logname(void) { char *bp; char c; - /* Flush pending input (esp. after parsing or switching the baud rate). */ + /* Flush pending input (esp. after parsing or switching the baud rate) */ usleep(100*1000); /* 0.1 sec */ tcflush(STDIN_FILENO, TCIOFLUSH); - /* Prompt for and read a login name. */ + /* Prompt for and read a login name */ G.line_buf[0] = '\0'; while (!G.line_buf[0]) { - /* Write issue file and prompt. */ + /* Write issue file and prompt */ #ifdef ISSUE if (!(option_mask32 & F_NOISSUE)) print_login_issue(G.issue, G.tty); #endif print_login_prompt(); - /* Read name, watch for break, parity, erase, kill, end-of-line. */ + /* Read name, watch for break, parity, erase, kill, end-of-line */ bp = G.line_buf; G.eol = '\0'; while (1) { - /* Do not report trivial EINTR/EIO errors. */ + /* Do not report trivial EINTR/EIO errors */ errno = EINTR; /* make read of 0 bytes be silent too */ if (read(STDIN_FILENO, &c, 1) < 1) { if (errno == EINTR || errno == EIO) @@ -367,7 +404,7 @@ static char *get_logname(void) if (c == '\0' && G.numspeed > 1) return NULL; - /* Do erase, kill and end-of-line processing. */ + /* Do erase, kill and end-of-line processing */ switch (c) { case CR: case NL: @@ -376,7 +413,7 @@ static char *get_logname(void) goto got_logname; case BS: case DEL: - G.erase = c; + G.termios.c_cc[VERASE] = c; if (bp > G.line_buf) { full_write(STDOUT_FILENO, "\010 \010", 3); bp--; @@ -407,61 +444,22 @@ static char *get_logname(void) return G.line_buf; } -/* set the final tty mode bits */ -static void termios_final(void) -{ - /* General terminal-independent stuff. */ - G.termios.c_iflag |= IXON | IXOFF; /* 2-way flow control */ - G.termios.c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE; - /* no longer in lflag: | ECHOCTL | ECHOPRT */ - G.termios.c_oflag |= OPOST; - /* G.termios.c_cflag = 0; */ - G.termios.c_cc[VINTR] = DEF_INTR; /* default interrupt */ - G.termios.c_cc[VQUIT] = DEF_QUIT; /* default quit */ - G.termios.c_cc[VEOF] = DEF_EOF; /* default EOF character */ - G.termios.c_cc[VEOL] = DEF_EOL; -#ifdef VSWTC - G.termios.c_cc[VSWTC] = DEF_SWITCH; /* default switch character */ -#endif - - /* Account for special characters seen in input. */ - if (G.eol == CR) { - G.termios.c_iflag |= ICRNL; /* map CR in input to NL */ - G.termios.c_oflag |= ONLCR; /* map NL in output to CR-NL */ - } - G.termios.c_cc[VERASE] = G.erase; /* set erase character */ - G.termios.c_cc[VKILL] = DEF_KILL; /* set kill character */ - -#ifdef CRTSCTS - /* Optionally enable hardware flow control */ - if (option_mask32 & F_RTSCTS) - G.termios.c_cflag |= CRTSCTS; -#endif - - /* Finally, make the new settings effective */ - if (tcsetattr_stdin_TCSANOW(&G.termios) < 0) - bb_perror_msg_and_die("tcsetattr"); -} - int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int getty_main(int argc UNUSED_PARAM, char **argv) { int n; pid_t pid; - char *fakehost = NULL; /* Fake hostname for ut_host */ char *logname; INIT_G(); G.login = _PATH_LOGIN; /* default login program */ - G.initstring = ""; /* modem init string */ #ifdef ISSUE G.issue = ISSUE; /* default issue file */ #endif - G.erase = DEF_ERASE; G.eol = CR; - /* Parse command-line arguments. */ - parse_args(argv, &fakehost); + /* Parse command-line arguments */ + parse_args(argv); logmode = LOGMODE_NONE; @@ -524,9 +522,9 @@ int getty_main(int argc UNUSED_PARAM, char **argv) #endif /* Update the utmp file. This tty is ours now! */ - update_utmp(pid, LOGIN_PROCESS, G.tty, "LOGIN", fakehost); + update_utmp(pid, LOGIN_PROCESS, G.tty, "LOGIN", G.fakehost); - /* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */ + /* Initialize the termios settings (raw mode, eight-bit, blocking i/o) */ debug("calling termios_init\n"); termios_init(G.speeds[0]); @@ -563,30 +561,30 @@ int getty_main(int argc UNUSED_PARAM, char **argv) int baud_index = 0; while (1) { - /* Read the login name. */ + /* Read the login name */ debug("reading login name\n"); logname = get_logname(); if (logname) break; - /* We are here only if G.numspeed > 1. */ + /* We are here only if G.numspeed > 1 */ baud_index = (baud_index + 1) % G.numspeed; cfsetspeed(&G.termios, G.speeds[baud_index]); tcsetattr_stdin_TCSANOW(&G.termios); } } - /* Disable timer. */ + /* Disable timer */ alarm(0); - /* Finalize the termios settings. */ + /* Finalize the termios settings */ termios_final(); - /* Now the newline character should be properly written. */ + /* Now the newline character should be properly written */ full_write(STDOUT_FILENO, "\n", 1); - /* Let the login program take care of password validation. */ + /* Let the login program take care of password validation */ /* We use PATH because we trust that root doesn't set "bad" PATH, - * and getty is not suid-root applet. */ + * and getty is not suid-root applet */ /* With -n, logname == NULL, and login will ask for username instead */ BB_EXECLP(G.login, G.login, "--", logname, NULL); bb_error_msg_and_die("can't execute '%s'", G.login); -- cgit v1.2.3-55-g6feb From 271c0ce379be4b59d28e17f4774f5a078e77f64b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 16:36:15 +0100 Subject: stty: make swtch and iutf8 visible/settable Signed-off-by: Denys Vlasenko --- coreutils/stty.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/coreutils/stty.c b/coreutils/stty.c index e28e15c97..25c00d1a5 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c @@ -59,6 +59,10 @@ #if defined(VEOL2) && !defined(CEOL2) # define CEOL2 _POSIX_VDISABLE #endif +/* glibc-2.12.1 uses only VSWTC name */ +#if defined(VSWTC) && !defined(VSWTCH) +# define VSWTCH VSWTC +#endif /* ISC renamed swtch to susp for termios, but we'll accept either name */ #if defined(VSUSP) && !defined(VSWTCH) # define VSWTCH VSUSP @@ -221,6 +225,9 @@ #ifndef XCASE # define XCASE 0 #endif +#ifndef IUTF8 +# define IUTF8 0 +#endif /* Which speeds to set */ enum speed_setting { @@ -347,6 +354,9 @@ static const char mode_name[] = #endif #if IMAXBEL MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 ) +#endif +#if IUTF8 + MI_ENTRY("iutf8", input, SANE_UNSET | REV, IUTF8, 0 ) #endif MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 ) #if OLCUC @@ -501,6 +511,9 @@ static const struct mode_info mode_info[] = { #endif #if IMAXBEL MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 ) +#endif +#if IUTF8 + MI_ENTRY("iutf8", input, SANE_UNSET | REV, IUTF8, 0 ) #endif MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 ) #if OLCUC -- cgit v1.2.3-55-g6feb From e3c127d846eb2febbdb86bcf6c0c92622ab98eea Mon Sep 17 00:00:00 2001 From: Chris Rees Date: Mon, 24 Jan 2011 17:03:36 +0100 Subject: FreeBSD compat Signed-off-by: Chris Rees Signed-off-by: Denys Vlasenko --- include/libbb.h | 6 ++++++ include/platform.h | 6 ++++++ libbb/getpty.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/libbb.h b/include/libbb.h index 6e37b8d04..aa7944a5d 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -38,6 +38,12 @@ #include #include #include +#ifndef HAVE_CLEARENV +# define clearenv() do { if (environ) environ[0] = NULL; } while (0) +#endif +#ifndef HAVE_FDATASYNC +# define fdatasync fsync +#endif #ifdef HAVE_MNTENT_H # include #endif diff --git a/include/platform.h b/include/platform.h index bbbc0a9b6..2bc88c391 100644 --- a/include/platform.h +++ b/include/platform.h @@ -10,9 +10,12 @@ /* Assume all these functions exist by default. Platforms where it is not * true will #undef them below. */ +#define HAVE_CLEARENV 1 +#define HAVE_FDATASYNC 1 #define HAVE_FDPRINTF 1 #define HAVE_MEMRCHR 1 #define HAVE_MKDTEMP 1 +#define HAVE_PTSNAME_R 1 #define HAVE_SETBIT 1 #define HAVE_SIGHANDLER_T 1 #define HAVE_STRCASESTR 1 @@ -253,7 +256,10 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; #if (defined __digital__ && defined __unix__) \ || defined __APPLE__ \ || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ +# undef HAVE_CLEARENV +# undef HAVE_FDATASYNC # undef HAVE_MNTENT_H +# undef HAVE_PTSNAME_R # undef HAVE_SYS_STATFS_H # undef HAVE_SIGHANDLER_T #else diff --git a/libbb/getpty.c b/libbb/getpty.c index ea653b0b6..6a15cff2f 100644 --- a/libbb/getpty.c +++ b/libbb/getpty.c @@ -19,7 +19,7 @@ int FAST_FUNC xgetpty(char *line) if (p > 0) { grantpt(p); /* chmod+chown corresponding slave pty */ unlockpt(p); /* (what does this do?) */ -#if 0 /* if ptsname_r is not available... */ +#ifndef HAVE_PTSNAME_R const char *name; name = ptsname(p); /* find out the name of slave pty */ if (!name) { -- cgit v1.2.3-55-g6feb From 330718ef5574d1f830e304107d2a43038aa6ff5c Mon Sep 17 00:00:00 2001 From: Chris Rees Date: Mon, 24 Jan 2011 17:07:06 +0100 Subject: FreeBSD compat Signed-off-by: Chris Rees Signed-off-by: Denys Vlasenko --- include/libbb.h | 15 +++++++++------ include/platform.h | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index aa7944a5d..e5988236d 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -38,12 +38,6 @@ #include #include #include -#ifndef HAVE_CLEARENV -# define clearenv() do { if (environ) environ[0] = NULL; } while (0) -#endif -#ifndef HAVE_FDATASYNC -# define fdatasync fsync -#endif #ifdef HAVE_MNTENT_H # include #endif @@ -103,6 +97,15 @@ typedef unsigned socklen_t; # endif #endif +#ifndef HAVE_CLEARENV +# define clearenv() do { if (environ) environ[0] = NULL; } while (0) +#endif +#ifndef HAVE_FDATASYNC +# define fdatasync fsync +#endif +#ifndef HAVE_XTABS +# define XTABS TAB3 +#endif /* Some libc's forget to declare these, do it ourself */ diff --git a/include/platform.h b/include/platform.h index 2bc88c391..9d6e21626 100644 --- a/include/platform.h +++ b/include/platform.h @@ -262,9 +262,12 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; # undef HAVE_PTSNAME_R # undef HAVE_SYS_STATFS_H # undef HAVE_SIGHANDLER_T +# undef HAVE_XTABS +# undef HAVE_FDPRINTF #else # define HAVE_MNTENT_H 1 # define HAVE_SYS_STATFS_H 1 +# define HAVE_XTABS 1 #endif /*----- Kernel versioning ------------------------------------*/ -- cgit v1.2.3-55-g6feb From e22af94afb904b8f727b4eaff329e15783ec1cc7 Mon Sep 17 00:00:00 2001 From: Chris Rees Date: Mon, 24 Jan 2011 17:07:40 +0100 Subject: FreeBSD compat for makedev Signed-off-by: Chris Rees Signed-off-by: Denys Vlasenko --- libbb/makedev.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libbb/makedev.c b/libbb/makedev.c index cf59e616b..1809fda4e 100644 --- a/libbb/makedev.c +++ b/libbb/makedev.c @@ -8,8 +8,14 @@ /* We do not include libbb.h - #define makedev() is there! */ #include "platform.h" -#include -#include +#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ + || defined(__APPLE__) \ + ) +# include +# include +#else +# include +#endif #ifdef __GLIBC__ /* At least glibc has horrendously large inline for this, so wrap it */ -- cgit v1.2.3-55-g6feb From 6b1ce455986ae547b9a0e1e238b90ba2a928599b Mon Sep 17 00:00:00 2001 From: Chris Rees Date: Mon, 24 Jan 2011 17:10:02 +0100 Subject: FreeBSD compat for match_fstype Signed-off-by: Chris Rees Signed-off-by: Denys Vlasenko --- libbb/Kbuild.src | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 0fa145159..a22e70892 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -59,7 +59,6 @@ lib-y += llist.o lib-y += login.o lib-y += make_directory.o lib-y += makedev.o -lib-y += match_fstype.o lib-y += hash_md5_sha.o # Alternative (disabled) MD5 implementation #lib-y += hash_md5prime.o @@ -120,6 +119,8 @@ lib-y += xgethostbyname.o lib-y += xreadlink.o lib-y += xrealloc_vector.o +lib-$(CONFIG_PLATFORM_LINUX) += match_fstype.o + lib-$(CONFIG_FEATURE_UTMP) += utmp.o # A mix of optimizations (why build stuff we know won't be used) -- cgit v1.2.3-55-g6feb From 7073964b5fc01fbe83eee17e52a2341b19cf11c5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 18:17:19 +0100 Subject: getty: simplify macros; improve VSWTC[H] compat Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index 402e1c097..ed7e09aca 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -68,19 +68,16 @@ static FILE *dbf; /* Some shorthands for control characters */ #define CTL(x) ((x) ^ 0100) /* Assumes ASCII dialect */ -#define CR CTL('M') /* carriage return */ -#define NL CTL('J') /* line feed */ #define BS CTL('H') /* back space */ #define DEL CTL('?') /* delete */ /* Defaults for line-editing etc. characters; you may want to change this */ -#define DEF_ERASE DEL /* default erase character */ #define DEF_INTR CTL('C') /* default interrupt character */ #define DEF_QUIT CTL('\\') /* default quit char */ #define DEF_KILL CTL('U') /* default kill char */ #define DEF_EOF CTL('D') /* default EOF char */ #define DEF_EOL '\n' -#define DEF_SWITCH 0 /* default switch char */ +#define DEF_SWITCH 0 /* default switch char (none) */ /* * When multiple baud rates are specified on the command line, @@ -293,9 +290,12 @@ static void termios_final(void) #ifdef VSWTC G.termios.c_cc[VSWTC] = DEF_SWITCH; #endif +#ifdef VSWTCH + G.termios.c_cc[VSWTCH] = DEF_SWITCH; +#endif /* Account for special characters seen in input */ - if (G.eol == CR) { + if (G.eol == '\r') { G.termios.c_iflag |= ICRNL; /* map CR in input to NL */ /* already done by termios_init */ /* G.termios.c_oflag |= ONLCR; map NL in output to CR-NL */ @@ -406,8 +406,8 @@ static char *get_logname(void) /* Do erase, kill and end-of-line processing */ switch (c) { - case CR: - case NL: + case '\r': + case '\n': *bp = '\0'; G.eol = c; goto got_logname; @@ -456,7 +456,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) #ifdef ISSUE G.issue = ISSUE; /* default issue file */ #endif - G.eol = CR; + G.eol = '\r'; /* Parse command-line arguments */ parse_args(argv); @@ -545,7 +545,6 @@ int getty_main(int argc UNUSED_PARAM, char **argv) /* Optionally wait for CR or LF before writing /etc/issue */ if (option_mask32 & F_WAITCRLF) { char ch; - debug("waiting for cr-lf\n"); while (safe_read(STDIN_FILENO, &ch, 1) == 1) { debug("read %x\n", (unsigned char)ch); -- cgit v1.2.3-55-g6feb From e54cfc5477def68dfe00f39ac0737f4eaeda27e9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 18:30:35 +0100 Subject: stty: enable line discipline display and change code if __linix__ function old new delta stty_main 1242 1276 +34 do_display 419 431 +12 display_speed 90 81 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 46/-9) Total: 37 bytes Signed-off-by: Denys Vlasenko --- coreutils/stty.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/coreutils/stty.c b/coreutils/stty.c index 25c00d1a5..1dd01c4dd 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c @@ -1004,8 +1004,9 @@ static void display_speed(const struct termios *mode, int fancy) const char *fmt_str = "%lu %lu\n\0ispeed %lu baud; ospeed %lu baud;"; unsigned long ispeed, ospeed; - ospeed = ispeed = cfgetispeed(mode); - if (ispeed == 0 || ispeed == (ospeed = cfgetospeed(mode))) { + ispeed = cfgetispeed(mode); + ospeed = cfgetospeed(mode); + if (ispeed == 0 || ispeed == ospeed) { ispeed = ospeed; /* in case ispeed was 0 */ //________ 0123 4 5 6 7 8 9 fmt_str = "%lu\n\0\0\0\0\0speed %lu baud;"; @@ -1024,7 +1025,7 @@ static void do_display(const struct termios *mode, int all) display_speed(mode, 1); if (all) display_window_size(1); -#ifdef HAVE_C_LINE +#ifdef __linux__ wrapf("line = %u;\n", mode->c_line); #else newline(); @@ -1357,7 +1358,7 @@ int stty_main(int argc UNUSED_PARAM, char **argv) } switch (param) { -#ifdef HAVE_C_LINE +#ifdef __linux__ case param_line: # ifndef TIOCGWINSZ xatoul_range_sfx(argnext, 1, INT_MAX, stty_suffixes); @@ -1461,7 +1462,7 @@ int stty_main(int argc UNUSED_PARAM, char **argv) } switch (param) { -#ifdef HAVE_C_LINE +#ifdef __linux__ case param_line: mode.c_line = xatoul_sfx(argnext, stty_suffixes); stty_state |= STTY_require_set_attr; -- cgit v1.2.3-55-g6feb From 136091886e287181c6c55bbeadf7325545285416 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 23:45:22 +0100 Subject: getty: flush _only_ input after switching to the next baud rate It was originally like this, but at some point TCIFLUSH was inadvertently changed to TCIOFLUSH. Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index ed7e09aca..becff5c78 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -375,7 +375,7 @@ static char *get_logname(void) /* Flush pending input (esp. after parsing or switching the baud rate) */ usleep(100*1000); /* 0.1 sec */ - tcflush(STDIN_FILENO, TCIOFLUSH); + tcflush(STDIN_FILENO, TCIFLUSH); /* Prompt for and read a login name */ G.line_buf[0] = '\0'; -- cgit v1.2.3-55-g6feb From 975c7141831aa6bf8d9abcafd1e5a9e108a910fc Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jan 2011 23:53:12 +0100 Subject: nicer looking ifdef in libbb/makedev.c Signed-off-by: Denys Vlasenko --- include/libbb.h | 2 +- libbb/makedev.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index e5988236d..968bdcf5a 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1297,7 +1297,7 @@ void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name) FAST void reset_ino_dev_hashtable(void) FAST_FUNC; #ifdef __GLIBC__ /* At least glibc has horrendously large inline for this, so wrap it */ -unsigned long long bb_makedev(unsigned int major, unsigned int minor) FAST_FUNC; +unsigned long long bb_makedev(unsigned major, unsigned minor) FAST_FUNC; #undef makedev #define makedev(a,b) bb_makedev(a,b) #endif diff --git a/libbb/makedev.c b/libbb/makedev.c index 1809fda4e..06c4039a3 100644 --- a/libbb/makedev.c +++ b/libbb/makedev.c @@ -8,22 +8,23 @@ /* We do not include libbb.h - #define makedev() is there! */ #include "platform.h" -#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ - || defined(__APPLE__) \ - ) + +/* Different Unixes want different headers for makedev */ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ + || defined(__APPLE__) +# include +#else # include # include -#else -# include #endif #ifdef __GLIBC__ -/* At least glibc has horrendously large inline for this, so wrap it */ +/* At least glibc has horrendously large inline for this, so wrap it. */ /* uclibc people please check - do we need "&& !__UCLIBC__" above? */ -/* suppress gcc "no previous prototype" warning */ -unsigned long long FAST_FUNC bb_makedev(unsigned int major, unsigned int minor); -unsigned long long FAST_FUNC bb_makedev(unsigned int major, unsigned int minor) +/* Suppress gcc "no previous prototype" warning */ +unsigned long long FAST_FUNC bb_makedev(unsigned major, unsigned minor); +unsigned long long FAST_FUNC bb_makedev(unsigned major, unsigned minor) { return makedev(major, minor); } -- cgit v1.2.3-55-g6feb From 444ff284c4097081108e0eded4711247aacda740 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Jan 2011 01:57:31 +0100 Subject: top: document a debugging script Signed-off-by: Denys Vlasenko --- procps/top.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/procps/top.c b/procps/top.c index 1eb33dc5d..d7cc9af1b 100644 --- a/procps/top.c +++ b/procps/top.c @@ -30,6 +30,15 @@ * * Licensed under GPLv2, see file LICENSE in this source tree. */ +/* Howto snapshot /proc for debugging top problems: + * for f in /proc/[0-9]*""/stat; do + * n=${f#/proc/} + * n=${n%/stat}_stat + * cp $f $n + * done + * cp /proc/stat /proc/meminfo . + * top -bn1 >top.out + */ #include "libbb.h" @@ -546,7 +555,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) pmem_scale /= 4; pmem_shift -= 2; } - pmem_half = (1U << pmem_shift) / (ENABLE_FEATURE_TOP_DECIMALS? 20 : 2); + pmem_half = (1U << pmem_shift) / (ENABLE_FEATURE_TOP_DECIMALS ? 20 : 2); #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE busy_jifs = cur_jif.busy - prev_jif.busy; /* This happens if there were lots of short-lived processes @@ -577,7 +586,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) pcpu_scale /= 4; pcpu_shift -= 2; } - pcpu_half = (1U << pcpu_shift) / (ENABLE_FEATURE_TOP_DECIMALS? 20 : 2); + pcpu_half = (1U << pcpu_shift) / (ENABLE_FEATURE_TOP_DECIMALS ? 20 : 2); /* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */ #endif -- cgit v1.2.3-55-g6feb From 9b3b9790b32d440eb89af5edda70a66b1829e861 Mon Sep 17 00:00:00 2001 From: Davide Cavalca Date: Tue, 25 Jan 2011 02:26:03 +0100 Subject: add ENABLE_FEATURE_SYSTEMD and use it in syslogd Signed-off-by: Davide Cavalca Signed-off-by: Denys Vlasenko --- include/libbb.h | 6 +++++ libbb/systemd_support.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ sysklogd/syslogd.c | 5 ++++ 3 files changed, 73 insertions(+) create mode 100644 libbb/systemd_support.c diff --git a/include/libbb.h b/include/libbb.h index 968bdcf5a..32e25a8d4 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1217,6 +1217,12 @@ extern void selinux_preserve_fcontext(int fdesc) FAST_FUNC; #endif extern void selinux_or_die(void) FAST_FUNC; + +/* systemd support */ +#define SD_LISTEN_FDS_START 3 +int sd_listen_fds(void); + + /* setup_environment: * if chdir pw->pw_dir: ok: else if to_tmp == 1: goto /tmp else: goto / or die * if clear_env = 1: cd(pw->pw_dir), clear environment, then set diff --git a/libbb/systemd_support.c b/libbb/systemd_support.c new file mode 100644 index 000000000..981296dbb --- /dev/null +++ b/libbb/systemd_support.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2011 Davide Cavalca + * + * Based on http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c + * Copyright 2010 Lennart Poettering + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "libbb.h" + +//config:config FEATURE_SYSTEMD +//config: bool "Enable systemd support" +//config: default y +//config: help +//config: If you plan to use busybox daemons on a system where daemons +//config: are controlled by systemd, enable this option. +//config: If you don't use systemd, it is still safe to enable it, +//config: but yhe downside is increased code size. + +//kbuild:lib-$(CONFIG_FEATURE_SYSTEMD) += systemd_support.o + +int sd_listen_fds(void) +{ + const char *e; + int n; + int fd; + + e = getenv("LISTEN_PID"); + if (!e) + return 0; + n = xatoi_positive(e); + /* Is this for us? */ + if (getpid() != (pid_t) n) + return 0; + + e = getenv("LISTEN_FDS"); + if (!e) + return 0; + n = xatoi_positive(e); + for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++) + close_on_exec_on(fd); + + return n; +} diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index fb7309538..24cab3b6c 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c @@ -512,6 +512,11 @@ static NOINLINE int create_socket(void) int sock_fd; char *dev_log_name; +#if ENABLE_FEATURE_SYSTEMD + if (sd_listen_fds() == 1) + return SD_LISTEN_FDS_START; +#endif + memset(&sunx, 0, sizeof(sunx)); sunx.sun_family = AF_UNIX; -- cgit v1.2.3-55-g6feb From 9aa599dc9dc076f6fa6e4312e4750a703cf16450 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Jan 2011 12:48:47 +0100 Subject: top: replace %MEM with %VSZ in header text Signed-off-by: Denys Vlasenko --- procps/top.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/procps/top.c b/procps/top.c index d7cc9af1b..ee6555188 100644 --- a/procps/top.c +++ b/procps/top.c @@ -19,9 +19,9 @@ * * Sept 2008: Vineet Gupta * Added Support for reporting SMP Information - * - CPU where Process was last seen running + * - CPU where process was last seen running * (to see effect of sched_setaffinity() etc) - * - CPU Time Split (idle/IO/wait etc) PER CPU + * - CPU time split (idle/IO/wait etc) per CPU * * Copyright (c) 1992 Branko Lankester * Copyright (c) 1992 Roger Binns @@ -30,14 +30,24 @@ * * Licensed under GPLv2, see file LICENSE in this source tree. */ -/* Howto snapshot /proc for debugging top problems: +/* How to snapshot /proc for debugging top problems: * for f in /proc/[0-9]*""/stat; do * n=${f#/proc/} * n=${n%/stat}_stat * cp $f $n * done - * cp /proc/stat /proc/meminfo . + * cp /proc/stat /proc/meminfo /proc/loadavg . * top -bn1 >top.out + * + * ...and how to run top on it on another machine: + * rm -rf proc; mkdir proc + * for f in [0-9]*_stat; do + * p=${f%_stat} + * mkdir -p proc/$p + * cp $f proc/$p/stat + * done + * cp stat meminfo loadavg proc + * chroot . ./top -bn1 >top1.out */ #include "libbb.h" @@ -528,7 +538,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) /* what info of the processes is shown */ printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, - " PID PPID USER STAT VSZ %MEM" + " PID PPID USER STAT VSZ %VSZ" IF_FEATURE_TOP_SMP_PROCESS(" CPU") IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") " COMMAND"); @@ -546,7 +556,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) # define FMT "%4u%%" #endif /* - * MEM% = s->vsz/MemTotal + * %VSZ = s->vsz/MemTotal */ pmem_shift = BITS_PER_INT-11; pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory; @@ -606,7 +616,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); else sprintf(vsz_str_buf, "%7ld", s->vsz); - /* PID PPID USER STAT VSZ %MEM [%CPU] COMMAND */ + /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ col = snprintf(line_buf, scr_width, "\n" "%5u%6u %-8.8s %s%s" FMT IF_FEATURE_TOP_SMP_PROCESS(" %3d") -- cgit v1.2.3-55-g6feb From 8d0e0cdadf726beab28ccdc7d69738c1534e1f74 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Jan 2011 23:21:46 +0100 Subject: move utmp.h include to libbb.h Signed-off-by: Denys Vlasenko --- Config.in | 20 ++++++++++---------- coreutils/who.c | 1 - include/libbb.h | 3 +++ init/halt.c | 1 - init/init.c | 3 --- libbb/messages.c | 11 ++++++----- libbb/utmp.c | 1 - loginutils/adduser.c | 6 +++--- loginutils/getty.c | 3 --- loginutils/login.c | 3 --- miscutils/last.c | 1 - miscutils/last_fancy.c | 1 - miscutils/runlevel.c | 1 - miscutils/wall.c | 1 - networking/telnetd.c | 4 ---- shell/ash.c | 2 ++ 16 files changed, 24 insertions(+), 38 deletions(-) diff --git a/Config.in b/Config.in index 1109b1016..0ae48e9fe 100644 --- a/Config.in +++ b/Config.in @@ -284,10 +284,19 @@ config FEATURE_CLEAN_UP Don't enable this unless you have a really good reason to clean things up manually. +config FEATURE_UTMP + bool "Support utmp file" + default y + help + The file /var/run/utmp is used to track who is currently logged in. + With this option on, certain applets (getty, login, telnetd etc) + will create and delete entries there. + "who" applet requires this option. + config FEATURE_WTMP bool "Support wtmp file" default y - select FEATURE_UTMP + depends on FEATURE_UTMP help The file /var/run/wtmp is used to track when users have logged into and logged out of the system. @@ -295,15 +304,6 @@ config FEATURE_WTMP will append new entries there. "last" applet requires this option. -config FEATURE_UTMP - bool "Support utmp file" - default y - help - The file /var/run/utmp is used to track who is currently logged in. - With this option on, certain applets (getty, login, telnetd etc) - will create and delete entries there. - "who" applet requires this option. - config FEATURE_PIDFILE bool "Support writing pidfiles" default y diff --git a/coreutils/who.c b/coreutils/who.c index 8384d9534..ab1e30fc8 100644 --- a/coreutils/who.c +++ b/coreutils/who.c @@ -19,7 +19,6 @@ /* BB_AUDIT SUSv3 _NOT_ compliant -- missing options -b, -d, -l, -m, -p, -q, -r, -s, -t, -T, -u; Missing argument 'file'. */ #include "libbb.h" -#include static void idle_string(char *str6, time_t t) { diff --git a/include/libbb.h b/include/libbb.h index 32e25a8d4..182b47988 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -50,6 +50,9 @@ # include # include #endif +#if ENABLE_FEATURE_UTMP +# include +#endif #if ENABLE_LOCALE_SUPPORT # include #else diff --git a/init/halt.c b/init/halt.c index f853ba4a1..a84a72747 100644 --- a/init/halt.c +++ b/init/halt.c @@ -74,7 +74,6 @@ #if ENABLE_FEATURE_WTMP #include -#include static void write_wtmp(void) { diff --git a/init/init.c b/init/init.c index d8e180746..586e34a18 100644 --- a/init/init.c +++ b/init/init.c @@ -115,9 +115,6 @@ #ifdef __linux__ #include #endif -#if ENABLE_FEATURE_UTMP -# include /* DEAD_PROCESS */ -#endif #include "reboot.h" /* reboot() constants */ /* Used only for sanitizing purposes in set_sane_term() below. On systems where diff --git a/libbb/messages.c b/libbb/messages.c index 66e466ffa..2acbc3bca 100644 --- a/libbb/messages.c +++ b/libbb/messages.c @@ -48,15 +48,16 @@ const int const_int_1 = 1; * and it will end up in bss */ const int const_int_0 = 0; -#include +#if ENABLE_FEATURE_WTMP /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ const char bb_path_wtmp_file[] ALIGN1 = -#if defined _PATH_WTMP +# if defined _PATH_WTMP _PATH_WTMP; -#elif defined WTMP_FILE +# elif defined WTMP_FILE WTMP_FILE; -#else -#error unknown path to wtmp file +# else +# error unknown path to wtmp file +# endif #endif /* We use it for "global" data via *(struct global*)&bb_common_bufsiz1. diff --git a/libbb/utmp.c b/libbb/utmp.c index 2bf9c11f2..09443fb6c 100644 --- a/libbb/utmp.c +++ b/libbb/utmp.c @@ -7,7 +7,6 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ #include "libbb.h" -#include static void touch(const char *filename) { diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 1a9949e97..d938b80f3 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c @@ -78,11 +78,11 @@ static void addgroup_wrapper(struct passwd *p, const char *group_name) free(cmd); } -static void passwd_wrapper(const char *login) NORETURN; +static void passwd_wrapper(const char *login_name) NORETURN; -static void passwd_wrapper(const char *login) +static void passwd_wrapper(const char *login_name) { - BB_EXECLP("passwd", "passwd", login, NULL); + BB_EXECLP("passwd", "passwd", login_name, NULL); bb_error_msg_and_die("can't execute passwd, you must set password manually"); } diff --git a/loginutils/getty.c b/loginutils/getty.c index becff5c78..b71d68a1f 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -24,9 +24,6 @@ #include "libbb.h" #include -#if ENABLE_FEATURE_UTMP -# include /* LOGIN_PROCESS */ -#endif #ifndef IUCLC # define IUCLC 0 #endif diff --git a/loginutils/login.c b/loginutils/login.c index c285b45a1..952b3aadd 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -4,9 +4,6 @@ */ #include "libbb.h" #include -#if ENABLE_FEATURE_UTMP -# include /* USER_PROCESS */ -#endif #include #if ENABLE_SELINUX diff --git a/miscutils/last.c b/miscutils/last.c index fec5b70a8..12457b157 100644 --- a/miscutils/last.c +++ b/miscutils/last.c @@ -8,7 +8,6 @@ */ #include "libbb.h" -#include /* NB: ut_name and ut_user are the same field, use only one name (ut_user) * to reduce confusion */ diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c index 7e69fc281..7e61b7691 100644 --- a/miscutils/last_fancy.c +++ b/miscutils/last_fancy.c @@ -8,7 +8,6 @@ */ #include "libbb.h" -#include /* NB: ut_name and ut_user are the same field, use only one name (ut_user) * to reduce confusion */ diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c index 363e45049..7024361e7 100644 --- a/miscutils/runlevel.c +++ b/miscutils/runlevel.c @@ -12,7 +12,6 @@ * initially busyboxified by Bernhard Reutner-Fischer */ #include "libbb.h" -#include int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int runlevel_main(int argc UNUSED_PARAM, char **argv) diff --git a/miscutils/wall.c b/miscutils/wall.c index eecfc166b..0a2b89e5e 100644 --- a/miscutils/wall.c +++ b/miscutils/wall.c @@ -7,7 +7,6 @@ */ #include "libbb.h" -#include int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int wall_main(int argc UNUSED_PARAM, char **argv) diff --git a/networking/telnetd.c b/networking/telnetd.c index 07c6a6a73..eec4417ca 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c @@ -31,10 +31,6 @@ #endif #include -#if ENABLE_FEATURE_UTMP -# include /* LOGIN_PROCESS */ -#endif - struct tsession { struct tsession *next; diff --git a/shell/ash.c b/shell/ash.c index 298ba3558..0bcbf9028 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4944,6 +4944,8 @@ stoppedjobs(void) * Code for dealing with input/output redirection. */ +#undef EMPTY +#undef CLOSED #define EMPTY -2 /* marks an unused slot in redirtab */ #define CLOSED -3 /* marks a slot of previously-closed fd */ -- cgit v1.2.3-55-g6feb