This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=8ba5b0e6e1a10933350f2780ccf2752df90e2554

commit 8ba5b0e6e1a10933350f2780ccf2752df90e2554
Author: Guillem Jover <[email protected]>
AuthorDate: Wed Jan 23 09:13:17 2019 +0100

    s-s-d: Move SO_PASSCRED setting into its own function
    
    This way we have the entire logic in one place, and can more cleanly
    conditionalize on SO_PASSCRED availability.
---
 utils/start-stop-daemon.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index d4d933f41..434cb40c8 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -570,13 +570,22 @@ setup_socket_name(const char *suffix)
        return notify_socket;
 }
 
+static void
+set_socket_passcred(int fd)
+{
+#ifdef SO_PASSCRED
+       static const int enable = 1;
+
+       setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable));
+#endif
+}
+
 static int
 create_notify_socket(void)
 {
        const char *sockname;
        struct sockaddr_un su;
        int fd, rc, flags;
-       static const int enable = 1;
 
        /* Create notification socket. */
        fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
@@ -612,11 +621,9 @@ create_notify_socket(void)
        if (rc < 0)
                fatal("cannot change notification socket ownership");
 
-#ifdef SO_PASSCRED
        /* XXX: Verify we are talking to an expected child? Although it is not
         * clear whether this is feasible given the knowledge we have got. */
-       setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable));
-#endif
+       set_socket_passcred(fd);
 
        return fd;
 }

-- 
Dpkg.Org's dpkg

Reply via email to