On Tue, Dec 28, 2010 at 09:36:43PM +0100, Stefan Sperling wrote:
> /etc/fstab:
> 736f610b58fed843.b none swap sw 0 0
>
> # swapctl -A
> swapctl: 736f610b58fed843.b: No such file or directory
>
> With patch below:
>
> # swapctl -A
> swapctl: adding 736f610b58fed843.b as swap device at priority 0
>
> Plug a tiny mem leak while here. ok?
Cleaner diff using isduid() from libutil.
Index: Makefile
===================================================================
RCS file: /cvs/src/sbin/swapctl/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 26 Feb 2000 04:06:23 -0000 1.2
+++ Makefile 29 Dec 2010 11:13:18 -0000
@@ -3,6 +3,7 @@
PROG= swapctl
SRCS= swapctl.c swaplist.c
+LDADD= -lutil
MAN= swapctl.8
LINKS= ${BINDIR}/swapctl ${BINDIR}/swapon
Index: swapctl.c
===================================================================
RCS file: /cvs/src/sbin/swapctl/swapctl.c,v
retrieving revision 1.17
diff -u -p -r1.17 swapctl.c
--- swapctl.c 26 Nov 2007 13:36:33 -0000 1.17
+++ swapctl.c 29 Dec 2010 11:12:39 -0000
@@ -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