summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Nurpmeso <steffen@sdaoden.eu>2019-01-22 22:11:33 +0100
committerJuergen Daubert <jue@jue.li>2019-03-23 07:16:12 +0100
commitfface7e3748bb5969e20fba5995340498b9e2c1c (patch)
treee11e68ff5a927df033052aa65470a16ec405f2cd
parent22c6dea592eda981160b5e251709dd0ca031026c (diff)
downloadstart-stop-daemon-fface7e3748bb5969e20fba5995340498b9e2c1c.tar.gz
start-stop-daemon-fface7e3748bb5969e20fba5995340498b9e2c1c.tar.xz
Sync with dpkg 1.19.4
-rw-r--r--start-stop-daemon.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/start-stop-daemon.c b/start-stop-daemon.c
index e7e1cdc..7a52643 100644
--- a/start-stop-daemon.c
+++ b/start-stop-daemon.c
@@ -570,13 +570,22 @@ setup_socket_name(const char *suffix)
return notify_socket;
}
+static void
+set_socket_passcred(int fd)
+{
+#ifdef SO_PASSCRED
+ static const int enable = 1;
+
+ setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable));
+#endif
+}
+
static int
create_notify_socket(void)
{
const char *sockname;
struct sockaddr_un su;
int fd, rc, flags;
- static const int enable = 1;
/* Create notification socket. */
fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
@@ -614,7 +623,7 @@ create_notify_socket(void)
/* XXX: Verify we are talking to an expected child? Although it is not
* clear whether this is feasible given the knowledge we have got. */
- setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable));
+ set_socket_passcred(fd);
return fd;
}
@@ -2256,8 +2265,13 @@ do_pidfile(const char *name)
/* If we are only matching on the pidfile, and it is owned by
* a non-root user, then this is a security risk, and the
* contents cannot be trusted, because the daemon might have
- * been compromised. */
- if (match_mode == MATCH_PIDFILE) {
+ * been compromised.
+ *
+ * If we got /dev/null specified as the pidfile, we ignore the
+ * checks, as this is being used to run processes no matter
+ * what. */
+ if (match_mode == MATCH_PIDFILE &&
+ strcmp(name, "/dev/null") != 0) {
struct stat st;
int fd = fileno(f);

Generated by cgit