diff options
author | Andrey Mazo <ahippo@yandex.com> | 2019-02-22 16:46:19 -0500 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-02-27 08:27:47 +0100 |
commit | 87e216294af9eec39c0c1d553555f8a98c15db38 (patch) | |
tree | 5d3232db1a6507056974fdc6a70b5519e7b655c6 | |
parent | 544143da0cd0309b46427d4da9858dcd1dca953d (diff) | |
download | busybox-w32-87e216294af9eec39c0c1d553555f8a98c15db38.tar.gz busybox-w32-87e216294af9eec39c0c1d553555f8a98c15db38.tar.bz2 busybox-w32-87e216294af9eec39c0c1d553555f8a98c15db38.zip |
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 <ahippo@yandex.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 8 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 38c91cbb4..8a4a4b7a5 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -1370,7 +1370,13 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1370 | bb_error_msg("no lease, forking to background"); | 1370 | bb_error_msg("no lease, forking to background"); |
1371 | client_background(); | 1371 | client_background(); |
1372 | /* do not background again! */ | 1372 | /* do not background again! */ |
1373 | opt = ((opt & ~OPT_b) | OPT_f); | 1373 | opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); |
1374 | /* ^^^ also disables -n (-b takes priority over -n): | ||
1375 | * ifup's default udhcpc options are -R -n, | ||
1376 | * and users want to be able to add -b | ||
1377 | * (in a config file) to make it background | ||
1378 | * _and not exit_. | ||
1379 | */ | ||
1374 | } else | 1380 | } else |
1375 | #endif | 1381 | #endif |
1376 | if (opt & OPT_n) { /* abort if no lease */ | 1382 | if (opt & OPT_n) { /* abort if no lease */ |
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) | |||
1484 | bb_error_msg("no lease, forking to background"); | 1484 | bb_error_msg("no lease, forking to background"); |
1485 | client_background(); | 1485 | client_background(); |
1486 | /* do not background again! */ | 1486 | /* do not background again! */ |
1487 | opt = ((opt & ~OPT_b) | OPT_f); | 1487 | opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); |
1488 | /* ^^^ also disables -n (-b takes priority over -n): | ||
1489 | * ifup's default udhcpc options are -R -n, | ||
1490 | * and users want to be able to add -b | ||
1491 | * (in a config file) to make it background | ||
1492 | * _and not exit_. | ||
1493 | */ | ||
1488 | } else | 1494 | } else |
1489 | #endif | 1495 | #endif |
1490 | if (opt & OPT_n) { /* abort if no lease */ | 1496 | if (opt & OPT_n) { /* abort if no lease */ |