From 309650aa4d4be1310b20e7293a3bc0c47aeecf0e Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 8 Aug 2021 18:22:17 +0200 Subject: seatd: Use path in chmod/chown operations c8b3a22d4ef0f69c3d22f0ec1170b89c93ef1dc3 snuck in a change which converts chown/chmod to fchown/fchmod using the socket fd. This appears to succeed under Linux, but fails with EINVAL on FreeBSD. As the error handling in this area was flawed, CI failed to catch the regression. Partially revert c8b3a22d4ef0f69c3d22f0ec1170b89c93ef1dc3 to fix the regression on FreeBSD. --- seatd/seatd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'seatd') diff --git a/seatd/seatd.c b/seatd/seatd.c index 4587e50..053d44b 100644 --- a/seatd/seatd.c +++ b/seatd/seatd.c @@ -40,12 +40,12 @@ static int open_socket(const char *path, int uid, int gid) { goto error; } if (uid != -1 || gid != -1) { - 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, strerror(errno)); goto error; } - if (fchmod(fd, 0770) == -1) { + if (chmod(path, 0770) == -1) { log_errorf("Could not chmod socket: %s", strerror(errno)); goto error; } @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) { int socket_fd = open_socket(socket_path, uid, gid); if (socket_fd == -1) { - log_errorf("Could not create server socket: %s", strerror(errno)); + log_error("Could not create server socket"); server_finish(&server); return 1; } -- cgit v1.2.3