seatd: Use path-based chmod/chown

The fd variants do not seem to work for sockets
This commit is contained in:
Kenny Levinsen 2020-08-08 15:27:43 +02:00
parent 24e2fc7861
commit f5bc8ab12b

View file

@ -42,10 +42,10 @@ static int open_socket(char *path, int uid, int gid) {
return -1; return -1;
} }
if (uid != 0 || gid != 0) { if (uid != 0 || gid != 0) {
if (fchown(fd, uid, gid) == -1) { if (chown(path, uid, gid) == -1) {
log_errorf("could not chown socket to uid %d, gid %d: %s", uid, gid, log_errorf("could not chown socket to uid %d, gid %d: %s", uid, gid,
strerror(errno)); strerror(errno));
} else if (fchmod(fd, 0770) == -1) { } else if (chmod(path, 0770) == -1) {
log_errorf("could not chmod socket: %s", strerror(errno)); log_errorf("could not chmod socket: %s", strerror(errno));
} }
} }