Fix some x86_64 warnings in the kernel (and remove nowerror).
[dragonfly.git] / contrib / opie / opieinfo.c
blob0833c92b7f516c820292cc5b7d644c59726e69fc
1 /*
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
7 the software.
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.
16 History:
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
21 some headers.
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
28 itself.
29 Modified at NRL for OPIE 2.0.
30 Written at Bellcore for the S/Key Version 1 software distribution
31 (keyinfo)
33 $FreeBSD: src/contrib/opie/opieinfo.c,v 1.1.1.2.6.4 2002/07/15 14:48:43 des Exp $
34 $DragonFly: src/contrib/opie/opieinfo.c,v 1.2 2003/06/17 04:24:05 dillon Exp $
38 #include "opie_cfg.h"
39 #include <sys/param.h>
40 #include <errno.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #if HAVE_UNISTD_H
45 #include <unistd.h>
46 #endif /* HAVE_UNISTD_H */
47 #include "opie.h"
49 /* extern char *optarg; */
50 /* extern int errno, optind; */
52 static char *getusername FUNCTION_NOARGS
54 char *login;
56 login = getlogin();
57 if (login == NULL) {
58 fprintf(stderr, "Cannot find login name\n");
59 exit(1);
61 return login;
64 int main FUNCTION((argc, argv), int argc AND char *argv[])
66 char *username;
67 struct opie opie;
68 int i;
70 while ((i = getopt(argc, argv, "hv")) != EOF) {
71 switch (i) {
72 case 'v':
73 opieversion();
74 case 'h':
75 default:
76 fprintf(stderr, "usage: %s [-h] [-v] [user_name]\n", argv[0]);
77 exit(0);
81 if (optind < argc) {
82 if (getuid() != 0) {
83 fprintf(stderr, "Only superuser may get another user's keys\n");
84 exit(1);
86 username = argv[optind];
87 } else
88 username = getusername();
90 if (strlen(username) >= MAXLOGNAME) {
91 fprintf(stderr, "Username too long.\n");
92 exit(1);
95 if ((i = opielookup(&opie, username)) && (i != 2)) {
96 if (i < 0)
97 fprintf(stderr, "Error opening database! (errno = %d)\n", errno);
98 else
99 fprintf(stderr, "%s not found in database.\n", username);
100 exit(1);
103 printf("%d %s\n", opie.opie_n - 1, opie.opie_seed);
105 return 0;