summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2010-12-29 12:14:42 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2010-12-29 12:14:42 +0000
commitb535eaad07436596fbb5fc44e9b2729d07857346 (patch)
tree648ecaa230a5f5e779b7c9c050ca002cf03bf51b /sbin
parenta111b498918d82e98e3bf5b7897b517c6e45acf6 (diff)
Fix swapctl -A with DUIDs in /etc/fstab, and plug a small memory leak.
ok jsing@ (who also pointed out a DPADD tweak missing from my diff)
Diffstat (limited to 'sbin')
-rw-r--r--sbin/swapctl/Makefile4
-rw-r--r--sbin/swapctl/swapctl.c7
2 files changed, 9 insertions, 2 deletions
diff --git a/sbin/swapctl/Makefile b/sbin/swapctl/Makefile
index c02cf2e9748..ee852faefbb 100644
--- a/sbin/swapctl/Makefile
+++ b/sbin/swapctl/Makefile
@@ -1,8 +1,10 @@
-# $OpenBSD: Makefile,v 1.2 2000/02/26 04:06:23 hugh Exp $
+# $OpenBSD: Makefile,v 1.3 2010/12/29 12:14:41 stsp Exp $
# $NetBSD: Makefile,v 1.2 1997/06/12 16:18:50 mrg Exp $
PROG= swapctl
SRCS= swapctl.c swaplist.c
+LDADD= -lutil
+DPADD= ${LIBUTIL}
MAN= swapctl.8
LINKS= ${BINDIR}/swapctl ${BINDIR}/swapon
diff --git a/sbin/swapctl/swapctl.c b/sbin/swapctl/swapctl.c
index d89d9f48adc..ddf693da592 100644
--- a/sbin/swapctl/swapctl.c
+++ b/sbin/swapctl/swapctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: swapctl.c,v 1.17 2007/11/26 13:36:33 deraadt Exp $ */
+/* $OpenBSD: swapctl.c,v 1.18 2010/12/29 12:14:41 stsp Exp $ */
/* $NetBSD: swapctl.c,v 1.9 1998/07/26 20:23:15 mycroft Exp $ */
/*
@@ -62,6 +62,7 @@
#include <stdlib.h>
#include <string.h>
#include <fstab.h>
+#include <util.h>
#include "swapctl.h"
@@ -395,8 +396,12 @@ do_fstab(void)
errx(1, "path too long");
if (system(cmd) != 0) {
warnx("%s: mount failed", fp->fs_spec);
+ free((char *)spec);
continue;
}
+ } else if (isduid(spec, 0)) {
+ if (rejecttype == S_IFBLK)
+ continue;
} else {
/*
* Determine blk-ness. Don't even consider a