aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c8
-rw-r--r--libbb/correct_password.c9
-rw-r--r--libbb/lineedit.c6
-rw-r--r--libbb/make_directory.c7
-rw-r--r--libbb/missing_syscalls.c42
-rw-r--r--libbb/procps.c2
-rw-r--r--libbb/read_key.c15
-rw-r--r--libbb/setup_environment.c8
-rw-r--r--libbb/xfuncs_printf.c4
9 files changed, 76 insertions, 25 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 76c4d8ff3..0c0d14499 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -629,11 +629,11 @@ static int busybox_main(char **argv)
629 full_write2_str(bb_banner); /* reuse const string */ 629 full_write2_str(bb_banner); /* reuse const string */
630 full_write2_str(" multi-call binary.\n"); /* reuse */ 630 full_write2_str(" multi-call binary.\n"); /* reuse */
631 full_write2_str( 631 full_write2_str(
632 "Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko\n" 632 "BusyBox is copyrighted by many authors between 1998-2012.\n"
633 "and others. Licensed under GPLv2.\n" 633 "Licensed under GPLv2. See source distribution for detailed\n"
634 "See source distribution for full notice.\n" 634 "copyright notices.\n"
635 "\n" 635 "\n"
636 "Usage: busybox [function] [arguments]...\n" 636 "Usage: busybox [function [arguments]...]\n"
637 " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n" 637 " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n"
638 IF_FEATURE_INSTALLER( 638 IF_FEATURE_INSTALLER(
639 " or: busybox --install [-s] [DIR]\n" 639 " or: busybox --install [-s] [DIR]\n"
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)
41 char *unencrypted, *encrypted; 41 char *unencrypted, *encrypted;
42 const char *correct; 42 const char *correct;
43 int r; 43 int r;
44#if ENABLE_FEATURE_SHADOWPASSWDS
45 /* Using _r function to avoid pulling in static buffers */
46 struct spwd spw;
47 char buffer[256];
48#endif
49
50 /* fake salt. crypt() can choke otherwise. */ 44 /* fake salt. crypt() can choke otherwise. */
51 correct = "aa"; 45 correct = "aa";
52 if (!pw) { 46 if (!pw) {
@@ -55,7 +49,10 @@ int FAST_FUNC correct_password(const struct passwd *pw)
55 } 49 }
56 correct = pw->pw_passwd; 50 correct = pw->pw_passwd;
57#if ENABLE_FEATURE_SHADOWPASSWDS 51#if ENABLE_FEATURE_SHADOWPASSWDS
52 /* Using _r function to avoid pulling in static buffers */
58 if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) { 53 if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) {
54 struct spwd spw;
55 char buffer[256];
59 /* getspnam_r may return 0 yet set result to NULL. 56 /* getspnam_r may return 0 yet set result to NULL.
60 * At least glibc 2.4 does this. Be extra paranoid here. */ 57 * At least glibc 2.4 does this. Be extra paranoid here. */
61 struct spwd *result = NULL; 58 struct spwd *result = NULL;
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 6990b91b6..65dffe56d 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -2552,9 +2552,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2552 /* Delete word forward */ 2552 /* Delete word forward */
2553 int nc, sc = cursor; 2553 int nc, sc = cursor;
2554 ctrl_right(); 2554 ctrl_right();
2555 nc = cursor; 2555 nc = cursor - sc;
2556 input_backward(cursor - sc); 2556 input_backward(nc);
2557 while (--nc >= cursor) 2557 while (--nc >= 0)
2558 input_delete(1); 2558 input_delete(1);
2559 break; 2559 break;
2560 } 2560 }
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index 8057f2cec..6f59fda29 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -114,6 +114,10 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
114 * an error. */ 114 * an error. */
115 if ((mode != -1) && (chmod(path, mode) < 0)) { 115 if ((mode != -1) && (chmod(path, mode) < 0)) {
116 fail_msg = "set permissions of"; 116 fail_msg = "set permissions of";
117 if (flags & FILEUTILS_IGNORE_CHMOD_ERR) {
118 flags = 0;
119 goto print_err;
120 }
117 break; 121 break;
118 } 122 }
119 goto ret0; 123 goto ret0;
@@ -123,8 +127,9 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
123 *s2 = c; 127 *s2 = c;
124 } /* while (1) */ 128 } /* while (1) */
125 129
126 bb_perror_msg("can't %s directory '%s'", fail_msg, path);
127 flags = -1; 130 flags = -1;
131 print_err:
132 bb_perror_msg("can't %s directory '%s'", fail_msg, path);
128 goto ret; 133 goto ret;
129 ret0: 134 ret0:
130 flags = 0; 135 flags = 0;
diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c
new file mode 100644
index 000000000..c50308ba8
--- /dev/null
+++ b/libbb/missing_syscalls.c
@@ -0,0 +1,42 @@
1/*
2 * Copyright 2012, Denys Vlasenko
3 *
4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */
6
7//kbuild:lib-$(CONFIG_PLATFORM_POSIX) += missing_syscalls.o
8
9/*#include <linux/timex.h> - for struct timex, but may collide with <time.h> */
10#include <sys/syscall.h>
11#include "libbb.h"
12
13#if defined(ANDROID) || defined(__ANDROID__)
14pid_t getsid(pid_t pid)
15{
16 return syscall(__NR_getsid, pid);
17}
18
19int stime(const time_t *t)
20{
21 struct timeval tv;
22 tv.tv_sec = *t;
23 tv.tv_usec = 0;
24 return settimeofday(&tv, NULL);
25}
26
27int sethostname(const char *name, size_t len)
28{
29 return syscall(__NR_sethostname, name, len);
30}
31
32struct timex;
33int adjtimex(struct timex *buf)
34{
35 return syscall(__NR_adjtimex, buf);
36}
37
38int pivot_root(const char *new_root, const char *put_old)
39{
40 return syscall(__NR_pivot_root, new_root, put_old);
41}
42#endif
diff --git a/libbb/procps.c b/libbb/procps.c
index dbae46e33..1080e0165 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -426,7 +426,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
426 if (n < 11) 426 if (n < 11)
427 continue; /* bogus data, get next /proc/XXX */ 427 continue; /* bogus data, get next /proc/XXX */
428# if ENABLE_FEATURE_TOP_SMP_PROCESS 428# if ENABLE_FEATURE_TOP_SMP_PROCESS
429 if (n < 11+15) 429 if (n == 11)
430 sp->last_seen_on_cpu = 0; 430 sp->last_seen_on_cpu = 0;
431# endif 431# endif
432 432
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)
15 const char *seq; 15 const char *seq;
16 int n; 16 int n;
17 17
18 /* Known escape sequences for cursor and function keys */ 18 /* Known escape sequences for cursor and function keys.
19 * See "Xterm Control Sequences"
20 * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
21 */
19 static const char esccmds[] ALIGN1 = { 22 static const char esccmds[] ALIGN1 = {
20 'O','A' |0x80,KEYCODE_UP , 23 'O','A' |0x80,KEYCODE_UP ,
21 'O','B' |0x80,KEYCODE_DOWN , 24 'O','B' |0x80,KEYCODE_DOWN ,
@@ -44,6 +47,8 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout)
44 /* ESC [ 1 ; 4 x, where x = A/B/C/D: Alt-Shift-<arrow> */ 47 /* ESC [ 1 ; 4 x, where x = A/B/C/D: Alt-Shift-<arrow> */
45 /* ESC [ 1 ; 5 x, where x = A/B/C/D: Ctrl-<arrow> - implemented below */ 48 /* ESC [ 1 ; 5 x, where x = A/B/C/D: Ctrl-<arrow> - implemented below */
46 /* ESC [ 1 ; 6 x, where x = A/B/C/D: Ctrl-Shift-<arrow> */ 49 /* ESC [ 1 ; 6 x, where x = A/B/C/D: Ctrl-Shift-<arrow> */
50 /* ESC [ 1 ; 7 x, where x = A/B/C/D: Ctrl-Alt-<arrow> */
51 /* ESC [ 1 ; 8 x, where x = A/B/C/D: Ctrl-Alt-Shift-<arrow> */
47 '[','H' |0x80,KEYCODE_HOME , /* xterm */ 52 '[','H' |0x80,KEYCODE_HOME , /* xterm */
48 '[','F' |0x80,KEYCODE_END , /* xterm */ 53 '[','F' |0x80,KEYCODE_END , /* xterm */
49 /* [ESC] ESC [ [2] H - [Alt-][Shift-]Home (End similarly?) */ 54 /* [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)
64 '[','7','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */ 69 '[','7','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */
65 '[','8','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */ 70 '[','8','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */
66#if 0 71#if 0
67 '[','1','1','~'|0x80,KEYCODE_FUN1 , 72 '[','1','1','~'|0x80,KEYCODE_FUN1 , /* old xterm, deprecated by ESC O P */
68 '[','1','2','~'|0x80,KEYCODE_FUN2 , 73 '[','1','2','~'|0x80,KEYCODE_FUN2 , /* old xterm... */
69 '[','1','3','~'|0x80,KEYCODE_FUN3 , 74 '[','1','3','~'|0x80,KEYCODE_FUN3 , /* old xterm... */
70 '[','1','4','~'|0x80,KEYCODE_FUN4 , 75 '[','1','4','~'|0x80,KEYCODE_FUN4 , /* old xterm... */
71 '[','1','5','~'|0x80,KEYCODE_FUN5 , 76 '[','1','5','~'|0x80,KEYCODE_FUN5 ,
72 /* [ESC] ESC [ 1 5 [;2] ~ - [Alt-][Shift-]F5 */ 77 /* [ESC] ESC [ 1 5 [;2] ~ - [Alt-][Shift-]F5 */
73 '[','1','7','~'|0x80,KEYCODE_FUN6 , 78 '[','1','7','~'|0x80,KEYCODE_FUN6 ,
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
37 37
38 /* Change the current working directory to be the home directory 38 /* Change the current working directory to be the home directory
39 * of the user */ 39 * of the user */
40 if (chdir(pw->pw_dir)) { 40 if (!(flags & SETUP_ENV_NO_CHDIR)) {
41 xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/"); 41 if (chdir(pw->pw_dir) != 0) {
42 bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); 42 bb_error_msg("can't change directory to '%s'", pw->pw_dir);
43 xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
44 }
43 } 45 }
44 46
45 if (flags & SETUP_ENV_CLEARENV) { 47 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)
355void FAST_FUNC xchdir(const char *path) 355void FAST_FUNC xchdir(const char *path)
356{ 356{
357 if (chdir(path)) 357 if (chdir(path))
358 bb_perror_msg_and_die("chdir(%s)", path); 358 bb_perror_msg_and_die("can't change directory to '%s'", path);
359} 359}
360 360
361void FAST_FUNC xchroot(const char *path) 361void FAST_FUNC xchroot(const char *path)
362{ 362{
363 if (chroot(path)) 363 if (chroot(path))
364 bb_perror_msg_and_die("can't change root directory to %s", path); 364 bb_perror_msg_and_die("can't change root directory to '%s'", path);
365 xchdir("/"); 365 xchdir("/");
366} 366}
367 367