From ab518eea9c41235a3fcde80f3ea99669eaade621 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 16 Mar 2017 16:49:37 +0100 Subject: mount: create loop devices with LO_FLAGS_AUTOCLEAR flag The "autolooped" mount (mount [-oloop] IMAGE /DIR/DIR) always creates AUTOCLEARed loopdevs, so that umounting drops them (and this does not require any code in the umount userspace). This happens since circa linux-2.6.25: commit 96c5865559cee0f9cbc5173f3c949f6ce3525581 Date: Wed Feb 6 01:36:27 2008 -0800 Subject: Allow auto-destruction of loop devices IOW: in this case, umount does not have to use -d to drop the loopdev. The explicit loop mount (mount /dev/loopN /DIR/DIR) does not do this. In this case, umount without -d should not drop loopdev. Unfortunately, bbox umount currently always implies -d, this probably needs fixing. function old new delta set_loop 537 597 +60 singlemount 1101 1138 +37 losetup_main 419 432 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 110/0) Total: 110 bytes Signed-off-by: Denys Vlasenko --- libbb/loop.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'libbb') diff --git a/libbb/loop.c b/libbb/loop.c index d30b378d7..f0d4296ae 100644 --- a/libbb/loop.c +++ b/libbb/loop.c @@ -78,22 +78,24 @@ int FAST_FUNC del_loop(const char *device) return rc; } -/* Returns 0 if mounted RW, 1 if mounted read-only, <0 for error. - *device is loop device to use, or if *device==NULL finds a loop device to - mount it on and sets *device to a strdup of that loop device name. This - search will re-use an existing loop device already bound to that - file/offset if it finds one. +/* Returns opened fd to the loop device, <0 on error. + * *device is loop device to use, or if *device==NULL finds a loop device to + * mount it on and sets *device to a strdup of that loop device name. This + * search will re-use an existing loop device already bound to that + * file/offset if it finds one. */ -int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offset, int ro) +int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offset, unsigned flags) { char dev[LOOP_NAMESIZE]; char *try; bb_loop_info loopinfo; struct stat statbuf; - int i, dfd, ffd, mode, rc = -1; + int i, dfd, ffd, mode, rc; + + rc = dfd = -1; /* Open the file. Barf if this doesn't work. */ - mode = ro ? O_RDONLY : O_RDWR; + mode = (flags & BB_LO_FLAGS_READ_ONLY) ? O_RDONLY : O_RDWR; open_ffd: ffd = open(file, mode); if (ffd < 0) { @@ -144,20 +146,35 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse /* If device is free, claim it. */ if (rc && errno == ENXIO) { - memset(&loopinfo, 0, sizeof(loopinfo)); - safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE); - loopinfo.lo_offset = offset; /* Associate free loop device with file. */ if (ioctl(dfd, LOOP_SET_FD, ffd) == 0) { - if (ioctl(dfd, BB_LOOP_SET_STATUS, &loopinfo) == 0) - rc = 0; - else + memset(&loopinfo, 0, sizeof(loopinfo)); + safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE); + loopinfo.lo_offset = offset; + /* + * Used by mount to set LO_FLAGS_AUTOCLEAR. + * LO_FLAGS_READ_ONLY is not set because RO is controlled by open type of the file. + * Note that closing LO_FLAGS_AUTOCLEARed dfd before mount + * is wrong (would free the loop device!) + */ + loopinfo.lo_flags = (flags & ~BB_LO_FLAGS_READ_ONLY); + rc = ioctl(dfd, BB_LOOP_SET_STATUS, &loopinfo); + if (rc != 0 && (loopinfo.lo_flags & BB_LO_FLAGS_AUTOCLEAR)) { + /* Old kernel, does not support LO_FLAGS_AUTOCLEAR? */ + /* (this code path is not tested) */ + loopinfo.lo_flags -= BB_LO_FLAGS_AUTOCLEAR; + rc = ioctl(dfd, BB_LOOP_SET_STATUS, &loopinfo); + } + if (rc != 0) { ioctl(dfd, LOOP_CLR_FD, 0); + } } } else { rc = -1; } - close(dfd); + if (rc != 0) { + close(dfd); + } try_again: if (*device) break; } @@ -165,7 +182,7 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse if (rc == 0) { if (!*device) *device = xstrdup(dev); - return (mode == O_RDONLY); /* 1:ro, 0:rw */ + return dfd; } return rc; } -- cgit v1.2.3-55-g6feb From 4f0b540d08f5912b273c427218cc665512b12de5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 6 Apr 2017 15:22:24 +0200 Subject: modprobe: do not descend into /etc/modprobe.d/DIR/. Closes 8686 Also expanded comments in recursive_action.c Signed-off-by: Denys Vlasenko --- libbb/recursive_action.c | 46 +++++++++++++++++++++++++++++----------------- modutils/modprobe.c | 9 +++++++++ 2 files changed, 38 insertions(+), 17 deletions(-) (limited to 'libbb') diff --git a/libbb/recursive_action.c b/libbb/recursive_action.c index b5cf7c0ab..8f2b8b932 100644 --- a/libbb/recursive_action.c +++ b/libbb/recursive_action.c @@ -30,24 +30,37 @@ static int FAST_FUNC true_action(const char *fileName UNUSED_PARAM, return TRUE; } -/* fileAction return value of 0 on any file in directory will make - * recursive_action() return 0, but it doesn't stop directory traversal +/* fileName is (l)stat'ed (depending on ACTION_FOLLOWLINKS[_L0]). + * + * If it is a file: fileAction in run on it, its return value is returned. + * + * In case we are in a recursive invocation (see below): + * normally, fileAction should return 1 (TRUE) to indicate that + * everything is okay and processing should continue. + * fileAction return value of 0 (FALSE) on any file in directory will make + * recursive_action() also return 0, but it doesn't stop directory traversal * (fileAction/dirAction will be called on each file). * - * If !ACTION_RECURSE, dirAction is called on the directory and its + * [TODO: maybe introduce -1 to mean "stop traversal NOW and return"] + * + * If it is a directory: + * + * If !ACTION_RECURSE, dirAction is called and its * return value is returned from recursive_action(). No recursion. * - * If ACTION_RECURSE, recursive_action() is called on each directory. + * If ACTION_RECURSE, directory is opened, and recursive_action() is called + * on each file/subdirectory. * If any one of these calls returns 0, current recursive_action() returns 0. * + * If !ACTION_DEPTHFIRST, dirAction is called before recurse. + * Return value of 0 (FALSE) is an error: prevents recursion, + * the warning is printed (unless ACTION_QUIET) and recursive_action() returns 0. + * Return value of 2 (SKIP) prevents recursion, instead recursive_action() + * returns 1 (TRUE, no error). + * * If ACTION_DEPTHFIRST, dirAction is called after recurse. * If it returns 0, the warning is printed and recursive_action() returns 0. * - * If !ACTION_DEPTHFIRST, dirAction is called before we recurse. - * Return value of 0 (FALSE) or 2 (SKIP) prevents recursion - * into that directory, instead recursive_action() returns 0 (if FALSE) - * or 1 (if SKIP) - * * ACTION_FOLLOWLINKS mainly controls handling of links to dirs. * 0: lstat(statbuf). Calls fileAction on link name even if points to dir. * 1: stat(statbuf). Calls dirAction and optionally recurse on link to dir. @@ -105,7 +118,7 @@ int FAST_FUNC recursive_action(const char *fileName, if (!(flags & ACTION_DEPTHFIRST)) { status = dirAction(fileName, &statbuf, userData, depth); - if (!status) + if (status == FALSE) goto done_nak_warn; if (status == SKIP) return TRUE; @@ -121,24 +134,23 @@ int FAST_FUNC recursive_action(const char *fileName, status = TRUE; while ((next = readdir(dir)) != NULL) { char *nextFile; + int s; nextFile = concat_subpath_file(fileName, next->d_name); if (nextFile == NULL) continue; + /* process every file (NB: ACTION_RECURSE is set in flags) */ - if (!recursive_action(nextFile, flags, fileAction, dirAction, - userData, depth + 1)) + s = recursive_action(nextFile, flags, fileAction, dirAction, + userData, depth + 1); + if (s == FALSE) status = FALSE; -// s = recursive_action(nextFile, flags, fileAction, dirAction, -// userData, depth + 1); free(nextFile); -//#define RECURSE_RESULT_ABORT 3 +//#define RECURSE_RESULT_ABORT -1 // if (s == RECURSE_RESULT_ABORT) { // closedir(dir); // return s; // } -// if (s == FALSE) -// status = FALSE; } closedir(dir); diff --git a/modutils/modprobe.c b/modutils/modprobe.c index c82eaa8d8..51ede9204 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -252,6 +252,15 @@ static int FAST_FUNC config_file_action(const char *filename, if (base[0] == '.') goto error; + /* "man modprobe.d" from kmod version 22 suggests + * that we shouldn't recurse into /etc/modprobe.d/dir/ + * _subdirectories_: + */ + if (depth > 1) + return SKIP; /* stop recursing */ +//TODO: instead, can use dirAction in recursive_action() to SKIP dirs +//on depth == 1 level. But that's more code... + /* In dir recursion, skip files that do not end with a ".conf" * depth==0: read_config("modules.{symbols,alias}") must work, * "include FILE_NOT_ENDING_IN_CONF" must work too. -- cgit v1.2.3-55-g6feb From 8a134ec68075fc2fd415558bcf6a37cda3ff285f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 11 Apr 2017 07:34:56 +0200 Subject: libbb: move isqrt from factor, use it in diff too Signed-off-by: Denys Vlasenko --- coreutils/factor.c | 19 +---------------- editors/diff.c | 11 ---------- include/libbb.h | 2 ++ libbb/isqrt.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 29 deletions(-) create mode 100644 libbb/isqrt.c (limited to 'libbb') diff --git a/coreutils/factor.c b/coreutils/factor.c index f910fdb44..11cc04f92 100644 --- a/coreutils/factor.c +++ b/coreutils/factor.c @@ -44,24 +44,7 @@ typedef unsigned long half_t; #error Cant find an integer type which is half as wide as ullong #endif -/* Returns such x that x+1 > sqrt(N) */ -static inline half_t isqrt(wide_t N) -{ - half_t x; - unsigned shift; - - shift = WIDE_BITS - 2; - x = 0; - do { - x = (x << 1) + 1; - if ((wide_t)x * x > (N >> shift)) - x--; /* whoops, that +1 was too much */ - shift -= 2; - } while ((int)shift >= 0); - return x; -} - -static NOINLINE half_t isqrt_odd(wide_t N) +static half_t isqrt_odd(wide_t N) { half_t s = isqrt(N); /* Subtract 1 from even s, odd s won't change: */ diff --git a/editors/diff.c b/editors/diff.c index 0eb825cfb..3304edb26 100644 --- a/editors/diff.c +++ b/editors/diff.c @@ -295,17 +295,6 @@ static int search(const int *c, int k, int y, const struct cand *list) } } -static unsigned isqrt(unsigned n) -{ - unsigned x = 1; - while (1) { - const unsigned y = x; - x = ((n / x) + x) >> 1; - if (x <= (y + 1) && x >= (y - 1)) - return x; - } -} - static void stone(const int *a, int n, const int *b, int *J, int pref) { const unsigned isq = isqrt(n); diff --git a/include/libbb.h b/include/libbb.h index a2c699b54..04071639a 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -342,6 +342,8 @@ extern int *const bb_errno; uint64_t bb_bswap_64(uint64_t x) FAST_FUNC; #endif +unsigned long FAST_FUNC isqrt(unsigned long long N); + unsigned long long monotonic_ns(void) FAST_FUNC; unsigned long long monotonic_us(void) FAST_FUNC; unsigned long long monotonic_ms(void) FAST_FUNC; diff --git a/libbb/isqrt.c b/libbb/isqrt.c new file mode 100644 index 000000000..817b7d036 --- /dev/null +++ b/libbb/isqrt.c @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2017 Denys Vlasenko + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ + +//kbuild:lib-y += isqrt.o + +#ifndef ISQRT_TEST +# include "libbb.h" +#else +/* gcc -DISQRT_TEST -Wall -O2 isqrt.c -oisqrt && ./isqrt $((RANDOM*RANDOM)) */ +# include +# include +# include +# define FAST_FUNC /* nothing */ +#endif + +/* Returns such x that x+1 > sqrt(N) */ +unsigned long FAST_FUNC isqrt(unsigned long long N) +{ + unsigned long x; + unsigned shift; +#define LL_WIDTH_BITS (unsigned)(sizeof(N)*8) + + shift = LL_WIDTH_BITS - 2; + x = 0; + do { + x = (x << 1) + 1; + if ((unsigned long long)x * x > (N >> shift)) + x--; /* whoops, that +1 was too much */ + shift -= 2; + } while ((int)shift >= 0); + return x; +} + +#ifdef ISQRT_TEST +int main(int argc, char **argv) +{ + unsigned long long n = argv[1] ? strtoull(argv[1], NULL, 0) : time(NULL); + for (;;) { + unsigned long h; + n--; + h = isqrt(n); + if (!(n & 0xffff)) + printf("isqrt(%llx)=%lx\n", n, h); + if ((unsigned long long)h * h > n) { + printf("BAD1: isqrt(%llx)=%lx\n", n, h); + return 1; + } + h++; + if ((unsigned long long)h * h != 0 /* this can overflow to 0 - not a bug */ + && (unsigned long long)h * h <= n) + { + printf("BAD2: isqrt(%llx)=%lx\n", n, h); + return 1; + } + } +} +#endif -- cgit v1.2.3-55-g6feb From d9eb40c18519d10aac3b3d008aa7e338ae830b72 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 12 Apr 2017 15:48:19 +0200 Subject: fix errors found with make_single_applets.sh Signed-off-by: Denys Vlasenko --- coreutils/cat.c | 27 --------------------------- coreutils/who.c | 5 +++-- include/libbb.h | 2 +- libbb/bb_cat.c | 33 +++++++++++++++++++++++++++++++++ libbb/print_numbered_lines.c | 29 +++++++++++++++++++++++++++++ procps/kill.c | 10 +++++----- 6 files changed, 71 insertions(+), 35 deletions(-) create mode 100644 libbb/bb_cat.c create mode 100644 libbb/print_numbered_lines.c (limited to 'libbb') diff --git a/coreutils/cat.c b/coreutils/cat.c index 4169d9516..96970b19d 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c @@ -16,8 +16,6 @@ //applet:IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat)) //kbuild:lib-$(CONFIG_CAT) += cat.o -// For -n: -//kbuild:lib-$(CONFIG_CAT) += nl.o /* BB_AUDIT SUSv3 compliant */ /* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */ @@ -49,31 +47,6 @@ /* This is a NOFORK applet. Be very careful! */ - -int bb_cat(char **argv) -{ - int fd; - int retval = EXIT_SUCCESS; - - if (!*argv) - argv = (char**) &bb_argv_dash; - - do { - fd = open_or_warn_stdin(*argv); - if (fd >= 0) { - /* This is not a xfunc - never exits */ - off_t r = bb_copyfd_eof(fd, STDOUT_FILENO); - if (fd != STDIN_FILENO) - close(fd); - if (r >= 0) - continue; - } - retval = EXIT_FAILURE; - } while (*++argv); - - return retval; -} - int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int cat_main(int argc UNUSED_PARAM, char **argv) { diff --git a/coreutils/who.c b/coreutils/who.c index ec9d25159..4adead77e 100644 --- a/coreutils/who.c +++ b/coreutils/who.c @@ -40,11 +40,12 @@ // APPLET_ODDNAME:name main location suid_type help //applet:IF_USERS(APPLET_ODDNAME(users, who, BB_DIR_USR_BIN, BB_SUID_DROP, users)) -//applet:IF_USERS(APPLET_ODDNAME(w, who, BB_DIR_USR_BIN, BB_SUID_DROP, w)) +//applet:IF_W( APPLET_ODDNAME(w, who, BB_DIR_USR_BIN, BB_SUID_DROP, w)) //applet:IF_WHO( APPLET( who, BB_DIR_USR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_USERS) += who.o -//kbuild:lib-$(CONFIG_WHO) += who.o +//kbuild:lib-$(CONFIG_W) += who.o +//kbuild:lib-$(CONFIG_WHO) += who.o /* BB_AUDIT SUSv3 _NOT_ compliant -- missing options -b, -d, -l, -m, -p, -q, -r, -s, -t, -T, -u; Missing argument 'file'. */ diff --git a/include/libbb.h b/include/libbb.h index 04071639a..2c30bde6f 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1247,7 +1247,7 @@ extern void bb_logenv_override(void) FAST_FUNC; /* Applets which are useful from another applets */ -int bb_cat(char** argv); +int bb_cat(char** argv) FAST_FUNC; /* If shell needs them, they exist even if not enabled as applets */ int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); diff --git a/libbb/bb_cat.c b/libbb/bb_cat.c new file mode 100644 index 000000000..0a4a350fb --- /dev/null +++ b/libbb/bb_cat.c @@ -0,0 +1,33 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright (C) 2003 Manuel Novoa III + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ +//kbuild:lib-y += bb_cat.o + +#include "libbb.h" + +int FAST_FUNC bb_cat(char **argv) +{ + int fd; + int retval = EXIT_SUCCESS; + + if (!*argv) + argv = (char**) &bb_argv_dash; + + do { + fd = open_or_warn_stdin(*argv); + if (fd >= 0) { + /* This is not a xfunc - never exits */ + off_t r = bb_copyfd_eof(fd, STDOUT_FILENO); + if (fd != STDIN_FILENO) + close(fd); + if (r >= 0) + continue; + } + retval = EXIT_FAILURE; + } while (*++argv); + + return retval; +} diff --git a/libbb/print_numbered_lines.c b/libbb/print_numbered_lines.c new file mode 100644 index 000000000..702aed1ea --- /dev/null +++ b/libbb/print_numbered_lines.c @@ -0,0 +1,29 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright (C) 2017 Denys Vlasenko + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ +//kbuild:lib-y += print_numbered_lines.o + +#include "libbb.h" + +void FAST_FUNC print_numbered_lines(struct number_state *ns, const char *filename) +{ + FILE *fp = fopen_or_warn_stdin(filename); + unsigned N = ns->start; + char *line; + + while ((line = xmalloc_fgetline(fp)) != NULL) { + if (ns->all + || (ns->nonempty && line[0]) + ) { + printf("%*u%s%s\n", ns->width, N, ns->sep, line); + N += ns->inc; + } else if (ns->empty_str) + fputs(ns->empty_str, stdout); + free(line); + } + + fclose(fp); +} diff --git a/procps/kill.c b/procps/kill.c index 7ae5beead..975a3e8c5 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -201,7 +201,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv) pid_t sid; procps_status_t* p = NULL; /* compat: exitcode 2 is "no one was signaled" */ - int ret = 2; + errors = 2; /* Find out our session id */ sid = getsid(pid); @@ -229,7 +229,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv) arg = *args++; if (arg[0] != '-' || arg[1] != 'o') { bb_error_msg("bad option '%s'", arg); - ret = 1; + errors = 1; goto resume; } arg += 2; @@ -238,21 +238,21 @@ int kill_main(int argc UNUSED_PARAM, char **argv) omit = bb_strtoi(arg, NULL, 10); if (errno) { bb_error_msg("invalid number '%s'", arg); - ret = 1; + errors = 1; goto resume; } if (p->pid == omit) goto dont_kill; } kill(p->pid, signo); - ret = 0; + errors = 0; dont_kill: ; } resume: /* And let them continue */ if (signo != SIGSTOP && signo != SIGCONT) kill(-1, SIGCONT); - return ret; + return errors; } #if ENABLE_KILL || ENABLE_KILLALL -- cgit v1.2.3-55-g6feb From 835ad3a984c5590ae4f6c94f2f0781ea049d1ae8 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Wed, 12 Apr 2017 00:58:46 +0300 Subject: libbb: GETOPT_RESET macro Signed-off-by: Kaarle Ritvanen Signed-off-by: Denys Vlasenko --- include/libbb.h | 22 ++++++++++++++++++++++ libbb/getopt32.c | 8 +------- libbb/vfork_daemon_rexec.c | 28 ++-------------------------- runit/sv.c | 7 +------ shell/shell_common.c | 8 +------- util-linux/getopt.c | 7 +------ 6 files changed, 28 insertions(+), 52 deletions(-) (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index 2c30bde6f..11d022fb5 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1178,6 +1178,28 @@ extern uint32_t option_mask32; extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC; +/* BSD-derived getopt() functions require that optind be set to 1 in + * order to reset getopt() state. This used to be generally accepted + * way of resetting getopt(). However, glibc's getopt() + * has additional getopt() state beyond optind (specifically, glibc + * extensions ('+' and '-' at the start of the string), and requires + * that optind be set to zero to reset its state. BSD-derived versions + * of getopt() misbehaved if optind is set to 0 in order to reset getopt(), + * and glibc's getopt() used to coredump if optind is set 1 in order + * to reset getopt(). + * Then BSD introduced additional variable "optreset" which + * be set to 1 in order to reset getopt(). Sigh. Standards, anyone? + * + * By ~2008, OpenBSD 3.4 was changed to survive glibc-like optind = 0 + * (to interpret it as if optreset was set). + */ +#ifdef __GLIBC__ +#define GETOPT_RESET() (optind = 0) +#else /* BSD style */ +#define GETOPT_RESET() (optind = 1) +#endif + + /* Having next pointer as a first member allows easy creation * of "llist-compatible" structs, and using llist_FOO functions * on them. diff --git a/libbb/getopt32.c b/libbb/getopt32.c index 497fc016f..3104826ef 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c @@ -576,13 +576,7 @@ getopt32(char **argv, const char *applet_opts, ...) * run_nofork_applet() does this, but we might end up here * also via gunzip_main() -> gzip_main(). Play safe. */ -#ifdef __GLIBC__ - optind = 0; -#else /* BSD style */ - optind = 1; - /* optreset = 1; */ -#endif - /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */ + GETOPT_RESET(); /* Note: just "getopt() <= 0" will not work well for * "fake" short options, like this one: diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 2e7dc2d9b..fd481bf6e 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c @@ -121,28 +121,8 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv) /* In case getopt() or getopt32() was already called: * reset the libc getopt() function, which keeps internal state. - * - * BSD-derived getopt() functions require that optind be set to 1 in - * order to reset getopt() state. This used to be generally accepted - * way of resetting getopt(). However, glibc's getopt() - * has additional getopt() state beyond optind, and requires that - * optind be set to zero to reset its state. So the unfortunate state of - * affairs is that BSD-derived versions of getopt() misbehave if - * optind is set to 0 in order to reset getopt(), and glibc's getopt() - * will core dump if optind is set 1 in order to reset getopt(). - * - * More modern versions of BSD require that optreset be set to 1 in - * order to reset getopt(). Sigh. Standards, anyone? */ -#ifdef __GLIBC__ - optind = 0; -#else /* BSD style */ - optind = 1; - /* optreset = 1; */ -#endif - /* optarg = NULL; opterr = 1; optopt = 63; - do we need this too? */ - /* (values above are what they initialized to in glibc and uclibc) */ - /* option_mask32 = 0; - not needed, no applet depends on it being 0 */ + GETOPT_RESET(); argc = 1; while (argv[argc]) @@ -167,11 +147,7 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv) restore_nofork_data(&old); /* Other globals can be simply reset to defaults */ -#ifdef __GLIBC__ - optind = 0; -#else /* BSD style */ - optind = 1; -#endif + GETOPT_RESET(); return rc & 0xff; /* don't confuse people with "exitcodes" >255 */ } diff --git a/runit/sv.c b/runit/sv.c index 9e2132259..64f1ae395 100644 --- a/runit/sv.c +++ b/runit/sv.c @@ -688,12 +688,7 @@ int svc_main(int argc UNUSED_PARAM, char **argv) /* getopt32() was already called: * reset the libc getopt() function, which keeps internal state. */ -#ifdef __GLIBC__ - optind = 0; -#else /* BSD style */ - optind = 1; - /* optreset = 1; */ -#endif + GETOPT_RESET(); do { if (opts & 1) { diff --git a/shell/shell_common.c b/shell/shell_common.c index 549b17ca1..fb86e680f 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c @@ -401,13 +401,7 @@ shell_builtin_ulimit(char **argv) /* In case getopt was already called: * reset the libc getopt() function, which keeps internal state. */ -#ifdef __GLIBC__ - optind = 0; -#else /* BSD style */ - optind = 1; - /* optreset = 1; */ -#endif - /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */ + GETOPT_RESET(); argc = 1; while (argv[argc]) diff --git a/util-linux/getopt.c b/util-linux/getopt.c index 63294c520..79d54854b 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c @@ -246,12 +246,7 @@ static int generate_output(char **argv, int argc, const char *optstr, const stru /* We used it already in main() in getopt32(), * we *must* reset getopt(3): */ -#ifdef __GLIBC__ - optind = 0; -#else /* BSD style */ - optind = 1; - /* optreset = 1; */ -#endif + GETOPT_RESET(); while (1) { #if ENABLE_FEATURE_GETOPT_LONG -- cgit v1.2.3-55-g6feb From 517a82c5b6b5e279f3e96a6774445a2952ca312b Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Sat, 2 Jan 2016 00:20:39 +0200 Subject: login: move check_securetty to libbb Signed-off-by: Kaarle Ritvanen Signed-off-by: Denys Vlasenko --- include/libbb.h | 5 +++++ libbb/Kbuild.src | 1 + libbb/securetty.c | 22 ++++++++++++++++++++++ loginutils/login.c | 19 ------------------- 4 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 libbb/securetty.c (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index 777a4a884..6b33ffad6 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1481,6 +1481,11 @@ extern void selinux_or_die(void) FAST_FUNC; #define SETUP_ENV_NO_CHDIR (1 << 4) void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC; void nuke_str(char *str) FAST_FUNC; +#if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM +int check_securetty(const char *short_tty) FAST_FUNC; +#else +static ALWAYS_INLINE int check_securetty(const char *short_tty UNUSED_PARAM) { return 1; } +#endif int check_password(const struct passwd *pw, const char *plaintext) FAST_FUNC; int ask_and_check_password_extended(const struct passwd *pw, int timeout, const char *prompt) FAST_FUNC; int ask_and_check_password(const struct passwd *pw) FAST_FUNC; diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 898a51a89..49493c501 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -83,6 +83,7 @@ lib-y += safe_gethostname.o lib-y += safe_poll.o lib-y += safe_strncpy.o lib-y += safe_write.o +lib-y += securetty.o lib-y += setup_environment.o lib-y += signals.o lib-y += simplify_path.o diff --git a/libbb/securetty.c b/libbb/securetty.c new file mode 100644 index 000000000..176cee129 --- /dev/null +++ b/libbb/securetty.c @@ -0,0 +1,22 @@ +/* vi: set sw=4 ts=4: */ +/* + * /etc/securetty checking. + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ +#include "libbb.h" + +int FAST_FUNC check_securetty(const char *short_tty) +{ + char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */ + parser_t *parser = config_open2("/etc/securetty", fopen_for_read); + while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) { + if (strcmp(buf, short_tty) == 0) + break; + buf = NULL; + } + config_close(parser); + /* buf != NULL here if config file was not found, empty + * or line was found which equals short_tty */ + return buf != NULL; +} diff --git a/loginutils/login.c b/loginutils/login.c index d1757a65d..661a87448 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -175,25 +175,6 @@ static void die_if_nologin(void) # define die_if_nologin() ((void)0) #endif -#if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM -static int check_securetty(const char *short_tty) -{ - char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */ - parser_t *parser = config_open2("/etc/securetty", fopen_for_read); - while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) { - if (strcmp(buf, short_tty) == 0) - break; - buf = NULL; - } - config_close(parser); - /* buf != NULL here if config file was not found, empty - * or line was found which equals short_tty */ - return buf != NULL; -} -#else -static ALWAYS_INLINE int check_securetty(const char *short_tty UNUSED_PARAM) { return 1; } -#endif - #if ENABLE_SELINUX static void initselinux(char *username, char *full_tty, security_context_t *user_sid) -- cgit v1.2.3-55-g6feb From 335681ca8e39144fa19814f7ba10d0fe760e4055 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 13 Apr 2017 12:57:04 +0200 Subject: su: FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY When this feature is enabled, blank passwords are not accepted by su unless the user is on a secure TTY defined in /etc/securetty. This resembles the default PAM configuration of some Linux distros which specify the nullok_secure option for pam_unix.so. Based on patch by Kaarle Ritvanen Signed-off-by: Denys Vlasenko --- include/libbb.h | 1 + libbb/correct_password.c | 4 ++-- loginutils/su.c | 27 ++++++++++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index 6b33ffad6..b889dd7d7 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1486,6 +1486,7 @@ int check_securetty(const char *short_tty) FAST_FUNC; #else static ALWAYS_INLINE int check_securetty(const char *short_tty UNUSED_PARAM) { return 1; } #endif +#define CHECKPASS_PW_HAS_EMPTY_PASSWORD 2 int check_password(const struct passwd *pw, const char *plaintext) FAST_FUNC; int ask_and_check_password_extended(const struct passwd *pw, int timeout, const char *prompt) FAST_FUNC; int ask_and_check_password(const struct passwd *pw) FAST_FUNC; diff --git a/libbb/correct_password.c b/libbb/correct_password.c index 513c93028..3436edc30 100644 --- a/libbb/correct_password.c +++ b/libbb/correct_password.c @@ -88,7 +88,7 @@ int FAST_FUNC check_password(const struct passwd *pw, const char *plaintext) /* Ask the user for a password. - * Return 1 without asking if PW has an empty password. + * Return CHECKPASS_PW_HAS_EMPTY_PASSWORD without asking if PW has an empty password. * Return -1 on EOF, error while reading input, or timeout. * Return 1 if the user gives the correct password for entry PW, * 0 if not. @@ -105,7 +105,7 @@ int FAST_FUNC ask_and_check_password_extended(const struct passwd *pw, pw_pass = get_passwd(pw, buffer); if (!pw_pass[0]) /* empty password field? */ - return 1; + return CHECKPASS_PW_HAS_EMPTY_PASSWORD; plaintext = bb_ask(STDIN_FILENO, timeout, prompt); if (!plaintext) { diff --git a/loginutils/su.c b/loginutils/su.c index d04b85fb1..f2cd799ae 100644 --- a/loginutils/su.c +++ b/loginutils/su.c @@ -23,6 +23,11 @@ //config: bool "If user's shell is not in /etc/shells, disallow -s PROG" //config: default y //config: depends on SU +//config: +//config:config FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY +//config: bool "Disallow blank passwords from TTYs other than specified in /etc/securetty" +//config: default n +//config: depends on SU //applet:/* Needs to be run by root or be suid root - needs to change uid and gid: */ //applet:IF_SU(APPLET(su, BB_DIR_BIN, BB_SUID_REQUIRE)) @@ -79,6 +84,7 @@ int su_main(int argc UNUSED_PARAM, char **argv) char user_buf[64]; #endif const char *old_user; + int r; /* Note: we don't use "'+': stop at first non-option" idiom here. * For su, "SCRIPT ARGS" or "-c CMD ARGS" do not stop option parsing: @@ -99,6 +105,11 @@ int su_main(int argc UNUSED_PARAM, char **argv) argv++; } + tty = xmalloc_ttyname(STDIN_FILENO); + if (!tty) + tty = "none"; + tty = skip_dev_pfx(tty); + if (ENABLE_FEATURE_SU_SYSLOG) { /* The utmp entry (via getlogin) is probably the best way to * identify the user, especially if someone su's from a su-shell. @@ -112,20 +123,26 @@ int su_main(int argc UNUSED_PARAM, char **argv) pw = getpwuid(cur_uid); old_user = pw ? xstrdup(pw->pw_name) : ""; } - tty = xmalloc_ttyname(2); - if (!tty) { - tty = "none"; - } openlog(applet_name, 0, LOG_AUTH); } pw = xgetpwnam(opt_username); - if (cur_uid == 0 || ask_and_check_password(pw) > 0) { + r = 1; + if (cur_uid != 0) + r = ask_and_check_password(pw); + if (r > 0) { + if (ENABLE_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY + && r == CHECKPASS_PW_HAS_EMPTY_PASSWORD + && !check_securetty(tty) + ) { + goto fail; + } if (ENABLE_FEATURE_SU_SYSLOG) syslog(LOG_NOTICE, "%c %s %s:%s", '+', tty, old_user, opt_username); } else { + fail: if (ENABLE_FEATURE_SU_SYSLOG) syslog(LOG_NOTICE, "%c %s %s:%s", '-', tty, old_user, opt_username); -- cgit v1.2.3-55-g6feb From a3de0b3b86deb37c2adc993c6357c1a31b7ecb5b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 13 Apr 2017 13:04:05 +0200 Subject: libbb: make check_password() also return CHECKPASS_PW_HAS_EMPTY_PASSWORD Signed-off-by: Denys Vlasenko --- include/libbb.h | 4 ++-- libbb/correct_password.c | 4 ++-- libbb/securetty.c | 6 ++++-- loginutils/login.c | 2 +- loginutils/su.c | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index b889dd7d7..9b72c97be 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1482,9 +1482,9 @@ extern void selinux_or_die(void) FAST_FUNC; void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC; void nuke_str(char *str) FAST_FUNC; #if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM -int check_securetty(const char *short_tty) FAST_FUNC; +int is_tty_secure(const char *short_tty) FAST_FUNC; #else -static ALWAYS_INLINE int check_securetty(const char *short_tty UNUSED_PARAM) { return 1; } +static ALWAYS_INLINE int is_tty_secure(const char *short_tty UNUSED_PARAM) { return 1; } #endif #define CHECKPASS_PW_HAS_EMPTY_PASSWORD 2 int check_password(const struct passwd *pw, const char *plaintext) FAST_FUNC; diff --git a/libbb/correct_password.c b/libbb/correct_password.c index 3436edc30..f4635a5bc 100644 --- a/libbb/correct_password.c +++ b/libbb/correct_password.c @@ -63,7 +63,7 @@ static const char *get_passwd(const struct passwd *pw, char buffer[SHADOW_BUFSIZ } /* - * Return 1 if PW has an empty password. + * Return CHECKPASS_PW_HAS_EMPTY_PASSWORD if PW has an empty password. * Return 1 if the user gives the correct password for entry PW, * 0 if not. * NULL pw means "just fake it for login with bad username" @@ -77,7 +77,7 @@ int FAST_FUNC check_password(const struct passwd *pw, const char *plaintext) pw_pass = get_passwd(pw, buffer); if (!pw_pass[0]) { /* empty password field? */ - return 1; + return CHECKPASS_PW_HAS_EMPTY_PASSWORD; } encrypted = pw_encrypt(plaintext, /*salt:*/ pw_pass, 1); diff --git a/libbb/securetty.c b/libbb/securetty.c index 176cee129..67a123689 100644 --- a/libbb/securetty.c +++ b/libbb/securetty.c @@ -6,7 +6,7 @@ */ #include "libbb.h" -int FAST_FUNC check_securetty(const char *short_tty) +int FAST_FUNC is_tty_secure(const char *short_tty) { char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */ parser_t *parser = config_open2("/etc/securetty", fopen_for_read); @@ -17,6 +17,8 @@ int FAST_FUNC check_securetty(const char *short_tty) } config_close(parser); /* buf != NULL here if config file was not found, empty - * or line was found which equals short_tty */ + * or line was found which equals short_tty. + * In all these cases, we report "this tty is secure". + */ return buf != NULL; } diff --git a/loginutils/login.c b/loginutils/login.c index 661a87448..be05def09 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -486,7 +486,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) if (opt & LOGIN_OPT_f) break; /* -f USER: success without asking passwd */ - if (pw->pw_uid == 0 && !check_securetty(short_tty)) + if (pw->pw_uid == 0 && !is_tty_secure(short_tty)) goto auth_failed; /* Don't check the password if password entry is empty (!) */ diff --git a/loginutils/su.c b/loginutils/su.c index f2cd799ae..ef74aa77d 100644 --- a/loginutils/su.c +++ b/loginutils/su.c @@ -134,7 +134,7 @@ int su_main(int argc UNUSED_PARAM, char **argv) if (r > 0) { if (ENABLE_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY && r == CHECKPASS_PW_HAS_EMPTY_PASSWORD - && !check_securetty(tty) + && !is_tty_secure(tty) ) { goto fail; } -- cgit v1.2.3-55-g6feb From 44c0ab410278656b4b82ec20a24c3644a254da89 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 13 Apr 2017 17:55:05 +0200 Subject: libbb: fix "error: redefinition of 'is_tty_secure'" Signed-off-by: Denys Vlasenko --- libbb/securetty.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libbb') diff --git a/libbb/securetty.c b/libbb/securetty.c index 67a123689..21354e2fa 100644 --- a/libbb/securetty.c +++ b/libbb/securetty.c @@ -6,6 +6,7 @@ */ #include "libbb.h" +#if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM int FAST_FUNC is_tty_secure(const char *short_tty) { char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */ @@ -22,3 +23,4 @@ int FAST_FUNC is_tty_secure(const char *short_tty) */ return buf != NULL; } +#endif -- cgit v1.2.3-55-g6feb From 10ad622dc2a9fb6563fab13719ead8baf15ff9e4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 17 Apr 2017 16:13:32 +0200 Subject: Spelling fixes in comments, documentation, tests and examples By klemens Signed-off-by: Denys Vlasenko --- archival/dpkg.c | 26 +++++++++++++------------- archival/libarchive/decompress_bunzip2.c | 2 +- archival/libarchive/unxz/xz_dec_lzma2.c | 4 ++-- archival/tar.c | 4 ++-- coreutils/dos2unix.c | 2 +- docs/sigint.htm | 10 +++++----- docs/style-guide.txt | 2 +- editors/sed.c | 8 ++++---- examples/var_service/dhcp_if/dhcp_handler | 2 +- findutils/find.c | 2 +- findutils/grep.c | 4 ++-- libbb/getopt32.c | 2 +- libpwdgrp/pwd_grp.c | 4 ++-- loginutils/cryptpw.c | 2 +- miscutils/inotifyd.c | 2 +- miscutils/less.c | 2 +- miscutils/time.c | 2 +- modutils/Config.src | 2 +- modutils/modinfo.c | 2 +- modutils/modprobe-small.c | 4 ++-- networking/dnsd.c | 2 +- networking/ifenslave.c | 2 +- networking/isrv.c | 2 +- networking/nc_bloaty.c | 4 ++-- networking/ntpd.c | 6 +++--- networking/ping.c | 4 ++-- networking/tcpudp.c | 2 +- networking/udhcp/dhcpc.c | 2 +- networking/udhcp/dhcprelay.c | 2 +- networking/vconfig.c | 2 +- shell/ash.c | 12 ++++++------ shell/ash_test/ash-misc/unicode1.tests | 2 +- shell/hush.c | 12 ++++++------ shell/hush_test/hush-misc/unicode1.tests | 2 +- sysklogd/logread.c | 4 ++-- testsuite/readlink.tests | 2 +- util-linux/cal.c | 2 +- util-linux/hwclock.c | 2 +- util-linux/renice.c | 2 +- util-linux/switch_root.c | 2 +- util-linux/volume_id/udf.c | 2 +- 41 files changed, 80 insertions(+), 80 deletions(-) (limited to 'libbb') diff --git a/archival/dpkg.c b/archival/dpkg.c index f133299e3..1cd45eda4 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c @@ -18,7 +18,7 @@ * known difference between busybox dpkg and the official dpkg that i don't * consider important, its worth keeping a note of differences anyway, just to * make it easier to maintain. - * - the first value for the confflile: field isnt placed on a new line. + * - the first value for the confflile: field isn't placed on a new line. * - when installing a package the status: field is placed at the end of the * section, rather than just after the package: field. * @@ -110,7 +110,7 @@ typedef struct common_node_s { edge_t **edge; } common_node_t; -/* Currently it doesnt store packages that have state-status of not-installed +/* Currently it doesn't store packages that have state-status of not-installed * So it only really has to be the size of the maximum number of packages * likely to be installed at any one time, so there is a bit of leeway here */ #define STATUS_HASH_PRIME 8191 @@ -205,7 +205,7 @@ static int search_name_hashtable(const char *key) return probe_address; } -/* this DOESNT add the key to the hashtable +/* this DOESN'T add the key to the hashtable * TODO make it consistent with search_name_hashtable */ static unsigned search_status_hashtable(const char *key) @@ -467,7 +467,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole version = strchr(field2, '('); if (version == NULL) { edge->operator = VER_ANY; - /* Get the versions hash number, adding it if the number isnt already in there */ + /* Get the versions hash number, adding it if the number isn't already in there */ edge->version = search_name_hashtable("ANY"); } else { /* Skip leading ' ' or '(' */ @@ -496,7 +496,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole /* Truncate version at trailing ' ' or ')' */ version[strcspn(version, " )")] = '\0'; - /* Get the versions hash number, adding it if the number isnt already in there */ + /* Get the versions hash number, adding it if the number isn't already in there */ edge->version = search_name_hashtable(version); } @@ -562,7 +562,7 @@ static int read_package_field(const char *package_buffer, char **field_name, cha offset_name_end = offset; offset_value_start = next_offset; } - /* TODO: Name might still have trailing spaces if ':' isnt + /* TODO: Name might still have trailing spaces if ':' isn't * immediately after name */ break; case '\n': @@ -776,7 +776,7 @@ static void index_status_file(const char *filename) const unsigned package_num = fill_package_struct(control_buffer); if (package_num != -1) { status_node = xmalloc(sizeof(status_node_t)); - /* fill_package_struct doesnt handle the status field */ + /* fill_package_struct doesn't handle the status field */ status_line = strstr(control_buffer, "Status:"); if (status_line != NULL) { status_line += 7; @@ -850,7 +850,7 @@ static void write_status_file(deb_file_t **deb_file) if (status_hashtable[status_num] != NULL) { const char *status_from_hashtable = name_hashtable[status_hashtable[status_num]->status]; if (strcmp(status_from_file, status_from_hashtable) != 0) { - /* New status isnt exactly the same as old status */ + /* New status isn't exactly the same as old status */ const int state_status = get_status(status_num, 3); if ((strcmp("installed", name_hashtable[state_status]) == 0) || (strcmp("unpacked", name_hashtable[state_status]) == 0) @@ -919,7 +919,7 @@ static void write_status_file(deb_file_t **deb_file) } } } - /* If the package from the status file wasnt handle above, do it now*/ + /* If the package from the status file wasn't handle above, do it now*/ if (!write_flag) { fprintf(new_status_file, "%s\n\n", control_buffer); } @@ -946,7 +946,7 @@ static void write_status_file(deb_file_t **deb_file) if (errno != ENOENT) bb_error_msg_and_die("can't create backup status file"); /* Its ok if renaming the status file fails because status - * file doesnt exist, maybe we are starting from scratch */ + * file doesn't exist, maybe we are starting from scratch */ bb_error_msg("no status file found, creating new one"); } @@ -1061,7 +1061,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count } - /* Check dependendcies */ + /* Check dependentcies */ for (i = 0; i < PACKAGE_HASH_PRIME; i++) { int status_num = 0; int number_of_alternatives = 0; @@ -1244,7 +1244,7 @@ static void run_package_script_or_die(const char *package_name, const char *scri script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type); - /* If the file doesnt exist is isnt fatal */ + /* If the file doesn't exist it isn't fatal */ result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path); free(script_path); if (result) @@ -1839,7 +1839,7 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv) ) { status_node = xmalloc(sizeof(status_node_t)); status_node->package = deb_file[deb_count]->package; - /* reinstreq isnt changed to "ok" until the package control info + /* reinstreq isn't changed to "ok" until the package control info * is written to the status file*/ status_node->status = search_name_hashtable("install reinstreq not-installed"); status_hashtable[status_num] = status_node; diff --git a/archival/libarchive/decompress_bunzip2.c b/archival/libarchive/decompress_bunzip2.c index 4fb989c29..803702f75 100644 --- a/archival/libarchive/decompress_bunzip2.c +++ b/archival/libarchive/decompress_bunzip2.c @@ -308,7 +308,7 @@ static int get_next_block(bunzip_data *bd) base = hufGroup->base - 1; limit = hufGroup->limit - 1; - /* Calculate permute[]. Concurently, initialize temp[] and limit[]. */ + /* Calculate permute[]. Concurrently, initialize temp[] and limit[]. */ pp = 0; for (i = minLen; i <= maxLen; i++) { int k; diff --git a/archival/libarchive/unxz/xz_dec_lzma2.c b/archival/libarchive/unxz/xz_dec_lzma2.c index 351251f7c..bca41e705 100644 --- a/archival/libarchive/unxz/xz_dec_lzma2.c +++ b/archival/libarchive/unxz/xz_dec_lzma2.c @@ -486,11 +486,11 @@ static __always_inline void XZ_FUNC rc_normalize(struct rc_dec *rc) } /* - * Decode one bit. In some versions, this function has been splitted in three + * Decode one bit. In some versions, this function has been split in three * functions so that the compiler is supposed to be able to more easily avoid * an extra branch. In this particular version of the LZMA decoder, this * doesn't seem to be a good idea (tested with GCC 3.3.6, 3.4.6, and 4.3.3 - * on x86). Using a non-splitted version results in nicer looking code too. + * on x86). Using a non-split version results in nicer looking code too. * * NOTE: This must return an int. Do not make it return a bool or the speed * of the code generated by GCC 3.x decreases 10-15 %. (GCC 4.3 doesn't care, diff --git a/archival/tar.c b/archival/tar.c index b1d58a2df..b70e00a8b 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -529,8 +529,8 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb /* * Check to see if we are dealing with a hard link. * If so - - * Treat the first occurance of a given dev/inode as a file while - * treating any additional occurances as hard links. This is done + * Treat the first occurrence of a given dev/inode as a file while + * treating any additional occurrences as hard links. This is done * by adding the file information to the HardLinkInfo linked list. */ tbInfo->hlInfo = NULL; diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index 6d2347163..9d81ccca6 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c @@ -2,7 +2,7 @@ /* * dos2unix for BusyBox * - * dos2unix '\n' convertor 0.5.0 + * dos2unix '\n' converter 0.5.0 * based on Unix2Dos 0.9.0 by Peter Hanecak (made 19.2.1997) * Copyright 1997,.. by Peter Hanecak . * All rights reserved. diff --git a/docs/sigint.htm b/docs/sigint.htm index e230f4df7..d656aeb8c 100644 --- a/docs/sigint.htm +++ b/docs/sigint.htm @@ -45,7 +45,7 @@ intention. Required knowledge: You have to know what it means to catch SIGINT or SIGQUIT and how -processes are waiting for other processes (childs) they spawned. +processes are waiting for other processes (children) they spawned. @@ -366,7 +366,7 @@ signal, it has to take care of communicating the signal status itself.

Some programs don't do this. On SIGINT, they do cleanup and exit -immediatly, but the calling shell isn't told about the non-normal exit +immediately, but the calling shell isn't told about the non-normal exit and it will call the next program in the script.

As a result, the user hits SIGINT and while one program exits, the @@ -446,7 +446,7 @@ handlers, so it is portable. trap command. Here, the same as for C programs apply. If the intention of SIGINT is to end your program, you have to exit in a way that the calling programs "sees" that you have been killed. If -you don't catch SIGINT, this happend automatically, but of you catch +you don't catch SIGINT, this happened automatically, but of you catch SIGINT, i.e. to do cleanup work, you have to end the program by killing yourself, not by calling exit. @@ -466,7 +466,7 @@ files (which isn't really portable in C, though). bourne shell. Every language implementation that lets you catch SIGINT should also give you the option to reset the signal and kill yourself. -

It is always desireable to exit the right way, even if you don't +

It is always desirable to exit the right way, even if you don't expect your usual callers to depend on it, some unusual one will come along. This proper exit status will be needed for WCE and will not hurt when the calling shell uses IUE or WUE. @@ -565,7 +565,7 @@ comments the scripts echo. What happens when a shellscript called emacs, the user did not use C-c and the script has additional commands in it? What happens if a non-interactive child catches SIGINT? -To behave properly, childs must do what? +To behave properly, children must do what? diff --git a/docs/style-guide.txt b/docs/style-guide.txt index 10ed893dc..9eed7f125 100644 --- a/docs/style-guide.txt +++ b/docs/style-guide.txt @@ -329,7 +329,7 @@ With "const int" compiler may fail to optimize it out and will reserve a real storage in rodata for it! (Hopefully, newer gcc will get better at it...). With "define", you have slight risk of polluting namespace (#define doesn't allow you to redefine the name in the inner scopes), -and complex "define" are evaluated each time they uesd, not once +and complex "define" are evaluated each time they used, not once at declarations like enums. Also, the preprocessor does _no_ type checking whatsoever, making it much more error prone. diff --git a/editors/sed.c b/editors/sed.c index 637a6851b..ca9ab2054 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -337,7 +337,7 @@ static int get_address(const char *my_str, int *linenum, regex_t ** regex) if (isdigit(*my_str)) { *linenum = strtol(my_str, (char**)&pos, 10); - /* endstr shouldnt ever equal NULL */ + /* endstr shouldn't ever equal NULL */ } else if (*my_str == '$') { *linenum = -1; pos++; @@ -444,7 +444,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr) free(fname); break; } - /* Ignore case (gnu exension) */ + /* Ignore case (gnu extension) */ case 'i': case 'I': cflags |= REG_ICASE; @@ -587,7 +587,7 @@ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr) free(match); free(replace); } - /* if it wasnt a single-letter command that takes no arguments + /* if it wasn't a single-letter command that takes no arguments * then it must be an invalid command. */ else if (idx >= IDX_nul) { /* not d,D,g,G,h,H,l,n,N,p,P,q,x,=,{,} */ @@ -751,7 +751,7 @@ static void do_subst_w_backrefs(char *line, char *replace) continue; } /* I _think_ it is impossible to get '\' to be - * the last char in replace string. Thus we dont check + * the last char in replace string. Thus we don't check * for replace[i] == NUL. (counterexample anyone?) */ /* if we find a backslash escaped character, print the character */ pipe_putc(replace[i]); diff --git a/examples/var_service/dhcp_if/dhcp_handler b/examples/var_service/dhcp_if/dhcp_handler index 3d2a5cb79..3d44a6022 100755 --- a/examples/var_service/dhcp_if/dhcp_handler +++ b/examples/var_service/dhcp_if/dhcp_handler @@ -21,7 +21,7 @@ # ntpsrv=10.34.32.125 10.34.255.7 # # renew: lease is renewed. Environment is similar to "bound". -# The IP address does not change, however, the other DHCP paramaters, +# The IP address does not change, however, the other DHCP parameters, # such as the default gateway, subnet mask, and dns server may change. # # nak: udhcpc received a NAK message. diff --git a/findutils/find.c b/findutils/find.c index 67aa40b21..0596c0059 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -182,7 +182,7 @@ //config: default y //config: depends on FIND //config: help -//config: If the file is a directory, dont descend into it. Useful for +//config: If the file is a directory, don't descend into it. Useful for //config: exclusion .svn and CVS directories. //config: //config:config FEATURE_FIND_DELETE diff --git a/findutils/grep.c b/findutils/grep.c index 261e563d5..d66d85a53 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -515,7 +515,7 @@ static int grep_file(FILE *file) if (option_mask32 & OPT_o) { if (FGREP_FLAG) { /* -Fo just prints the pattern - * (unless -v: -Fov doesnt print anything at all) */ + * (unless -v: -Fov doesn't print anything at all) */ if (found) print_line(gl->pattern, strlen(gl->pattern), linenum, ':'); } else while (1) { @@ -823,7 +823,7 @@ int grep_main(int argc UNUSED_PARAM, char **argv) grep_done: ; } while (*argv && *++argv); - /* destroy all the elments in the pattern list */ + /* destroy all the elements in the pattern list */ if (ENABLE_FEATURE_CLEAN_UP) { while (pattern_head) { llist_t *pattern_head_ptr = pattern_head; diff --git a/libbb/getopt32.c b/libbb/getopt32.c index 3104826ef..b87b83538 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c @@ -128,7 +128,7 @@ const char *opt_complementary "abc" If groups of two or more chars are specified, the first char is the main option and the other chars are secondary options. Their flags will be turned on if the main option is found even - if they are not specifed on the command line. For example: + if they are not specified on the command line. For example: opt_complementary = "abc"; flags = getopt32(argv, "abcd") diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index cefbc8a7e..c9bbc8bda 100644 --- a/libpwdgrp/pwd_grp.c +++ b/libpwdgrp/pwd_grp.c @@ -14,7 +14,7 @@ * exit using the atexit function to make valgrind happy. * 2) the passwd/group files: * a) must contain the expected number of fields (as per count of field - * delimeters ":") or we will complain with a error message. + * delimiters ":") or we will complain with a error message. * b) leading and trailing whitespace in fields is stripped. * c) some fields are not allowed to be empty (e.g. username, uid/gid), * and in this case NULL is returned and errno is set to EINVAL. @@ -149,7 +149,7 @@ static struct statics *get_S(void) /* Internal functions */ /* Divide the passwd/group/shadow record in fields - * by substituting the given delimeter + * by substituting the given delimiter * e.g. ':' or ',' with '\0'. * Returns the number of fields found. * Strips leading and trailing whitespace in fields. diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c index 696e169fc..3dc8232e0 100644 --- a/loginutils/cryptpw.c +++ b/loginutils/cryptpw.c @@ -64,7 +64,7 @@ OPTIONS $1$. -R, --rounds=NUMBER Use NUMBER rounds. This argument is ignored if the method - choosen does not support variable rounds. For the OpenBSD Blowfish + chosen does not support variable rounds. For the OpenBSD Blowfish method this is the logarithm of the number of rounds. -m, --method=TYPE Compute the password using the TYPE method. If TYPE is 'help' diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c index 601df6465..db8ddce92 100644 --- a/miscutils/inotifyd.c +++ b/miscutils/inotifyd.c @@ -12,7 +12,7 @@ * Use as follows: * # inotifyd /user/space/agent dir/or/file/being/watched[:mask] ... * - * When a filesystem event matching the specified mask is occured on specified file (or directory) + * When a filesystem event matching the specified mask is occurred on specified file (or directory) * a userspace agent is spawned and given the following parameters: * $1. actual event(s) * $2. file (or directory) name diff --git a/miscutils/less.c b/miscutils/less.c index 0b0a9aed4..507e579c4 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -267,7 +267,7 @@ struct globals { /* flines[] are lines read from stdin, each in malloc'ed buffer. * Line numbers are stored as uint32_t prepended to each line. * Pointer is adjusted so that flines[i] points directly past - * line number. Accesor: */ + * line number. Accessor: */ #define MEMPTR(p) ((char*)(p) - 4) #define LINENO(p) (*(uint32_t*)((p) - 4)) diff --git a/miscutils/time.c b/miscutils/time.c index a73a837d8..2be750664 100644 --- a/miscutils/time.c +++ b/miscutils/time.c @@ -397,7 +397,7 @@ static void run_command(char *const *cmd, resource_t *resp) } /* Have signals kill the child but not self (if possible). */ -//TODO: just block all sigs? and reenable them in the very end in main? +//TODO: just block all sigs? and re-enable them in the very end in main? interrupt_signal = signal(SIGINT, SIG_IGN); quit_signal = signal(SIGQUIT, SIG_IGN); diff --git a/modutils/Config.src b/modutils/Config.src index 5f0b0cec4..9b76c83d2 100644 --- a/modutils/Config.src +++ b/modutils/Config.src @@ -75,7 +75,7 @@ config FEATURE_INSMOD_KSYMOOPS_SYMBOLS depends on FEATURE_2_4_MODULES && (INSMOD || MODPROBE) help By adding module symbols to the kernel symbol table, Oops messages - occuring within kernel modules can be properly debugged. By enabling + occurring within kernel modules can be properly debugged. By enabling this feature, module symbols will always be added to the kernel symbol table for proper debugging support. If you are not interested in Oops messages from kernel modules, say N. diff --git a/modutils/modinfo.c b/modutils/modinfo.c index aa641ad54..ead2cf16f 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c @@ -104,7 +104,7 @@ static void modinfo(const char *path, const char *version, char *after_pattern; ptr = memchr(ptr, *pattern, len - (ptr - (char*)the_module)); - if (ptr == NULL) /* no occurance left, done */ + if (ptr == NULL) /* no occurrence left, done */ break; after_pattern = is_prefixed_with(ptr, pattern); if (after_pattern && *after_pattern == '=') { diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 1285783d0..053a7df89 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -169,7 +169,7 @@ static char* find_keyword(char *ptr, size_t len, const char *word) /* search for the first char in word */ ptr = memchr(ptr, word[0], len); - if (ptr == NULL) /* no occurance left, done */ + if (ptr == NULL) /* no occurrence left, done */ break; after_word = is_prefixed_with(ptr, word); if (after_word) @@ -411,7 +411,7 @@ static FAST_FUNC int fileAction(const char *pathname, if (load_module(pathname, module_load_options) == 0) { /* Load was successful, there is nothing else to do. * This can happen ONLY for "top-level" module load, - * not a dep, because deps dont do dirscan. */ + * not a dep, because deps don't do dirscan. */ exit(EXIT_SUCCESS); } } diff --git a/networking/dnsd.c b/networking/dnsd.c index 7be90018d..1b85618c6 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c @@ -360,7 +360,7 @@ RDATA a variable length string of octets that describes the resource. In order to reduce the size of messages, domain names coan be compressed. An entire domain name or a list of labels at the end of a domain name -is replaced with a pointer to a prior occurance of the same name. +is replaced with a pointer to a prior occurrence of the same name. The pointer takes the form of a two octet sequence: +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ diff --git a/networking/ifenslave.c b/networking/ifenslave.c index 1cb765e23..070931209 100644 --- a/networking/ifenslave.c +++ b/networking/ifenslave.c @@ -55,7 +55,7 @@ * * - 2003/03/18 - Tsippy Mendelson and * Shmulik Hen - * - Moved setting the slave's mac address and openning it, from + * - Moved setting the slave's mac address and opening it, from * the application to the driver. This enables support of modes * that need to use the unique mac address of each slave. * The driver also takes care of closing the slave and restoring its diff --git a/networking/isrv.c b/networking/isrv.c index 3673db715..97f5c6d4e 100644 --- a/networking/isrv.c +++ b/networking/isrv.c @@ -191,7 +191,7 @@ static void handle_accept(isrv_state_t *state, int fd) DPRINTF("new_peer(%d)", newfd); n = state->new_peer(state, newfd); if (n) - remove_peer(state, n); /* unsuccesful peer start */ + remove_peer(state, n); /* unsuccessful peer start */ } static void handle_fd_set(isrv_state_t *state, fd_set *fds, int (*h)(int, void **)) diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index f8c375362..3db784982 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c @@ -459,7 +459,7 @@ create new one, and bind() it. TODO */ so I don't feel bad. The *real* question is why BFD sockets wasn't designed to allow listens for connections *from* specific hosts/ports, instead of requiring the caller to - accept the connection and then reject undesireable ones by closing. + accept the connection and then reject undesirable ones by closing. In other words, we need a TCP MSG_PEEK. */ /* bbox: removed most of it */ lcladdr = xmalloc_sockaddr2dotted(&ouraddr->u.sa); @@ -502,7 +502,7 @@ static int udptest(void) /* use the tcp-ping trick: try connecting to a normally refused port, which causes us to block for the time that SYN gets there and RST gets back. Not completely reliable, but it *does* mostly work. */ - /* Set a temporary connect timeout, so packet filtration doesnt cause + /* Set a temporary connect timeout, so packet filtration doesn't cause us to hang forever, and hit it */ o_wait = 5; /* enough that we'll notice?? */ rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0); diff --git a/networking/ntpd.c b/networking/ntpd.c index 5cc71ca7a..73d27ac20 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -393,7 +393,7 @@ struct globals { * too big and we will step. I observed it with -6. * * OTOH, setting precision_sec far too small would result in futile - * attempts to syncronize to an unachievable precision. + * attempts to synchronize to an unachievable precision. * * -6 is 1/64 sec, -7 is 1/128 sec and so on. * -8 is 1/256 ~= 0.003906 (worked well for me --vda) @@ -754,7 +754,7 @@ reset_peer_stats(peer_t *p, double offset) bool small_ofs = fabs(offset) < STEP_THRESHOLD; /* Used to set p->filter_datapoint[i].d_dispersion = MAXDISP - * and clear reachable bits, but this proved to be too agressive: + * and clear reachable bits, but this proved to be too aggressive: * after step (tested with suspending laptop for ~30 secs), * this caused all previous data to be considered invalid, * making us needing to collect full ~8 datapoints per peer @@ -1715,7 +1715,7 @@ update_local_clock(peer_t *p) * It looks like Linux kernel's PLL is far too gentle in changing * tmx.freq in response to clock offset. Offset keeps growing * and eventually we fall back to smaller poll intervals. - * We can make correction more agressive (about x2) by supplying + * We can make correction more aggressive (about x2) by supplying * PLL time constant which is one less than the real one. * To be on a safe side, let's do it only if offset is significantly * larger than jitter. diff --git a/networking/ping.c b/networking/ping.c index ef31e000b..94fb007f5 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -478,7 +478,7 @@ static void sendping_tail(void (*sp)(int), int size_pkt) } else { /* -c NN, and all NN are sent (and no deadline) */ /* Wait for the last ping to come back. * -W timeout: wait for a response in seconds. - * Affects only timeout in absense of any responses, + * Affects only timeout in absence of any responses, * otherwise ping waits for two RTTs. */ unsigned expire = timeout; @@ -712,7 +712,7 @@ static void ping4(len_and_sockaddr *lsa) if (opt_ttl != 0) { setsockopt_int(pingsock, IPPROTO_IP, IP_TTL, opt_ttl); - /* above doesnt affect packets sent to bcast IP, so... */ + /* above doesn't affect packets sent to bcast IP, so... */ setsockopt_int(pingsock, IPPROTO_IP, IP_MULTICAST_TTL, opt_ttl); } diff --git a/networking/tcpudp.c b/networking/tcpudp.c index 3a6c68646..3ebe7d5fc 100644 --- a/networking/tcpudp.c +++ b/networking/tcpudp.c @@ -683,7 +683,7 @@ prog -E no special environment. Do not set up TCP-related environment variables. -v - verbose. Print verbose messsages to standard output. + verbose. Print verbose messages to standard output. -vv more verbose. Print more verbose messages to standard output. * no difference between -v and -vv in busyboxed version diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 881512cf3..c45a0af1a 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -1460,7 +1460,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) already_waited_sec += (unsigned)monotonic_sec() - timestamp_before_wait; continue; } - /* Else: an error occured, panic! */ + /* Else: an error occurred, panic! */ bb_perror_msg_and_die("select"); } } diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index 7cb19b14e..ea84c0dd7 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c @@ -361,7 +361,7 @@ int dhcprelay_main(int argc, char **argv) // which the reply must be sent (i.e., the host or router interface // connected to the same network as the BOOTP client). If the content // of the 'giaddr' field does not match one of the relay agent's -// directly-connected logical interfaces, the BOOTREPLY messsage MUST be +// directly-connected logical interfaces, the BOOTREPLY message MUST be // silently discarded. if (udhcp_read_interface(iface_list[i], NULL, &dhcp_msg.gateway_nip, NULL)) { /* Fall back to our IP on server iface */ diff --git a/networking/vconfig.c b/networking/vconfig.c index f3020409a..854eca0a1 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c @@ -138,7 +138,7 @@ int vconfig_main(int argc, char **argv) /* I suppose one could try to combine some of the function calls below, * since ifr.u.flag, ifr.u.VID, and ifr.u.skb_priority are all same-sized * (unsigned) int members of a unions. But because of the range checking, - * doing so wouldn't save that much space and would also make maintainence + * doing so wouldn't save that much space and would also make maintenance * more of a pain. */ if (ifr.cmd == SET_VLAN_FLAG_CMD) { diff --git a/shell/ash.c b/shell/ash.c index e170bec2a..70ee15ed8 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -3849,7 +3849,7 @@ setjobctl(int on) } /* fd is a tty at this point */ fd = fcntl(fd, F_DUPFD, 10); - if (ofd >= 0) /* if it is "/dev/tty", close. If 0/1/2, dont */ + if (ofd >= 0) /* if it is "/dev/tty", close. If 0/1/2, don't */ close(ofd); if (fd < 0) goto out; /* F_DUPFD failed */ @@ -6310,7 +6310,7 @@ static char *evalvar(char *p, int flags, struct strlist *var_str_list); * $@ like $* since no splitting will be performed. * * var_str_list (can be NULL) is a list of "VAR=val" strings which take precedence - * over shell varables. Needed for "A=a B=$A; echo $B" case - we use it + * over shell variables. Needed for "A=a B=$A; echo $B" case - we use it * for correct expansion of "B=$A" word. */ static void @@ -6520,8 +6520,8 @@ scanright(char *startp, char *rmesc, char *rmescend, if (try2optimize) { /* Maybe we can optimize this: * if pattern ends with unescaped *, we can avoid checking - * shorter strings: if "foo*" doesnt match "raw_value_of_v", - * it wont match truncated "raw_value_of_" strings too. + * shorter strings: if "foo*" doesn't match "raw_value_of_v", + * it won't match truncated "raw_value_of_" strings too. */ unsigned plen = strlen(pattern); /* Does it end with "*"? */ @@ -7248,7 +7248,7 @@ expandmeta(struct strlist *str /*, int flag*/) // Which means you need to unescape the string, right? Not so fast: // if there _is_ a file named "file\?" (with backslash), it is returned // as "file\?" too (whichever pattern you used to find it, say, "file*"). -// You DONT KNOW by looking at the result whether you need to unescape it. +// You DON'T KNOW by looking at the result whether you need to unescape it. // // Worse, globbing of "file\?" in a directory with two files, "file?" and "file\?", // returns "file\?" - which is WRONG: "file\?" pattern matches "file?" file. @@ -13088,7 +13088,7 @@ exportcmd(int argc UNUSED_PARAM, char **argv) } flag_off = ~flag_off; - /*if (opt_p_not_specified) - bash doesnt check this. Try "export -p NAME" */ + /*if (opt_p_not_specified) - bash doesn't check this. Try "export -p NAME" */ { aptr = argptr; name = *aptr; diff --git a/shell/ash_test/ash-misc/unicode1.tests b/shell/ash_test/ash-misc/unicode1.tests index 8788ba910..b8479cb41 100755 --- a/shell/ash_test/ash-misc/unicode1.tests +++ b/shell/ash_test/ash-misc/unicode1.tests @@ -5,7 +5,7 @@ a=`printf "\xcc\x80"` # Should print 1 echo ${#a} -# A Japanese katakana charachter U+30a3 +# A Japanese katakana character U+30a3 a=`printf "\xe3\x82\xa3"` # Should print 1 echo ${#a} diff --git a/shell/hush.c b/shell/hush.c index 4123cc19e..e18920f50 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1908,7 +1908,7 @@ static int check_and_run_traps(void) G.count_SIGCHLD++; //bb_error_msg("[%d] check_and_run_traps: G.count_SIGCHLD:%d G.handled_SIGCHLD:%d", getpid(), G.count_SIGCHLD, G.handled_SIGCHLD); /* Note: - * We dont do 'last_sig = sig' here -> NOT returning this sig. + * We don't do 'last_sig = sig' here -> NOT returning this sig. * This simplifies wait builtin a bit. */ break; @@ -1917,7 +1917,7 @@ static int check_and_run_traps(void) debug_printf_exec("%s: sig:%d default handling is to ignore\n", __func__, sig); /* SIGTERM, SIGQUIT, SIGTTIN, SIGTTOU, SIGTSTP */ /* Note: - * We dont do 'last_sig = sig' here -> NOT returning this sig. + * We don't do 'last_sig = sig' here -> NOT returning this sig. * Example: wait is not interrupted by TERM * in interactive shell, because TERM is ignored. */ @@ -2280,7 +2280,7 @@ static void reinit_unicode_for_hush(void) * AT\ * H\ * \ - * It excercises a lot of corner cases. + * It exercises a lot of corner cases. */ static void cmdedit_update_prompt(void) { @@ -5235,7 +5235,7 @@ static void o_addblock_duplicate_backslash(o_string *o, const char *str, int len /* And now we want to add { or } and continue: * o_addchr(o, c); * continue; - * luckily, just falling throught achieves this. + * luckily, just falling through achieves this. */ } #endif @@ -5830,7 +5830,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg) arg++; /* Can't just stuff it into output o_string, * expanded result may need to be globbed - * and $IFS-splitted */ + * and $IFS-split */ debug_printf_subst("SUBST '%s' first_ch %x\n", arg, first_ch); G.last_exitcode = process_command_subs(&subst_result, arg); debug_printf_subst("SUBST RES:%d '%s'\n", G.last_exitcode, subst_result.data); @@ -7320,7 +7320,7 @@ static int process_wait_result(struct pipe *fg_pipe, pid_t childpid, int status) /* There are still running processes in the fg_pipe */ return -1; } - /* It wasnt in fg_pipe, look for process in bg pipes */ + /* It wasn't in fg_pipe, look for process in bg pipes */ } #if ENABLE_HUSH_JOB diff --git a/shell/hush_test/hush-misc/unicode1.tests b/shell/hush_test/hush-misc/unicode1.tests index 8788ba910..b8479cb41 100755 --- a/shell/hush_test/hush-misc/unicode1.tests +++ b/shell/hush_test/hush-misc/unicode1.tests @@ -5,7 +5,7 @@ a=`printf "\xcc\x80"` # Should print 1 echo ${#a} -# A Japanese katakana charachter U+30a3 +# A Japanese katakana character U+30a3 a=`printf "\xe3\x82\xa3"` # Should print 1 echo ${#a} diff --git a/sysklogd/logread.c b/sysklogd/logread.c index 1f0c6252d..71459941e 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c @@ -24,7 +24,7 @@ //config: default y //config: depends on LOGREAD //config: help -//config: 'logread' ouput to slow serial terminals can have +//config: 'logread' output to slow serial terminals can have //config: side effects on syslog because of the semaphore. //config: This option make logread to double buffer copy //config: from circular buffer, minimizing semaphore @@ -159,7 +159,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv) cur, shbuf_tail, shbuf_size); if (!(follow & 1)) { /* not -f */ - /* if -F, "convert" it to -f, so that we dont + /* if -F, "convert" it to -f, so that we don't * dump the entire buffer on each iteration */ follow >>= 1; diff --git a/testsuite/readlink.tests b/testsuite/readlink.tests index e9d8da0fc..27b52f6c4 100755 --- a/testsuite/readlink.tests +++ b/testsuite/readlink.tests @@ -29,7 +29,7 @@ pwd=`$pwd` testing "readlink -f on a file" "readlink -f ./$TESTFILE" "$pwd/$TESTFILE\n" "" "" testing "readlink -f on a link" "readlink -f ./$TESTLINK" "$pwd/$TESTFILE\n" "" "" testing "readlink -f on an invalid link" "readlink -f ./$FAILLINK" "" "" "" -testing "readlink -f on a wierd dir" "readlink -f $TESTDIR/../$TESTFILE" "$pwd/$TESTFILE\n" "" "" +testing "readlink -f on a weird dir" "readlink -f $TESTDIR/../$TESTFILE" "$pwd/$TESTFILE\n" "" "" # clean up diff --git a/util-linux/cal.c b/util-linux/cal.c index af02608f0..8196619b0 100644 --- a/util-linux/cal.c +++ b/util-linux/cal.c @@ -35,7 +35,7 @@ #include "libbb.h" #include "unicode.h" -/* We often use "unsigned" intead of "int", it's easier to div on most CPUs */ +/* We often use "unsigned" instead of "int", it's easier to div on most CPUs */ #define THURSDAY 4 /* for reformation */ #define SATURDAY 6 /* 1 Jan 1 was a Saturday */ diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index d65011a71..8cb908cb3 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -167,7 +167,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc) * On x86, even though code does set hw clock within <1ms of exact * whole seconds, apparently hw clock (at least on some machines) * doesn't reset internal fractional seconds to 0, - * making all this a pointless excercise. + * making all this a pointless exercise. */ /* If we see that we are N usec away from whole second, * we'll sleep for N-ADJ usecs. ADJ corrects for the fact diff --git a/util-linux/renice.c b/util-linux/renice.c index 64213c680..4da3394a8 100644 --- a/util-linux/renice.c +++ b/util-linux/renice.c @@ -141,7 +141,7 @@ int renice_main(int argc UNUSED_PARAM, char **argv) retval = EXIT_FAILURE; } - /* No need to check for errors outputing to stderr since, if it + /* No need to check for errors outputting to stderr since, if it * was used, the HAD_ERROR label was reached and retval was set. */ return retval; diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c index aaee35a3e..f18e8a5ce 100644 --- a/util-linux/switch_root.c +++ b/util-linux/switch_root.c @@ -183,7 +183,7 @@ So there's a step that needs to be sort of atomic but can't be as a shell script. (You can work around this with static linking or very carefully laid out paths and sequencing, but it's brittle, ugly, and non-obvious.) -2) The "find | rm" bit will acually delete everything because the mount points +2) The "find | rm" bit will actually delete everything because the mount points still show up (even if their contents don't), and rm -rf will then happily zap that. So the first line is an oversimplification of what you need to do _not_ to descend into other filesystems and delete their contents. diff --git a/util-linux/volume_id/udf.c b/util-linux/volume_id/udf.c index 613c80c86..fa5dccee7 100644 --- a/util-linux/volume_id/udf.c +++ b/util-linux/volume_id/udf.c @@ -137,7 +137,7 @@ anchor: if (type != 2) /* TAG_ID_AVDP */ goto found; - /* get desriptor list address and block count */ + /* get descriptor list address and block count */ count = le32_to_cpu(vd->type.anchor.length) / bs; loc = le32_to_cpu(vd->type.anchor.location); dbg("0x%x descriptors starting at logical secor 0x%x", count, loc); -- cgit v1.2.3-55-g6feb