NetBSD Problem Report #893

From gnats  Wed Mar 22 06:04:58 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with ESMTP id GAA00996 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Wed, 22 Mar 1995 06:04:57 -0800
Message-Id: <9503221329.AA06461@leidecker.gsfc.nasa.gov>
Date: Wed, 22 Mar 95 08:29:44 -0500
From: Kenneth Stailey <kstailey@leidecker.gsfc.nasa.gov>
To: gnats-bugs@NetBSD.ORG
Subject: mount_portal trashes /tmp if killed
X-Send-Pr-Version: 3.2

>Number:         893
>Category:       misc
>Synopsis:       mount_portal leaves unreferenced inode in /tmp if killed
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    misc-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 22 06:05:03 +0000 1995
>Closed-Date:    Sat Mar 23 02:35:59 +0000 1996
>Last-Modified:  Sat Mar 23 02:39:17 +0000 1996
>Originator:     Kenneth Stailey
>Release:        March 18th tarballs
>Organization:
self
>Environment:
System: NetBSD pluto 1.0A NetBSD 1.0A (PLUTO) #19: Sat Mar 18 16:46:13 EST 1995 ken@pluto:/usr/src/sys/arch/i386/compile/PLUTO i386


>Description:
	/sbin/mount_portal creates an unreferenced AF_LOCAL socket
	when run.  It does not clean this up if killed.  It does
	clean it up if you run 'umount' instead of kill on it.
>How-To-Repeat:
	1) make sure portal is not running
	2) make sure that the directory "/p" exists.
	   my /p looks like this:

drwxr-xr-x  2 root  wheel  512 Dec 24 15:49 /p

	3) Make sure that /etc/portal.conf exists and looks like this:

# from: Id: portal.conf,v 1.1 1992/05/27 06:50:13 jsp Exp
# from: @(#)portal.conf 8.1 (Berkeley) 6/5/93
# $Id: portal.conf,v 1.2 1994/06/08 19:24:50 mycroft Exp $
tcplisten/      tcplisten tcplisten/
tcp/            tcp tcp/
fs/             file fs/
pipe/           pipe

	3) Run fsck on /tmp (or root if you have no seperate /tmp)
	   to show that it's clean (if it's not you cannot proceed)
	4) Run "/sbin/mount_portal /etc/portal.conf /p"
	5) Run fsck on your /tmp (or root if you have no seperate /tmp).
	   You should see an unreferenced socket.
	6) If you kill mount_portal this will not be cleaned up by
	   anything but fsck.  If you "umount /p" it will be cleaned up.

>Fix:
	I added a sigterm handler to mount_portal to make it unmount
	itself when killed.

--- mount_portal.c.DIST	Wed Mar 22 06:58:49 1995
+++ mount_portal.c	Wed Mar 22 07:52:20 1995
@@ -69,6 +69,8 @@
 	{ NULL }
 };

+static char *mountpt;		/* made available to signal handler */
+
 static void usage __P((void));

 static sig_atomic_t readcf;	/* Set when SIGHUP received */
@@ -84,6 +86,14 @@
 		syslog(LOG_WARNING, "waitpid: %s", strerror(errno));
 }

+static void sigterm(sig)
+int sig;
+{
+	if (unmount(mountpt, MNT_FORCE) < 0)
+		syslog(LOG_WARNING, "sigterm: unmounting %s failed: %s",
+		       mountpt, strerror(errno));
+}
+
 int
 main(argc, argv)
 	int argc;
@@ -92,7 +102,6 @@
 	struct portal_args args;
 	struct sockaddr_un un;
 	char *conf;
-	char *mountpt;
 	int mntflags = 0;
 	char tag[32];

@@ -154,7 +163,7 @@
 	(void) listen(so, 5);

 	args.pa_socket = so;
-	sprintf(tag, "portal:%d", getpid());
+	sprintf(tag, "portal:%d", getpid() + 1);
 	args.pa_config = tag;

 	rc = mount(MOUNT_PORTAL, mountpt, mntflags, &args);
@@ -175,6 +184,7 @@
 	readcf = 1;

 	signal(SIGCHLD, sigchld);
+	signal(SIGTERM, sigterm);

 	/*
 	 * Just loop waiting for new connections and activating them

--HAA00579.795876875/pluto.spacenet.com--


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mrg 
State-Changed-When: Fri Mar 22 21:35:59 EST 1996 
State-Changed-Why:  
applied suggested change. 

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.