diff --git a/sbin/mount_portal/activate.c b/sbin/mount_portal/activate.c index 0e16bd9b212f..f45a33b97222 100644 --- a/sbin/mount_portal/activate.c +++ b/sbin/mount_portal/activate.c @@ -1,4 +1,4 @@ -/* $NetBSD: activate.c,v 1.7 1997/09/16 12:32:23 lukem Exp $ */ +/* $NetBSD: activate.c,v 1.8 1997/09/21 02:35:40 enami Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #include #ifndef lint -__RCSID("$NetBSD: activate.c,v 1.7 1997/09/16 12:32:23 lukem Exp $"); +__RCSID("$NetBSD: activate.c,v 1.8 1997/09/21 02:35:40 enami Exp $"); #endif /* not lint */ #include @@ -163,14 +163,14 @@ send_reply(so, fd, error) * Send to kernel... */ if ((n = sendmsg(so, &msg, MSG_EOR)) < 0) - syslog(LOG_ERR, "send: %s", strerror(errno)); + syslog(LOG_ERR, "send: %m"); #ifdef DEBUG fprintf(stderr, "sent %d bytes\n", n); #endif sleep(1); /*XXX*/ #ifdef notdef if (shutdown(so, 2) < 0) - syslog(LOG_ERR, "shutdown: %s", strerror(errno)); + syslog(LOG_ERR, "shutdown: %m"); #endif /* * Throw away the open file descriptor @@ -194,7 +194,7 @@ activate(q, so) */ error = get_request(so, &pcred, key, sizeof(key)); if (error) { - syslog(LOG_ERR, "activate: recvmsg: %s", strerror(error)); + syslog(LOG_ERR, "activate: recvmsg: %m"); goto drop; } @@ -217,9 +217,8 @@ activate(q, so) fd = -1; else if (fd < 0) error = -1; - } else { + } else error = ENOENT; - } if (error >= 0) send_reply(so, fd, error); diff --git a/sbin/mount_portal/conf.c b/sbin/mount_portal/conf.c index b77a510d3461..574e8ac4b950 100644 --- a/sbin/mount_portal/conf.c +++ b/sbin/mount_portal/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.6 1997/09/16 08:37:11 mrg Exp $ */ +/* $NetBSD: conf.c,v 1.7 1997/09/21 02:35:41 enami Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #include #ifndef lint -__RCSID("$NetBSD: conf.c,v 1.6 1997/09/16 08:37:11 mrg Exp $"); +__RCSID("$NetBSD: conf.c,v 1.7 1997/09/21 02:35:41 enami Exp $"); #endif /* not lint */ #include @@ -157,7 +157,7 @@ regerror(s) const char *s; { syslog(LOG_ERR, "%s:%d: regcomp %s: %s", - conf_file, curp->p_lno, curp->p_key, s); + conf_file, curp->p_lno, curp->p_key, s); } static path * @@ -226,9 +226,8 @@ palloc(cline, lno) curp = p; /* XXX */ p->p_re = regcomp(p->p_key); curp = 0; /* XXX */ - } else { + } else p->p_re = 0; - } p->p_lno = lno; return (p); @@ -327,10 +326,8 @@ conf_read(q, conf) readfp(q, fp); conf_file = 0; /* XXX */ (void) fclose(fp); - } else { - syslog(LOG_ERR, "open config file \"%s\": %s", conf, - strerror(errno)); - } + } else + syslog(LOG_ERR, "open config file \"%s\": %m", conf); } diff --git a/sbin/mount_portal/mount_portal.c b/sbin/mount_portal/mount_portal.c index a5298337d662..62a9ecd4c0d8 100644 --- a/sbin/mount_portal/mount_portal.c +++ b/sbin/mount_portal/mount_portal.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_portal.c,v 1.10 1997/09/16 12:32:23 lukem Exp $ */ +/* $NetBSD: mount_portal.c,v 1.11 1997/09/21 02:35:42 enami Exp $ */ /* * Copyright (c) 1992, 1993, 1994 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95"; #else -__RCSID("$NetBSD: mount_portal.c,v 1.10 1997/09/16 12:32:23 lukem Exp $"); +__RCSID("$NetBSD: mount_portal.c,v 1.11 1997/09/21 02:35:42 enami Exp $"); #endif #endif /* not lint */ @@ -93,7 +93,7 @@ sigchld(sig) while ((pid = waitpid((pid_t) -1, (int *) 0, WNOHANG)) > 0) ; if (pid < 0 && errno != ECHILD) - syslog(LOG_WARNING, "waitpid: %s", strerror(errno)); + syslog(LOG_WARNING, "waitpid: %m"); } static void @@ -108,9 +108,10 @@ static void sigterm(sig) int sig; { + if (unmount(mountpt, MNT_FORCE) < 0) - syslog(LOG_WARNING, "sigterm: unmounting %s failed: %s", - mountpt, strerror(errno)); + syslog(LOG_WARNING, "sigterm: unmounting %s failed: %m", + mountpt); } int @@ -161,19 +162,15 @@ 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); un.sun_len = strlen(un.sun_path); 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"); (void) unlink(un.sun_path); if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0) err(1, "%s", ""); @@ -185,7 +182,7 @@ main(argc, argv) sprintf(tag, "portal:%d", getpid() + 1); args.pa_config = tag; - rc = mount("portal", mountpt, mntflags, &args); + rc = mount(MOUNT_PORTAL, mountpt, mntflags, &args); if (rc < 0) err(1, "%s", ""); @@ -238,7 +235,7 @@ main(argc, argv) if (rc < 0) { if (errno == EINTR) continue; - syslog(LOG_ERR, "select: %s", strerror(errno)); + syslog(LOG_ERR, "select: %m"); exit(1); } if (rc == 0) @@ -252,7 +249,7 @@ main(argc, argv) if (errno == ECONNABORTED) break; if (errno != EINTR) { - syslog(LOG_ERR, "accept: %s", strerror(errno)); + syslog(LOG_ERR, "accept: %m"); exit(1); } continue; @@ -268,7 +265,7 @@ main(argc, argv) sleep(1); goto eagain; } - syslog(LOG_ERR, "fork: %s", strerror(errno)); + syslog(LOG_ERR, "fork: %m"); break; case 0: (void) close(so); @@ -286,6 +283,7 @@ main(argc, argv) static void usage() { + (void)fprintf(stderr, "usage: mount_portal [-o options] config mount-point\n"); exit(1); diff --git a/sbin/mount_portal/pt_exec.c b/sbin/mount_portal/pt_exec.c index 1fc8cb4496da..3012b78468cc 100644 --- a/sbin/mount_portal/pt_exec.c +++ b/sbin/mount_portal/pt_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: pt_exec.c,v 1.5 1997/09/15 05:58:29 lukem Exp $ */ +/* $NetBSD: pt_exec.c,v 1.6 1997/09/21 02:35:42 enami Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pt_exec.c,v 1.5 1997/09/15 05:58:29 lukem Exp $"); +__RCSID("$NetBSD: pt_exec.c,v 1.6 1997/09/21 02:35:42 enami Exp $"); #endif /* not lint */ #include @@ -62,5 +62,6 @@ portal_exec(pcr, key, v, so, fdp) int so; int *fdp; { + return (ENOEXEC); } diff --git a/sbin/mount_portal/pt_file.c b/sbin/mount_portal/pt_file.c index 246932071d83..5fa489a2d2a3 100644 --- a/sbin/mount_portal/pt_file.c +++ b/sbin/mount_portal/pt_file.c @@ -1,4 +1,4 @@ -/* $NetBSD: pt_file.c,v 1.9 1997/09/16 12:32:24 lukem Exp $ */ +/* $NetBSD: pt_file.c,v 1.10 1997/09/21 02:35:43 enami Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pt_file.c,v 1.9 1997/09/16 12:32:24 lukem Exp $"); +__RCSID("$NetBSD: pt_file.c,v 1.10 1997/09/21 02:35:43 enami Exp $"); #endif /* not lint */ #include @@ -72,7 +72,8 @@ portal_file(pcr, key, v, so, fdp) strcpy(pbuf+1, key + (v[1] ? strlen(v[1]) : 0)); #ifdef DEBUG - printf("path = %s, uid = %d, gid = %d\n", pbuf, pcr->pcr_uid, pcr->pcr_gid); + printf("path = %s, uid = %d, gid = %d\n", pbuf, pcr->pcr_uid, + pcr->pcr_gid); #endif if (setegid(pcr->pcr_gid) < 0 || @@ -90,7 +91,7 @@ portal_file(pcr, key, v, so, fdp) if (seteuid((uid_t) 0) < 0) { /* XXX - should reset gidset too */ error = errno; - syslog(LOG_ERR, "setcred: %s", strerror(error)); + syslog(LOG_ERR, "setcred: %m"); if (fd >= 0) { (void) close(fd); fd = -1; @@ -101,7 +102,8 @@ portal_file(pcr, key, v, so, fdp) *fdp = fd; #ifdef DEBUG - fprintf(stderr, "pt_file returns *fdp = %d, error = %d\n", *fdp, error); + fprintf(stderr, "pt_file returns *fdp = %d, error = %d\n", *fdp, + error); #endif return (error); diff --git a/sbin/mount_portal/pt_tcp.c b/sbin/mount_portal/pt_tcp.c index ff1c0ae102f3..4721b0439ce9 100644 --- a/sbin/mount_portal/pt_tcp.c +++ b/sbin/mount_portal/pt_tcp.c @@ -1,4 +1,4 @@ -/* $NetBSD: pt_tcp.c,v 1.11 1997/09/16 12:32:25 lukem Exp $ */ +/* $NetBSD: pt_tcp.c,v 1.12 1997/09/21 02:35:44 enami Exp $ */ /* * Copyright (c) 1992, 1993, 1994 @@ -41,7 +41,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pt_tcp.c,v 1.11 1997/09/16 12:32:25 lukem Exp $"); +__RCSID("$NetBSD: pt_tcp.c,v 1.12 1997/09/21 02:35:44 enami Exp $"); #endif /* not lint */ #include @@ -151,7 +151,8 @@ portal_tcp(pcr, key, v, kso, fdp) } sain.sin_addr = *ipp[0]; - if (connect(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) { + if (connect(so, (struct sockaddr *) &sain, + sizeof(sain)) == 0) { *fdp = so; return (0); }