]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
dhcpcd: dump lease on the unpriviledged socket
authorRoy Marples <roy@marples.name>
Sat, 28 Mar 2020 17:01:49 +0000 (17:01 +0000)
committerRoy Marples <roy@marples.name>
Sat, 28 Mar 2020 17:01:49 +0000 (17:01 +0000)
src/control.c
src/control.h
src/dhcpcd.c

index 42a8ab9cc18b1a1bd41e3bd72187605eed53c88b..44c57a9279ba4fa568a029dcf8ab5be2baeb5bca 100644 (file)
@@ -193,7 +193,7 @@ control_handle_unpriv(void *arg)
 }
 
 static int
-make_sock(struct sockaddr_un *sa, const char *ifname, int unpriv)
+make_sock(struct sockaddr_un *sa, const char *ifname, bool unpriv)
 {
        int fd;
 
@@ -318,12 +318,12 @@ control_stop(struct dhcpcd_ctx *ctx)
 }
 
 int
-control_open(const char *ifname)
+control_open(const char *ifname, bool unpriv)
 {
        struct sockaddr_un sa;
        int fd;
 
-       if ((fd = make_sock(&sa, ifname, 0)) != -1) {
+       if ((fd = make_sock(&sa, ifname, unpriv)) != -1) {
                socklen_t len;
 
                len = (socklen_t)SUN_LEN(&sa);
index 72f601bfb8547ac9d40c593e439c989a64334b2c..a94cbd2f733ba5675f0c5e7d309a46a583979b78 100644 (file)
@@ -68,7 +68,7 @@ TAILQ_HEAD(fd_list_head, fd_list);
 
 int control_start(struct dhcpcd_ctx *, const char *);
 int control_stop(struct dhcpcd_ctx *);
-int control_open(const char *);
+int control_open(const char *, bool);
 ssize_t control_send(struct dhcpcd_ctx *, int, char * const *);
 int control_queue(struct fd_list *, void *, size_t, bool);
 
index de72d954104d5cade4a6f2557dbbeec37232e8c4..057a1fd9e09cce5b5458da8dc966d5c0b7ab8e5c 100644 (file)
@@ -1679,6 +1679,8 @@ again3:
                                } else if (dp[1] == 'd' &&
                                    isdigit((unsigned char)dp[2]))
                                        print = true;
+                               else
+                                       print = false;
                        } else
                                print = false;
                        while (dp < de && *dp != '\0') {
@@ -2018,9 +2020,11 @@ printpidfile:
 #endif
                ctx.options |= DHCPCD_FORKED; /* avoid socket unlink */
                if (!(ctx.options & DHCPCD_MASTER))
-                       ctx.control_fd = control_open(argv[optind]);
+                       ctx.control_fd = control_open(argv[optind],
+                           ctx.options & DHCPCD_DUMPLEASE);
                if (ctx.control_fd == -1)
-                       ctx.control_fd = control_open(NULL);
+                       ctx.control_fd = control_open(NULL,
+                           ctx.options & DHCPCD_DUMPLEASE);
                if (ctx.control_fd != -1) {
                        if (!(ctx.options & DHCPCD_DUMPLEASE))
                                loginfox("sending commands to dhcpcd process");