diff options
author | Francis Dupont <fdupont@isc.org> | 2015-05-23 16:20:26 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2015-05-23 16:20:26 +0200 |
commit | 5e79dd4e0a1b4217bb51aa59c4072f3b9dc31e71 (patch) | |
tree | a0ab494c5db7ad3a4932af60ee635625200deb5d | |
parent | 4136513e59b6906e585eac0f0fd88706bdefcb5b (diff) | |
download | isc-dhcp-5e79dd4e0a1b4217bb51aa59c4072f3b9dc31e71.tar.gz |
merged rt38692
-rw-r--r-- | client/dhclient.c | 16 | ||||
-rw-r--r-- | dhcpctl/omshell.c | 17 | ||||
-rw-r--r-- | includes/site.h | 6 | ||||
-rw-r--r-- | relay/dhcrelay.c | 29 | ||||
-rw-r--r-- | server/dhcpd.c | 22 |
5 files changed, 73 insertions, 17 deletions
diff --git a/client/dhclient.c b/client/dhclient.c index 2adf98d8..1dd172f0 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -37,6 +37,7 @@ #include <sys/time.h> #include <sys/wait.h> #include <limits.h> +#include <isc/file.h> #include <dns/result.h> TIME default_lease_time = 43200; /* 12 hours... */ @@ -89,6 +90,8 @@ int wanted_ia_ta = 0; int wanted_ia_pd = 0; char *mockup_relay = NULL; +char *progname = NULL; + void run_stateless(int exit_mode); static void usage(void); @@ -126,6 +129,12 @@ main(int argc, char **argv) { #endif /* DHCPv6 */ char *s; +#ifdef OLD_LOG_NAME + progname = "dhclient"; +#else + progname = argv[0]; +#endif + /* Initialize client globals. */ memset(&default_duid, 0, sizeof(default_duid)); @@ -142,7 +151,7 @@ main(int argc, char **argv) { else if (fd != -1) close(fd); - openlog("dhclient", DHCP_LOG_OPTIONS, LOG_DAEMON); + openlog(isc_file_basename(progname), DHCP_LOG_OPTIONS, LOG_DAEMON); #if !(defined(DEBUG) || defined(__CYGWIN32__)) setlogmask(LOG_UPTO(LOG_INFO)); @@ -747,7 +756,7 @@ static void usage() log_info(url); - log_fatal("Usage: dhclient " + log_fatal("Usage: %s " #ifdef DHCPv6 "[-4|-6] [-SNTPI1dvrxi] [-nw] [-p <port>] [-D LL|LLT] \n" #else /* DHCPv6 */ @@ -756,7 +765,8 @@ static void usage() " [-s server-addr] [-cf config-file]\n" " [-df duid-file] [-lf lease-file]\n" " [-pf pid-file] [--no-pid] [-e VAR=val]\n" - " [-sf script-file] [interface]"); + " [-sf script-file] [interface]", + isc_file_basename(progname)); } void run_stateless(int exit_mode) diff --git a/dhcpctl/omshell.c b/dhcpctl/omshell.c index 44fd2726..adf4b9ae 100644 --- a/dhcpctl/omshell.c +++ b/dhcpctl/omshell.c @@ -3,7 +3,7 @@ Examine and modify omapi objects. */ /* - * Copyright (c) 2009-2011,2013,2014 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2009-2011,2013-2015 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 2001-2003 by Internet Software Consortium * @@ -39,6 +39,7 @@ #include <syslog.h> #include "dhcpctl.h" #include "dhcpd.h" +#include <isc/file.h> /* Fixups */ isc_result_t find_class (struct class **c, const char *n, const char *f, int l) @@ -63,7 +64,7 @@ int check_collection (struct packet *p, struct lease *l, struct collection *c) } void classify (struct packet *packet, struct class *class) { } -static void usage (char *s) { +static void usage (const char *s) { fprintf (stderr, "Usage: %s\n", s); exit (1); } @@ -94,13 +95,21 @@ main(int argc, char **argv) { char s1[1024]; int connected = 0; char hex_buf[1025]; + char *progname; + +#ifdef OLD_LOG_NAME + progname = "omshell"; +#else + progname = argv[0]; +#endif for (i = 1; i < argc; i++) { - usage(argv[0]); + usage(isc_file_basename(progname)); } /* Initially, log errors to stderr as well as to syslogd. */ - openlog ("omshell", DHCP_LOG_OPTIONS, DHCPD_LOG_FACILITY); + openlog (isc_file_basename(progname), + DHCP_LOG_OPTIONS, DHCPD_LOG_FACILITY); status = dhcpctl_initialize (); if (status != ISC_R_SUCCESS) { fprintf (stderr, "dhcpctl_initialize: %s\n", diff --git a/includes/site.h b/includes/site.h index bbc0c918..075c47a9 100644 --- a/includes/site.h +++ b/includes/site.h @@ -187,6 +187,12 @@ /* #define USE_RAW_SOCKETS */ +/* Define this to keep the old program name (e.g., "dhcpd" for + the DHCP server) in place of the (base) name the program was + invoked with. */ + +/* #define OLD_LOG_NAME */ + /* Define this to change the logging facility used by dhcpd. */ /* #define DHCPD_LOG_FACILITY LOG_DAEMON */ diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c index 15b49976..67933de1 100644 --- a/relay/dhcrelay.c +++ b/relay/dhcrelay.c @@ -30,6 +30,7 @@ #include <syslog.h> #include <signal.h> #include <sys/time.h> +#include <isc/file.h> TIME default_lease_time = 43200; /* 12 hours... */ TIME max_lease_time = 86400; /* 24 hours... */ @@ -140,15 +141,17 @@ static const char message[] = static const char url[] = "For info, please visit https://www.isc.org/software/dhcp/"; +char *progname; + #ifdef DHCPv6 #define DHCRELAY_USAGE \ -"Usage: dhcrelay [-4] [-d] [-q] [-a] [-D]\n"\ +"Usage: %s [-4] [-d] [-q] [-a] [-D]\n"\ " [-A <length>] [-c <hops>] [-p <port>]\n" \ " [-pf <pid-file>] [--no-pid]\n"\ " [-m append|replace|forward|discard]\n" \ " [-i interface0 [ ... -i interfaceN]\n" \ " server0 [ ... serverN]\n\n" \ -" dhcrelay -6 [-d] [-q] [-I] [-c <hops>] [-p <port>]\n" \ +" %s -6 [-d] [-q] [-I] [-c <hops>] [-p <port>]\n" \ " [-pf <pid-file>] [--no-pid]\n" \ " [-s <subscriber-id>]\n" \ " -l lower0 [ ... -l lowerN]\n" \ @@ -157,7 +160,7 @@ static const char url[] = " upper (server link): [address%%]interface" #else #define DHCRELAY_USAGE \ -"Usage: dhcrelay [-d] [-q] [-a] [-D] [-A <length>] [-c <hops>] [-p <port>]\n" \ +"Usage: %s [-d] [-q] [-a] [-D] [-A <length>] [-c <hops>] [-p <port>]\n" \ " [-pf <pid-file>] [--no-pid]\n" \ " [-m append|replace|forward|discard]\n" \ " [-i interface0 [ ... -i interfaceN]\n" \ @@ -165,7 +168,11 @@ static const char url[] = #endif static void usage() { - log_fatal(DHCRELAY_USAGE); + log_fatal(DHCRELAY_USAGE, +#ifdef DHCPv6 + isc_file_basename(progname), +#endif + isc_file_basename(progname)); } int @@ -184,6 +191,12 @@ main(int argc, char **argv) { int local_family_set = 0; #endif +#ifdef OLD_LOG_NAME + progname = "dhcrelay"; +#else + progname = argv[0]; +#endif + /* Make sure that file descriptors 0(stdin), 1,(stdout), and 2(stderr) are open. To do this, we assume that when we open a file the lowest available file descriptor is used. */ @@ -197,7 +210,7 @@ main(int argc, char **argv) { else if (fd != -1) close(fd); - openlog("dhcrelay", DHCP_LOG_OPTIONS, LOG_DAEMON); + openlog(isc_file_basename(progname), DHCP_LOG_OPTIONS, LOG_DAEMON); #if !defined(DEBUG) setlogmask(LOG_UPTO(LOG_INFO)); @@ -388,7 +401,11 @@ main(int argc, char **argv) { exit(0); } else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { - log_info(DHCRELAY_USAGE); + log_info(DHCRELAY_USAGE, +#ifdef DHCPv6 + isc_file_basename(progname), +#endif + isc_file_basename(progname)); exit(0); } else if (argv[i][0] == '-') { usage(); diff --git a/server/dhcpd.c b/server/dhcpd.c index 3d2aa09a..12b20bf5 100644 --- a/server/dhcpd.c +++ b/server/dhcpd.c @@ -41,6 +41,7 @@ static const char url [] = #include <limits.h> #include <sys/types.h> #include <sys/time.h> +#include <isc/file.h> #if defined (PARANOIA) # include <sys/types.h> @@ -90,6 +91,10 @@ int omapi_port; trace_type_t *trace_srandom; #endif +#ifndef UNIT_TEST +char *progname; +#endif + static isc_result_t verify_addr (omapi_object_t *l, omapi_addr_t *addr) { return ISC_R_SUCCESS; } @@ -185,6 +190,12 @@ main(int argc, char **argv) { gid_t set_gid = 0; #endif /* PARANOIA */ +#ifdef OLD_LOG_NAME + progname = "dhcpd"; +#else + progname = argv[0]; +#endif + /* Make sure that file descriptors 0 (stdin), 1, (stdout), and 2 (stderr) are open. To do this, we assume that when we open a file the lowest available file descriptor is used. */ @@ -221,7 +232,8 @@ main(int argc, char **argv) { dhcp_common_objects_setup (); /* Initially, log errors to stderr as well as to syslogd. */ - openlog ("dhcpd", DHCP_LOG_OPTIONS, DHCPD_LOG_FACILITY); + openlog (isc_file_basename(progname), + DHCP_LOG_OPTIONS, DHCPD_LOG_FACILITY); for (i = 1; i < argc; i++) { if (!strcmp (argv [i], "-p")) { @@ -1043,7 +1055,8 @@ void postconf_initialization (int quiet) &global_scope, oc, MDL)) { if (db.len == 1) { closelog (); - openlog("dhcpd", DHCP_LOG_OPTIONS, db.data[0]); + openlog(isc_file_basename(progname), + DHCP_LOG_OPTIONS, db.data[0]); /* Log the startup banner into the new log file. */ /* Don't log to stderr twice. */ @@ -1147,7 +1160,7 @@ usage(void) { log_info(copyright); log_info(arr); - log_fatal("Usage: dhcpd [-p <UDP port #>] [-f] [-d] [-q] [-t|-T]\n" + log_fatal("Usage: %s [-p <UDP port #>] [-f] [-d] [-q] [-t|-T]\n" #ifdef DHCPv6 " [-4|-6] [-cf config-file] [-lf lease-file]\n" #else /* !DHCPv6 */ @@ -1162,7 +1175,8 @@ usage(void) { " [-play trace-input-file]\n" #endif /* TRACING */ " [-pf pid-file] [--no-pid] [-s server]\n" - " [if0 [...ifN]]"); + " [if0 [...ifN]]", + isc_file_basename(progname)); } #endif |