aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-03 19:00:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-03 19:03:32 +0200
commit39194f030918b87eeb3e11e94cfa05f575fb47b4 (patch)
tree97ea35e2c5984c5c6757ff9a540630ada4b234d5 /libbb
parent663ae52676eae3b0fdc6bb968ff6497279a034a4 (diff)
downloadbusybox-w32-39194f030918b87eeb3e11e94cfa05f575fb47b4.tar.gz
busybox-w32-39194f030918b87eeb3e11e94cfa05f575fb47b4.tar.bz2
busybox-w32-39194f030918b87eeb3e11e94cfa05f575fb47b4.zip
new NOFORKs: pwdx,kill[all5],ttysize,realpath,readlink NOEXECs: date,resize
function old new delta run_nofork_applet 258 280 +22 readlink_main 112 123 +11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 33/0) Total: 33 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/bb_pwd.c3
-rw-r--r--libbb/vfork_daemon_rexec.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/libbb/bb_pwd.c b/libbb/bb_pwd.c
index 4829b723a..dca0a150b 100644
--- a/libbb/bb_pwd.c
+++ b/libbb/bb_pwd.c
@@ -31,9 +31,9 @@ struct group* FAST_FUNC xgetgrnam(const char *name)
31 return gr; 31 return gr;
32} 32}
33 33
34
35struct passwd* FAST_FUNC xgetpwuid(uid_t uid) 34struct passwd* FAST_FUNC xgetpwuid(uid_t uid)
36{ 35{
36 /* Note: used in nofork applets (whoami), be careful not to leak anything */
37 struct passwd *pw = getpwuid(uid); 37 struct passwd *pw = getpwuid(uid);
38 if (!pw) 38 if (!pw)
39 bb_error_msg_and_die("unknown uid %u", (unsigned)uid); 39 bb_error_msg_and_die("unknown uid %u", (unsigned)uid);
@@ -50,6 +50,7 @@ struct group* FAST_FUNC xgetgrgid(gid_t gid)
50 50
51char* FAST_FUNC xuid2uname(uid_t uid) 51char* FAST_FUNC xuid2uname(uid_t uid)
52{ 52{
53 /* Note: used in nofork applets (whoami), be careful not to leak anything */
53 struct passwd *pw = xgetpwuid(uid); 54 struct passwd *pw = xgetpwuid(uid);
54 return pw->pw_name; 55 return pw->pw_name;
55} 56}
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index 576534ee5..487ecb0e4 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -92,6 +92,7 @@ struct nofork_save_area {
92 void (*die_func)(void); 92 void (*die_func)(void);
93 const char *applet_name; 93 const char *applet_name;
94 uint32_t option_mask32; 94 uint32_t option_mask32;
95 smallint logmode;
95 uint8_t xfunc_error_retval; 96 uint8_t xfunc_error_retval;
96}; 97};
97static void save_nofork_data(struct nofork_save_area *save) 98static void save_nofork_data(struct nofork_save_area *save)
@@ -100,6 +101,7 @@ static void save_nofork_data(struct nofork_save_area *save)
100 save->die_func = die_func; 101 save->die_func = die_func;
101 save->applet_name = applet_name; 102 save->applet_name = applet_name;
102 save->option_mask32 = option_mask32; 103 save->option_mask32 = option_mask32;
104 save->logmode = logmode;
103 save->xfunc_error_retval = xfunc_error_retval; 105 save->xfunc_error_retval = xfunc_error_retval;
104} 106}
105static void restore_nofork_data(struct nofork_save_area *save) 107static void restore_nofork_data(struct nofork_save_area *save)
@@ -108,6 +110,7 @@ static void restore_nofork_data(struct nofork_save_area *save)
108 die_func = save->die_func; 110 die_func = save->die_func;
109 applet_name = save->applet_name; 111 applet_name = save->applet_name;
110 option_mask32 = save->option_mask32; 112 option_mask32 = save->option_mask32;
113 logmode = save->logmode;
111 xfunc_error_retval = save->xfunc_error_retval; 114 xfunc_error_retval = save->xfunc_error_retval;
112} 115}
113 116
@@ -118,8 +121,8 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv)
118 121
119 save_nofork_data(&old); 122 save_nofork_data(&old);
120 123
124 logmode = LOGMODE_STDIO;
121 xfunc_error_retval = EXIT_FAILURE; 125 xfunc_error_retval = EXIT_FAILURE;
122
123 /* In case getopt() or getopt32() was already called: 126 /* In case getopt() or getopt32() was already called:
124 * reset the libc getopt() function, which keeps internal state. 127 * reset the libc getopt() function, which keeps internal state.
125 */ 128 */
@@ -146,7 +149,6 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv)
146 149
147 /* Restoring some globals */ 150 /* Restoring some globals */
148 restore_nofork_data(&old); 151 restore_nofork_data(&old);
149
150 /* Other globals can be simply reset to defaults */ 152 /* Other globals can be simply reset to defaults */
151 GETOPT_RESET(); 153 GETOPT_RESET();
152 154