Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e79bc6c77 | ||
|
|
30f0ea6cab | ||
|
|
92e531458a | ||
|
|
12d97b6680 | ||
|
|
2a1571bfa0 |
No files matched your search
@@ -126,10 +126,10 @@ config FEATURE_INSTALLER
|
||||
config INSTALL_NO_USR
|
||||
bool "Don't use /usr"
|
||||
default n
|
||||
depends on FEATURE_INSTALLER
|
||||
help
|
||||
Disable use of /usr. busybox --install will install applets
|
||||
only to /bin and /sbin, never to /usr/bin or /usr/sbin.
|
||||
Disable use of /usr. busybox --install and "make install"
|
||||
will install applets only to /bin and /sbin,
|
||||
never to /usr/bin or /usr/sbin.
|
||||
|
||||
config LOCALE_SUPPORT
|
||||
bool "Enable locale support (system needs locale for this to work)"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 18
|
||||
SUBLEVEL = 0
|
||||
SUBLEVEL = 5
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
|
||||
+4
-2
@@ -128,10 +128,12 @@ IF_DESKTOP(long long) int FAST_FUNC compressStream(unpack_info_t *info UNUSED_PA
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
/* Can't be conditional on ENABLE_FEATURE_CLEAN_UP -
|
||||
* we are called repeatedly
|
||||
*/
|
||||
BZ2_bzCompressEnd(strm);
|
||||
free(iobuf);
|
||||
#endif
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
@@ -308,16 +308,12 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* -L makes sense only with -o or -p */
|
||||
|
||||
#if !ENABLE_FEATURE_CPIO_O
|
||||
/* no parameters */
|
||||
opt_complementary = "=0";
|
||||
opt = getopt32(argv, OPTION_STR, &cpio_filename);
|
||||
argv += optind;
|
||||
if (opt & CPIO_OPT_FILE) { /* -F */
|
||||
xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
|
||||
}
|
||||
#else
|
||||
/* _exactly_ one parameter for -p, thus <= 1 param if -p is allowed */
|
||||
opt_complementary = ENABLE_FEATURE_CPIO_P ? "?1" : "=0";
|
||||
opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt);
|
||||
argv += optind;
|
||||
if ((opt & (CPIO_OPT_FILE|CPIO_OPT_CREATE)) == CPIO_OPT_FILE) { /* -F without -o */
|
||||
|
||||
@@ -361,7 +361,6 @@ int BZ2_bzCompress(bz_stream *strm, int action)
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
static
|
||||
void BZ2_bzCompressEnd(bz_stream *strm)
|
||||
{
|
||||
@@ -372,9 +371,8 @@ void BZ2_bzCompressEnd(bz_stream *strm)
|
||||
free(s->arr2);
|
||||
free(s->ftab);
|
||||
free(s->crc32table);
|
||||
free(strm->state);
|
||||
free(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
|
||||
+4
-2
@@ -1037,8 +1037,10 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
tar_handle->src_fd = tar_fd;
|
||||
tar_handle->seek = seek_by_read;
|
||||
} else {
|
||||
if (ENABLE_FEATURE_TAR_AUTODETECT && flags == O_RDONLY) {
|
||||
get_header_ptr = get_header_tar;
|
||||
if (ENABLE_FEATURE_TAR_AUTODETECT
|
||||
&& flags == O_RDONLY
|
||||
&& get_header_ptr == get_header_tar
|
||||
) {
|
||||
tar_handle->src_fd = open_zipped(tar_filename);
|
||||
if (tar_handle->src_fd < 0)
|
||||
bb_perror_msg_and_die("can't open '%s'", tar_filename);
|
||||
|
||||
@@ -38,6 +38,7 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
#define read_buf bb_common_bufsiz1
|
||||
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
|
||||
length += bytes_read;
|
||||
crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
+8
-8
@@ -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 */
|
||||
) {
|
||||
|
||||
@@ -56,6 +56,11 @@ s - suid type:
|
||||
# define APPLET_NOFORK(name,main,l,s,name2) { #name, #main, l, s, 1, 1 },
|
||||
#endif
|
||||
|
||||
#if ENABLE_INSTALL_NO_USR
|
||||
# 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))
|
||||
|
||||
+3
-1
@@ -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)
|
||||
{
|
||||
@@ -448,7 +450,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;
|
||||
|
||||
+25
-25
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
/* Prefix for optional rounds specification. */
|
||||
static const char str_rounds[] = "rounds=%u$";
|
||||
static const char str_rounds[] ALIGN1 = "rounds=%u$";
|
||||
|
||||
/* Maximum salt string length. */
|
||||
#define SALT_LEN_MAX 16
|
||||
@@ -19,8 +19,8 @@ NOINLINE
|
||||
sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
|
||||
{
|
||||
void (*sha_begin)(void *ctx) FAST_FUNC;
|
||||
void (*sha_hash)(const void *buffer, size_t len, void *ctx) FAST_FUNC;
|
||||
void (*sha_end)(void *resbuf, void *ctx) FAST_FUNC;
|
||||
void (*sha_hash)(void *ctx, const void *buffer, size_t len) FAST_FUNC;
|
||||
void (*sha_end)(void *ctx, void *resbuf) FAST_FUNC;
|
||||
int _32or64;
|
||||
|
||||
char *result, *resptr;
|
||||
@@ -103,40 +103,40 @@ sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
|
||||
|
||||
/* Add KEY, SALT. */
|
||||
sha_begin(&ctx);
|
||||
sha_hash(key_data, key_len, &ctx);
|
||||
sha_hash(salt_data, salt_len, &ctx);
|
||||
sha_hash(&ctx, key_data, key_len);
|
||||
sha_hash(&ctx, salt_data, salt_len);
|
||||
|
||||
/* Compute alternate SHA sum with input KEY, SALT, and KEY.
|
||||
The final result will be added to the first context. */
|
||||
sha_begin(&alt_ctx);
|
||||
sha_hash(key_data, key_len, &alt_ctx);
|
||||
sha_hash(salt_data, salt_len, &alt_ctx);
|
||||
sha_hash(key_data, key_len, &alt_ctx);
|
||||
sha_end(alt_result, &alt_ctx);
|
||||
sha_hash(&alt_ctx, key_data, key_len);
|
||||
sha_hash(&alt_ctx, salt_data, salt_len);
|
||||
sha_hash(&alt_ctx, key_data, key_len);
|
||||
sha_end(&alt_ctx, alt_result);
|
||||
|
||||
/* Add result of this to the other context. */
|
||||
/* Add for any character in the key one byte of the alternate sum. */
|
||||
for (cnt = key_len; cnt > _32or64; cnt -= _32or64)
|
||||
sha_hash(alt_result, _32or64, &ctx);
|
||||
sha_hash(alt_result, cnt, &ctx);
|
||||
sha_hash(&ctx, alt_result, _32or64);
|
||||
sha_hash(&ctx, alt_result, cnt);
|
||||
|
||||
/* Take the binary representation of the length of the key and for every
|
||||
1 add the alternate sum, for every 0 the key. */
|
||||
for (cnt = key_len; cnt != 0; cnt >>= 1)
|
||||
if ((cnt & 1) != 0)
|
||||
sha_hash(alt_result, _32or64, &ctx);
|
||||
sha_hash(&ctx, alt_result, _32or64);
|
||||
else
|
||||
sha_hash(key_data, key_len, &ctx);
|
||||
sha_hash(&ctx, key_data, key_len);
|
||||
|
||||
/* Create intermediate result. */
|
||||
sha_end(alt_result, &ctx);
|
||||
sha_end(&ctx, alt_result);
|
||||
|
||||
/* Start computation of P byte sequence. */
|
||||
/* For every character in the password add the entire password. */
|
||||
sha_begin(&alt_ctx);
|
||||
for (cnt = 0; cnt < key_len; ++cnt)
|
||||
sha_hash(key_data, key_len, &alt_ctx);
|
||||
sha_end(temp_result, &alt_ctx);
|
||||
sha_hash(&alt_ctx, key_data, key_len);
|
||||
sha_end(&alt_ctx, temp_result);
|
||||
|
||||
/* NB: past this point, raw key_data is not used anymore */
|
||||
|
||||
@@ -153,8 +153,8 @@ sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
|
||||
/* For every character in the password add the entire password. */
|
||||
sha_begin(&alt_ctx);
|
||||
for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt)
|
||||
sha_hash(salt_data, salt_len, &alt_ctx);
|
||||
sha_end(temp_result, &alt_ctx);
|
||||
sha_hash(&alt_ctx, salt_data, salt_len);
|
||||
sha_end(&alt_ctx, temp_result);
|
||||
|
||||
/* NB: past this point, raw salt_data is not used anymore */
|
||||
|
||||
@@ -174,22 +174,22 @@ sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
|
||||
|
||||
/* Add key or last result. */
|
||||
if ((cnt & 1) != 0)
|
||||
sha_hash(p_bytes, key_len, &ctx);
|
||||
sha_hash(&ctx, p_bytes, key_len);
|
||||
else
|
||||
sha_hash(alt_result, _32or64, &ctx);
|
||||
sha_hash(&ctx, alt_result, _32or64);
|
||||
/* Add salt for numbers not divisible by 3. */
|
||||
if (cnt % 3 != 0)
|
||||
sha_hash(s_bytes, salt_len, &ctx);
|
||||
sha_hash(&ctx, s_bytes, salt_len);
|
||||
/* Add key for numbers not divisible by 7. */
|
||||
if (cnt % 7 != 0)
|
||||
sha_hash(p_bytes, key_len, &ctx);
|
||||
sha_hash(&ctx, p_bytes, key_len);
|
||||
/* Add key or last result. */
|
||||
if ((cnt & 1) != 0)
|
||||
sha_hash(alt_result, _32or64, &ctx);
|
||||
sha_hash(&ctx, alt_result, _32or64);
|
||||
else
|
||||
sha_hash(p_bytes, key_len, &ctx);
|
||||
sha_hash(&ctx, p_bytes, key_len);
|
||||
|
||||
sha_end(alt_result, &ctx);
|
||||
sha_end(&ctx, alt_result);
|
||||
}
|
||||
|
||||
/* Append encrypted password to result buffer */
|
||||
|
||||
@@ -52,6 +52,7 @@ pid_t FAST_FUNC spawn(char **argv)
|
||||
* Interested party can wait on pid and learn exit code.
|
||||
* If 111 - then it (most probably) failed to exec */
|
||||
if (failed) {
|
||||
safe_waitpid(pid, NULL, 0); /* prevent zombie */
|
||||
errno = failed;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
+9
-8
@@ -175,23 +175,24 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
|
||||
llist_add_to_end(&aborts, arg);
|
||||
#if ENABLE_FEATURE_CHAT_CLR_ABORT
|
||||
} else if (DIR_CLR_ABORT == key) {
|
||||
llist_t *l;
|
||||
// remove the string from abort conditions
|
||||
// N.B. gotta refresh maximum length too...
|
||||
#if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
|
||||
# if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
|
||||
max_abort_len = 0;
|
||||
#endif
|
||||
for (llist_t *l = aborts; l; l = l->link) {
|
||||
#if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
|
||||
# endif
|
||||
for (l = aborts; l; l = l->link) {
|
||||
# if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
|
||||
size_t len = strlen(l->data);
|
||||
#endif
|
||||
if (!strcmp(arg, l->data)) {
|
||||
# endif
|
||||
if (strcmp(arg, l->data) == 0) {
|
||||
llist_unlink(&aborts, l);
|
||||
continue;
|
||||
}
|
||||
#if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
|
||||
# if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
|
||||
if (len > max_abort_len)
|
||||
max_abort_len = len;
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
} else if (DIR_TIMEOUT == key) {
|
||||
|
||||
@@ -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" */
|
||||
@@ -844,13 +845,17 @@ 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 (!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("")
|
||||
) != 0)
|
||||
) != 0
|
||||
) {
|
||||
bb_error_msg_and_die("can't insert '%s': %s",
|
||||
*argv, moderror(errno));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2474,6 +2474,7 @@ new_process_module_arguments(struct obj_file *f, const char *options)
|
||||
n = 0;
|
||||
p = val;
|
||||
while (*p != 0) {
|
||||
char sv_ch;
|
||||
char *endp;
|
||||
|
||||
if (++n > max)
|
||||
@@ -2482,14 +2483,17 @@ new_process_module_arguments(struct obj_file *f, const char *options)
|
||||
switch (*pinfo) {
|
||||
case 's':
|
||||
len = strcspn(p, ",");
|
||||
sv_ch = p[len];
|
||||
p[len] = 0;
|
||||
obj_string_patch(f, sym->secidx,
|
||||
loc - contents, p);
|
||||
loc += tgt_sizeof_char_p;
|
||||
p += len;
|
||||
*p = sv_ch;
|
||||
break;
|
||||
case 'c':
|
||||
len = strcspn(p, ",");
|
||||
sv_ch = p[len];
|
||||
p[len] = 0;
|
||||
if (len >= charssize)
|
||||
bb_error_msg_and_die("string too long for %s (max %ld)", param,
|
||||
@@ -2497,6 +2501,7 @@ new_process_module_arguments(struct obj_file *f, const char *options)
|
||||
strcpy((char *) loc, p);
|
||||
loc += charssize;
|
||||
p += len;
|
||||
*p = sv_ch;
|
||||
break;
|
||||
case 'b':
|
||||
*loc++ = strtoul(p, &endp, 0);
|
||||
|
||||
+5
-6
@@ -71,12 +71,11 @@ char* FAST_FUNC parse_cmdline_module_options(char **argv)
|
||||
optlen = 0;
|
||||
while (*++argv) {
|
||||
options = xrealloc(options, optlen + 2 + strlen(*argv) + 2);
|
||||
/* Older versions were enclosing space-containing *argv in "",
|
||||
* but both modprobe and insmod from module-init-tools 3.11.1
|
||||
* don't do this anymore. (As to extra trailing space,
|
||||
* insmod adds it but modprobe does not. We do in both cases)
|
||||
*/
|
||||
optlen += sprintf(options + optlen, "%s ", *argv);
|
||||
/* Spaces handled by "" pairs, but no way of escaping quotes */
|
||||
//TODO: module-init-tools version 3.11.1 quotes only value:
|
||||
//it generates var="val with spaces", not "var=val with spaces"
|
||||
//(and it won't quote var *name* even if it has spaces)
|
||||
optlen += sprintf(options + optlen, (strchr(*argv, ' ') ? "\"%s\" " : "%s "), *argv);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -394,7 +394,7 @@ static void sendping4(int junk UNUSED_PARAM)
|
||||
#if ENABLE_PING6
|
||||
static void sendping6(int junk UNUSED_PARAM)
|
||||
{
|
||||
struct icmp6_hdr *pkt = alloca(datalen + sizeof(struct icmp6_hdr) + 4);
|
||||
struct icmp6_hdr *pkt = G.snd_packet;
|
||||
|
||||
//memset(pkt, 0, datalen + sizeof(struct icmp6_hdr) + 4);
|
||||
pkt->icmp6_type = ICMP6_ECHO_REQUEST;
|
||||
|
||||
+12
-27
@@ -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 */
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ static NOINLINE void attach_option(
|
||||
new->data = xmalloc(length + OPT_DATA);
|
||||
new->data[OPT_CODE] = optflag->code;
|
||||
new->data[OPT_LEN] = length;
|
||||
memcpy(new->data + OPT_DATA, buffer, length);
|
||||
memcpy(new->data + OPT_DATA, (allocated ? allocated : buffer), length);
|
||||
|
||||
curr = opt_list;
|
||||
while (*curr && (*curr)->data[OPT_CODE] < optflag->code)
|
||||
|
||||
+50
-15
@@ -446,7 +446,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_
|
||||
|
||||
static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd)
|
||||
{
|
||||
char buf[512];
|
||||
char buf[4*1024]; /* made bigger to speed up local xfers */
|
||||
#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
|
||||
# if ENABLE_FEATURE_WGET_TIMEOUT
|
||||
unsigned second_cnt;
|
||||
@@ -455,7 +455,6 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd)
|
||||
|
||||
polldata.fd = fileno(dfp);
|
||||
polldata.events = POLLIN | POLLPRI;
|
||||
ndelay_on(polldata.fd);
|
||||
#endif
|
||||
progress_meter(PROGRESS_START);
|
||||
|
||||
@@ -464,6 +463,10 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd)
|
||||
|
||||
/* Loops only if chunked */
|
||||
while (1) {
|
||||
|
||||
#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
|
||||
ndelay_on(polldata.fd);
|
||||
#endif
|
||||
while (1) {
|
||||
int n;
|
||||
unsigned rdsz;
|
||||
@@ -493,22 +496,46 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd)
|
||||
progress_meter(PROGRESS_BUMP);
|
||||
}
|
||||
#endif
|
||||
/* fread internally uses read loop, which in our case
|
||||
* is usually exited when we get EAGAIN.
|
||||
* In this case, libc sets error marker on the stream.
|
||||
* Need to clear it before next fread to avoid possible
|
||||
* rare false positive ferror below. Rare because usually
|
||||
* fread gets more than zero bytes, and we don't fall
|
||||
* into if (n <= 0) ...
|
||||
*/
|
||||
clearerr(dfp);
|
||||
errno = 0;
|
||||
n = safe_fread(buf, rdsz, dfp);
|
||||
/* man fread:
|
||||
* If error occurs, or EOF is reached, the return value
|
||||
* is a short item count (or zero).
|
||||
* fread does not distinguish between EOF and error.
|
||||
*/
|
||||
if (n <= 0) {
|
||||
if (ferror(dfp)) {
|
||||
/* perror will not work: ferror doesn't set errno */
|
||||
bb_error_msg_and_die(bb_msg_read_error);
|
||||
}
|
||||
break;
|
||||
#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
|
||||
if (errno == EAGAIN) /* poll lied, there is no data? */
|
||||
continue; /* yes */
|
||||
#endif
|
||||
if (ferror(dfp))
|
||||
bb_perror_msg_and_die(bb_msg_read_error);
|
||||
break; /* EOF, not error */
|
||||
}
|
||||
|
||||
xwrite(output_fd, buf, n);
|
||||
#if ENABLE_FEATURE_WGET_STATUSBAR
|
||||
G.transferred += n;
|
||||
progress_meter(PROGRESS_BUMP);
|
||||
#endif
|
||||
if (G.got_clen)
|
||||
if (G.got_clen) {
|
||||
G.content_len -= n;
|
||||
if (G.content_len == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
|
||||
ndelay_off(polldata.fd);
|
||||
#endif
|
||||
|
||||
if (!G.chunked)
|
||||
break;
|
||||
@@ -706,6 +733,11 @@ int wget_main(int argc UNUSED_PARAM, char **argv)
|
||||
fprintf(sfp, "Host: %s\r\nUser-Agent: %s\r\n",
|
||||
target.host, user_agent);
|
||||
|
||||
/* Ask server to close the connection as soon as we are done
|
||||
* (IOW: we do not intend to send more requests)
|
||||
*/
|
||||
fprintf(sfp, "Connection: close\r\n");
|
||||
|
||||
#if ENABLE_FEATURE_WGET_AUTHENTICATION
|
||||
if (target.user) {
|
||||
fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6,
|
||||
@@ -719,22 +751,25 @@ int wget_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
if (G.beg_range)
|
||||
fprintf(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range);
|
||||
|
||||
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
|
||||
if (extra_headers)
|
||||
fputs(extra_headers, sfp);
|
||||
|
||||
if (opt & WGET_OPT_POST_DATA) {
|
||||
char *estr = URL_escape(post_data);
|
||||
fprintf(sfp, "Content-Type: application/x-www-form-urlencoded\r\n");
|
||||
fprintf(sfp, "Content-Length: %u\r\n" "\r\n" "%s",
|
||||
(int) strlen(estr), estr);
|
||||
/*fprintf(sfp, "Connection: Keep-Alive\r\n\r\n");*/
|
||||
/*fprintf(sfp, "%s\r\n", estr);*/
|
||||
fprintf(sfp,
|
||||
"Content-Type: application/x-www-form-urlencoded\r\n"
|
||||
"Content-Length: %u\r\n"
|
||||
"\r\n"
|
||||
"%s",
|
||||
(int) strlen(estr), estr
|
||||
);
|
||||
free(estr);
|
||||
} else
|
||||
#endif
|
||||
{ /* If "Connection:" is needed, document why */
|
||||
fprintf(sfp, /* "Connection: close\r\n" */ "\r\n");
|
||||
{
|
||||
fprintf(sfp, "\r\n");
|
||||
}
|
||||
|
||||
fflush(sfp);
|
||||
|
||||
+1
-1
@@ -271,7 +271,7 @@ Find processes which use FILEs or PORTs
|
||||
if (sscanf(*pp, "%u/%4s", &port, tproto) != 2)
|
||||
goto file;
|
||||
sprintf(path, "/proc/net/%s", tproto);
|
||||
if (access(path, R_OK) != 0) { /* PORT/PROTO */
|
||||
if (access(path, R_OK) == 0) { /* PORT/PROTO */
|
||||
scan_proc_net(path, port);
|
||||
} else { /* FILE */
|
||||
file:
|
||||
|
||||
+5
-2
@@ -312,8 +312,11 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
last_mtime = s.st_mtime;
|
||||
last_dev = s.st_dev;
|
||||
last_ino = s.st_ino;
|
||||
//if (now <= mtime)
|
||||
// sleep(1);
|
||||
/* if the svdir changed this very second, wait until the
|
||||
* next second, because we won't be able to detect more
|
||||
* changes within this second */
|
||||
while (time(NULL) == last_mtime)
|
||||
usleep(100000);
|
||||
need_rescan = do_rescan();
|
||||
while (fchdir(curdir) == -1) {
|
||||
warn2_cannot("change directory, pausing", "");
|
||||
|
||||
@@ -18,14 +18,14 @@ generate()
|
||||
local src="$1" dst="$2" header="$3" insert="$4"
|
||||
#chk "${dst}"
|
||||
(
|
||||
echo "${header}"
|
||||
printf "%s\n" "${header}"
|
||||
if grep -qs '^INSERT$' "${src}"; then
|
||||
sed -n '1,/^INSERT$/p' "${src}"
|
||||
echo "${insert}"
|
||||
printf "%s\n" "${insert}"
|
||||
sed -n '/^INSERT$/,$p' "${src}"
|
||||
else
|
||||
if [ -n "${insert}" ]; then
|
||||
echo "ERROR: INSERT line missing in: ${src}" 1>&2
|
||||
printf "%s\n" "ERROR: INSERT line missing in: ${src}" 1>&2
|
||||
fi
|
||||
cat "${src}"
|
||||
fi
|
||||
|
||||
@@ -256,7 +256,7 @@ search_help[] = N_(
|
||||
" USB$ => find all CONFIG_ symbols ending with USB\n"
|
||||
"\n");
|
||||
|
||||
static char buf[4096], *bufptr = buf;
|
||||
static char buf[4096*10], *bufptr = buf;
|
||||
static char input_buf[4096];
|
||||
static const char filename[] = ".config";
|
||||
static char *args[1024], **argptr = args;
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ echo "\
|
||||
*/
|
||||
static const char bbconfig_config[] ALIGN1 ="
|
||||
|
||||
grep '^#\? \?CONFIG_' "$config" \
|
||||
grep -e '^# CONFIG_' -e '^CONFIG_' "$config" \
|
||||
| sed -e 's/\"/\\\"/g' -e 's/^/"/' -e 's/$/\\n"/'
|
||||
|
||||
echo ";"
|
||||
@@ -63,7 +63,7 @@ echo "\
|
||||
*/
|
||||
static const char bbconfig_config_bz2[] ALIGN1 = {"
|
||||
|
||||
grep '^#\? \?CONFIG_' "$config" \
|
||||
grep -e '^# CONFIG_' -e '^CONFIG_' "$config" \
|
||||
| bzip2 -1 | dd bs=2 skip=1 2>/dev/null \
|
||||
| od -v -t x1 \
|
||||
| sed -e 's/^[^ ]*//' \
|
||||
|
||||
+147
-96
@@ -427,6 +427,15 @@ enum {
|
||||
/* Used for initialization: o_string foo = NULL_O_STRING; */
|
||||
#define NULL_O_STRING { NULL }
|
||||
|
||||
#ifndef debug_printf_parse
|
||||
static const char *const assignment_flag[] = {
|
||||
"MAYBE_ASSIGNMENT",
|
||||
"DEFINITELY_ASSIGNMENT",
|
||||
"NOT_ASSIGNMENT",
|
||||
"WORD_IS_KEYWORD",
|
||||
};
|
||||
#endif
|
||||
|
||||
/* I can almost use ordinary FILE*. Is open_memstream() universally
|
||||
* available? Where is it documented? */
|
||||
typedef struct in_str {
|
||||
@@ -913,7 +922,7 @@ static const struct built_in_command bltins2[] = {
|
||||
*/
|
||||
#if HUSH_DEBUG
|
||||
/* prevent disasters with G.debug_indent < 0 */
|
||||
# define indent() fprintf(stderr, "%*s", (G.debug_indent * 2) & 0xff, "")
|
||||
# define indent() fdprintf(2, "%*s", (G.debug_indent * 2) & 0xff, "")
|
||||
# define debug_enter() (G.debug_indent++)
|
||||
# define debug_leave() (G.debug_indent--)
|
||||
#else
|
||||
@@ -923,56 +932,56 @@ static const struct built_in_command bltins2[] = {
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf
|
||||
# define debug_printf(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_parse
|
||||
# define debug_printf_parse(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_parse(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_exec
|
||||
#define debug_printf_exec(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
#define debug_printf_exec(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_env
|
||||
# define debug_printf_env(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_env(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_jobs
|
||||
# define debug_printf_jobs(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_jobs(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
# define DEBUG_JOBS 1
|
||||
#else
|
||||
# define DEBUG_JOBS 0
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_expand
|
||||
# define debug_printf_expand(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_expand(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
# define DEBUG_EXPAND 1
|
||||
#else
|
||||
# define DEBUG_EXPAND 0
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_varexp
|
||||
# define debug_printf_varexp(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_varexp(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_glob
|
||||
# define debug_printf_glob(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_glob(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
# define DEBUG_GLOB 1
|
||||
#else
|
||||
# define DEBUG_GLOB 0
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_list
|
||||
# define debug_printf_list(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_list(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_subst
|
||||
# define debug_printf_subst(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_subst(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef debug_printf_clean
|
||||
# define debug_printf_clean(...) (indent(), fprintf(stderr, __VA_ARGS__))
|
||||
# define debug_printf_clean(...) (indent(), fdprintf(2, __VA_ARGS__))
|
||||
# define DEBUG_CLEAN 1
|
||||
#else
|
||||
# define DEBUG_CLEAN 0
|
||||
@@ -982,9 +991,9 @@ static const struct built_in_command bltins2[] = {
|
||||
static void debug_print_strings(const char *prefix, char **vv)
|
||||
{
|
||||
indent();
|
||||
fprintf(stderr, "%s:\n", prefix);
|
||||
fdprintf(2, "%s:\n", prefix);
|
||||
while (*vv)
|
||||
fprintf(stderr, " '%s'\n", *vv++);
|
||||
fdprintf(2, " '%s'\n", *vv++);
|
||||
}
|
||||
#else
|
||||
# define debug_print_strings(prefix, vv) ((void)0)
|
||||
@@ -1416,6 +1425,22 @@ static void hush_exit(int exitcode)
|
||||
builtin_eval(argv);
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
{
|
||||
struct variable *cur_var;
|
||||
if (G.cwd != bb_msg_unknown)
|
||||
free((char*)G.cwd);
|
||||
cur_var = G.top_var;
|
||||
while (cur_var) {
|
||||
struct variable *tmp = cur_var;
|
||||
if (!cur_var->max_len)
|
||||
free(cur_var->varstr);
|
||||
cur_var = cur_var->next;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_HUSH_JOB
|
||||
fflush_all();
|
||||
sigexit(- (exitcode & 0xff));
|
||||
@@ -2158,22 +2183,22 @@ static void debug_print_list(const char *prefix, o_string *o, int n)
|
||||
int i = 0;
|
||||
|
||||
indent();
|
||||
fprintf(stderr, "%s: list:%p n:%d string_start:%d length:%d maxlen:%d glob:%d quoted:%d escape:%d\n",
|
||||
fdprintf(2, "%s: list:%p n:%d string_start:%d length:%d maxlen:%d glob:%d quoted:%d escape:%d\n",
|
||||
prefix, list, n, string_start, o->length, o->maxlen,
|
||||
!!(o->o_expflags & EXP_FLAG_GLOB),
|
||||
o->has_quoted_part,
|
||||
!!(o->o_expflags & EXP_FLAG_ESC_GLOB_CHARS));
|
||||
while (i < n) {
|
||||
indent();
|
||||
fprintf(stderr, " list[%d]=%d '%s' %p\n", i, (int)list[i],
|
||||
o->data + (int)list[i] + string_start,
|
||||
o->data + (int)list[i] + string_start);
|
||||
fdprintf(2, " list[%d]=%d '%s' %p\n", i, (int)(uintptr_t)list[i],
|
||||
o->data + (int)(uintptr_t)list[i] + string_start,
|
||||
o->data + (int)(uintptr_t)list[i] + string_start);
|
||||
i++;
|
||||
}
|
||||
if (n) {
|
||||
const char *p = o->data + (int)list[n - 1] + string_start;
|
||||
const char *p = o->data + (int)(uintptr_t)list[n - 1] + string_start;
|
||||
indent();
|
||||
fprintf(stderr, " total_sz:%ld\n", (long)((p + strlen(p) + 1) - o->data));
|
||||
fdprintf(2, " total_sz:%ld\n", (long)((p + strlen(p) + 1) - o->data));
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -2672,18 +2697,18 @@ static void debug_print_tree(struct pipe *pi, int lvl)
|
||||
|
||||
pin = 0;
|
||||
while (pi) {
|
||||
fprintf(stderr, "%*spipe %d res_word=%s followup=%d %s\n", lvl*2, "",
|
||||
fdprintf(2, "%*spipe %d res_word=%s followup=%d %s\n", lvl*2, "",
|
||||
pin, RES[pi->res_word], pi->followup, PIPE[pi->followup]);
|
||||
prn = 0;
|
||||
while (prn < pi->num_cmds) {
|
||||
struct command *command = &pi->cmds[prn];
|
||||
char **argv = command->argv;
|
||||
|
||||
fprintf(stderr, "%*s cmd %d assignment_cnt:%d",
|
||||
fdprintf(2, "%*s cmd %d assignment_cnt:%d",
|
||||
lvl*2, "", prn,
|
||||
command->assignment_cnt);
|
||||
if (command->group) {
|
||||
fprintf(stderr, " group %s: (argv=%p)%s%s\n",
|
||||
fdprintf(2, " group %s: (argv=%p)%s%s\n",
|
||||
CMDTYPE[command->cmd_type],
|
||||
argv
|
||||
# if !BB_MMU
|
||||
@@ -2697,10 +2722,10 @@ static void debug_print_tree(struct pipe *pi, int lvl)
|
||||
continue;
|
||||
}
|
||||
if (argv) while (*argv) {
|
||||
fprintf(stderr, " '%s'", *argv);
|
||||
fdprintf(2, " '%s'", *argv);
|
||||
argv++;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
fdprintf(2, "\n");
|
||||
prn++;
|
||||
}
|
||||
pi = pi->next;
|
||||
@@ -2869,24 +2894,24 @@ static const struct reserved_combo* match_reserved_word(o_string *word)
|
||||
*/
|
||||
static const struct reserved_combo reserved_list[] = {
|
||||
# if ENABLE_HUSH_IF
|
||||
{ "!", RES_NONE, NOT_ASSIGNMENT , 0 },
|
||||
{ "if", RES_IF, WORD_IS_KEYWORD, FLAG_THEN | FLAG_START },
|
||||
{ "then", RES_THEN, WORD_IS_KEYWORD, FLAG_ELIF | FLAG_ELSE | FLAG_FI },
|
||||
{ "elif", RES_ELIF, WORD_IS_KEYWORD, FLAG_THEN },
|
||||
{ "else", RES_ELSE, WORD_IS_KEYWORD, FLAG_FI },
|
||||
{ "fi", RES_FI, NOT_ASSIGNMENT , FLAG_END },
|
||||
{ "!", RES_NONE, NOT_ASSIGNMENT , 0 },
|
||||
{ "if", RES_IF, MAYBE_ASSIGNMENT, FLAG_THEN | FLAG_START },
|
||||
{ "then", RES_THEN, MAYBE_ASSIGNMENT, FLAG_ELIF | FLAG_ELSE | FLAG_FI },
|
||||
{ "elif", RES_ELIF, MAYBE_ASSIGNMENT, FLAG_THEN },
|
||||
{ "else", RES_ELSE, MAYBE_ASSIGNMENT, FLAG_FI },
|
||||
{ "fi", RES_FI, NOT_ASSIGNMENT , FLAG_END },
|
||||
# endif
|
||||
# if ENABLE_HUSH_LOOPS
|
||||
{ "for", RES_FOR, NOT_ASSIGNMENT , FLAG_IN | FLAG_DO | FLAG_START },
|
||||
{ "while", RES_WHILE, WORD_IS_KEYWORD, FLAG_DO | FLAG_START },
|
||||
{ "until", RES_UNTIL, WORD_IS_KEYWORD, FLAG_DO | FLAG_START },
|
||||
{ "in", RES_IN, NOT_ASSIGNMENT , FLAG_DO },
|
||||
{ "do", RES_DO, WORD_IS_KEYWORD, FLAG_DONE },
|
||||
{ "done", RES_DONE, NOT_ASSIGNMENT , FLAG_END },
|
||||
{ "for", RES_FOR, NOT_ASSIGNMENT , FLAG_IN | FLAG_DO | FLAG_START },
|
||||
{ "while", RES_WHILE, MAYBE_ASSIGNMENT, FLAG_DO | FLAG_START },
|
||||
{ "until", RES_UNTIL, MAYBE_ASSIGNMENT, FLAG_DO | FLAG_START },
|
||||
{ "in", RES_IN, NOT_ASSIGNMENT , FLAG_DO },
|
||||
{ "do", RES_DO, MAYBE_ASSIGNMENT, FLAG_DONE },
|
||||
{ "done", RES_DONE, NOT_ASSIGNMENT , FLAG_END },
|
||||
# endif
|
||||
# if ENABLE_HUSH_CASE
|
||||
{ "case", RES_CASE, NOT_ASSIGNMENT , FLAG_MATCH | FLAG_START },
|
||||
{ "esac", RES_ESAC, NOT_ASSIGNMENT , FLAG_END },
|
||||
{ "case", RES_CASE, NOT_ASSIGNMENT , FLAG_MATCH | FLAG_START },
|
||||
{ "esac", RES_ESAC, NOT_ASSIGNMENT , FLAG_END },
|
||||
# endif
|
||||
};
|
||||
const struct reserved_combo *r;
|
||||
@@ -2952,6 +2977,7 @@ static int reserved_word(o_string *word, struct parse_context *ctx)
|
||||
ctx->ctx_res_w = r->res;
|
||||
ctx->old_flag = r->flag;
|
||||
word->o_assignment = r->assignment_flag;
|
||||
debug_printf_parse("word->o_assignment='%s'\n", assignment_flag[word->o_assignment]);
|
||||
|
||||
if (ctx->old_flag & FLAG_END) {
|
||||
struct parse_context *old;
|
||||
@@ -3018,18 +3044,6 @@ static int done_word(o_string *word, struct parse_context *ctx)
|
||||
debug_printf_parse("word stored in rd_filename: '%s'\n", word->data);
|
||||
ctx->pending_redirect = NULL;
|
||||
} else {
|
||||
/* If this word wasn't an assignment, next ones definitely
|
||||
* can't be assignments. Even if they look like ones. */
|
||||
if (word->o_assignment != DEFINITELY_ASSIGNMENT
|
||||
&& word->o_assignment != WORD_IS_KEYWORD
|
||||
) {
|
||||
word->o_assignment = NOT_ASSIGNMENT;
|
||||
} else {
|
||||
if (word->o_assignment == DEFINITELY_ASSIGNMENT)
|
||||
command->assignment_cnt++;
|
||||
word->o_assignment = MAYBE_ASSIGNMENT;
|
||||
}
|
||||
|
||||
#if HAS_KEYWORDS
|
||||
# if ENABLE_HUSH_CASE
|
||||
if (ctx->ctx_dsemicolon
|
||||
@@ -3049,8 +3063,9 @@ static int done_word(o_string *word, struct parse_context *ctx)
|
||||
&& ctx->ctx_res_w != RES_CASE
|
||||
# endif
|
||||
) {
|
||||
debug_printf_parse("checking '%s' for reserved-ness\n", word->data);
|
||||
if (reserved_word(word, ctx)) {
|
||||
int reserved = reserved_word(word, ctx);
|
||||
debug_printf_parse("checking for reserved-ness: %d\n", reserved);
|
||||
if (reserved) {
|
||||
o_reset_to_empty_unquoted(word);
|
||||
debug_printf_parse("done_word return %d\n",
|
||||
(ctx->ctx_res_w == RES_SNTX));
|
||||
@@ -3071,6 +3086,23 @@ static int done_word(o_string *word, struct parse_context *ctx)
|
||||
"groups and arglists don't mix\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If this word wasn't an assignment, next ones definitely
|
||||
* can't be assignments. Even if they look like ones. */
|
||||
if (word->o_assignment != DEFINITELY_ASSIGNMENT
|
||||
&& word->o_assignment != WORD_IS_KEYWORD
|
||||
) {
|
||||
word->o_assignment = NOT_ASSIGNMENT;
|
||||
} else {
|
||||
if (word->o_assignment == DEFINITELY_ASSIGNMENT) {
|
||||
command->assignment_cnt++;
|
||||
debug_printf_parse("++assignment_cnt=%d\n", command->assignment_cnt);
|
||||
}
|
||||
debug_printf_parse("word->o_assignment was:'%s'\n", assignment_flag[word->o_assignment]);
|
||||
word->o_assignment = MAYBE_ASSIGNMENT;
|
||||
}
|
||||
debug_printf_parse("word->o_assignment='%s'\n", assignment_flag[word->o_assignment]);
|
||||
|
||||
if (word->has_quoted_part
|
||||
/* optimization: and if it's ("" or '') or ($v... or `cmd`...): */
|
||||
&& (word->data[0] == '\0' || word->data[0] == SPECIAL_VAR_SYMBOL)
|
||||
@@ -4089,6 +4121,7 @@ static struct pipe *parse_stream(char **pstring,
|
||||
&& is_well_formed_var_name(dest.data, '=')
|
||||
) {
|
||||
dest.o_assignment = DEFINITELY_ASSIGNMENT;
|
||||
debug_printf_parse("dest.o_assignment='%s'\n", assignment_flag[dest.o_assignment]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -4106,7 +4139,27 @@ 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 check #1, interactive shell
|
||||
* ignores even bare <newline>,
|
||||
* and shows the continuation prompt:
|
||||
* ps1_prompt$ <enter>
|
||||
* ps2> _ <=== wrong, should be ps1
|
||||
* Without check #2, "cmd & <newline>"
|
||||
* is similarly mistreated.
|
||||
* (BTW, this makes "cmd & cmd"
|
||||
* and "cmd && cmd" non-orthogonal.
|
||||
* Really, ask yourself, why
|
||||
* "cmd && <newline>" doesn't start
|
||||
* cmd but waits for more input?
|
||||
* No reason...)
|
||||
*/
|
||||
struct pipe *pi = ctx.list_head;
|
||||
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);
|
||||
@@ -4118,6 +4171,7 @@ static struct pipe *parse_stream(char **pstring,
|
||||
heredoc_cnt = 0;
|
||||
}
|
||||
dest.o_assignment = MAYBE_ASSIGNMENT;
|
||||
debug_printf_parse("dest.o_assignment='%s'\n", assignment_flag[dest.o_assignment]);
|
||||
ch = ';';
|
||||
/* note: if (is_blank) continue;
|
||||
* will still trigger for us */
|
||||
@@ -4167,6 +4221,7 @@ static struct pipe *parse_stream(char **pstring,
|
||||
}
|
||||
done_pipe(&ctx, PIPE_SEQ);
|
||||
dest.o_assignment = MAYBE_ASSIGNMENT;
|
||||
debug_printf_parse("dest.o_assignment='%s'\n", assignment_flag[dest.o_assignment]);
|
||||
/* Do we sit outside of any if's, loops or case's? */
|
||||
if (!HAS_KEYWORDS
|
||||
IF_HAS_KEYWORDS(|| (ctx.ctx_res_w == RES_NONE && ctx.old_flag == 0))
|
||||
@@ -4273,6 +4328,7 @@ static struct pipe *parse_stream(char **pstring,
|
||||
/* ch is a special char and thus this word
|
||||
* cannot be an assignment */
|
||||
dest.o_assignment = NOT_ASSIGNMENT;
|
||||
debug_printf_parse("dest.o_assignment='%s'\n", assignment_flag[dest.o_assignment]);
|
||||
}
|
||||
|
||||
/* Note: nommu_addchr(&ctx.as_string, ch) is already done */
|
||||
@@ -4370,6 +4426,7 @@ static struct pipe *parse_stream(char **pstring,
|
||||
/* We just finished a cmd. New one may start
|
||||
* with an assignment */
|
||||
dest.o_assignment = MAYBE_ASSIGNMENT;
|
||||
debug_printf_parse("dest.o_assignment='%s'\n", assignment_flag[dest.o_assignment]);
|
||||
break;
|
||||
case '&':
|
||||
if (done_word(&dest, &ctx)) {
|
||||
@@ -6995,27 +7052,30 @@ static int run_list(struct pipe *pi)
|
||||
|
||||
#if ENABLE_HUSH_LOOPS
|
||||
/* Check syntax for "for" */
|
||||
for (struct pipe *cpipe = pi; cpipe; cpipe = cpipe->next) {
|
||||
if (cpipe->res_word != RES_FOR && cpipe->res_word != RES_IN)
|
||||
continue;
|
||||
/* current word is FOR or IN (BOLD in comments below) */
|
||||
if (cpipe->next == NULL) {
|
||||
syntax_error("malformed for");
|
||||
debug_leave();
|
||||
debug_printf_exec("run_list lvl %d return 1\n", G.run_list_level);
|
||||
return 1;
|
||||
}
|
||||
/* "FOR v; do ..." and "for v IN a b; do..." are ok */
|
||||
if (cpipe->next->res_word == RES_DO)
|
||||
continue;
|
||||
/* next word is not "do". It must be "in" then ("FOR v in ...") */
|
||||
if (cpipe->res_word == RES_IN /* "for v IN a b; not_do..."? */
|
||||
|| cpipe->next->res_word != RES_IN /* FOR v not_do_and_not_in..."? */
|
||||
) {
|
||||
syntax_error("malformed for");
|
||||
debug_leave();
|
||||
debug_printf_exec("run_list lvl %d return 1\n", G.run_list_level);
|
||||
return 1;
|
||||
{
|
||||
struct pipe *cpipe;
|
||||
for (cpipe = pi; cpipe; cpipe = cpipe->next) {
|
||||
if (cpipe->res_word != RES_FOR && cpipe->res_word != RES_IN)
|
||||
continue;
|
||||
/* current word is FOR or IN (BOLD in comments below) */
|
||||
if (cpipe->next == NULL) {
|
||||
syntax_error("malformed for");
|
||||
debug_leave();
|
||||
debug_printf_exec("run_list lvl %d return 1\n", G.run_list_level);
|
||||
return 1;
|
||||
}
|
||||
/* "FOR v; do ..." and "for v IN a b; do..." are ok */
|
||||
if (cpipe->next->res_word == RES_DO)
|
||||
continue;
|
||||
/* next word is not "do". It must be "in" then ("FOR v in ...") */
|
||||
if (cpipe->res_word == RES_IN /* "for v IN a b; not_do..."? */
|
||||
|| cpipe->next->res_word != RES_IN /* FOR v not_do_and_not_in..."? */
|
||||
) {
|
||||
syntax_error("malformed for");
|
||||
debug_leave();
|
||||
debug_printf_exec("run_list lvl %d return 1\n", G.run_list_level);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -7253,7 +7313,10 @@ static int run_list(struct pipe *pi)
|
||||
#endif
|
||||
#if ENABLE_HUSH_LOOPS
|
||||
/* Beware of "while false; true; do ..."! */
|
||||
if (pi->next && pi->next->res_word == RES_DO) {
|
||||
if (pi->next
|
||||
&& (pi->next->res_word == RES_DO || pi->next->res_word == RES_DONE)
|
||||
/* (the second check above is needed for "while ...; do \n done" case) */
|
||||
) {
|
||||
if (rword == RES_WHILE) {
|
||||
if (rcode) {
|
||||
/* "while false; do...done" - exitcode 0 */
|
||||
@@ -7442,7 +7505,7 @@ int hush_main(int argc, char **argv)
|
||||
unsigned builtin_argc;
|
||||
char **e;
|
||||
struct variable *cur_var;
|
||||
struct variable shell_ver;
|
||||
struct variable *shell_ver;
|
||||
|
||||
INIT_G();
|
||||
if (EXIT_SUCCESS) /* if EXIT_SUCCESS == 0, it is already done */
|
||||
@@ -7451,17 +7514,17 @@ int hush_main(int argc, char **argv)
|
||||
G.argv0_for_re_execing = argv[0];
|
||||
#endif
|
||||
/* Deal with HUSH_VERSION */
|
||||
memset(&shell_ver, 0, sizeof(shell_ver));
|
||||
shell_ver.flg_export = 1;
|
||||
shell_ver.flg_read_only = 1;
|
||||
shell_ver = xzalloc(sizeof(*shell_ver));
|
||||
shell_ver->flg_export = 1;
|
||||
shell_ver->flg_read_only = 1;
|
||||
/* Code which handles ${var<op>...} needs writable values for all variables,
|
||||
* therefore we xstrdup: */
|
||||
shell_ver.varstr = xstrdup(hush_version_str),
|
||||
G.top_var = &shell_ver;
|
||||
shell_ver->varstr = xstrdup(hush_version_str);
|
||||
/* Create shell local variables from the values
|
||||
* currently living in the environment */
|
||||
debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION");
|
||||
unsetenv("HUSH_VERSION"); /* in case it exists in initial env */
|
||||
G.top_var = shell_ver;
|
||||
cur_var = G.top_var;
|
||||
e = environ;
|
||||
if (e) while (*e) {
|
||||
@@ -7476,8 +7539,8 @@ int hush_main(int argc, char **argv)
|
||||
e++;
|
||||
}
|
||||
/* (Re)insert HUSH_VERSION into env (AFTER we scanned the env!) */
|
||||
debug_printf_env("putenv '%s'\n", shell_ver.varstr);
|
||||
putenv(shell_ver.varstr);
|
||||
debug_printf_env("putenv '%s'\n", shell_ver->varstr);
|
||||
putenv(shell_ver->varstr);
|
||||
|
||||
/* Export PWD */
|
||||
set_pwd_var(/*exp:*/ 1);
|
||||
@@ -7837,18 +7900,6 @@ int hush_main(int argc, char **argv)
|
||||
parse_and_run_file(stdin);
|
||||
|
||||
final_return:
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
if (G.cwd != bb_msg_unknown)
|
||||
free((char*)G.cwd);
|
||||
cur_var = G.top_var->next;
|
||||
while (cur_var) {
|
||||
struct variable *tmp = cur_var;
|
||||
if (!cur_var->max_len)
|
||||
free(cur_var->varstr);
|
||||
cur_var = cur_var->next;
|
||||
free(tmp);
|
||||
}
|
||||
#endif
|
||||
hush_exit(G.last_exitcode);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
OK:0
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
while false; do
|
||||
# bash will require at least ":" here...
|
||||
done
|
||||
echo OK:$?
|
||||
+30
-1
@@ -150,12 +150,41 @@ int klogd_main(int argc UNUSED_PARAM, char **argv)
|
||||
*/
|
||||
klogd_open();
|
||||
openlog("kernel", 0, LOG_KERN);
|
||||
/*
|
||||
* glibc problem: for some reason, glibc changes LOG_KERN to LOG_USER
|
||||
* above. The logic behind this is that standard
|
||||
* http://pubs.opengroup.org/onlinepubs/9699919799/functions/syslog.html
|
||||
* says the following about openlog and syslog:
|
||||
* "LOG_USER
|
||||
* Messages generated by arbitrary processes.
|
||||
* This is the default facility identifier if none is specified."
|
||||
*
|
||||
* I believe glibc misinterpreted this text as "if openlog's
|
||||
* third parameter is 0 (=LOG_KERN), treat it as LOG_USER".
|
||||
* Whereas it was meant to say "if *syslog* is called with facility
|
||||
* 0 in its 1st parameter without prior call to openlog, then perform
|
||||
* implicit openlog(LOG_USER)".
|
||||
*
|
||||
* As a result of this, eh, feature, standard klogd was forced
|
||||
* to open-code its own openlog and syslog implementation (!).
|
||||
*
|
||||
* Note that prohibiting openlog(LOG_KERN) on libc level does not
|
||||
* add any security: any process can open a socket to "/dev/log"
|
||||
* and write a string "<0>Voila, a LOG_KERN + LOG_EMERG message"
|
||||
*
|
||||
* Google code search tells me there is no widespread use of
|
||||
* openlog("foo", 0, 0), thus fixing glibc won't break userspace.
|
||||
*
|
||||
* The bug against glibc was filed:
|
||||
* bugzilla.redhat.com/show_bug.cgi?id=547000
|
||||
*/
|
||||
|
||||
if (i)
|
||||
klogd_setloglevel(i);
|
||||
|
||||
bb_signals(BB_FATAL_SIGS, record_signo);
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
/* We want klogd_read to not be restarted, thus _norestart: */
|
||||
bb_signals_recursive_norestart(BB_FATAL_SIGS, record_signo);
|
||||
|
||||
syslog(LOG_NOTICE, "klogd started: %s", bb_banner);
|
||||
|
||||
|
||||
@@ -354,7 +354,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
|
||||
@@ -364,7 +363,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.
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user