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
This commit is contained in:
parent
cb3ec8e0c1
commit
7c7cef7278
@ -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
|
||||
|
@ -157,6 +157,7 @@ SUBDIR= alias \
|
||||
${_quota} \
|
||||
renice \
|
||||
rev \
|
||||
revoke \
|
||||
${_rlogin} \
|
||||
${_rpcgen} \
|
||||
rpcinfo \
|
||||
|
7
usr.bin/revoke/Makefile
Normal file
7
usr.bin/revoke/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= revoke
|
||||
|
||||
WARNS?= 6
|
||||
|
||||
.include <bsd.prog.mk>
|
56
usr.bin/revoke/revoke.1
Normal file
56
usr.bin/revoke/revoke.1
Normal file
@ -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
|
59
usr.bin/revoke/revoke.c
Normal file
59
usr.bin/revoke/revoke.c
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user