diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-09-24 14:28:08 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-09-24 14:28:08 +0000 |
commit | da6534c0e155ca52e99b25cac0328ea92f7aaa37 (patch) | |
tree | 0341637b7d3fd3ec99a02b86b2479ddb72c79b75 /usr.bin/cvs | |
parent | 6e2ea7ce732c94456d0c49db94ed26c8576c51d7 (diff) |
When creating the local socket, set the group to the server's group ID
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/cvsd.h | 5 | ||||
-rw-r--r-- | usr.bin/cvs/sock.c | 12 |
2 files changed, 14 insertions, 3 deletions
diff --git a/usr.bin/cvs/cvsd.h b/usr.bin/cvs/cvsd.h index 0fdfcd586a4..fe435e197fb 100644 --- a/usr.bin/cvs/cvsd.h +++ b/usr.bin/cvs/cvsd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvsd.h,v 1.2 2004/07/25 03:29:35 jfb Exp $ */ +/* $OpenBSD: cvsd.h,v 1.3 2004/09/24 14:28:07 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -35,6 +35,7 @@ #include <netinet/in.h> #include <pwd.h> +#include <grp.h> #include <signal.h> #include "cvs.h" @@ -115,6 +116,8 @@ struct cvsd_addr { extern volatile sig_atomic_t running; extern volatile sig_atomic_t restart; +extern uid_t cvsd_uid; +extern gid_t cvsd_gid; diff --git a/usr.bin/cvs/sock.c b/usr.bin/cvs/sock.c index 7415f18e925..7c948fe1f66 100644 --- a/usr.bin/cvs/sock.c +++ b/usr.bin/cvs/sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.c,v 1.4 2004/08/02 17:34:10 jfb Exp $ */ +/* $OpenBSD: sock.c,v 1.5 2004/09/24 14:28:07 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -93,7 +93,15 @@ cvsd_sock_open(void) return (-1); } - listen(cvsd_sock, 10); + (void)listen(cvsd_sock, 10); + + if (chown(cvsd_sock_path, getuid(), cvsd_gid) == -1) { + cvs_log(LP_ERRNO, "failed to change owner of `%s'", + cvsd_sock_path); + (void)close(cvsd_sock); + (void)unlink(cvsd_sock_path); + return (-1); + } if (chmod(cvsd_sock_path, CVSD_SOCK_PERMS) == -1) { cvs_log(LP_ERRNO, "failed to change mode of `%s'", |