Cosmetic changes:
- Use syslog(..., "...%m") instead of syslog(..., "...%s", strerror(errno)). - Don't put a simple and single statement into a block. - Indent continuation line by four space. - Add an empty line at the beginning of a function if it doesn't have local variable. - Use err() or errx() instead of fprintf(stderr, "progname: ....\n") and exit() (there was two place left). - Use MOUNT_PORTAL, which is defined as "portal" in sys/mount.h, instead of using "portal" directly. - Fold long line to fit column < 80.
This commit is contained in:
parent
8732be2e09
commit
0ac5bcaa77
@ -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 <sys/cdefs.h>
|
||||
#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 <stdio.h>
|
||||
@ -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);
|
||||
|
@ -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 <sys/cdefs.h>
|
||||
#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 <stdio.h>
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <sys/cdefs.h>
|
||||
#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 <stdio.h>
|
||||
@ -62,5 +62,6 @@ portal_exec(pcr, key, v, so, fdp)
|
||||
int so;
|
||||
int *fdp;
|
||||
{
|
||||
|
||||
return (ENOEXEC);
|
||||
}
|
||||
|
@ -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 <sys/cdefs.h>
|
||||
#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 <stdio.h>
|
||||
@ -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);
|
||||
|
@ -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 <sys/cdefs.h>
|
||||
#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 <stdio.h>
|
||||
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user