summaryrefslogtreecommitdiff
path: root/src/conn-tools/s6-ipcserver-socketbinder.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-12-11 19:11:23 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-12-11 19:11:23 +0000
commit1a7a0c79040d9efa654c151d8a057f34eb9be585 (patch)
tree8874b1684780bba3713fdb59d85fdea7b5a1086a /src/conn-tools/s6-ipcserver-socketbinder.c
parent6ee2e470aa4c66b3477449e7f48343b706c70ddc (diff)
downloads6-1a7a0c79040d9efa654c151d8a057f34eb9be585.tar.xz
Add "-a perms" option to s6-ipcserver(-socketbinder)
Diffstat (limited to 'src/conn-tools/s6-ipcserver-socketbinder.c')
-rw-r--r--src/conn-tools/s6-ipcserver-socketbinder.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/conn-tools/s6-ipcserver-socketbinder.c b/src/conn-tools/s6-ipcserver-socketbinder.c
index 8215fa2..3bc6b52 100644
--- a/src/conn-tools/s6-ipcserver-socketbinder.c
+++ b/src/conn-tools/s6-ipcserver-socketbinder.c
@@ -9,7 +9,7 @@
#include <skalibs/djbunix.h>
#include <skalibs/webipc.h>
-#define USAGE "s6-ipcserver-socketbinder [ -d | -D ] [ -b backlog ] [ -M | -m ] path prog..."
+#define USAGE "s6-ipcserver-socketbinder [ -d | -D ] [ -b backlog ] [ -M | -m ] [ -a perms ] path prog..."
#define dieusage() strerr_dieusage(100, USAGE)
int main (int argc, char const *const *argv, char const *const *envp)
@@ -17,12 +17,13 @@ int main (int argc, char const *const *argv, char const *const *envp)
unsigned int backlog = SOMAXCONN ;
int flagreuse = 1 ;
int flagdgram = 0 ;
+ unsigned int perms = 0777 ;
PROG = "s6-ipcserver-socketbinder" ;
{
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- int opt = subgetopt_r(argc, argv, "DdMmb:", &l) ;
+ int opt = subgetopt_r(argc, argv, "DdMmb:a:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -31,6 +32,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'M' : flagdgram = 0 ; break ;
case 'm' : flagdgram = 1 ; break ;
case 'b' : if (!uint0_scan(l.arg, &backlog)) dieusage() ; break ;
+ case 'a' : if (!uint0_oscan(l.arg, &perms)) dieusage() ; break ;
default : dieusage() ;
}
}
@@ -40,7 +42,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
close(0) ;
if (flagdgram ? ipc_datagram() : ipc_stream()) strerr_diefu1sys(111, "create socket") ;
{
- mode_t m = umask(0) ;
+ mode_t m = umask(~perms & 0777) ;
if ((flagreuse ? ipc_bind_reuse(0, argv[0]) : ipc_bind(0, argv[0])) < 0)
strerr_diefu2sys(111, "bind to ", argv[0]) ;
umask(m) ;