Mercurial > hg > dhcpcd
changeset 945:cd4fa21cbb60 draft
Don't use a needless buffer for cffile.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 05 Sep 2008 13:28:44 +0000 |
| parents | 057fcc76587f |
| children | c1bfb85d50b9 |
| files | dhcpcd.c if-options.c |
| diffstat | 2 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/dhcpcd.c Fri Sep 05 13:12:35 2008 +0000 +++ b/dhcpcd.c Fri Sep 05 13:28:44 2008 +0000 @@ -69,7 +69,7 @@ static char **ifv = NULL; static int ifc = 0; static int linkfd = -1; -static char cffile[PATH_MAX]; +static char *cffile = NULL; static char pidfile[PATH_MAX] = { '\0' }; static struct interface *ifaces = NULL; @@ -755,7 +755,7 @@ ifs->nakoff = 1; configure_interface(iface, argc, argv); - if (!(ifs->options->options & DHCPCD_TEST)) + if (!(options & DHCPCD_TEST)) run_script(iface, "PREINIT"); if (ifs->options->options & DHCPCD_LINK) { @@ -969,7 +969,6 @@ /* Saves calling fflush(stream) in the logger */ setlinebuf(stdout); openlog(PACKAGE, LOG_PID, LOG_LOCAL0); - strlcpy(cffile, CONFIG, sizeof(cffile)); options = DHCPCD_DAEMONISE; /* Test for --help and --version */ @@ -993,7 +992,7 @@ setloglevel(LOG_DEBUG); break; case 'f': - strlcpy(cffile, optarg, sizeof(cffile)); + cffile = optarg; break; case 'k': sig = SIGHUP; @@ -1037,7 +1036,7 @@ } #ifdef THERE_IS_NO_FORK - ifo->options &= ~DHCPCD_DAEMONISE; + options &= ~DHCPCD_DAEMONISE; #endif chdir("/"); @@ -1056,6 +1055,9 @@ logger(LOG_ERR, "failed to send commands"); exit(EXIT_FAILURE); } + } else { + if (errno != EEXIST) + logger(LOG_ERR, "open_control: %m"); } }
--- a/if-options.c Fri Sep 05 13:12:35 2008 +0000 +++ b/if-options.c Fri Sep 05 13:28:44 2008 +0000 @@ -39,8 +39,8 @@ #include <unistd.h> #include <time.h> +#include "config.h" #include "common.h" -#include "config.h" #include "dhcpf.h" #include "if-options.h" #include "logger.h" @@ -567,7 +567,7 @@ "%s %s", PACKAGE, VERSION); /* Parse our options file */ - f = fopen(file, "r"); + f = fopen(file ? file : CONFIG, "r"); if (!f) return ifo;
