|
|
1.1 root 1: /* $Header: getXNSuser.c,v 1.2 87/07/28 08:39:23 ed Exp $ */
2:
3: /*
4: * Copyright (c) 1986, 1987 Xerox Corporation.
5: */
6:
7: /* $Log: getXNSuser.c,v $
8: * Revision 1.2 87/07/28 08:39:23 ed
9: * fprintf to stderr instead of stdin (how did it work?).
10: *
11: * Revision 1.1 87/03/23 10:26:08 ed
12: * Initial revision
13: *
14: */
15:
16: #include <stdio.h>
17: #include <xnscourier/Authentication2.h>
18: #include <xnscourier/Clearinghouse2.h>
19: #include <ctype.h>
20:
21: /* This should be constant somewhere ?? */
22: static char name[85]; /* 80 is max three part name + 3 for separators(:) */
23: static Cardinal passwd;
24:
25: getXNSuser(xnsname, xnspwd)
26: char **xnsname;
27: Cardinal **xnspwd;
28: {
29: char *pwd, *cp, *username;
30: char *getXNSpass(), *getenv(), *index();
31: FILE *tty, *fopen();
32:
33: if ( ((username= getenv("XNSNAME")) == NULL) || (username[0] == '\0') ) {
34: if ( (tty= fopen("/dev/tty", "r+")) == NULL ) {
35: tty= stdin;
36: } else {
37: setbuf(tty, (char *)NULL);
38: }
39: fprintf(stderr, "Enter XNS name: ");
40: fgets(name, sizeof(name), tty);
41: if ( (cp= index(name, '\n')) )
42: *cp= '\0';
43: if ( name[0] == '\0' )
44: *xnsname= "Unknown";
45: else
46: *xnsname= name;
47: fclose(tty);
48: } else {
49: *xnsname= username;
50: }
51:
52: if ( ((pwd= getenv("XNSPASSWD")) == NULL) || (*pwd == '\0') ) {
53: pwd= getXNSpass("Enter XNS password: ");
54: passwd= hashpass(pwd);
55: } else {
56: passwd= atoi(pwd);
57: }
58:
59: *xnspwd= &passwd;
60: }
61:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.