aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/0012-udhcpc-Don-t-background-if-n-is-given.patch
blob: 8d4a4880141b1ec10259d460e0a2955744c0809e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From a74c9074136192461b459df3f10a08ad416f4cb4 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 6 Jul 2017 13:39:15 +0200
Subject: [PATCH] udhcpc: Don't background if -n is given

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.

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
---
 networking/udhcp/d6_dhcpc.c | 20 +++++++-------------
 networking/udhcp/dhcpc.c    | 20 +++++++-------------
 2 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index fc2d672b7..bf9363bac 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -1432,25 +1432,19 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
 				}
  leasefail:
 				d6_run_script_no_option("leasefail");
+				if (opt & OPT_n) { /* abort if no lease */
+					bb_simple_info_msg("no lease, failing");
+					retval = 1;
+					goto ret;
+				}
 #if BB_MMU /* -b is not supported on NOMMU */
 				if (opt & OPT_b) { /* background if no lease */
 					bb_simple_info_msg("no lease, forking to background");
 					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_.
-					 */
-				} else
-#endif
-				if (opt & OPT_n) { /* abort if no lease */
-					bb_simple_info_msg("no lease, failing");
-					retval = 1;
-					goto ret;
+					opt = ((opt & ~OPT_b) | OPT_f);
 				}
+#endif
 				/* wait before trying again */
 				timeout = tryagain_timeout;
 				packet_num = 0;
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 102178a4f..f20d3ddb9 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1438,25 +1438,19 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 				}
  leasefail:
 				udhcp_run_script(NULL, "leasefail");
+				if (opt & OPT_n) { /* abort if no lease */
+					bb_simple_info_msg("no lease, failing");
+					retval = 1;
+					goto ret;
+				}
 #if BB_MMU /* -b is not supported on NOMMU */
 				if (opt & OPT_b) { /* background if no lease */
 					bb_simple_info_msg("no lease, forking to background");
 					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_.
-					 */
-				} else
-#endif
-				if (opt & OPT_n) { /* abort if no lease */
-					bb_simple_info_msg("no lease, failing");
-					retval = 1;
-					goto ret;
+					opt = ((opt & ~OPT_b) | OPT_f);
 				}
+#endif
 				/* wait before trying again */
 				timeout = tryagain_timeout;
 				packet_num = 0;