Move the wpa socket files out of /tmp and into /tmp/dhcpcd
authorRoy Marples <roy@marples.name>
Tue, 5 May 2015 23:11:58 +0000 (23:11 +0000)
committerRoy Marples <roy@marples.name>
Tue, 5 May 2015 23:11:58 +0000 (23:11 +0000)
src/libdhcpcd/dhcpcd.h
src/libdhcpcd/wpa.c

index 755705f53545e3ec6d1f647dcb4f8d2b2b8063ef..bdac29abd14505690a337a5ecb69966c2ad36673 100644 (file)
@@ -47,6 +47,10 @@ extern "C" {
 #define WPA_CTRL_DIR           "/var/run/wpa_supplicant"
 #endif
 
+#ifndef DHCPCD_TMP_DIR
+#define DHCPCD_TMP_DIR         "/tmp/dhcpcd"
+#endif
+
 #define DHCPCD_RETRYOPEN       100     /* milliseconds */
 #define DHCPCD_WPA_PING                500     /* milliseconds */
 #define DHCPCD_WPA_SCAN_LONG   60000   /* milliseconds */
index d7bdd3be7ac0012230b42647467cfba28c8c99aa..0a3967967fbe163e0cd84a00f41afa9c5f539216 100644 (file)
@@ -58,13 +58,16 @@ wpa_open(const char *ifname, char **path)
        socklen_t len;
        struct sockaddr_un sun;
 
+       if (mkdir(DHCPCD_TMP_DIR, 0700) == -1 && errno != EEXIST)
+               return -1;
+
        if ((fd = socket(AF_UNIX,
            SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) == -1)
                return -1;
        memset(&sun, 0, sizeof(sun));
        sun.sun_family = AF_UNIX;
        snprintf(sun.sun_path, sizeof(sun.sun_path),
-           "/tmp/libdhcpcd-wpa-%d.%d", getpid(), counter++);
+           DHCPCD_TMP_DIR "/libdhcpcd-wpa-%d.%d", getpid(), counter++);
        *path = strdup(sun.sun_path);
        len = (socklen_t)SUN_LEN(&sun);
        if (bind(fd, (struct sockaddr *)&sun, len) == -1) {