From: Roy Marples Date: Fri, 16 Oct 2009 19:59:30 +0000 (+0000) Subject: Add back -w, --waitip so that user has total control over behaviour. X-Git-Tag: v5.1.2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a07a2afd84967f5b9e0953ee0ad85c1b5cc87ec;p=thirdparty%2Fdhcpcd.git Add back -w, --waitip so that user has total control over behaviour. --- diff --git a/dhcpcd.8.in b/dhcpcd.8.in index 2c772700..ee968d4c 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 15, 2009 +.Dd October 16, 2009 .Dt DHCPCD 8 SMM .Os .Sh NAME @@ -30,7 +30,7 @@ .Nd an RFC 2131 compliant DHCP client .Sh SYNOPSIS .Nm -.Op Fl bdgknpqABDEGKLTV +.Op Fl bdgknpqwABDEGKLTV .Op Fl c , -script Ar script .Op Fl e , -env Ar value .Op Fl f , -config Ar file @@ -336,6 +336,8 @@ Set the vendor option 03 with an IP address as a string. .D1 dhcpcd \-v 03,\e"192.168.0.2\e" eth0 Set un-encapulated vendor option to hello world. .D1 dhcpcd \-v ,"hello world" eth0 +.It Fl w , -waitip +Wait for an address to be assigned before forking to the background. .It Fl x , -exit This will signal an existing .Nm diff --git a/dhcpcd.c b/dhcpcd.c index c41488d3..a8944264 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1800,7 +1800,10 @@ main(int argc, char **argv) if (iface->carrier != LINK_DOWN) opt = 1; } - if (options & DHCPCD_LINK && opt == 0) { + if (opt == 0 && + options & DHCPCD_LINK && + !(options & DHCPCD_WAITIP)) + { syslog(LOG_WARNING, "no interfaces have a carrier"); daemonise(); } else if (options & DHCPCD_DAEMONISE && ifo->timeout > 0) { diff --git a/dhcpcd.conf.5.in b/dhcpcd.conf.5.in index 7fcc58cc..7becfa11 100644 --- a/dhcpcd.conf.5.in +++ b/dhcpcd.conf.5.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 7, 2009 +.Dd October 16, 2009 .Dt DHCPCD.CONF 5 SMM .Os .Sh NAME @@ -272,6 +272,8 @@ Set un-encapulated vendor option to hello world. .It Ic vendorclassid Ar string Change the default vendorclassid sent from dhcpcd-version. If not set then none is sent. +.It Ic waitip +Wait for an address to be assigned before forking to the background. .El .Sh SEE ALSO .Xr dhcpcd-run-hooks 8 , diff --git a/if-options.c b/if-options.c index 53bb1a18..c4d8d096 100644 --- a/if-options.c +++ b/if-options.c @@ -72,6 +72,7 @@ const struct option cf_options[] = { {"timeout", required_argument, NULL, 't'}, {"userclass", required_argument, NULL, 'u'}, {"vendor", required_argument, NULL, 'v'}, + {"waitip", no_argument, NULL, 'w'}, {"exit", no_argument, NULL, 'x'}, {"allowinterfaces", required_argument, NULL, 'z'}, {"reboot", required_argument, NULL, 'y'}, @@ -507,6 +508,9 @@ parse_option(struct if_options *ifo, int opt, const char *arg) ifo->vendor[0] += s + 2; } break; + case 'w': + ifo->options |= DHCPCD_WAITIP; + break; case 'y': ifo->reboot = atoint(arg); if (ifo->reboot < 0) { diff --git a/if-options.h b/if-options.h index 532bcd48..9f49021a 100644 --- a/if-options.h +++ b/if-options.h @@ -37,7 +37,7 @@ /* Don't set any optional arguments here so we retain POSIX * compatibility with getopt */ -#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:xy:z:ABC:DEF:GI:KLN:O:Q:TVW:X:Z:" +#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GI:KLN:O:Q:TVW:X:Z:" #define DEFAULT_TIMEOUT 30 #define DEFAULT_REBOOT 10 @@ -71,6 +71,7 @@ #define DHCPCD_BACKGROUND (1 << 22) #define DHCPCD_VENDORRAW (1 << 23) #define DHCPCD_TIMEOUT_IPV4LL (1 << 24) +#define DHCPCD_WAITIP (1 << 25) extern const struct option cf_options[];