chiark / gitweb /
Allow the caller to configure the administration socket permissions.
[tripe] / server / admin.c
index 32b35772fc52788792859a3c63b2974b690f6e5a..8eb5ec3ca5a16d3565739ffdea48ff553c75e13f 100644 (file)
@@ -2213,13 +2213,14 @@ void a_daemon(void) { flags |= F_DAEMON; }
  * Arguments:  @const char *name@ = socket name to create
  *             @uid_t u@ = user to own the socket
  *             @gid_t g@ = group to own the socket
+ *             @mode_t m@ = permissions to set on the socket
  *
  * Returns:    ---
  *
  * Use:                Creates the admin listening socket.
  */
 
-void a_init(const char *name, uid_t u, gid_t g)
+void a_init(const char *name, uid_t u, gid_t g, mode_t m)
 {
   int fd;
   int n = 5;
@@ -2275,14 +2276,14 @@ again:
     close(fd);
     goto again;
   }
-  if (chmod(sun.sun_path, 0600)) {
-    die(EXIT_FAILURE, "failed to set socket permissions: %s",
-       strerror(errno));
-  }
   if (chown(sun.sun_path, u, g)) {
     die(EXIT_FAILURE, "failed to set socket owner: %s",
        strerror(errno));
   }
+  if (chmod(sun.sun_path, m)) {
+    die(EXIT_FAILURE, "failed to set socket permissions: %s",
+       strerror(errno));
+  }
   umask(omask);
   fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
   if (listen(fd, 5))