]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Don't use a needless buffer for cffile.
authorRoy Marples <roy@marples.name>
Fri, 5 Sep 2008 13:28:44 +0000 (13:28 +0000)
committerRoy Marples <roy@marples.name>
Fri, 5 Sep 2008 13:28:44 +0000 (13:28 +0000)
dhcpcd.c
if-options.c

index 2ffd0f4027c33ba5050d78f8e7eb4849c1dee0af..a42aa02488da9b2872b885a9f10526e5c9c8e10e 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -69,7 +69,7 @@ int pidfd = -1;
 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 @@ init_state(struct interface *iface, int argc, char **argv)
        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 @@ main(int argc, char **argv)
        /* 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 @@ main(int argc, char **argv)
                        setloglevel(LOG_DEBUG);
                        break;
                case 'f':
-                       strlcpy(cffile, optarg, sizeof(cffile));
+                       cffile = optarg;
                        break;
                case 'k':
                        sig = SIGHUP;
@@ -1037,7 +1036,7 @@ main(int argc, char **argv)
        }
        
 #ifdef THERE_IS_NO_FORK
-       ifo->options &= ~DHCPCD_DAEMONISE;
+       options &= ~DHCPCD_DAEMONISE;
 #endif
 
        chdir("/");
@@ -1056,6 +1055,9 @@ main(int argc, char **argv)
                                logger(LOG_ERR, "failed to send commands");
                                exit(EXIT_FAILURE);
                        }
+               } else {
+                       if (errno != EEXIST)
+                               logger(LOG_ERR, "open_control: %m");
                }
        }
 
index 23b8ca65dda3b249394f1946c6acb8c7c5f4f78a..6cb3bcb400064fb959caa372d6adb6cca4bc862f 100644 (file)
@@ -39,8 +39,8 @@
 #include <unistd.h>
 #include <time.h>
 
-#include "common.h"
 #include "config.h"
+#include "common.h"
 #include "dhcpf.h"
 #include "if-options.h"
 #include "logger.h"
@@ -567,7 +567,7 @@ read_config(const char *file, const char *ifname)
                                             "%s %s", PACKAGE, VERSION);
 
        /* Parse our options file */
-       f = fopen(file, "r");
+       f = fopen(file ? file : CONFIG, "r");
        if (!f)
                return ifo;