|
|
1.1 ! root 1: #ifndef lint ! 2: static char *rcsid = "$Header: MakeSecondaryCreds.c,v 1.5 87/04/16 15:47:29 ed Exp $"; ! 3: #endif lint ! 4: ! 5: /* ! 6: * Copyright (c) 1986, 1987 Xerox Corp. ! 7: */ ! 8: ! 9: /* ! 10: * $Log: MakeSecondaryCreds.c,v $ ! 11: * Revision 1.5 87/04/16 15:47:29 ed ! 12: * length becomes a Cardinal. ! 13: * ! 14: * Revision 1.4 87/03/31 14:20:31 ed ! 15: * Prompt with host name. ! 16: * ! 17: * Revision 1.3 87/03/27 15:21:10 ed ! 18: * Corrected missing argument on index(). ! 19: * ! 20: * Revision 1.2 87/03/18 08:42:08 ed ! 21: * Minor changes. ! 22: * ! 23: * Revision 1.1 86/12/31 11:26:19 ed ! 24: * Initial revision ! 25: * ! 26: * ! 27: */ ! 28: ! 29: #include <stdio.h> ! 30: #include <sys/time.h> ! 31: #include <sys/param.h> ! 32: #include <sys/stat.h> ! 33: #include <netns/ns.h> ! 34: #include <netns/sp.h> ! 35: #include <xnscourier/FilingSubset1.h> ! 36: #include <xnscourier/CH.h> ! 37: ! 38: MakeSecondaryCreds(host, user, pwd, creds) ! 39: char *host; ! 40: char *user; ! 41: char *pwd; ! 42: FilingSubset1_SecondaryCredentials *creds; ! 43: { ! 44: Cardinal length; ! 45: Unspecified buf[2048], *bp; ! 46: static FilingSubset1_SecondaryItem items[2]; ! 47: FILE *tty; ! 48: char *cp, buffer[128], *index(), *getXNSpass(); ! 49: char *userpwd, *username; ! 50: ! 51: if ( user == 0 ) { ! 52: if ( (tty= fopen("/dev/tty", "r+")) == NULL ) ! 53: tty= stdin; ! 54: else ! 55: setbuf(tty, (char *)NULL); ! 56: fprintf(tty, "Enter %s username: ", host); ! 57: fgets(buffer, sizeof(buffer), tty); ! 58: if ( (cp= index(buffer, '\n')) ) *cp= '\0'; ! 59: username= buffer; ! 60: fclose(tty); ! 61: } else { ! 62: username= user; ! 63: } ! 64: ! 65: if ( pwd == 0 ) { ! 66: char prompt[100]; ! 67: sprintf(prompt,"Enter %s password: ", host); ! 68: userpwd= getXNSpass(prompt); ! 69: } else { ! 70: userpwd= pwd; ! 71: } ! 72: ! 73: if ( creds != 0 ) { ! 74: creds->designator= FilingSubset1_simple; ! 75: items[0].type= FilingSubset1_userName; ! 76: items[0].value.sequence= Allocate(sizeof_String(&username)); ! 77: bp= buf + sizeof_Cardinal(length); ! 78: length= externalize_String(&username, bp); ! 79: externalize_Cardinal(&length, buf); ! 80: internalize_Clearinghouse3_Item(&(items[0].value), buf); ! 81: ! 82: items[1].type= FilingSubset1_userPassword; ! 83: items[1].value.sequence= Allocate(sizeof_String(&userpwd)); ! 84: bp= buf + sizeof_Cardinal(length); ! 85: length= externalize_String(&userpwd, bp); ! 86: externalize_Cardinal(&length, buf); ! 87: internalize_Clearinghouse3_Item(&(items[1].value), buf); ! 88: ! 89: creds->designator= FilingSubset1_simple; ! 90: creds->FilingSubset1_simple_case.length= 2; ! 91: creds->FilingSubset1_simple_case.sequence= items; ! 92: } ! 93: ! 94: return; ! 95: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.