2024-09-27 09:07:54 +02:00
|
|
|
From 1525edfc632c10164ffaa929a3d470c82802e6f9 Mon Sep 17 00:00:00 2001
|
2017-07-06 15:39:38 +02:00
|
|
|
From: Natanael Copa <ncopa@alpinelinux.org>
|
2023-01-04 13:38:02 +01:00
|
|
|
Date: Thu, 6 Jul 2017 07:05:15 +0200
|
2018-08-04 00:11:42 +02:00
|
|
|
Subject: [PATCH] udhcpc: Don't background if -n is given
|
2023-01-04 13:38:02 +01:00
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
2017-05-23 18:43:11 +02:00
|
|
|
|
|
|
|
we need add -b to our udhcpc options to prevent boot forever if there are no
|
|
|
|
dhcp server. We also need a way for users to disable this behavior by making
|
|
|
|
it possible to set -n option at runtime.
|
2019-07-23 12:01:21 +02:00
|
|
|
|
|
|
|
Since busybox 1.31.0 -b takes precedence over -n [0]. However, since we
|
|
|
|
enable -b instead of -n by default (through our busyboxconfig) this is
|
|
|
|
not desired, this commit therefore also reverts the upstream patch
|
|
|
|
introducing this change.
|
|
|
|
|
|
|
|
See also: https://bugs.busybox.net/11691
|
|
|
|
|
|
|
|
[0]: https://git.busybox.net/busybox/commit/?id=87e216294af9eec39c0c1d553555f8a98c15db38
|
2023-01-04 13:38:02 +01:00
|
|
|
|
2017-07-06 15:39:38 +02:00
|
|
|
---
|
2019-09-10 19:36:58 +02:00
|
|
|
networking/udhcp/d6_dhcpc.c | 20 +++++++-------------
|
2019-07-23 12:01:21 +02:00
|
|
|
networking/udhcp/dhcpc.c | 20 +++++++-------------
|
2019-09-10 19:36:58 +02:00
|
|
|
2 files changed, 14 insertions(+), 26 deletions(-)
|
2017-05-23 18:43:11 +02:00
|
|
|
|
2019-07-23 12:01:21 +02:00
|
|
|
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
|
2024-09-27 09:07:54 +02:00
|
|
|
index edebf983b..1bc0cacfc 100644
|
2019-07-23 12:01:21 +02:00
|
|
|
--- a/networking/udhcp/d6_dhcpc.c
|
|
|
|
+++ b/networking/udhcp/d6_dhcpc.c
|
2024-09-27 09:07:54 +02:00
|
|
|
@@ -1404,25 +1404,19 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
|
2019-09-10 19:36:58 +02:00
|
|
|
leasefail:
|
2021-08-21 07:18:43 +02:00
|
|
|
change_listen_mode(LISTEN_NONE);
|
2019-09-10 19:36:58 +02:00
|
|
|
d6_run_script_no_option("leasefail");
|
|
|
|
+ if (opt & OPT_n) { /* abort if no lease */
|
2020-06-27 00:14:43 +02:00
|
|
|
+ bb_simple_info_msg("no lease, failing");
|
2019-09-10 19:36:58 +02:00
|
|
|
+ retval = 1;
|
|
|
|
+ goto ret;
|
|
|
|
+ }
|
|
|
|
#if BB_MMU /* -b is not supported on NOMMU */
|
|
|
|
if (opt & OPT_b) { /* background if no lease */
|
2020-06-27 00:14:43 +02:00
|
|
|
bb_simple_info_msg("no lease, forking to background");
|
2019-07-23 12:01:21 +02:00
|
|
|
client_background();
|
|
|
|
/* do not background again! */
|
|
|
|
- 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_.
|
|
|
|
- */
|
2019-09-10 19:36:58 +02:00
|
|
|
- } else
|
|
|
|
-#endif
|
|
|
|
- if (opt & OPT_n) { /* abort if no lease */
|
2020-06-27 00:14:43 +02:00
|
|
|
- bb_simple_info_msg("no lease, failing");
|
2019-09-10 19:36:58 +02:00
|
|
|
- retval = 1;
|
|
|
|
- goto ret;
|
2019-07-23 12:01:21 +02:00
|
|
|
+ opt = ((opt & ~OPT_b) | OPT_f);
|
2019-09-10 19:36:58 +02:00
|
|
|
}
|
|
|
|
+#endif
|
2021-08-21 07:18:43 +02:00
|
|
|
/* Wait before trying again */
|
2019-09-10 19:36:58 +02:00
|
|
|
timeout = tryagain_timeout;
|
|
|
|
packet_num = 0;
|
2017-05-23 18:43:11 +02:00
|
|
|
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
|
2024-09-27 09:07:54 +02:00
|
|
|
index 090fbcc07..215d01594 100644
|
2017-05-23 18:43:11 +02:00
|
|
|
--- a/networking/udhcp/dhcpc.c
|
|
|
|
+++ b/networking/udhcp/dhcpc.c
|
2024-09-27 09:07:54 +02:00
|
|
|
@@ -1446,25 +1446,19 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|
2017-05-23 18:43:11 +02:00
|
|
|
leasefail:
|
2021-08-21 07:18:43 +02:00
|
|
|
change_listen_mode(LISTEN_NONE);
|
|
|
|
d4_run_script(NULL, "leasefail");
|
2017-05-23 18:43:11 +02:00
|
|
|
+ if (opt & OPT_n) { /* abort if no lease */
|
2020-06-27 00:14:43 +02:00
|
|
|
+ bb_simple_info_msg("no lease, failing");
|
2017-05-23 18:43:11 +02:00
|
|
|
+ retval = 1;
|
|
|
|
+ goto ret;
|
|
|
|
+ }
|
|
|
|
#if BB_MMU /* -b is not supported on NOMMU */
|
|
|
|
if (opt & OPT_b) { /* background if no lease */
|
2020-06-27 00:14:43 +02:00
|
|
|
bb_simple_info_msg("no lease, forking to background");
|
2017-05-23 18:43:11 +02:00
|
|
|
client_background();
|
|
|
|
/* do not background again! */
|
2019-07-23 12:01:21 +02:00
|
|
|
- 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_.
|
|
|
|
- */
|
2017-05-23 18:43:11 +02:00
|
|
|
- } else
|
|
|
|
-#endif
|
|
|
|
- if (opt & OPT_n) { /* abort if no lease */
|
2020-06-27 00:14:43 +02:00
|
|
|
- bb_simple_info_msg("no lease, failing");
|
2017-05-23 18:43:11 +02:00
|
|
|
- retval = 1;
|
|
|
|
- goto ret;
|
2019-07-23 12:01:21 +02:00
|
|
|
+ opt = ((opt & ~OPT_b) | OPT_f);
|
2017-05-23 18:43:11 +02:00
|
|
|
}
|
|
|
|
+#endif
|
2021-08-21 07:18:43 +02:00
|
|
|
/* Wait before trying again */
|
2017-05-23 18:43:11 +02:00
|
|
|
timeout = tryagain_timeout;
|
|
|
|
packet_num = 0;
|