summaryrefslogtreecommitdiff
path: root/sbin/unwind/control.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/unwind/control.c')
-rw-r--r--sbin/unwind/control.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/sbin/unwind/control.c b/sbin/unwind/control.c
index 22a4858b642..0435ab35ecf 100644
--- a/sbin/unwind/control.c
+++ b/sbin/unwind/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.3 2019/01/29 19:13:01 florian Exp $ */
+/* $OpenBSD: control.c,v 1.4 2019/01/31 13:36:42 solene Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -74,7 +74,7 @@ control_init(char *path)
}
umask(old_umask);
- if (chmod(path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) {
+ if (chmod(path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) == -1) {
log_warn("%s: chmod", __func__);
close(fd);
(void)unlink(path);
@@ -204,6 +204,8 @@ control_dispatch_imsg(int fd, short event, void *bula)
struct imsg imsg;
ssize_t n;
int verbose;
+ uid_t euid;
+ gid_t egid;
if ((c = control_connbyfd(fd)) == NULL) {
log_warnx("%s: fd %d: not found", __func__, fd);
@@ -224,6 +226,11 @@ control_dispatch_imsg(int fd, short event, void *bula)
}
}
+ if (getpeereid(fd, &euid, &egid) == -1) {
+ control_close(fd);
+ return;
+ }
+
for (;;) {
if ((n = imsg_get(&c->iev.ibuf, &imsg)) == -1) {
control_close(fd);
@@ -233,6 +240,20 @@ control_dispatch_imsg(int fd, short event, void *bula)
break;
switch (imsg.hdr.type) {
+ case IMSG_CTL_LOG_VERBOSE:
+ case IMSG_CTL_RELOAD:
+ if (euid != 0) {
+ log_debug("%s: need to be root", __func__);
+ imsg_free(&imsg);
+ control_close(fd);
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+
+ switch (imsg.hdr.type) {
case IMSG_CTL_RELOAD:
frontend_imsg_compose_main(imsg.hdr.type, 0, NULL, 0);
break;