diff options
author | joerg <joerg@FreeBSD.org> | 1996-04-26 21:35:11 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1996-04-26 21:35:11 +0000 |
commit | 651af4a301f28f59b7174fc381c01258bdbeebff (patch) | |
tree | aa8fce9741e46086cc0e0b5aee858d3ff9024a87 | |
parent | 2d430f5746ff743957a88b3d67c2cb037327ad56 (diff) | |
download | FreeBSD-src-651af4a301f28f59b7174fc381c01258bdbeebff.zip FreeBSD-src-651af4a301f28f59b7174fc381c01258bdbeebff.tar.gz |
Implement keyinfo(1) as a setuid Perl script, so /etc/skeykeys can
be made mode 0600.
Pointed out by: kieber@sax.de (Ulf Kieber)
Reviewed by: pst
-rw-r--r-- | usr.bin/keyinfo/Makefile | 5 | ||||
-rw-r--r-- | usr.bin/keyinfo/keyinfo.1 | 20 | ||||
-rw-r--r-- | usr.bin/keyinfo/keyinfo.pl | 27 | ||||
-rw-r--r-- | usr.bin/keyinfo/keyinfo.sh | 10 |
4 files changed, 46 insertions, 16 deletions
diff --git a/usr.bin/keyinfo/Makefile b/usr.bin/keyinfo/Makefile index 3227586..93bfb8a 100644 --- a/usr.bin/keyinfo/Makefile +++ b/usr.bin/keyinfo/Makefile @@ -1,9 +1,12 @@ # @(#)Makefile 5.5 (Berkeley) 7/1/90 +BINOWN= root +BINMODE=4555 + MAN1= keyinfo.1 beforeinstall: ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/keyinfo.sh ${DESTDIR}${BINDIR}/keyinfo + ${.CURDIR}/keyinfo.pl ${DESTDIR}${BINDIR}/keyinfo .include <bsd.prog.mk> diff --git a/usr.bin/keyinfo/keyinfo.1 b/usr.bin/keyinfo/keyinfo.1 index b12aa96..9ddea83 100644 --- a/usr.bin/keyinfo/keyinfo.1 +++ b/usr.bin/keyinfo/keyinfo.1 @@ -1,9 +1,10 @@ .ll 6i .pl 10.5i -.\" @(#)keyinfo.1 1.1 (Bellcore) 7/20/93 +.\" from: @(#)keyinfo.1 1.1 (Bellcore) 7/20/93 +.\" $Id$ .\" .lt 6.0i -.TH KEYINFO 1 "20 July 1993" +.TH KEYINFO 1 "26 April 1996" .AT 3 .SH NAME keyinfo \- display current S/Key sequence number and seed @@ -19,12 +20,12 @@ on a field trip, by combining with the command .I key in the form: .sp - >key \-n <number of passwords to print> `keyinfo`|lpr + > key \-n <number of passwords> `keyinfo`|lpr .SH EXAMPLE .sh Usage example: .sp 0 - >keyinfo + > keyinfo .sp 0 0098 ws91340 .LP @@ -33,8 +34,17 @@ Usage example: .B username The S/key user to display the information for. The default is to display S/Key information on the user who invokes the command. +.SH DIAGNOSTICS +.I keyinfo +exits with status 0 if a key for the requested user has been found, +else with status 1. .SH SEE ALSO .BR keyinit(1), .BR key(1) .SH AUTHOR -Command by Phil Karn, Neil M. Haller, John S. Walden +Original command by Phil Karn, Neil M. Haller, John S. Walden. +Rewritten in Perl by +.ie t J\(:org \%Wunsch +.el Joerg Wunsch +so it can be made setuid, and the S/Key keys file can be read-protected +from the users. diff --git a/usr.bin/keyinfo/keyinfo.pl b/usr.bin/keyinfo/keyinfo.pl new file mode 100644 index 0000000..260a724 --- /dev/null +++ b/usr.bin/keyinfo/keyinfo.pl @@ -0,0 +1,27 @@ +#!/usr/bin/suidperl +# +# Search /etc/skeykeys for the skey string for this user OR user specified +# in 1st parameter. +# +# $Id$ +# + +die "usage: keyinfo [user]\n" unless $#ARGV < 1; + +open(K, "/etc/skeykeys") || exit 1; + +if ($#ARGV == 0) { + $user = $ARGV[0]; +} else { + $user = (getpwuid($<))[0]; +} + +while (<K>) { + ($id, $seq, $serial) = split; + if ($id eq $user) { + printf "%d %s\n", $seq - 1, $serial; + exit 0; + } +} +exit 1; + diff --git a/usr.bin/keyinfo/keyinfo.sh b/usr.bin/keyinfo/keyinfo.sh deleted file mode 100644 index 5879442..0000000 --- a/usr.bin/keyinfo/keyinfo.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# search /etc/skeykeys for the skey string for this user OR user specified -# in 1st parameter - -PATH=/bin:/usr/bin - -test -f /etc/skeykeys && { - WHO=${1-`id | sed 's/^[^(]*(\([^)]*\).*/\1/'`} - awk '/^'${WHO}'[ ]/ { print $2-1, $3 }' /etc/skeykeys -} |