4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
47 #include <sys/types.h>
50 #include <rpc/key_prot.h>
51 #include <rpcsvc/nis.h>
52 #include <rpcsvc/nis_dhext.h>
53 #include <rpcsvc/ypclnt.h>
60 #define CURMECH mechs[mcount]
61 #define DESCREDPASSLEN sizeof (des_block)
63 static char CRED_TABLE
[] = "cred.org_dir";
64 static char PKMAP
[] = "publickey.byname";
65 static char PKFILE
[] = "/etc/publickey";
66 #define MAXHOSTNAMELEN 256
68 #define ROOTKEY_FILE "/etc/.rootkey"
69 #define ROOTKEY_FILE_BACKUP "/etc/.rootkey.bak"
70 #define MAXROOTKEY_LINE_LEN 4224 /* Good upto 16384-bit keys */
71 #define MAXROOTKEY_LEN 4096
73 /* Should last up to 16384-bit keys */
74 #define MAXPKENTLEN 8500
76 bool_t makenew
= TRUE
; /* Make new keys or reencrypt existing */
77 bool_t specmech
= FALSE
; /* Specific mechs requested */
79 int dest_service
= 0; /* To which nameservice do we store key(s) */
83 mechanism_t
**mechs
= NULL
; /* List of DH mechanisms */
84 char **plist
= NULL
; /* List of public key(s) */
85 char **slist
= NULL
; /* List of secret key(s) */
86 char **clist
= NULL
; /* List of encrypted secret key(s) */
87 int numspecmech
= 0; /* Number of mechanisms specified */
89 struct passwd
*pw
= NULL
; /* passwd entry of user */
90 struct spwd
*spw
= NULL
; /* shadow entry of user */
92 char *netname
= NULL
; /* RPC netname of user */
93 char local_domain
[MAXNETNAMELEN
+ 1];
94 char *sec_domain
= NULL
;
96 char **rpc_pws
= NULL
; /* List of S-RPC passwords */
97 int rpc_pw_count
= 0; /* Number of passwords entered by user */
98 char *login_pw
= NULL
; /* Unencrypted login password */
99 char short_login_pw
[DESCREDPASSLEN
+ 1];
100 /* Short S-RPC password, which has first 8 chars of login_pw */
102 static int add_cred_obj(nis_object
*, char *);
103 static void cmp_passwd();
104 static void encryptkeys();
105 static void error_msg();
106 static char *fgets_ignorenul();
107 static void getpublics();
108 static void getrpcpws();
109 static void getsecrets();
110 static void initkeylist(bool_t
);
111 static void keylogin(keylen_t
, algtype_t
);
112 static void keylogin_des();
113 static void makenewkeys();
114 static int modify_cred_obj(nis_object
*, char *);
115 static void storekeys();
117 static void write_rootkey();
119 extern nis_object
*init_entry();
120 extern int get_pk_source(char *);
121 extern int localupdate(char *, char *, uint_t
, char *);
122 extern int xencrypt();
123 extern int xencrypt_g();
124 extern int __gen_dhkeys();
125 extern int key_setnet();
126 extern int key_setnet_g();
127 extern int key_secretkey_is_set_g();
128 extern int __getnetnamebyuid();
129 extern int getdomainname();
130 extern int ldap_update(char *, char *, char *, char *, char *);
136 if (sec_domain
&& *sec_domain
&&
137 strcasecmp(sec_domain
, local_domain
)) {
139 "The system default domain '%s' is different from the Secure RPC\n\
140 domain %s where the key is stored. \n", local_domain
, sec_domain
);
149 fprintf(stderr
, "usage: %s [-p] [-s ldap | nis | files] \n",
155 /* Encrypt secret key(s) with login_pw */
159 int mcount
, ccount
= 0;
162 for (mcount
= 0; CURMECH
; mcount
++) {
165 if (!xencrypt_g(slist
[mcount
], CURMECH
->keylen
,
166 CURMECH
->algtype
, short_login_pw
, netname
,
168 /* Could not crypt key */
172 clist
[mcount
] = crypt
;
178 (char *)malloc(HEXKEYBYTES
+ KEYCHECKSUMSIZE
+ 1))) {
179 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
183 (void) memcpy(crypt
, slist
[0], HEXKEYBYTES
);
184 (void) memcpy(crypt
+ HEXKEYBYTES
, slist
[0], KEYCHECKSUMSIZE
);
185 crypt
[HEXKEYBYTES
+ KEYCHECKSUMSIZE
] = 0;
186 xencrypt(crypt
, short_login_pw
);
193 fprintf(stderr
, "%s: Could not encrypt any secret keys.\n",
200 /* Initialize the array of public, secret, and encrypted secret keys */
202 initkeylist(bool_t nomech
)
207 assert(mechs
&& mechs
[0]);
208 for (mcount
= 0; CURMECH
; mcount
++)
213 if (!(plist
= (char **)malloc(sizeof (char *) * mcount
))) {
214 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
217 if (!(slist
= (char **)malloc(sizeof (char *) * mcount
))) {
218 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
221 if (!(clist
= (char **)malloc(sizeof (char *) * mcount
))) {
222 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
228 /* Retrieve public key(s) */
236 for (mcount
= 0; CURMECH
; mcount
++) {
240 hexkeylen
= ((CURMECH
->keylen
/ 8) * 2) + 1;
241 if (!(public = (char *)malloc(hexkeylen
))) {
242 fprintf(stderr
, "%s: Malloc failure.\n",
246 if (!getpublickey_g(netname
, CURMECH
->keylen
,
247 CURMECH
->algtype
, public,
249 /* Could not get public key */
251 "Could not get %s public key.\n",
252 VALID_ALIAS(CURMECH
->alias
) ?
253 CURMECH
->alias
: "");
259 plist
[mcount
] = public;
264 if (!(public = (char *)malloc(HEXKEYBYTES
+ 1))) {
265 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
268 if (!getpublickey(netname
, public)) {
278 fprintf(stderr
, "%s: cannot get any public keys for %s.\n",
279 program_name
, pw
->pw_name
);
282 "Make sure that the public keys are stored in the domain %s.\n",
289 /* Generate a new set of public/secret key pair(s) */
296 for (mcount
= 0; CURMECH
; mcount
++) {
297 char *public, *secret
;
303 hexkeylen
= ((CURMECH
->keylen
/ 8) * 2) + 1;
305 if (!(public = malloc(hexkeylen
))) {
306 fprintf(stderr
, "%s: Malloc failure.\n",
310 if (!(secret
= malloc(hexkeylen
))) {
311 fprintf(stderr
, "%s: Malloc failure.\n",
316 if (!(__gen_dhkeys_g(public, secret
, CURMECH
->keylen
,
317 CURMECH
->algtype
, short_login_pw
))) {
318 /* Could not generate key pair */
320 "WARNING Could not generate key pair %s\n",
321 VALID_ALIAS(CURMECH
->alias
) ?
322 CURMECH
->alias
: "");
329 plist
[mcount
] = public;
330 slist
[mcount
] = secret
;
333 char *public, *secret
;
337 if (!(public = malloc(HEXKEYBYTES
+ 1))) {
338 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
341 if (!(secret
= malloc(HEXKEYBYTES
+ 1))) {
342 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
346 __gen_dhkeys(public, secret
, short_login_pw
);
355 * Make sure that the entered Secure-RPC password(s) match the login
361 char baseprompt
[] = "Please enter the login password for";
363 char *en_login_pw
= spw
->sp_pwdp
;
364 char short_en_login_pw
[DESCREDPASSLEN
+ 1];
365 char *try_en_login_pw
;
366 bool_t pwmatch
= FALSE
;
367 int done
= 0, tries
= 0, pcount
;
369 snprintf(prompt
, BUFSIZ
, "%s %s:", baseprompt
, pw
->pw_name
);
371 (void) strlcpy(short_en_login_pw
, en_login_pw
,
372 sizeof (short_en_login_pw
));
374 if (en_login_pw
&& (strlen(en_login_pw
) != 0)) {
375 for (pcount
= 0; pcount
< rpc_pw_count
; pcount
++) {
378 try_en_rpc_pw
= crypt(rpc_pws
[pcount
], short_en_login_pw
);
379 if (strcmp(try_en_rpc_pw
, short_en_login_pw
) == 0) {
380 login_pw
= rpc_pws
[pcount
];
381 (void) strlcpy(short_login_pw
, login_pw
,
382 sizeof (short_login_pw
));
391 login_pw
= getpassphrase(prompt
);
392 (void) strlcpy(short_login_pw
, login_pw
,
393 sizeof (short_login_pw
));
394 if (login_pw
&& strlen(login_pw
)) {
395 /* pw was not empty */
396 try_en_login_pw
= crypt(login_pw
,
398 /* compare the pw's */
399 if (!(strcmp(try_en_login_pw
,
424 "%s: key-pair(s) unchanged for %s.\n",
429 /* Need a password */
430 snprintf(prompt
, BUFSIZ
,
431 "Need a password. %s %s:",
443 "%s: no passwd found for %s in the shadow passwd entry.\n",
444 program_name
, pw
->pw_name
);
450 /* Prompt the user for a Secure-RPC password and store it in a cache. */
452 getrpcpws(char *flavor
)
455 char prompt
[BUFSIZ
+ 1];
458 snprintf(prompt
, BUFSIZ
,
459 "Please enter the %s Secure-RPC password for %s:",
460 flavor
, pw
->pw_name
);
462 snprintf(prompt
, BUFSIZ
,
463 "Please enter the Secure-RPC password for %s:",
466 cur_pw
= getpass(prompt
);
469 fprintf(stderr
, "%s: key-pair(s) unchanged for %s.\n",
470 program_name
, pw
->pw_name
);
476 (char **)realloc(rpc_pws
, sizeof (char *) * rpc_pw_count
))) {
477 fprintf(stderr
, "%s: Realloc failure.\n", program_name
);
480 rpc_pws
[rpc_pw_count
- 1] = cur_pw
;
484 /* Retrieve the secret key(s) for the user and attempt to decrypt them */
488 int mcount
, scount
= 0;
494 for (mcount
= 0; CURMECH
; mcount
++) {
499 hexkeylen
= ((CURMECH
->keylen
/ 8) * 2) + 1;
500 if (!(secret
= (char *)calloc(hexkeylen
,
502 fprintf(stderr
, "%s: Malloc failure.\n",
507 for (pcount
= 0; pcount
< rpc_pw_count
; pcount
++) {
508 if (!getsecretkey_g(netname
, CURMECH
->keylen
,
509 CURMECH
->algtype
, secret
,
521 getsecrets_tryagain_g
:
522 if (secret
[0] == 0) {
525 * No existing pw can decrypt
528 getrpcpws(CURMECH
->alias
);
529 if (!getsecretkey_g(netname
,
541 goto getsecrets_abort
;
544 if (secret
[0] == 0) {
545 /* Still no go, ask again */
546 free(rpc_pws
[pcount
]);
549 printf("Try again. ");
551 goto getsecrets_tryagain_g
;
556 "%s: key-pair unchanged for %s.\n",
557 program_name
, pw
->pw_name
);
564 slist
[mcount
] = secret
;
569 if (!(secret
= (char *)malloc(HEXKEYBYTES
+ 1))) {
570 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
574 if (!getsecretkey(netname
, secret
, rpc_pws
[0])) {
576 "%s: could not get secret key for '%s'\n",
577 program_name
, netname
);
581 if (secret
[0] == 0) {
586 printf("Try again. ");
589 goto getsecrets_tryagain
;
592 "%s: key-pair unchanged for %s.\n",
593 program_name
, pw
->pw_name
);
603 (void) fprintf(stderr
,
604 "%s: could not get nor decrypt any secret keys for '%s'\n",
605 program_name
, netname
);
612 /* Register AUTH_DES secret key with keyserv */
616 char *secret
= slist
[0];
617 struct key_netstarg netst
;
620 * try to revoke the existing key/credentials, assuming
621 * one exists. this will effectively mark "stale" any
622 * cached credientials...
624 if (key_setsecret(secret
) < 0) {
630 * it looks like a credential already existed, so try and
631 * revoke any lingering Secure-NFS privledges.
634 nra
.authtype
= AUTH_DES
;
637 if (_nfssys(NFS_REVAUTH
, &nra
) < 0)
638 perror("Warning: NFS credentials not destroyed");
639 #endif /* NFS_AUTH */
641 (void) memcpy(netst
.st_priv_key
, secret
, HEXKEYBYTES
);
643 netst
.st_pub_key
[0] = '\0';
644 netst
.st_netname
= strdup(netname
);
646 /* do actual key login */
647 if (key_setnet(&netst
) < 0) {
648 fprintf(stderr
, "Could not set %s's secret key\n", netname
);
649 fprintf(stderr
, "May be the keyserv is down?\n");
654 /* Register a secret key with the keyserv */
656 keylogin(keylen_t keylen
, algtype_t algtype
)
661 for (mcount
= 0; CURMECH
; mcount
++) {
662 if (keylen
== CURMECH
->keylen
&&
663 algtype
== CURMECH
->algtype
) {
664 if (key_setnet_g(netname
, slist
[mcount
],
670 "Could not set %s's %s secret key\n",
672 VALID_ALIAS(CURMECH
->alias
) ?
673 CURMECH
->alias
: "");
677 if (keylen
== 192 && algtype
== 0)
684 * fgets is "broken" in that if it reads a NUL character it will
685 * always return EOF for all reads, even when there is data left in
686 * the file. This replacement can deal with NUL's in a calm, rational
690 fgets_ignorenul(char *s
, int n
, FILE *stream
)
692 int fildes
= fileno(stream
);
701 rs
= read(fildes
, &c
, 1);
731 /* Write unencrypted secret key into root key file */
733 write_rootkey(char *secret
, char *flavor
, keylen_t keylen
, algtype_t algtype
)
735 char line
[MAXROOTKEY_LINE_LEN
];
736 char keyent
[MAXROOTKEY_LEN
];
738 int rootfd
, bakfd
, hexkeybytes
;
739 bool_t lineone
= TRUE
;
740 bool_t gotit
= FALSE
;
741 FILE *rootfile
, *bakfile
;
743 unlink(ROOTKEY_FILE_BACKUP
);
744 if ((rename(ROOTKEY_FILE
, ROOTKEY_FILE_BACKUP
)) < 0) {
745 if ((bakfd
= creat(ROOTKEY_FILE_BACKUP
, 0600)) < 0) {
746 perror("Could not create /etc/.rootkey.bak");
752 if ((rootfd
= open(ROOTKEY_FILE
, O_WRONLY
+O_CREAT
, 0600)) < 0) {
753 perror("Could not open /etc/.rootkey for writing");
755 "Attempting to restore original /etc/.rootkey\n");
756 rename(ROOTKEY_FILE_BACKUP
, ROOTKEY_FILE
);
759 if (!(rootfile
= fdopen(rootfd
, "w"))) {
760 perror("Could not open /etc/.rootkey for writing");
762 "Attempting to restore original /etc/.rootkey\n");
764 unlink(ROOTKEY_FILE
);
765 rename(ROOTKEY_FILE_BACKUP
, ROOTKEY_FILE
);
768 if (!(bakfile
= fopen(ROOTKEY_FILE_BACKUP
, "r"))) {
769 perror("Could not open /etc/.rootkey.bak for reading");
771 "Attempting to restore original /etc/.rootkey\n");
773 unlink(ROOTKEY_FILE
);
774 rename(ROOTKEY_FILE_BACKUP
, ROOTKEY_FILE
);
778 hexkeybytes
= ((keylen
+ 7) / 8) * 2;
780 while (fgets_ignorenul(line
, MAXROOTKEY_LINE_LEN
, bakfile
)) {
781 if (sscanf(line
, "%s %d", keyent
, &atent
) < 2) {
783 * No encryption algorithm found in the file
784 * (atent) so default to DES.
786 atent
= AUTH_DES_ALGTYPE
;
789 * 192-bit keys always go on the first line
795 fprintf(rootfile
, "%s\n", secret
);
797 fprintf(rootfile
, "%s", line
);
800 if ((strlen(keyent
) == hexkeybytes
) &&
801 (atent
== algtype
)) {
803 * Silently remove lines with the same
811 fprintf(rootfile
, "%s %d\n", secret
, algtype
);
813 fprintf(rootfile
, "%s", line
);
818 /* Append key to rootkey file */
821 fprintf(rootfile
, "%s\n", secret
);
824 fprintf(rootfile
, "\n");
825 fprintf(rootfile
, "%s %d\n", secret
, algtype
);
831 unlink(ROOTKEY_FILE_BACKUP
);
835 fprintf(stderr
, "WARNING: Could not write %s key to /etc/.rootkey\n",
839 /* Store new key information in the specified name service */
843 int mcount
, ucount
= 0;
844 char *ypmaster
, *ypdomain
= NULL
, pkent
[MAXPKENTLEN
];
849 switch (dest_service
) {
853 yp_get_default_domain(&ypdomain
);
854 if (yp_master(ypdomain
, PKMAP
, &ypmaster
) != 0) {
856 "%s: cannot find master of NIS publickey database\n",
861 "Sending key change request to %s ...\n", ypmaster
);
864 if (geteuid() != 0) {
866 "%s: non-root users cannot change their key-pair in %s\n",
867 program_name
, PKFILE
);
873 "could not update; database %d unknown\n",
879 for (mcount
= 0; CURMECH
; mcount
++) {
880 char authtype
[MECH_MAXATNAME
];
882 if (!plist
[mcount
] && !clist
[mcount
])
885 __nis_mechalias2authtype(CURMECH
->alias
, authtype
,
889 "Could not generate auth_type for %s.\n",
894 snprintf(pkent
, MAXPKENTLEN
, "%s:%s:%d",
895 plist
[mcount
], clist
[mcount
],
898 switch (dest_service
) {
900 if (ldap_update(CURMECH
->alias
, netname
,
901 plist
[mcount
], clist
[mcount
],
904 "%s: unable to update %s key in LDAP database\n",
905 program_name
, authtype
);
911 /* Should never get here. */
915 /* Should never get here. */
922 assert(plist
[0] && clist
[0]);
923 snprintf(pkent
, MAXPKENTLEN
, "%s:%s", plist
[0], clist
[0]);
925 switch (dest_service
) {
927 if (ldap_update("dh192-0", netname
,
931 "%s: unable to update %s key in LDAP database\n",
938 if (status
= yp_update(ypdomain
, PKMAP
,
940 strlen(netname
), pkent
,
943 "%s: unable to update NIS database (%u): %s\n",
944 program_name
, status
,
945 yperr_string(status
));
951 if (localupdate(netname
, PKFILE
, YPOP_STORE
, pkent
)) {
953 "%s: hence, unable to update publickey database\n",
960 /* Should never get here */
966 fprintf(stderr
, "%s: unable to update any key-pairs for %s.\n",
967 program_name
, pw
->pw_name
);
973 addmechtolist(char *mechtype
)
975 mechanism_t
**realmechlist
;
978 if (realmechlist
= __nis_get_mechanisms(FALSE
)) {
979 /* Match requested mech with list */
980 for (i
= 0; realmechlist
[i
]; i
++) {
981 if (realmechlist
[i
]->alias
)
982 if (strcmp(realmechlist
[i
]->alias
, mechtype
)
985 * Match, add it to the mechs.
986 * Don't worry about qop or
987 * secserv since they are not
992 (mechanism_t
**)realloc(mechs
,
993 sizeof (mechanism_t
*) *
994 (numspecmech
+ 1))) == NULL
) {
995 perror("Can not change keys");
999 if ((mechs
[numspecmech
- 1] =
1000 (mechanism_t
*)malloc(
1001 sizeof (mechanism_t
))) == NULL
) {
1002 perror("Can not change keys");
1005 if (realmechlist
[i
]->mechname
)
1006 mechs
[numspecmech
- 1]->mechname
=
1007 strdup(realmechlist
[i
]->mechname
);
1008 if (realmechlist
[i
]->alias
)
1009 mechs
[numspecmech
- 1]->alias
=
1010 strdup(realmechlist
[i
]->alias
);
1011 mechs
[numspecmech
- 1]->keylen
=
1012 realmechlist
[i
]->keylen
;
1013 mechs
[numspecmech
- 1]->algtype
=
1014 realmechlist
[i
]->algtype
;
1015 mechs
[numspecmech
] = NULL
;
1016 __nis_release_mechanisms(realmechlist
);
1022 "WARNING: Mechanism '%s' not configured, skipping...\n",
1024 __nis_release_mechanisms(realmechlist
);
1028 "WARNING: Mechanism '%s' not configured, skipping...\n",
1034 main(int argc
, char **argv
)
1039 char *service
= NULL
;
1040 program_name
= argv
[0];
1042 mechs
= __nis_get_mechanisms(FALSE
);
1044 while ((c
= getopt(argc
, argv
, "fps:m:")) != -1) {
1048 * Not documented as of on1093.
1049 * Temporarily supported
1058 service
= strdup(optarg
);
1063 if (mechs
&& specmech
== FALSE
) {
1064 __nis_release_mechanisms(mechs
);
1068 addmechtolist(optarg
);
1078 dest_service
= get_pk_source(service
);
1080 if (!(netname
= malloc(MAXNETNAMELEN
+ 1))) {
1081 fprintf(stderr
, "%s: Malloc failure.\n", program_name
);
1084 if (!__getnetnamebyuid(netname
, uid
= getuid())) {
1085 fprintf(stderr
, "%s: cannot generate netname for uid %d\n",
1089 sec_domain
= strdup(strchr(netname
, '@') + 1);
1090 getdomainname(local_domain
, MAXNETNAMELEN
);
1093 fprintf(stdout
, "Generating new key for '%s'.\n", netname
);
1095 fprintf(stdout
, "Reencrypting key for '%s'.\n", netname
);
1098 if (dest_service
== PK_YP
|| dest_service
== PK_FILES
) {
1100 "%s: can not add non-DES public keys to %s, skipping.\n",
1101 program_name
, service
);
1102 __nis_release_mechanisms(mechs
);
1111 orig_euid
= geteuid();
1113 /* Get password information */
1114 if ((pw
= getpwuid(uid
)) == NULL
) {
1116 "%s: Can not find passwd information for %d.\n",
1121 /* Set eUID to user */
1124 /* Obtain a list of decrypted secret keys */
1127 /* Keylogin user if not already done */
1131 for (mcount
= 0; CURMECH
; mcount
++) {
1132 keylen_t keylen
= CURMECH
->keylen
;
1133 algtype_t algtype
= CURMECH
->algtype
;
1135 if (!key_secretkey_is_set_g(keylen
, algtype
) &&
1137 keylogin(CURMECH
->keylen
, CURMECH
->algtype
);
1138 if ((uid
== 0) && (makenew
== FALSE
))
1139 write_rootkey(slist
[mcount
],
1140 VALID_ALIAS(CURMECH
->alias
) ?
1148 if (!key_secretkey_is_set()) {
1150 if ((uid
== 0) && (makenew
== FALSE
))
1151 write_rootkey(slist
[0], "des", 192, 0);
1155 /* Set eUID back to root */
1156 (void) seteuid(orig_euid
);
1159 * Call getspnam() after the keylogin has been done so we have
1160 * the best chance of having read access to the encrypted pw.
1162 * The eUID must be 0 for the getspnam() so the name service
1163 * switch can handle the following eUID sensitive cases:
1165 * files/compat: read /etc/shadow
1168 if ((spw
= getspnam(pw
->pw_name
)) == 0) {
1170 /* Set eUID back to user */
1171 (void) seteuid(uid
);
1173 (void) fprintf(stderr
,
1174 "%s: cannot find shadow entry for %s.\n",
1175 program_name
, pw
->pw_name
);
1179 /* Set eUID back to user */
1180 (void) seteuid(uid
);
1182 if (strcmp(spw
->sp_pwdp
, NOPWDRTR
) == 0) {
1183 (void) fprintf(stderr
,
1184 "%s: do not have read access to the passwd field for %s\n",
1185 program_name
, pw
->pw_name
);
1190 * force will be only supported for a while
1191 * -- it is NOT documented as of s1093
1194 char *prompt
= "Please enter New password:";
1196 login_pw
= getpassphrase(prompt
);
1197 (void) strlcpy(short_login_pw
, login_pw
,
1198 sizeof (short_login_pw
));
1199 if (!login_pw
|| !(strlen(login_pw
))) {
1200 fprintf(stderr
, "%s: key-pair(s) unchanged for %s.\n",
1201 program_name
, pw
->pw_name
);
1206 * Reconsile rpc_pws and login_pw.
1208 * This function will either return with login_pw == rpc_pw
1209 * (and thus, the new pw to encrypt keys) or it will exit.
1226 for (mcount
= 0; CURMECH
; mcount
++) {
1229 write_rootkey(slist
[mcount
],
1236 write_rootkey(slist
[0], "des", 192, 0);
1240 for (mcount
= 0; CURMECH
; mcount
++)
1241 keylogin(CURMECH
->keylen
,