summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-15 21:52:27 +0000
committered <ed@FreeBSD.org>2009-06-15 21:52:27 +0000
commit675236a73e61660960610d1bca4fb88271cf0426 (patch)
treec534908bf30e3b007c9ef7d441157448110031a7
parent8e18b541e72bb508f317616f45dc8ca4ea75510e (diff)
downloadFreeBSD-src-675236a73e61660960610d1bca4fb88271cf0426.zip
FreeBSD-src-675236a73e61660960610d1bca4fb88271cf0426.tar.gz
Add revoke(1).
While hacking on TTY code, I often miss a small utility to revoke my own (pseudo-)terminals. This small utility is just a small wrapper around the revoke(2) call, so you can destroy your very own login sessions. Approved by: re
-rw-r--r--lib/libc/sys/revoke.23
-rw-r--r--usr.bin/Makefile1
-rw-r--r--usr.bin/revoke/Makefile7
-rw-r--r--usr.bin/revoke/revoke.156
-rw-r--r--usr.bin/revoke/revoke.c59
5 files changed, 125 insertions, 1 deletions
diff --git a/lib/libc/sys/revoke.2 b/lib/libc/sys/revoke.2
index c88222e..57abdbb 100644
--- a/lib/libc/sys/revoke.2
+++ b/lib/libc/sys/revoke.2
@@ -97,7 +97,8 @@ operation on the named file.
The caller is neither the owner of the file nor the super user.
.El
.Sh SEE ALSO
-.Xr close 2
+.Xr close 2 ,
+.Xr revoke 1
.Sh HISTORY
The
.Fn revoke
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index f45c2c8..6497743 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -157,6 +157,7 @@ SUBDIR= alias \
${_quota} \
renice \
rev \
+ revoke \
${_rlogin} \
${_rpcgen} \
rpcinfo \
diff --git a/usr.bin/revoke/Makefile b/usr.bin/revoke/Makefile
new file mode 100644
index 0000000..b3c4ee6
--- /dev/null
+++ b/usr.bin/revoke/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= revoke
+
+WARNS?= 6
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/revoke/revoke.1 b/usr.bin/revoke/revoke.1
new file mode 100644
index 0000000..6dd6e2f
--- /dev/null
+++ b/usr.bin/revoke/revoke.1
@@ -0,0 +1,56 @@
+.\" Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd June 15, 2009
+.Dt REVOKE 1
+.Os
+.Sh NAME
+.Nm revoke
+.Nd "revoke a character device"
+.Sh SYNOPSIS
+.Nm
+.Ar
+.Sh DESCRIPTION
+The
+.Nm
+program revokes the character devices using
+.Xr revoke 2 .
+When used on a TTY, calls like
+.Xr read 2 ,
+.Xr write 2
+and
+.Xr ioctl 2 ,
+will be aborted immediately, effectively causing login sessions to be
+terminated.
+.Sh SEE ALSO
+.Xr revoke 2
+.Sh HISTORY
+The
+.Nm
+program first appeared in
+.Fx 8.0 .
+.Sh AUTHORS
+.An Ed Schouten Aq ed@FreeBSD.org
diff --git a/usr.bin/revoke/revoke.c b/usr.bin/revoke/revoke.c
new file mode 100644
index 0000000..bc9f838
--- /dev/null
+++ b/usr.bin/revoke/revoke.c
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static void
+usage(void)
+{
+
+ fprintf(stderr, "usage: revoke file ...\n");
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char **d;
+ int error = 0;
+
+ if (argc == 1)
+ usage();
+
+ for (d = &argv[1]; *d != NULL; d++) {
+ if (revoke(*d) != 0) {
+ perror(*d);
+ error = 1;
+ }
+ }
+
+ return (error);
+}
OpenPOWER on IntegriCloud