From 088fec36fedff2cd50437c95b7fb430abf8d303c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 14 Jan 2019 14:45:18 +0100 Subject: start-stop-daemon: create pidfile before parent exits, closes 8596 This removes DAEMON_DOUBLE_FORK flag from bb_daemonize_or_rexec(), as SSD was the only user. Also includes fix for -S: now works without -a and -x, does not print pids (compat with "start-stop-daemon (OpenRC) 0.34.11 (Gentoo Linux)"). function old new delta start_stop_daemon_main 1018 1084 +66 add_interface 99 103 +4 fail_hunk 139 136 -3 bb_daemonize_or_rexec 205 183 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 70/-25) Total: 45 bytes Signed-off-by: Denys Vlasenko --- libbb/vfork_daemon_rexec.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libbb') diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index c0bea0ed2..1aac27b36 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c @@ -292,14 +292,14 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv) dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); - if (flags & DAEMON_DOUBLE_FORK) { - /* On Linux, session leader can acquire ctty - * unknowingly, by opening a tty. - * Prevent this: stop being a session leader. - */ - if (fork_or_rexec(argv)) - _exit(EXIT_SUCCESS); /* parent */ - } +// if (flags & DAEMON_DOUBLE_FORK) { +// /* On Linux, session leader can acquire ctty +// * unknowingly, by opening a tty. +// * Prevent this: stop being a session leader. +// */ +// if (fork_or_rexec(argv)) +// _exit(EXIT_SUCCESS); /* parent */ +// } } while (fd > 2) { close(fd--); -- cgit v1.2.3-55-g6feb From 11cb9eeffec0e2575c8722e83de3116f81b61b4f Mon Sep 17 00:00:00 2001 From: Mark Marshall Date: Fri, 18 Jan 2019 09:10:34 +0100 Subject: capability: fix string comparison in cap_name_to_number The result of strcasecmp was being used incorrectly. This function returns 0 if the strings match. Signed-off-by: Mark Marshall Signed-off-by: Denys Vlasenko --- libbb/capability.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libbb') diff --git a/libbb/capability.c b/libbb/capability.c index 6587dcbf7..d0ae78b91 100644 --- a/libbb/capability.c +++ b/libbb/capability.c @@ -67,7 +67,7 @@ unsigned FAST_FUNC cap_name_to_number(const char *cap) goto found; } for (i = 0; i < ARRAY_SIZE(capabilities); i++) { - if (strcasecmp(capabilities[i], cap) != 0) + if (strcasecmp(capabilities[i], cap) == 0) goto found; } bb_error_msg_and_die("unknown capability '%s'", cap); -- cgit v1.2.3-55-g6feb From 779f96a24c43209be841f9cc0e7715a2c57db487 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 4 Feb 2019 16:16:30 +0100 Subject: lineedit: fix SEGV in isk, hexedit, ed, closes 11661 fdisk, hexedit and ed calls read_line_edit in libbb/lineedit.c with NULL as first argument. On line 2373 of lineedit.c of busybox version 1.29.3, state->hist_file is referenced without checking the state->flag. This causes segmentation fault on fdisk, hexedit and ed on ARM Cortex-A9. It somehow works on x86_64. Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libbb') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 0a888fa70..1d5fef5ee 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -2383,13 +2383,14 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman timeout = st->timeout; } #if MAX_HISTORY > 0 + if (state->flags & DO_HISTORY) { # if ENABLE_FEATURE_EDITING_SAVEHISTORY - if (state->hist_file) - if (state->cnt_history == 0) - load_history(state); + if (state->hist_file) + if (state->cnt_history == 0) + load_history(state); # endif - if (state->flags & DO_HISTORY) state->cur_history = state->cnt_history; + } #endif /* prepare before init handlers */ -- cgit v1.2.3-55-g6feb