2 opieinfo: Print a user's current OPIE sequence number and seed
4 %%% portions-copyright-cmetz-96
5 Portions of this software are Copyright 1996-1999 by Craig Metz, All Rights
6 Reserved. The Inner Net License Version 2 applies to these portions of
8 You should have received a copy of the license with this software. If
9 you didn't get a copy, you may request one from <license@inner.net>.
11 Portions of this software are Copyright 1995 by Randall Atkinson and Dan
12 McDonald, All Rights Reserved. All Rights under this copyright are assigned
13 to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
14 License Agreement applies to this software.
18 Modified by cmetz for OPIE 2.3. Removed unneeded debug message.
19 Modified by cmetz for OPIE 2.2. Use FUNCTION definition et al.
20 Fixed include order. Make everything static. Ifdef around
22 Modified at NRL for OPIE 2.1. Substitute @@KEY_FILE@@. Re-write in
24 Modified at NRL for OPIE 2.01. Remove hard-coded paths for grep and
25 awk and let PATH take care of it. Substitute for Makefile
26 variables $(EXISTS) and $(KEY_FILE). Only compute $WHO if
27 there's a key file. Got rid of grep since awk can do the job
29 Modified at NRL for OPIE 2.0.
30 Written at Bellcore for the S/Key Version 1 software distribution
33 $FreeBSD: head/contrib/opie/opieinfo.c 257264 2013-10-28 18:24:31Z sbruno $
38 #include <sys/param.h>
45 #endif /* HAVE_UNISTD_H */
48 /* extern char *optarg; */
49 /* extern int errno, optind; */
51 static char *getusername FUNCTION_NOARGS
57 fprintf(stderr
, "Cannot find login name\n");
63 int main
FUNCTION((argc
, argv
), int argc AND
char *argv
[])
69 while ((i
= getopt(argc
, argv
, "hv")) != EOF
) {
75 fprintf(stderr
, "usage: %s [-h] [-v] [user_name]\n", argv
[0]);
82 fprintf(stderr
, "Only superuser may get another user's keys\n");
85 username
= argv
[optind
];
87 username
= getusername();
89 if (strlen(username
) >= MAXLOGNAME
) {
90 fprintf(stderr
, "Username too long.\n");
94 if ((i
= opielookup(&opie
, username
)) && (i
!= 2)) {
96 fprintf(stderr
, "Error opening database! (errno = %d)\n", errno
);
98 fprintf(stderr
, "%s not found in database.\n", username
);
102 printf("%d %s\n", opie
.opie_n
- 1, opie
.opie_seed
);