Skip to content

Commit 5e7f901

Browse files
committed
move socket to /base/run and remove umask from uc_bind
1 parent a72ebe4 commit 5e7f901

2 files changed

Lines changed: 10 additions & 26 deletions

File tree

configure

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ uselds=yes # use custom ld script if available for the target
66

77
# Configurable global paths for config.h
88

9-
BASE_BIN="/base/bin"
109
BASE_ETC="/base/etc" # config files
11-
BASE_VAR="/var/base" # saved state
10+
BASE_VAR="/base/var" # saved state
1211
INIT_ETC="/etc" # config files in initrd mode
13-
RUN_CTRL="/run/ctrl" # control sockets
12+
RUN_CTRL="/base/run" # control sockets
1413

1514
HERE="" # gets prepended to misc global paths, HERE "/run" -> "./run"
1615

@@ -193,7 +192,6 @@ fi
193192
chmod a+x mini-cc
194193

195194
cat > config.h <<END
196-
#define BASE_BIN "$BASE_BIN"
197195
#define BASE_ETC "$BASE_ETC"
198196
#define BASE_VAR "$BASE_VAR"
199197
#define INIT_ETC "$INIT_ETC"
@@ -212,7 +210,6 @@ echo " STRIP = $strip"
212210
echo " CFLAGS = $cflags"
213211
test -n "$qemu" && echo " QEMU = $qemu"
214212
echo
215-
echo " BASE_BIN = $BASE_BIN"
216213
echo " BASE_ETC = $BASE_ETC"
217214
echo " BASE_VAR = $BASE_VAR"
218215
echo " INIT_ETC = $INIT_ETC"

lib/nlusctl/addr_bind.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,19 @@
1919
If at some point sticky sockets become an option, this function should be
2020
removed. But that is not expected to happen soon, so for now, it's here. */
2121

22-
/* Regarding umask use: in Linux, file permissions on local sockets do matter,
23-
but handling them is quite difficult, and considering the planned security
24-
model for this project, most likely pointless. It is pretty much decided
25-
that permissions will be set (statically) on the directory instead. To make
26-
that work, we force 0777 on sockets here, otherwise the missing bits would
27-
change effective permissions.
22+
/* Regarding socket permissions: by default it's uid/gid/~umask of the
23+
process, just like any other files, but actual usage will likely require
24+
different permissions *and* different gid. It is possible to chmod it here
25+
(for instance by temporarily setting particular umask) but there's no good
26+
way to change gid, so it will likely require external efforts.
2827
29-
There are no other ways of passing initial socket permissions in Linux
30-
afaik. In pretty much all cases, current umask will NOT be 0000, in fact
31-
using 0000 outside of this code is a pretty bad idea for most services.
32-
33-
Note in BSD things work exactly like that, without any umask calls, because
34-
they just ignore file permissions on sockets. */
28+
If not done here, it's the same problem as with device access, so whatever
29+
will get implemented with devices might also apply to the sockets. */
3530

3631
int uc_listen(int fd, const char* path, int backlog)
3732
{
38-
int ret, mask = 0000;
3933
struct sockaddr_un addr;
40-
41-
if((ret = sys_umask(mask)) < 0)
42-
goto err;
43-
44-
mask = ret;
34+
int ret;
4535

4636
if((ret = uc_address(&addr, path)) < 0)
4737
goto err;
@@ -57,9 +47,6 @@ int uc_listen(int fd, const char* path, int backlog)
5747
if((ret = sys_bind(fd, &addr, sizeof(addr))) < 0)
5848
goto err;
5949
got:
60-
if((ret = sys_umask(mask)) < 0)
61-
goto err;
62-
6350
ret = sys_listen(fd, backlog);
6451
err:
6552
return ret;

0 commit comments

Comments
 (0)