From 7442b7fbebafadbcdb4222dba2085519da7e5fd0 Mon Sep 17 00:00:00 2001 From: kib Date: Mon, 15 Apr 2019 13:12:54 +0000 Subject: [PATCH] MFC r346038: Exercise some care before sending SIGHUP to mountd. --- sbin/mount/mount.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index 08ddc290e44..d90ede7b9af 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -224,6 +224,7 @@ restart_mountd(void) struct pidfh *pfh; pid_t mountdpid; + mountdpid = 0; pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &mountdpid); if (pfh != NULL) { /* Mountd is not running. */ @@ -234,6 +235,16 @@ restart_mountd(void) /* Cannot open pidfile for some reason. */ return; } + + /* + * Refuse to send broadcast or group signals, this has + * happened due to the bugs in pidfile(3). + */ + if (mountdpid <= 0) { + warnx("mountd pid %d, refusing to send SIGHUP", mountdpid); + return; + } + /* We have mountd(8) PID in mountdpid varible, let's signal it. */ if (kill(mountdpid, SIGHUP) == -1) err(1, "signal mountd"); -- 2.45.0