From 87e216294af9eec39c0c1d553555f8a98c15db38 Mon Sep 17 00:00:00 2001 From: Andrey Mazo Date: Fri, 22 Feb 2019 16:46:19 -0500 Subject: udhcpc: don't exit after backgrounding on -n -b Currently, running "udhcpc -n -b" causes udhcpc to go to background and then exit after some time unless a lease is obtained. It's not very useful to do so as the calling process doesn't know if the lease was obtained or not anyway. The code actually tries to favor "-b" over "-n", but doesn't clear "-n" flag while clearing "-b" after backgrounding. So, clear "-n" flag after going into background. This effectively makes "-b" override "-n" completely and "-n -b" behave the same as "-b". This allows to override default "-n" option, passed to udhcpc by ifupdown, without recompiling busybox. URL: https://bugs.busybox.net/11691 Signed-off-by: Andrey Mazo Signed-off-by: Denys Vlasenko --- networking/udhcp/dhcpc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'networking/udhcp/dhcpc.c') diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index d491e8906..e2fb18aba 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -1484,7 +1484,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) bb_error_msg("no lease, forking to background"); client_background(); /* do not background again! */ - opt = ((opt & ~OPT_b) | OPT_f); + opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); + /* ^^^ also disables -n (-b takes priority over -n): + * ifup's default udhcpc options are -R -n, + * and users want to be able to add -b + * (in a config file) to make it background + * _and not exit_. + */ } else #endif if (opt & OPT_n) { /* abort if no lease */ -- cgit v1.2.3