add -1 option: Try once, if we fail, EXIT

Obtained from:	OpenBSD
This commit is contained in:
David E. O'Brien 1999-02-10 23:51:25 +00:00
parent ddb444e895
commit d2c596b2e7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43861
2 changed files with 14 additions and 1 deletions

View File

@ -45,6 +45,9 @@ dhclient - Dynamic Host Configuration Protocol Client
.I port .I port
] ]
[ [
.B -1
]
[
.B -d .B -d
] ]
[ [
@ -128,6 +131,9 @@ To run force dhclient to always run as a foreground process, the
.B -d .B -d
flag should be specified. This is useful when running dhclient under flag should be specified. This is useful when running dhclient under
a debugger, or when running it out of inittab on System V systems. a debugger, or when running it out of inittab on System V systems.
The
.B -1
flag cause dhclient to try once to get a lease. If it fails, dhclient exits.
.PP .PP
.SH CONFIGURATION .SH CONFIGURATION
The syntax of the dhclient.conf(8) file is discussed seperately. The syntax of the dhclient.conf(8) file is discussed seperately.

View File

@ -92,6 +92,7 @@ u_int16_t remote_port;
int log_priority; int log_priority;
int no_daemon; int no_daemon;
int save_scripts; int save_scripts;
int onetry;
static void usage PROTO ((void)); static void usage PROTO ((void));
@ -126,6 +127,8 @@ int main (argc, argv, envp)
no_daemon = 1; no_daemon = 1;
} else if (!strcmp (argv [i], "-D")) { } else if (!strcmp (argv [i], "-D")) {
save_scripts = 1; save_scripts = 1;
} else if (!strcmp (argv [i], "-1")) {
onetry = 1;
} else if (argv [i][0] == '-') { } else if (argv [i][0] == '-') {
usage (); usage ();
} else { } else {
@ -240,7 +243,7 @@ int main (argc, argv, envp)
static void usage () static void usage ()
{ {
error ("Usage: dhclient [-c] [-p <port>] [interface]"); error ("Usage: dhclient [-1] [-c] [-p <port>] [interface]");
} }
void cleanup () void cleanup ()
@ -1090,6 +1093,10 @@ void state_panic (ipp)
/* No leases were available, or what was available didn't work, so /* No leases were available, or what was available didn't work, so
tell the shell script that we failed to allocate an address, tell the shell script that we failed to allocate an address,
and try again later. */ and try again later. */
if (onetry) {
exit(1);
note ("Unable to obtain a lease on first try - exiting.\n");
}
note ("No working leases in persistent database - sleeping.\n"); note ("No working leases in persistent database - sleeping.\n");
script_init (ip, "FAIL", (struct string_list *)0); script_init (ip, "FAIL", (struct string_list *)0);
if (ip -> client -> alias) if (ip -> client -> alias)