summaryrefslogtreecommitdiff
path: root/sbin/mount_portal
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-03-23 03:04:31 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-03-23 03:04:31 +0000
commit71149d873a58779a3442a1d6ee2c6b1e63523669 (patch)
treee261db9fa04ba3455a955ea691e6cc9be77f7010 /sbin/mount_portal
parente51352172c2ed09ad14cea4ffa4165bff1a4a8a0 (diff)
-Wall happiness, use mkstemp(3) instead of mktemp(3), and some
minor KNF.
Diffstat (limited to 'sbin/mount_portal')
-rw-r--r--sbin/mount_portal/conf.c4
-rw-r--r--sbin/mount_portal/mount_portal.c51
-rw-r--r--sbin/mount_portal/pathnames.h4
-rw-r--r--sbin/mount_portal/pt_file.c3
4 files changed, 32 insertions, 30 deletions
diff --git a/sbin/mount_portal/conf.c b/sbin/mount_portal/conf.c
index eebe5be573c..18f9c3bdea1 100644
--- a/sbin/mount_portal/conf.c
+++ b/sbin/mount_portal/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.2 1996/06/23 14:31:31 deraadt Exp $ */
+/* $OpenBSD: conf.c,v 1.3 1997/03/23 03:04:28 millert Exp $ */
/* $NetBSD: conf.c,v 1.4 1995/04/23 10:33:19 cgd Exp $ */
/*
@@ -137,7 +137,7 @@ qelem *q0;
void regerror(s)
const char *s;
{
- syslog(LOG_ERR, "%s:%s: regcomp %s: %s",
+ syslog(LOG_ERR, "%s:%d: regcomp %s: %s",
conf_file, curp->p_lno, curp->p_key, s);
}
diff --git a/sbin/mount_portal/mount_portal.c b/sbin/mount_portal/mount_portal.c
index a29fb29f6a2..a5b801d19c9 100644
--- a/sbin/mount_portal/mount_portal.c
+++ b/sbin/mount_portal/mount_portal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_portal.c,v 1.5 1997/01/15 23:41:24 millert Exp $ */
+/* $OpenBSD: mount_portal.c,v 1.6 1997/03/23 03:04:29 millert Exp $ */
/* $NetBSD: mount_portal.c,v 1.8 1996/04/13 01:31:54 jtc Exp $ */
/*
@@ -47,7 +47,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_portal.c 8.4 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.5 1997/01/15 23:41:24 millert Exp $";
+static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.6 1997/03/23 03:04:29 millert Exp $";
#endif
#endif /* not lint */
@@ -56,6 +56,7 @@ static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.5 1997/01/15 23:41:24 miller
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/syslog.h>
+#include <sys/stat.h>
#include <sys/mount.h>
#include <err.h>
@@ -75,6 +76,8 @@ const struct mntopt mopts[] = {
{ NULL }
};
+extern char *__progname; /* from crt0.o */
+
static char *mountpt; /* made available to signal handler */
static void usage __P((void));
@@ -105,6 +108,7 @@ static void
sigterm(sig)
int sig;
{
+
if (unmount(mountpt, MNT_FORCE) < 0)
syslog(LOG_WARNING, "sigterm: unmounting %s failed: %s",
mountpt, strerror(errno));
@@ -159,36 +163,35 @@ main(argc, argv)
* Construct the listening socket
*/
un.sun_family = AF_UNIX;
- if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path)) {
- fprintf(stderr, "mount_portal: portal socket name too long\n");
- exit(1);
- }
+ if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path))
+ errx(1, "portal socket name too long");
strcpy(un.sun_path, _PATH_TMPPORTAL);
- mktemp(un.sun_path);
+ so = mkstemp(un.sun_path);
+ if (so < 0)
+ err(1, "can't create portal socket name: %s", un.sun_path);
un.sun_len = strlen(un.sun_path);
+ (void)close(so);
so = socket(AF_UNIX, SOCK_STREAM, 0);
- if (so < 0) {
- fprintf(stderr, "mount_portal: socket: %s\n", strerror(errno));
- exit(1);
- }
+ if (so < 0)
+ err(1, "socket(2)");
um = umask(077);
- (void) unlink(un.sun_path);
+ (void)unlink(un.sun_path);
if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0)
- err(1, NULL);
- (void) unlink(un.sun_path);
- (void) umask(um);
+ err(1, "bind(2)");
+ (void)unlink(un.sun_path);
+ (void)umask(um);
- (void) listen(so, 5);
+ (void)listen(so, 5);
args.pa_socket = so;
- sprintf(tag, "portal:%d", getpid() + 1);
+ (void)sprintf(tag, "portal:%d", getpid() + 1);
args.pa_config = tag;
rc = mount(MOUNT_PORTAL, mountpt, mntflags, &args);
if (rc < 0)
- err(1, NULL);
+ err(1, "mount(2)");
/*
* Everything is ready to go - now is a good time to fork
@@ -203,9 +206,9 @@ main(argc, argv)
q.q_forw = q.q_back = &q;
readcf = 1;
- signal(SIGCHLD, sigchld);
- signal(SIGHUP, sighup);
- signal(SIGTERM, sigterm);
+ (void)signal(SIGCHLD, sigchld);
+ (void)signal(SIGHUP, sighup);
+ (void)signal(SIGTERM, sigterm);
/*
* Just loop waiting for new connections and activating them
@@ -272,11 +275,11 @@ main(argc, argv)
syslog(LOG_ERR, "fork: %s", strerror(errno));
break;
case 0:
- (void) close(so);
+ (void)close(so);
activate(&q, so2);
exit(0);
default:
- (void) close(so2);
+ (void)close(so2);
break;
}
}
@@ -288,6 +291,6 @@ static void
usage()
{
(void)fprintf(stderr,
- "usage: mount_portal [-o options] config mount-point\n");
+ "usage: %s [-o options] config mount-point\n", __progname);
exit(1);
}
diff --git a/sbin/mount_portal/pathnames.h b/sbin/mount_portal/pathnames.h
index a588b1e95a9..3e127e56eae 100644
--- a/sbin/mount_portal/pathnames.h
+++ b/sbin/mount_portal/pathnames.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathnames.h,v 1.2 1996/06/23 14:31:33 deraadt Exp $ */
+/* $OpenBSD: pathnames.h,v 1.3 1997/03/23 03:04:29 millert Exp $ */
/* $NetBSD: pathnames.h,v 1.4 1995/04/23 10:33:21 cgd Exp $ */
/*
@@ -42,4 +42,4 @@
#include <paths.h>
-#define _PATH_TMPPORTAL "/tmp/portalXXXXXX" /* Scratch socket name */
+#define _PATH_TMPPORTAL "/tmp/portalXXXXXXXXXX" /* Scratch socket name */
diff --git a/sbin/mount_portal/pt_file.c b/sbin/mount_portal/pt_file.c
index eec22fc72b7..22fd16d84f8 100644
--- a/sbin/mount_portal/pt_file.c
+++ b/sbin/mount_portal/pt_file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pt_file.c,v 1.2 1996/06/23 14:31:36 deraadt Exp $ */
+/* $OpenBSD: pt_file.c,v 1.3 1997/03/23 03:04:30 millert Exp $ */
/* $NetBSD: pt_file.c,v 1.7 1995/06/06 19:54:30 mycroft Exp $ */
/*
@@ -62,7 +62,6 @@ int *fdp;
int fd;
char pbuf[MAXPATHLEN];
int error;
- int i;
pbuf[0] = '/';
strcpy(pbuf+1, key + (v[1] ? strlen(v[1]) : 0));