diff --git a/lib/libc/sys/revoke.2 b/lib/libc/sys/revoke.2 index c88222e61320..57abdbb65cbc 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 f45c2c8b04b1..64977431214e 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 000000000000..b3c4ee690a65 --- /dev/null +++ b/usr.bin/revoke/Makefile @@ -0,0 +1,7 @@ +# $FreeBSD$ + +PROG= revoke + +WARNS?= 6 + +.include diff --git a/usr.bin/revoke/revoke.1 b/usr.bin/revoke/revoke.1 new file mode 100644 index 000000000000..6dd6e2f22f4a --- /dev/null +++ b/usr.bin/revoke/revoke.1 @@ -0,0 +1,56 @@ +.\" Copyright (c) 2009 Ed Schouten +.\" 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 000000000000..bc9f838bf37c --- /dev/null +++ b/usr.bin/revoke/revoke.c @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 2009 Ed Schouten + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +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); +}