diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-30 05:05:31 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-30 05:05:31 +0000 |
commit | 76ddc2e3e4837d0557fb6626394f87648e5f8c3b (patch) | |
tree | f545fe36c1ebc20c743ab28bc0df2b0f1d28b59d /libbb | |
parent | d6e8f9450cf055f0abfa424c5aa9e5a7c30d6593 (diff) | |
download | busybox-w32-76ddc2e3e4837d0557fb6626394f87648e5f8c3b.tar.gz busybox-w32-76ddc2e3e4837d0557fb6626394f87648e5f8c3b.tar.bz2 busybox-w32-76ddc2e3e4837d0557fb6626394f87648e5f8c3b.zip |
libbb: add bb_unsetenv (taken from hush).
udhcpc: stop filtering environment passed to the script.
crond: fix uncovered potential bug (failing unsetenv)
mdev: fix uncovered potential bug (failing unsetenv)
tcp, udpsvd: fix uncovered potential bug (failing unsetenv)
function old new delta
safe_setenv - 58 +58
bb_unsetenv - 55 +55
builtin_unset 139 138 -1
tcpudpsvd_main 1843 1830 -13
free_strings_and_unsetenv 87 53 -34
udhcp_run_script 1186 1133 -53
safe_setenv4 62 - -62
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/4 up/down: 113/-163) Total: -50 bytes
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/xfuncs_printf.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 108e14043..46ae7ac60 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -333,6 +333,29 @@ void FAST_FUNC xsetenv(const char *key, const char *value) | |||
333 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 333 | bb_error_msg_and_die(bb_msg_memory_exhausted); |
334 | } | 334 | } |
335 | 335 | ||
336 | /* Handles "VAR=VAL" strings, even those which are part of environ | ||
337 | * _right now_ | ||
338 | */ | ||
339 | void FAST_FUNC bb_unsetenv(const char *var) | ||
340 | { | ||
341 | char *tp = strchr(var, '='); | ||
342 | |||
343 | if (!tp) { | ||
344 | unsetenv(var); | ||
345 | return; | ||
346 | } | ||
347 | |||
348 | /* In case var was putenv'ed, we can't replace '=' | ||
349 | * with NUL and unsetenv(var) - it won't work, | ||
350 | * env is modified by the replacement, unsetenv | ||
351 | * sees "VAR" instead of "VAR=VAL" and does not remove it! | ||
352 | * horror :( */ | ||
353 | tp = xstrndup(var, tp - var); | ||
354 | unsetenv(tp); | ||
355 | free(tp); | ||
356 | } | ||
357 | |||
358 | |||
336 | // Die with an error message if we can't set gid. (Because resource limits may | 359 | // Die with an error message if we can't set gid. (Because resource limits may |
337 | // limit this user to a given number of processes, and if that fills up the | 360 | // limit this user to a given number of processes, and if that fills up the |
338 | // setgid() will fail and we'll _still_be_root_, which is bad.) | 361 | // setgid() will fail and we'll _still_be_root_, which is bad.) |