From owner-svn-src-all@FreeBSD.ORG Mon Jun 15 21:52:28 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A6DC1065670; Mon, 15 Jun 2009 21:52:28 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 577EA8FC0A; Mon, 15 Jun 2009 21:52:28 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5FLqSxC002936; Mon, 15 Jun 2009 21:52:28 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5FLqSms002931; Mon, 15 Jun 2009 21:52:28 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200906152152.n5FLqSms002931@svn.freebsd.org> From: Ed Schouten Date: Mon, 15 Jun 2009 21:52:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194267 - in head: lib/libc/sys usr.bin usr.bin/revoke X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2009 21:52:28 -0000 Author: ed Date: Mon Jun 15 21:52:27 2009 New Revision: 194267 URL: http://svn.freebsd.org/changeset/base/194267 Log: 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 Added: head/usr.bin/revoke/ head/usr.bin/revoke/Makefile (contents, props changed) head/usr.bin/revoke/revoke.1 (contents, props changed) head/usr.bin/revoke/revoke.c (contents, props changed) Modified: head/lib/libc/sys/revoke.2 head/usr.bin/Makefile Modified: head/lib/libc/sys/revoke.2 ============================================================================== --- head/lib/libc/sys/revoke.2 Mon Jun 15 21:05:00 2009 (r194266) +++ head/lib/libc/sys/revoke.2 Mon Jun 15 21:52:27 2009 (r194267) @@ -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 Modified: head/usr.bin/Makefile ============================================================================== --- head/usr.bin/Makefile Mon Jun 15 21:05:00 2009 (r194266) +++ head/usr.bin/Makefile Mon Jun 15 21:52:27 2009 (r194267) @@ -157,6 +157,7 @@ SUBDIR= alias \ ${_quota} \ renice \ rev \ + revoke \ ${_rlogin} \ ${_rpcgen} \ rpcinfo \ Added: head/usr.bin/revoke/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/revoke/Makefile Mon Jun 15 21:52:27 2009 (r194267) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +PROG= revoke + +WARNS?= 6 + +.include Added: head/usr.bin/revoke/revoke.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/revoke/revoke.1 Mon Jun 15 21:52:27 2009 (r194267) @@ -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 Added: head/usr.bin/revoke/revoke.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/revoke/revoke.c Mon Jun 15 21:52:27 2009 (r194267) @@ -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); +}