From 02b8b9b0144d9de65e55015c0f3848a529a0738b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 14 May 2012 23:52:57 +0200 Subject: busybox: tweak help text and copyright year Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 73f71f1d0..09e886d7a 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -627,11 +627,11 @@ static int busybox_main(char **argv) full_write2_str(bb_banner); /* reuse const string */ full_write2_str(" multi-call binary.\n"); /* reuse */ full_write2_str( - "Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko\n" + "Copyright (C) 1998-2012 Erik Andersen, Rob Landley, Denys Vlasenko\n" "and others. Licensed under GPLv2.\n" "See source distribution for full notice.\n" "\n" - "Usage: busybox [function] [arguments]...\n" + "Usage: busybox [function [arguments]...]\n" " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n" IF_FEATURE_INSTALLER( " or: busybox --install [-s] [DIR]\n" -- cgit v1.2.3-55-g6feb From 02112d8ae3d0c07214fb2b132e0eacb4ff39d167 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 22 May 2012 17:11:46 +0200 Subject: unzip: ignore chmod errors This makes unzip to FAT filesystems not exit with error. This is similar to how the "normal" unzip works. Signed-off-by: Natanael Copa Signed-off-by: Denys Vlasenko --- archival/unzip.c | 2 +- include/libbb.h | 1 + libbb/make_directory.c | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'libbb') diff --git a/archival/unzip.c b/archival/unzip.c index 3c76cdafc..c1b945a44 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -596,7 +596,7 @@ int unzip_main(int argc, char **argv) printf(" creating: %s\n", dst_fn); } unzip_create_leading_dirs(dst_fn); - if (bb_make_directory(dst_fn, dir_mode, 0)) { + if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) { xfunc_die(); } } else { diff --git a/include/libbb.h b/include/libbb.h index f12800f53..5e5c8c7e8 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -333,6 +333,7 @@ enum { /* DO NOT CHANGE THESE VALUES! cp.c, mv.c, install.c depend on them. */ FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 9, /* -c */ FILEUTILS_SET_SECURITY_CONTEXT = 1 << 10, #endif + FILEUTILS_IGNORE_CHMOD_ERR = 1 << 11, }; #define FILEUTILS_CP_OPTSTR "pdRfilsLH" IF_SELINUX("c") extern int remove_file(const char *path, int flags) FAST_FUNC; diff --git a/libbb/make_directory.c b/libbb/make_directory.c index 72303e7a3..7826b90f5 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c @@ -107,6 +107,10 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags) * an error. */ if ((mode != -1) && (chmod(path, mode) < 0)) { fail_msg = "set permissions of"; + if (flags & FILEUTILS_IGNORE_CHMOD_ERR) { + flags = 0; + goto print_err; + } break; } goto ret0; @@ -116,8 +120,9 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags) *s = c; } /* while (1) */ - bb_perror_msg("can't %s directory '%s'", fail_msg, path); flags = -1; + print_err: + bb_perror_msg("can't %s directory '%s'", fail_msg, path); goto ret; ret0: flags = 0; -- cgit v1.2.3-55-g6feb From c9677ed83c948c9afb7f1bbd9bac91c854289887 Mon Sep 17 00:00:00 2001 From: Tias Guns Date: Sun, 10 Jun 2012 14:40:30 +0200 Subject: libbb: add missing_syscalls.c: for now, only Android syscalls Signed-off-by: Tias Guns Signed-off-by: Denys Vlasenko --- libbb/missing_syscalls.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 libbb/missing_syscalls.c (limited to 'libbb') diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c new file mode 100644 index 000000000..dd430e3e2 --- /dev/null +++ b/libbb/missing_syscalls.c @@ -0,0 +1,42 @@ +/* + * Copyright 2012, Denys Vlasenko + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ + +//kbuild:lib-y += missing_syscalls.o + +/*#include - for struct timex, but may collide with */ +#include +#include "libbb.h" + +#if defined(ANDROID) || defined(__ANDROID__) +pid_t getsid(pid_t pid) +{ + return syscall(__NR_getsid, pid); +} + +int stime(const time_t *t) +{ + struct timeval tv; + tv.tv_sec = *t; + tv.tv_usec = 0; + return settimeofday(&tv, NULL); +} + +int sethostname(const char *name, size_t len) +{ + return syscall(__NR_sethostname, name, len); +} + +struct timex; +int adjtimex(struct timex *buf) +{ + return syscall(__NR_adjtimex, buf); +} + +int pivot_root(const char *new_root, const char *put_old) +{ + return syscall(__NR_pivot_root, new_root, put_old); +} +#endif -- cgit v1.2.3-55-g6feb From 0ccae4d8b379d310213a4e911670070b7030482d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 11 Jun 2012 14:40:17 +0200 Subject: Add comments in keyboard escape sequences table Signed-off-by: Denys Vlasenko --- libbb/read_key.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'libbb') diff --git a/libbb/read_key.c b/libbb/read_key.c index 8d72d2a63..ace23defb 100644 --- a/libbb/read_key.c +++ b/libbb/read_key.c @@ -15,7 +15,10 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) const char *seq; int n; - /* Known escape sequences for cursor and function keys */ + /* Known escape sequences for cursor and function keys. + * See "Xterm Control Sequences" + * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html + */ static const char esccmds[] ALIGN1 = { 'O','A' |0x80,KEYCODE_UP , 'O','B' |0x80,KEYCODE_DOWN , @@ -44,6 +47,8 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) /* ESC [ 1 ; 4 x, where x = A/B/C/D: Alt-Shift- */ /* ESC [ 1 ; 5 x, where x = A/B/C/D: Ctrl- - implemented below */ /* ESC [ 1 ; 6 x, where x = A/B/C/D: Ctrl-Shift- */ + /* ESC [ 1 ; 7 x, where x = A/B/C/D: Ctrl-Alt- */ + /* ESC [ 1 ; 8 x, where x = A/B/C/D: Ctrl-Alt-Shift- */ '[','H' |0x80,KEYCODE_HOME , /* xterm */ '[','F' |0x80,KEYCODE_END , /* xterm */ /* [ESC] ESC [ [2] H - [Alt-][Shift-]Home (End similarly?) */ @@ -64,10 +69,10 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) '[','7','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */ '[','8','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */ #if 0 - '[','1','1','~'|0x80,KEYCODE_FUN1 , - '[','1','2','~'|0x80,KEYCODE_FUN2 , - '[','1','3','~'|0x80,KEYCODE_FUN3 , - '[','1','4','~'|0x80,KEYCODE_FUN4 , + '[','1','1','~'|0x80,KEYCODE_FUN1 , /* old xterm, deprecated by ESC O P */ + '[','1','2','~'|0x80,KEYCODE_FUN2 , /* old xterm... */ + '[','1','3','~'|0x80,KEYCODE_FUN3 , /* old xterm... */ + '[','1','4','~'|0x80,KEYCODE_FUN4 , /* old xterm... */ '[','1','5','~'|0x80,KEYCODE_FUN5 , /* [ESC] ESC [ 1 5 [;2] ~ - [Alt-][Shift-]F5 */ '[','1','7','~'|0x80,KEYCODE_FUN6 , -- cgit v1.2.3-55-g6feb From 70fc8c17e2d032f34162f7abc3e65a67c0ff272a Mon Sep 17 00:00:00 2001 From: Pascal Bellard Date: Tue, 12 Jun 2012 13:21:02 +0200 Subject: su: do not change to home dir unless -l Signed-off-by: Pascal Bellard Signed-off-by: Denys Vlasenko --- include/libbb.h | 1 + libbb/setup_environment.c | 8 +++++--- libbb/xfuncs_printf.c | 4 ++-- loginutils/su.c | 3 ++- networking/httpd.c | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index 5e5c8c7e8..322a28cab 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1286,6 +1286,7 @@ int sd_listen_fds(void); #define SETUP_ENV_CHANGEENV (1 << 0) #define SETUP_ENV_CLEARENV (1 << 1) #define SETUP_ENV_TO_TMP (1 << 2) +#define SETUP_ENV_NO_CHDIR (1 << 4) extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC; extern int correct_password(const struct passwd *pw) FAST_FUNC; /* Returns a malloced string */ diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index 73229ca6c..4258656fe 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c @@ -37,9 +37,11 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct pass /* Change the current working directory to be the home directory * of the user */ - if (chdir(pw->pw_dir)) { - xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/"); - bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); + if (!(flags & SETUP_ENV_NO_CHDIR)) { + if (chdir(pw->pw_dir) != 0) { + bb_error_msg("can't change directory to '%s'", pw->pw_dir); + xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/"); + } } if (flags & SETUP_ENV_CLEARENV) { diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index d8a42ba0b..05aa07ce8 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -355,13 +355,13 @@ void FAST_FUNC xsetuid(uid_t uid) void FAST_FUNC xchdir(const char *path) { if (chdir(path)) - bb_perror_msg_and_die("chdir(%s)", path); + bb_perror_msg_and_die("can't change directory to '%s'", path); } void FAST_FUNC xchroot(const char *path) { if (chroot(path)) - bb_perror_msg_and_die("can't change root directory to %s", path); + bb_perror_msg_and_die("can't change root directory to '%s'", path); xchdir("/"); } diff --git a/loginutils/su.c b/loginutils/su.c index 57ea738f4..2ec05e125 100644 --- a/loginutils/su.c +++ b/loginutils/su.c @@ -131,7 +131,8 @@ int su_main(int argc UNUSED_PARAM, char **argv) change_identity(pw); setup_environment(opt_shell, ((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV) - + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV), + + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV) + + (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR), pw); IF_SELINUX(set_current_security_context(NULL);) diff --git a/networking/httpd.c b/networking/httpd.c index 12218a0a3..a942794f5 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -1414,7 +1414,7 @@ static void send_cgi_and_exit( if (script != url) { /* paranoia */ *script = '\0'; if (chdir(url + 1) != 0) { - bb_perror_msg("chdir(%s)", url + 1); + bb_perror_msg("can't change directory to '%s'", url + 1); goto error_execing_cgi; } // not needed: *script = '/'; -- cgit v1.2.3-55-g6feb From 0e941d542736dc5eb69add1d3377a4601536eb97 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 13 Jul 2012 11:38:38 -0400 Subject: Simplify copyright/license notice that appears in the binary. Existing copyright notice for binary would need to be longer to achieve optimal accuracy. This compromise punts to the source for full notices, but does note the years of the copyrights and that there are many authors, all licensing under GPLv2. Signed-off-by: Bradley M. Kuhn Signed-off-by: Tony Sebro Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 09e886d7a..da13bf36c 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -627,9 +627,9 @@ static int busybox_main(char **argv) full_write2_str(bb_banner); /* reuse const string */ full_write2_str(" multi-call binary.\n"); /* reuse */ full_write2_str( - "Copyright (C) 1998-2012 Erik Andersen, Rob Landley, Denys Vlasenko\n" - "and others. Licensed under GPLv2.\n" - "See source distribution for full notice.\n" + "BusyBox is copyrighted by many authors between 1998-2012.\n" + "Licensed under GPLv2. See source distribution for detailed\n" + "copyright notices.\n" "\n" "Usage: busybox [function [arguments]...]\n" " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n" -- cgit v1.2.3-55-g6feb From 4919565c152f2ecee760b5419c947764e991ab3e Mon Sep 17 00:00:00 2001 From: Cliff Frey Date: Tue, 7 Aug 2012 17:59:40 +0200 Subject: lineedit: fix Alt-D when cursor==0 Signed-off-by: Cliff Frey Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libbb') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index b89748a1c..92bea856e 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -2527,9 +2527,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman /* Delete word forward */ int nc, sc = cursor; ctrl_right(); - nc = cursor; - input_backward(cursor - sc); - while (--nc >= cursor) + nc = cursor - sc; + input_backward(nc); + while (--nc >= 0) input_delete(1); break; } -- cgit v1.2.3-55-g6feb From d1d794fd4878834324602ae12ad7af73064683a9 Mon Sep 17 00:00:00 2001 From: walter harms Date: Tue, 4 Sep 2012 12:26:20 +0200 Subject: refactor correct_password.c to avoid one if Signed-off-by: walter harms Signed-off-by: Denys Vlasenko --- libbb/correct_password.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'libbb') diff --git a/libbb/correct_password.c b/libbb/correct_password.c index 6301589e6..7cabd33d0 100644 --- a/libbb/correct_password.c +++ b/libbb/correct_password.c @@ -41,12 +41,6 @@ int FAST_FUNC correct_password(const struct passwd *pw) char *unencrypted, *encrypted; const char *correct; int r; -#if ENABLE_FEATURE_SHADOWPASSWDS - /* Using _r function to avoid pulling in static buffers */ - struct spwd spw; - char buffer[256]; -#endif - /* fake salt. crypt() can choke otherwise. */ correct = "aa"; if (!pw) { @@ -55,7 +49,10 @@ int FAST_FUNC correct_password(const struct passwd *pw) } correct = pw->pw_passwd; #if ENABLE_FEATURE_SHADOWPASSWDS + /* Using _r function to avoid pulling in static buffers */ if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) { + struct spwd spw; + char buffer[256]; /* getspnam_r may return 0 yet set result to NULL. * At least glibc 2.4 does this. Be extra paranoid here. */ struct spwd *result = NULL; -- cgit v1.2.3-55-g6feb From 50157f3decce78d3172314a5f97363faedba565a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 6 Sep 2012 12:43:22 +0200 Subject: top: fix "last CPU" parsing Signed-off-by: Denys Vlasenko --- libbb/procps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libbb') diff --git a/libbb/procps.c b/libbb/procps.c index 40587db82..295048c46 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -425,7 +425,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags) if (n < 11) continue; /* bogus data, get next /proc/XXX */ # if ENABLE_FEATURE_TOP_SMP_PROCESS - if (n < 11+15) + if (n == 11) sp->last_seen_on_cpu = 0; # endif -- cgit v1.2.3-55-g6feb