Subject: misc/1850: Patch to add a "zero" option to skeyinit
To: None <gnats-bugs@gnats.netbsd.org>
From: Todd C. Miller <Todd.Miller@cs.colorado.edu>
List: netbsd-bugs
Date: 12/19/1995 14:02:26
>Number: 1850
>Category: misc
>Synopsis: there is no way to zero out an entry in /etc/skeykeys
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: misc-bug-people (Misc Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Dec 19 16:20:09 1995
>Last-Modified:
>Originator: Todd C. Miller
>Organization:
Todd C. Miller Sysadmin--University of Colorado Todd.Miller@cs.colorado.edu
>Release: NetBSD-current as of 12/17/95
>Environment:
System: NetBSD scrap.cs.colorado.edu 1.1A NetBSD 1.1A (PEECEE) #1: Mon Dec 18 15:09:44 MST 1995 millert@scrap.cs.colorado.edu:/usr/src/sys/arch/i386/compile/PEECEE i386
>Description:
It would be nice to be able to remove an s/key entry from
the skeykeys file without editing it directly. The enclosed
patch implements a "-z" option to skeyinit that does this.
>How-To-Repeat:
>Fix:
*** src/usr.bin/skeyinit/skeyinit.1.DIST Fri Oct 13 21:24:50 1995
--- src/usr.bin/skeyinit/skeyinit.1 Tue Dec 19 13:44:20 1995
***************
*** 10,15 ****
--- 10,16 ----
.Sh SYNOPSIS
.Nm skeyinit
.Op Fl s
+ .Op Fl z
.Op Ar user
.Sh DESCRIPTION
.Nm skeyinit
***************
*** 28,33 ****
--- 29,36 ----
in another window to generate the correct 6 english words
for that count and seed.
You can then "cut-and-paste" or type the words into the skeyinit window.
+ .It Fl z
+ allows the user to zero their S/Key entry.
.It Ar user
the username to be changed/added. By default the current user is
operated on.
*** src/usr.bin/skeyinit/skeyinit.c.DIST Fri Oct 13 21:24:51 1995
--- src/usr.bin/skeyinit/skeyinit.c Tue Dec 19 13:45:17 1995
***************
*** 29,41 ****
#define NAMELEN 2
int skeylookup __ARGS((struct skey * mp, char *name));
int
main(argc, argv)
int argc;
char *argv[];
{
! int rval, n, nn, i, defaultsetup, l;
time_t now;
char hostname[MAXHOSTNAMELEN];
char seed[18], tmp[80], key[8], defaultseed[17];
--- 29,42 ----
#define NAMELEN 2
int skeylookup __ARGS((struct skey * mp, char *name));
+ int skeyzero __ARGS((struct skey * mp, char *name));
int
main(argc, argv)
int argc;
char *argv[];
{
! int rval, n, nn, i, defaultsetup, l, zerokey = 0;
time_t now;
char hostname[MAXHOSTNAMELEN];
char seed[18], tmp[80], key[8], defaultseed[17];
***************
*** 63,76 ****
err(1, "Who are you?");
defaultsetup = 1;
! if (argc > 1) {
! if (strcmp("-s", argv[1]) == 0)
defaultsetup = 0;
! else
! pp = getpwnam(argv[1]);
!
! if (argc > 2)
! pp = getpwnam(argv[2]);
}
if (pp == NULL) {
err(1, "User unknown");
--- 64,78 ----
err(1, "Who are you?");
defaultsetup = 1;
! for (i=1; i < argc; i++) {
! if (strcmp("-s", argv[i]) == 0)
defaultsetup = 0;
! else if (strcmp("-z", argv[i]) == 0)
! zerokey = 1;
! else {
! pp = getpwnam(argv[i]);
! break;
! }
}
if (pp == NULL) {
err(1, "User unknown");
***************
*** 104,109 ****
--- 106,115 ----
case -1:
err(1, "cannot open database");
case 0:
+ /* comment out user if asked to */
+ if (zerokey)
+ exit(skeyzero(&skey, pp->pw_name));
+
printf("[Updating %s]\n", pp->pw_name);
printf("Old key: %s\n", skey.seed);
*** src/lib/libskey/skeylogin.c.DIST Fri Oct 13 19:03:42 1995
--- src/lib/libskey/skeylogin.c Mon Dec 18 22:39:20 1995
***************
*** 364,366 ****
--- 364,394 ----
}
return -1;
}
+
+ /* Comment out user's entry in the s/key database
+ *
+ * Return codes:
+ * -1: Write error; database unchanged
+ * 0: Database updated
+ *
+ * The database file is always closed by this call.
+ */
+ int
+ skeyzero(mp,response)
+ struct skey *mp;
+ char *response;
+ {
+ /*
+ * Seek to the right place and write comment character
+ * which effectively zero's out the entry.
+ */
+ fseek(mp->keyfile,mp->recstart,0);
+ if (fputc('#', mp->keyfile) == EOF) {
+ fclose(mp->keyfile);
+ return -1;
+ }
+
+ fclose(mp->keyfile);
+
+ return 0;
+ }
>Audit-Trail:
>Unformatted: