diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2005-03-30 18:56:20 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2005-03-30 18:56:20 +0000 |
commit | 45c3be7cf6bc94ebaecea7f113ea7a7ca2c897f5 (patch) | |
tree | 1a4245ac32b33847deaeb7e68343f9dcc735c858 /usr.sbin | |
parent | 01fc6f13bf9e4f478e8587b96e50bdeeedb6c96f (diff) |
Fix some stuff noted by Theo.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sasyncd/conf.c | 27 | ||||
-rw-r--r-- | usr.sbin/sasyncd/log.c | 4 | ||||
-rw-r--r-- | usr.sbin/sasyncd/sasyncd.c | 8 |
3 files changed, 22 insertions, 17 deletions
diff --git a/usr.sbin/sasyncd/conf.c b/usr.sbin/sasyncd/conf.c index 80a7a8c8723..921569d8b3e 100644 --- a/usr.sbin/sasyncd/conf.c +++ b/usr.sbin/sasyncd/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.1 2005/03/30 18:44:49 ho Exp $ */ +/* $OpenBSD: conf.c,v 1.2 2005/03/30 18:56:19 ho Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -76,7 +76,7 @@ conf_parse_file(char *cfgfile) cfgstate.listen_on = strdup(name); if (!cfgstate.listen_on) { log_err("config: strdup() failed"); - return 1; + goto bad; } log_msg(2, "config(line %02d): listen on %s", lineno, cfgstate.listen_on); @@ -111,12 +111,12 @@ conf_parse_file(char *cfgfile) if (!peer) { log_err("config: calloc(1, %lu) failed", sizeof *peer); - return 1; + goto bad; } peer->name = strdup(name); if (!peer->name) { log_err("config: strdup() failed"); - return 1; + goto bad; } LIST_INSERT_HEAD(&cfgstate.peerlist, peer, link); log_msg(2, "config(line %02d): add peer %s", lineno, @@ -130,7 +130,7 @@ conf_parse_file(char *cfgfile) cfgstate.carp_ifname = strdup(name); if (!cfgstate.carp_ifname) { log_err("config: strdup failed"); - return 1; + goto bad; } log_msg(2, "config(line %02d): carp interface %s", lineno, cfgstate.carp_ifname); @@ -158,7 +158,7 @@ conf_parse_file(char *cfgfile) cfgstate.cafile = strdup(name); if (!cfgstate.cafile) { log_err("config: strdup failed"); - return 1; + goto bad; } log_msg(2, "config(line %02d): CAcertificate file $s", lineno, cfgstate.cafile); @@ -171,7 +171,7 @@ conf_parse_file(char *cfgfile) cfgstate.certfile = strdup(name); if (!cfgstate.certfile) { log_err("config: strdup failed"); - return 1; + goto bad; } log_msg(2, "config(line %02d): certificate file $s", lineno, cfgstate.certfile); @@ -184,7 +184,7 @@ conf_parse_file(char *cfgfile) cfgstate.privkeyfile = strdup(name); if (!cfgstate.privkeyfile) { log_err("config: strdup failed"); - return 1; + goto bad; } log_msg(2, "config(line %02d): private key file $s", lineno, cfgstate.privkeyfile); @@ -199,7 +199,7 @@ conf_parse_file(char *cfgfile) else { log_msg(0, "config(line %02d): unknown state " "%s", lineno, name); - return 1; + goto bad; } log_msg(2, "config(line %02d): runstate locked to %s", lineno, cfgstate.lockedstate == MASTER ? "MASTER" : @@ -211,16 +211,21 @@ conf_parse_file(char *cfgfile) /* Sanity checks. */ if (LIST_EMPTY(&cfgstate.peerlist)) { log_msg(0, "config: no peers defined"); - return 1; + goto bad; } if (!cfgstate.carp_ifname && cfgstate.lockedstate == INIT) { log_msg(0, "config: no carp interface or runstate defined"); - return 1; + goto bad; } /* Success. */ + fclose(fp); return 0; + + bad: + fclose(fp); + return 1; } int diff --git a/usr.sbin/sasyncd/log.c b/usr.sbin/sasyncd/log.c index 239f764b008..d8163468c34 100644 --- a/usr.sbin/sasyncd/log.c +++ b/usr.sbin/sasyncd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.1 2005/03/30 18:44:49 ho Exp $ */ +/* $OpenBSD: log.c,v 1.2 2005/03/30 18:56:19 ho Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -56,7 +56,7 @@ log_output(char *msg) if (cfgstate.debug) fprintf(stderr, "%s\n", msg); else - syslog(LOG_CRIT, msg); + syslog(LOG_CRIT, "%s", msg); } void diff --git a/usr.sbin/sasyncd/sasyncd.c b/usr.sbin/sasyncd/sasyncd.c index b59fc818025..71be1bac74f 100644 --- a/usr.sbin/sasyncd/sasyncd.c +++ b/usr.sbin/sasyncd/sasyncd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sasyncd.c,v 1.1 2005/03/30 18:44:49 ho Exp $ */ +/* $OpenBSD: sasyncd.c,v 1.2 2005/03/30 18:56:19 ho Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -51,18 +51,18 @@ privdrop(void) if (!pw) { log_err("%s: getpwnam(\"%s\") failed", __progname, SASYNCD_USER); - return -1; + exit(1); } if (chroot(pw->pw_dir) != 0 || chdir("/") != 0) { log_err("%s: chroot failed", __progname); - return -1; + exit(1); } if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) { log_err("%s: failed to drop privileges", __progname); - return -1; + exit(1); } return 0; |