Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/mount_portal be consistent (both internally and with ot...
details: https://anonhg.NetBSD.org/src/rev/bf2db80f66d8
branches: trunk
changeset: 501991:bf2db80f66d8
user: lukem <lukem%NetBSD.org@localhost>
date: Wed Jan 10 03:33:16 2001 +0000
description:
be consistent (both internally and with other programs):
log_err fatal errors
log_warning non-fatal errors & warnings
log_debug debug messages (#ifdef DEBUG)
diffstat:
sbin/mount_portal/activate.c | 12 ++++++------
sbin/mount_portal/conf.c | 10 +++++-----
sbin/mount_portal/mount_portal.c | 8 ++++----
sbin/mount_portal/pt_file.c | 38 ++++++++++++++++++++------------------
sbin/mount_portal/pt_filter.c | 10 +++++-----
sbin/mount_portal/pt_tcp.c | 8 ++++----
6 files changed, 44 insertions(+), 42 deletions(-)
diffs (truncated from 353 to 300 lines):
diff -r 020beafd41a4 -r bf2db80f66d8 sbin/mount_portal/activate.c
--- a/sbin/mount_portal/activate.c Wed Jan 10 03:05:48 2001 +0000
+++ b/sbin/mount_portal/activate.c Wed Jan 10 03:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: activate.c,v 1.9 2000/06/05 16:30:43 thorpej Exp $ */
+/* $NetBSD: activate.c,v 1.10 2001/01/10 03:33:16 lukem Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: activate.c,v 1.9 2000/06/05 16:30:43 thorpej Exp $");
+__RCSID("$NetBSD: activate.c,v 1.10 2001/01/10 03:33:16 lukem Exp $");
#endif /* not lint */
#include <stdio.h>
@@ -155,7 +155,7 @@
ctl = malloc(cmsgsize);
if (ctl == NULL) {
- syslog(LOG_ERR, "malloc control message: %m");
+ syslog(LOG_WARNING, "malloc control message: %m");
return;
}
memset(ctl, 0, cmsgsize);
@@ -176,14 +176,14 @@
* Send to kernel...
*/
if ((n = sendmsg(so, &msg, MSG_EOR)) < 0)
- syslog(LOG_ERR, "send: %m");
+ syslog(LOG_WARNING, "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: %m");
+ syslog(LOG_WARNING, "shutdown: %m");
#endif
/*
* Throw away the open file descriptor and control
@@ -211,7 +211,7 @@
*/
error = get_request(so, &pcred, key, sizeof(key));
if (error) {
- syslog(LOG_ERR, "activate: recvmsg: %m");
+ syslog(LOG_WARNING, "activate: recvmsg: %m");
goto drop;
}
diff -r 020beafd41a4 -r bf2db80f66d8 sbin/mount_portal/conf.c
--- a/sbin/mount_portal/conf.c Wed Jan 10 03:05:48 2001 +0000
+++ b/sbin/mount_portal/conf.c Wed Jan 10 03:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.c,v 1.8 2000/11/06 14:05:54 jdolecek Exp $ */
+/* $NetBSD: conf.c,v 1.9 2001/01/10 03:33:16 lukem Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: conf.c,v 1.8 2000/11/06 14:05:54 jdolecek Exp $");
+__RCSID("$NetBSD: conf.c,v 1.9 2001/01/10 03:33:16 lukem Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -118,7 +118,7 @@
void *p = malloc(siz);
if (p)
return (p);
- syslog(LOG_ALERT, "malloc: failed to get %lu bytes", (u_long)siz);
+ syslog(LOG_ERR, "malloc: failed to get %lu bytes", (u_long)siz);
exit(1);
}
@@ -221,7 +221,7 @@
char buf[200];
regerror(errcode, &p->p_re, buf, sizeof(buf));
- syslog(LOG_ERR, "%s, line %d: regcomp \"%s\": %s",
+ syslog(LOG_WARNING, "%s, line %d: regcomp \"%s\": %s",
conf_file, p->p_lno, p->p_key, buf);
}
}
@@ -323,7 +323,7 @@
readfp(q, fp, conf);
(void) fclose(fp);
} else
- syslog(LOG_ERR, "open config file \"%s\": %m", conf);
+ syslog(LOG_WARNING, "open config file \"%s\": %m", conf);
}
diff -r 020beafd41a4 -r bf2db80f66d8 sbin/mount_portal/mount_portal.c
--- a/sbin/mount_portal/mount_portal.c Wed Jan 10 03:05:48 2001 +0000
+++ b/sbin/mount_portal/mount_portal.c Wed Jan 10 03:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mount_portal.c,v 1.17 2000/11/06 14:00:38 jdolecek Exp $ */
+/* $NetBSD: mount_portal.c,v 1.18 2001/01/10 03:33:16 lukem Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
#else
-__RCSID("$NetBSD: mount_portal.c,v 1.17 2000/11/06 14:00:38 jdolecek Exp $");
+__RCSID("$NetBSD: mount_portal.c,v 1.18 2001/01/10 03:33:16 lukem Exp $");
#endif
#endif /* not lint */
@@ -221,7 +221,7 @@
/*
* Start logging (and change name)
*/
- openlog("portald", LOG_CONS|LOG_PID, LOG_DAEMON);
+ openlog("portald", LOG_PID, LOG_DAEMON);
q.q_forw = q.q_back = &q;
readcf = 1;
@@ -292,7 +292,7 @@
sleep(1);
goto eagain;
}
- syslog(LOG_ERR, "fork: %m");
+ syslog(LOG_WARNING, "fork: %m");
break;
case 0:
(void) close(so);
diff -r 020beafd41a4 -r bf2db80f66d8 sbin/mount_portal/pt_file.c
--- a/sbin/mount_portal/pt_file.c Wed Jan 10 03:05:48 2001 +0000
+++ b/sbin/mount_portal/pt_file.c Wed Jan 10 03:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pt_file.c,v 1.12 2000/01/15 06:21:40 bgrayson Exp $ */
+/* $NetBSD: pt_file.c,v 1.13 2001/01/10 03:33:16 lukem Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pt_file.c,v 1.12 2000/01/15 06:21:40 bgrayson Exp $");
+__RCSID("$NetBSD: pt_file.c,v 1.13 2001/01/10 03:33:16 lukem Exp $");
#endif /* not lint */
#include <stdio.h>
@@ -78,13 +78,13 @@
if (getuid() == 0) {
/* Set groups first ... */
if (setgroups(pcr->pcr_ngroups, pcr->pcr_groups) < 0) {
- syslog(LOG_ERR,
+ syslog(LOG_WARNING,
"lose_credentials: setgroups() failed (%m)");
return (errno);
}
/* ... then gid ... */
if (setgid(pcr->pcr_gid) < 0) {
- syslog(LOG_ERR,
+ syslog(LOG_WARNING,
"lose_credentials: setgid(%d) failed (%m)",
pcr->pcr_gid);
}
@@ -93,23 +93,24 @@
* powers (both real and effective userid).
*/
if (setuid(pcr->pcr_uid) < 0) {
- syslog(LOG_ERR,
+ syslog(LOG_WARNING,
"lose_credentials: setuid(%d) failed (%m)",
pcr->pcr_uid);
}
/* The credential change was successful! */
- DEBUG_SYSLOG(LOG_ERR, "Root-owned mount process lowered credentials -- returning successfully!\n");
+ DEBUG_SYSLOG(LOG_DEBUG, "Root-owned mount process lowered credentials -- returning successfully!\n");
return 0;
}
- DEBUG_SYSLOG(LOG_ERR, "Actual/effective/caller's creds are:");
- DEBUG_SYSLOG(LOG_ERR, "%d/%d %d/%d %d/%d", getuid(),
+ DEBUG_SYSLOG(LOG_DEBUG, "Actual/effective/caller's creds are:");
+ DEBUG_SYSLOG(LOG_DEBUG, "%d/%d %d/%d %d/%d", getuid(),
getgid(), geteuid(), getegid(), pcr->pcr_uid, pcr->pcr_gid);
/*
* Else, fail if the uid is neither actual or effective
* uid of mount process...
*/
if ((getuid() != pcr->pcr_uid) && (geteuid() != pcr->pcr_uid)) {
- syslog(LOG_ERR, "lose_credentials: uid %d != uid %d, or euid %d != uid %d",
+ syslog(LOG_WARNING,
+ "lose_credentials: uid %d != uid %d, or euid %d != uid %d",
getuid(), pcr->pcr_uid, geteuid(), pcr->pcr_uid);
return EPERM;
}
@@ -118,7 +119,8 @@
* gid of the mount process.
*/
if ((getgid() != pcr->pcr_gid) && (getegid() != pcr->pcr_gid)) {
- syslog(LOG_ERR, "lose_credentials: gid %d != gid %d, or egid %d != gid %d",
+ syslog(LOG_WARNING,
+ "lose_credentials: gid %d != gid %d, or egid %d != gid %d",
getgid(), pcr->pcr_gid, getegid(), pcr->pcr_gid);
return EPERM;
}
@@ -126,7 +128,7 @@
* If we make it here, we have a uid _and_ gid match! Allow the
* access.
*/
- DEBUG_SYSLOG(LOG_ERR, "Returning successfully!\n");
+ DEBUG_SYSLOG(LOG_DEBUG, "Returning successfully!\n");
return 0;
}
@@ -147,11 +149,11 @@
origgid = getgid();
pbuf[0] = '/';
strcpy(pbuf + 1, key + (v[1] ? strlen(v[1]) : 0));
- DEBUG_SYSLOG(LOG_ERR, "path = %s, uid = %d, gid = %d",
+ DEBUG_SYSLOG(LOG_DEBUG, "path = %s, uid = %d, gid = %d",
pbuf, pcr->pcr_uid, pcr->pcr_gid);
if ((error = lose_credentials(pcr)) != 0) {
- DEBUG_SYSLOG(LOG_ERR, "portal_file: Credential err %d", error);
+ DEBUG_SYSLOG(LOG_DEBUG, "portal_file: Credential err %d", error);
return error;
}
error = 0;
@@ -164,27 +166,27 @@
if (fd < 0) {
error = errno;
if (error == EACCES) {
- DEBUG_SYSLOG(LOG_ERR, "Error: could not open '%s' "
+ DEBUG_SYSLOG(LOG_DEBUG, "Error: could not open '%s' "
"read/write with create flag. "
"Trying read-only open...", pbuf);
/* Try opening read-only. */
fd = open(pbuf, O_RDONLY, 0);
if (fd < 0) {
error = errno;
- DEBUG_SYSLOG(LOG_ERR, "That failed too! %m");
+ DEBUG_SYSLOG(LOG_DEBUG, "That failed too! %m");
} else {
/* Clear the error indicator. */
error = 0;
}
} else {
- DEBUG_SYSLOG(LOG_ERR, "Error: could not open '%s': %m", pbuf);
+ DEBUG_SYSLOG(LOG_DEBUG, "Error: could not open '%s': %m", pbuf);
}
}
if (seteuid((uid_t) origuid) < 0) { /* XXX - should reset gidset
* too */
error = errno;
- syslog(LOG_ERR, "setcred: %m");
+ syslog(LOG_WARNING, "setcred: %m");
if (fd >= 0) {
(void) close(fd);
fd = -1;
@@ -193,7 +195,7 @@
if (error == 0)
*fdp = fd;
- DEBUG_SYSLOG(LOG_ERR, "pt_file returns *fdp = %d, error = %d", *fdp,
+ DEBUG_SYSLOG(LOG_DEBUG, "pt_file returns *fdp = %d, error = %d", *fdp,
error);
return (error);
}
diff -r 020beafd41a4 -r bf2db80f66d8 sbin/mount_portal/pt_filter.c
--- a/sbin/mount_portal/pt_filter.c Wed Jan 10 03:05:48 2001 +0000
+++ b/sbin/mount_portal/pt_filter.c Wed Jan 10 03:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pt_filter.c,v 1.3 2000/01/17 07:21:54 bgrayson Exp $ */
+/* $NetBSD: pt_filter.c,v 1.4 2001/01/10 03:33:16 lukem Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pt_filter.c,v 1.3 2000/01/17 07:21:54 bgrayson Exp $");
+__RCSID("$NetBSD: pt_filter.c,v 1.4 2001/01/10 03:33:16 lukem Exp $");
#endif /* not lint */
#include <stdio.h>
@@ -117,7 +117,7 @@
syslog(LOG_ERR,
"rfilter: got strip-key of %s, and command start of %s\n",
v[1], v[2]);
- exit(-1);
+ exit(1);
}
/*
* Format for rfilter in config file:
@@ -164,7 +164,7 @@
Home |
Main Index |
Thread Index |
Old Index