WARNSify, fix .Nm usage

This commit is contained in:
lukem 1997-10-19 12:29:35 +00:00
parent fa580a821a
commit b879efa7db
6 changed files with 121 additions and 125 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.4 1997/01/07 04:08:12 tls Exp $ */ /* $NetBSD: extern.h,v 1.5 1997/10/19 12:29:35 lukem Exp $ */
/* /*
* Copyright (c) 1994 * Copyright (c) 1994
@ -36,8 +36,8 @@
*/ */
int kadm_passwd __P((char *, char *, char *, char *)); int kadm_passwd __P((char *, char *, char *, char *));
int krb_check __P((void));
int krb_passwd __P((void)); int krb_passwd __P((void));
int local_passwd __P((char *)); int local_passwd __P((char *));
void to64 __P((char *, long, int));
int yp_passwd __P((char *)); int yp_passwd __P((char *));
int krb_check __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: krb5_passwd.c,v 1.4 1997/02/11 09:35:56 mrg Exp $ */ /* $NetBSD: krb5_passwd.c,v 1.5 1997/10/19 12:29:44 lukem Exp $ */
/*- /*-
* Copyright (c) 1990 The Regents of the University of California. * Copyright (c) 1990 The Regents of the University of California.
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "from: @(#)krb_passwd.c 5.4 (Berkeley) 3/1/91"; static char sccsid[] = "from: @(#)krb_passwd.c 5.4 (Berkeley) 3/1/91";
#else #else
static char rcsid[] = "$NetBSD: krb5_passwd.c,v 1.4 1997/02/11 09:35:56 mrg Exp $"; __RCSID("$NetBSD: krb5_passwd.c,v 1.5 1997/10/19 12:29:44 lukem Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -48,13 +48,14 @@ static char rcsid[] = "$NetBSD: krb5_passwd.c,v 1.4 1997/02/11 09:35:56 mrg Exp
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netdb.h> #include <err.h>
#include <signal.h>
#include <pwd.h>
#include <errno.h> #include <errno.h>
#include <netdb.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <krb5/adm_defs.h> #include <krb5/adm_defs.h>
#include <krb5/krb5.h> #include <krb5/krb5.h>
#include <krb5/kdb.h> #include <krb5/kdb.h>
@ -151,8 +152,7 @@ krb_passwd()
* Network() verifies the terminal device is not a pseudo tty * Network() verifies the terminal device is not a pseudo tty
*/ */
if (networked() && krb_secure) { if (networked() && krb_secure) {
fprintf(stderr,"passwd: Sorry but you cannot %s from a\n", argv[0]); warnx("Sorry but you cannot %s from a pseudo tty terminal", argv[0]);
fprintf(stderr," pseudo tty terminal.\n");
retval = 1; retval = 1;
goto finish; goto finish;
} }
@ -160,13 +160,13 @@ krb_passwd()
/* (3 * 255) + 1 (/) + 1 (@) + 1 (NULL) */ /* (3 * 255) + 1 (/) + 1 (@) + 1 (NULL) */
if ((client_name = (char *) calloc (1, (3 * 256))) == NULL) { if ((client_name = (char *) calloc (1, (3 * 256))) == NULL) {
fprintf(stderr, "passwd: No Memory for Client_name\n"); warnx("No Memory for Client_name");
retval = 1; retval = 1;
goto finish; goto finish;
} }
if ((requested_realm.data = (char *) calloc (1, 256)) == NULL) { if ((requested_realm.data = (char *) calloc (1, 256)) == NULL) {
fprintf(stderr, "passwd: No Memory for realm_name\n"); warnx("No Memory for realm_name");
retval = 1; retval = 1;
free(client_name); free(client_name);
goto finish; goto finish;
@ -177,8 +177,7 @@ krb_passwd()
(void)signal(SIGTSTP, SIG_IGN); (void)signal(SIGTSTP, SIG_IGN);
if (setrlimit(RLIMIT_CORE, &rl) < 0) { if (setrlimit(RLIMIT_CORE, &rl) < 0) {
(void)fprintf(stderr, warn("setrlimit");
"passwd: setrlimit: %s\n", strerror(errno));
return(1); return(1);
} }
@ -187,7 +186,7 @@ krb_passwd()
/* Identify Default Credentials Cache */ /* Identify Default Credentials Cache */
if ((retval = krb5_cc_default(&cache))) { if ((retval = krb5_cc_default(&cache))) {
fprintf(stderr, "passwd: Error while getting default ccache.\n"); warnx("Error while getting default ccache.");
goto finish; goto finish;
} }
@ -205,20 +204,19 @@ krb_passwd()
(void)strncpy(default_name, pw->pw_name, sizeof(default_name) - 1); (void)strncpy(default_name, pw->pw_name, sizeof(default_name) - 1);
} }
else { else {
fprintf(stderr, warnx("Unable to Identify Customer from Password File");
"passwd: Unable to Identify Customer from Password File\n");
retval = 1; retval = 1;
goto finish; goto finish;
} }
/* Use this to get default_realm and format client_name */ /* Use this to get default_realm and format client_name */
if ((retval = krb5_parse_name(default_name, &client))) { if ((retval = krb5_parse_name(default_name, &client))) {
fprintf(stderr, "passwd: Unable to Parse Client Name\n"); warnx("Unable to Parse Client Name");
goto finish; goto finish;
} }
if ((retval = krb5_unparse_name(client, &client_name))) { if ((retval = krb5_unparse_name(client, &client_name))) {
fprintf(stderr, "passwd: Unable to Parse Client Name\n"); warnx("Unable to Parse Client Name");
goto finish; goto finish;
} }
@ -230,12 +228,12 @@ krb_passwd()
else { else {
/* Read Client from Cache */ /* Read Client from Cache */
if ((retval = krb5_cc_get_principal(cache, (krb5_principal *) &client))) { if ((retval = krb5_cc_get_principal(cache, (krb5_principal *) &client))) {
fprintf(stderr, "passwd: Unable to Read Customer Credentials File\n"); warnx("Unable to Read Customer Credentials File");
goto finish; goto finish;
} }
if ((retval = krb5_unparse_name(client, &client_name))) { if ((retval = krb5_unparse_name(client, &client_name))) {
fprintf(stderr, "passwd: Unable to Parse Client Name\n"); warnx("Unable to Parse Client Name");
goto finish; goto finish;
} }
@ -252,11 +250,11 @@ krb_passwd()
getpid()); getpid());
if ((retval = krb5_cc_resolve(cache_name, &cache))) { if ((retval = krb5_cc_resolve(cache_name, &cache))) {
fprintf(stderr, "passwd: Unable to Resolve Cache: %s\n", cache_name); warnx("Unable to Resolve Cache: %s", cache_name);
} }
if ((retval = krb5_cc_initialize(cache, client))) { if ((retval = krb5_cc_initialize(cache, client))) {
fprintf(stderr, "passwd: Error initializing cache: %s\n", cache_name); warnx("Error initializing cache: %s", cache_name);
goto finish; goto finish;
} }
@ -280,7 +278,7 @@ krb_passwd()
retval = krb5_net_write(local_socket, (char *) &msg_length + 2, 2); retval = krb5_net_write(local_socket, (char *) &msg_length + 2, 2);
if (retval < 0) { if (retval < 0) {
fprintf(stderr, "passwd: krb5_net_write failure\n"); warnx("krb5_net_write failure");
goto finish; goto finish;
} }
} }
@ -296,7 +294,7 @@ krb_passwd()
/* compute checksum, using CRC-32 */ /* compute checksum, using CRC-32 */
if (!(send_cksum.contents = (krb5_octet *) if (!(send_cksum.contents = (krb5_octet *)
malloc(krb5_checksum_size(CKSUMTYPE_CRC32)))) { malloc(krb5_checksum_size(CKSUMTYPE_CRC32)))) {
fprintf(stderr, "passwd: Insufficient Memory while Allocating Checksum\n"); warnx("Insufficient Memory while Allocating Checksum");
goto finish; goto finish;
} }
cksum_alloc++; cksum_alloc++;
@ -308,8 +306,7 @@ krb_passwd()
0, /* if length is 0, crc-32 doesn't 0, /* if length is 0, crc-32 doesn't
use the seed */ use the seed */
&send_cksum)) { &send_cksum)) {
fprintf(stderr, "Error while Computing Checksum: %s\n", warnx("Error while Computing Checksum: %s", error_message(retval));
error_message(retval));
goto finish; goto finish;
} }
@ -329,27 +326,24 @@ krb_passwd()
0, /* don't need a subsession key */ 0, /* don't need a subsession key */
&err_ret, &err_ret,
&rep_ret))) { &rep_ret))) {
fprintf(stderr, "passwd: Error while performing sendauth: %s\n", warnx("Error while performing sendauth: %s", error_message(retval));
error_message(retval));
goto finish; goto finish;
} }
/* Get credentials : to use for safe and private messages */ /* Get credentials : to use for safe and private messages */
if (retval = krb5_get_credentials(0, cache, &my_creds)){ if (retval = krb5_get_credentials(0, cache, &my_creds)){
fprintf(stderr, "passwd: Error Obtaining Credentials: %s\n", warnx("Error Obtaining Credentials: %s", error_message(retval));
error_message(retval));
goto finish; goto finish;
} }
/* Read back what the server has to say... */ /* Read back what the server has to say... */
if (retval = krb5_read_message(&local_socket, &inbuf)){ if (retval = krb5_read_message(&local_socket, &inbuf)){
fprintf(stderr, "passwd: Read Message Error: %s\n", warnx("Read Message Error: %s", error_message(retval));
error_message(retval));
goto finish; goto finish;
} }
if ((inbuf.length != 2) || (inbuf.data[0] != KADMIND) || if ((inbuf.length != 2) || (inbuf.data[0] != KADMIND) ||
(inbuf.data[1] != KADMSAG)){ (inbuf.data[1] != KADMSAG)){
fprintf(stderr, "passwd: Invalid ack from admin server.\n"); warnx("Invalid ack from admin server.");
goto finish; goto finish;
} }
@ -367,15 +361,14 @@ krb_passwd()
0, 0,
0, 0,
&msg_data))) { &msg_data))) {
fprintf(stderr, "passwd: Error during First Message Encoding: %s\n", warnx("Error during First Message Encoding: %s", error_message(retval));
error_message(retval));
goto finish; goto finish;
} }
free(inbuf.data); free(inbuf.data);
/* write private message to server */ /* write private message to server */
if (krb5_write_message(&local_socket, &msg_data)){ if (krb5_write_message(&local_socket, &msg_data)){
fprintf(stderr, "passwd: Write Error During First Message Transmission\n"); warnx("Write Error During First Message Transmission");
retval = 1; retval = 1;
goto finish; goto finish;
} }
@ -387,8 +380,7 @@ krb_passwd()
#ifdef MACH_PASS /* Machine-generated Passwords */ #ifdef MACH_PASS /* Machine-generated Passwords */
/* Ok Now let's get the private message */ /* Ok Now let's get the private message */
if (retval = krb5_read_message(&local_socket, &inbuf)){ if (retval = krb5_read_message(&local_socket, &inbuf)){
fprintf(stderr, "passwd: Read Error During First Reply: %s\n", warnx("Read Error During First Reply: %s", error_message(retval));
error_message(retval));
retval = 1; retval = 1;
goto finish; goto finish;
} }
@ -402,15 +394,14 @@ krb_passwd()
0, 0,
0, 0,
&msg_data))) { &msg_data))) {
fprintf(stderr, "passwd: Error during First Read Decoding: %s\n", warnx("Error during First Read Decoding: %s", error_message(retval));
error_message(retval));
goto finish; goto finish;
} }
free(inbuf.data); free(inbuf.data);
#endif #endif
if ((new_password = (char *) calloc (1, ADM_MAX_PW_LENGTH+1)) == NULL) { if ((new_password = (char *) calloc (1, ADM_MAX_PW_LENGTH+1)) == NULL) {
fprintf(stderr, "passwd: Unable to Allocate Space for New Password\n"); warnx("Unable to Allocate Space for New Password");
goto finish; goto finish;
} }
@ -449,8 +440,8 @@ krb_passwd()
0, 0,
0, 0,
&msg_data))) { &msg_data))) {
fprintf(stderr, "passwd: Error during Second Message Encoding: %s\n", warnx("Error during Second Message Encoding: %s",
error_message(retval)); error_message(retval));
goto finish; goto finish;
} }
memset(inbuf.data,0,inbuf.length); memset(inbuf.data,0,inbuf.length);
@ -458,7 +449,7 @@ krb_passwd()
/* write private message to server */ /* write private message to server */
if (krb5_write_message(&local_socket, &msg_data)){ if (krb5_write_message(&local_socket, &msg_data)){
fprintf(stderr, "passwd: Write Error During Second Message Transmission\n"); warnx("Write Error During Second Message Transmission");
retval = 1; retval = 1;
goto finish; goto finish;
} }
@ -466,8 +457,7 @@ krb_passwd()
/* Ok Now let's get the private message */ /* Ok Now let's get the private message */
if (retval = krb5_read_message(&local_socket, &inbuf)){ if (retval = krb5_read_message(&local_socket, &inbuf)){
fprintf(stderr, "passwd: Read Error During Second Reply: %s\n", warnx("Read Error During Second Reply: %s", error_message(retval));
error_message(retval));
retval = 1; retval = 1;
goto finish; goto finish;
} }
@ -481,8 +471,7 @@ krb_passwd()
0, 0,
0, 0,
&msg_data))) { &msg_data))) {
fprintf(stderr, "passwd: Error during Second Read Decoding :%s\n", warnx("Error during Second Read Decoding :%s", error_message(retval));
error_message(retval));
goto finish; goto finish;
} }
@ -505,14 +494,14 @@ krb_passwd()
if (rd_priv_resp.appl_code == KPASSWD) { if (rd_priv_resp.appl_code == KPASSWD) {
if (rd_priv_resp.retn_code == KPASSBAD) { if (rd_priv_resp.retn_code == KPASSBAD) {
if (rd_priv_resp.message) if (rd_priv_resp.message)
fprintf(stderr, "passwd: %s\n", rd_priv_resp.message); warnx("%s", rd_priv_resp.message);
else else
fprintf(stderr, "passwd: Server returned KPASSBAD.\n"); warnx("Server returned KPASSBAD.");
} else if (rd_priv_resp.retn_code != KPASSGOOD) } else if (rd_priv_resp.retn_code != KPASSGOOD)
fprintf(stderr, "passwd: Server returned unknown kerberos code.\n"); warnx("Server returned unknown kerberos code.");
} else } else
fprintf(stderr, "passwd: Server returned bad application code %d\n", warnx("Server returned bad application code %d",
rd_priv_resp.appl_code); rd_priv_resp.appl_code);
if (rd_priv_resp.message) if (rd_priv_resp.message)
free(rd_priv_resp.message); free(rd_priv_resp.message);
@ -523,10 +512,8 @@ krb_passwd()
free(client_name); free(client_name);
free(requested_realm.data); free(requested_realm.data);
if (cksum_alloc) free(send_cksum.contents); if (cksum_alloc) free(send_cksum.contents);
if (retval) { if (retval)
fprintf(stderr, "passwd: Protocol Failure - Password NOT changed\n"); errx(1, "Protocol Failure - Password NOT changed");
exit(1);
}
exit(0); exit(0);
} }
@ -558,14 +545,14 @@ get_first_ticket(cache, client)
krb5_error_code retval; krb5_error_code retval;
if ((retval = krb5_unparse_name(client, &client_name))) { if ((retval = krb5_unparse_name(client, &client_name))) {
fprintf(stderr, "Unable to Unparse Client Name\n"); warnx("Unable to Unparse Client Name");
return(1); return(1);
} }
(void) printf("Changing Kerberos password for %s\n", client_name); (void) printf("Changing Kerberos password for %s\n", client_name);
if ((retval = krb5_os_localaddr(&my_addresses))) { if ((retval = krb5_os_localaddr(&my_addresses))) {
fprintf(stderr, "passwd: Unable to Get Customers Address\n"); warnx("Unable to Get Customers Address");
return(1); return(1);
} }
@ -582,13 +569,13 @@ get_first_ticket(cache, client)
/* instance is local realm */ /* instance is local realm */
client->realm.data, client->realm.data,
0))) { 0))) {
fprintf(stderr, "Error %s while building server name\n"); warnx("Error %s while building server name");
return(1); return(1);
} }
if ((old_password = (char *) calloc (1, 255)) == NULL) { if ((old_password = (char *) calloc (1, 255)) == NULL) {
fprintf(stderr, "passwd: No Memory for Retrieving old password\n"); warnx("No Memory for Retrieving old password");
return(1); return(1);
} }
@ -621,8 +608,7 @@ get_first_ticket(cache, client)
} }
if (retval) { if (retval) {
fprintf(stderr, "passwd: Unable to Get Initial Credentials : %s\n", warnx("Unable to Get Initial Credentials : %s", error_message(retval));
error_message(retval));
} }
/* Do NOT Forget to zap password */ /* Do NOT Forget to zap password */
@ -661,8 +647,8 @@ print_and_choose_password(new_password, decodable_pwd_string)
/* Decode Password and Phrase Information Obtained from krb5_rd_priv */ /* Decode Password and Phrase Information Obtained from krb5_rd_priv */
if ((retval = decode_krb5_pwd_data(decodable_pwd_string , &pwd_data))) { if ((retval = decode_krb5_pwd_data(decodable_pwd_string , &pwd_data))) {
fprintf(stderr, "passwd: Unable to Decode Passwords and Phrases\n"); warnx("Unable to Decode Passwords and Phrases\n%s",
fprintf(stderr, " Notify your System Administrator or the Kerberos Administrator\n"); " Notify your System Administrator or the Kerberos Administrator");
return(1); return(1);
} }
@ -671,10 +657,11 @@ print_and_choose_password(new_password, decodable_pwd_string)
memset((char *) phrase_in, 0, ADM_MAX_PHRASE_LENGTH); memset((char *) phrase_in, 0, ADM_MAX_PHRASE_LENGTH);
for ( j = 0; j <= ADM_MAX_PW_ITERATIONS; j++) { for ( j = 0; j <= ADM_MAX_PW_ITERATIONS; j++) {
if (j == ADM_MAX_PW_ITERATIONS) { if (j == ADM_MAX_PW_ITERATIONS) {
fprintf(stderr, "passwd: Sorry - You Have Exceeded the List of Choices (%d) Allowed for Password\n", warnx("Sorry - You Have Exceeded the List of Choices (%d)\n%s%s%s",
ADM_MAX_PW_ITERATIONS * ADM_MAX_PW_CHOICES); ADM_MAX_PW_ITERATIONS * ADM_MAX_PW_CHOICES,
fprintf(stderr, " Modification. You Must Repeat this Operation in order to Successfully\n"); "\tAllowed for Password Modification.\n",
fprintf(stderr, " Change your Password.\n"); "\tYou Must Repeat this Operation in order\n",
"\tto Successfully Change your Password.");
break; break;
} }
@ -687,7 +674,7 @@ print_and_choose_password(new_password, decodable_pwd_string)
for ( i = 0; i < ADM_MAX_PW_CHOICES; i++){ for ( i = 0; i < ADM_MAX_PW_CHOICES; i++){
if ((password_list[i] = (char *) calloc (1, if ((password_list[i] = (char *) calloc (1,
ADM_MAX_PW_LENGTH + 1)) == NULL) { ADM_MAX_PW_LENGTH + 1)) == NULL) {
fprintf(stderr, "passwd: Unable to Allocate Password List.\n"); warnx("Unable to Allocate Password List.");
return(1); return(1);
} }
@ -732,8 +719,7 @@ print_and_choose_password(new_password, decodable_pwd_string)
/* Read New Password from Terminal (Do Not Print on Screen) */ /* Read New Password from Terminal (Do Not Print on Screen) */
if ((retval = krb5_read_password(&prompt[0], 0, if ((retval = krb5_read_password(&prompt[0], 0,
new_password, &new_passwd_length))) { new_password, &new_passwd_length))) {
fprintf(stderr, warnx("Error Reading Password Input or Input Aborted");
"passwd: Error Reading Password Input or Input Aborted\n");
free_local_password_list(); free_local_password_list();
break;; break;;
} }
@ -786,8 +772,7 @@ int * local_socket;
(void) memset((char *)&remote_sin, 0, sizeof(remote_sin)); (void) memset((char *)&remote_sin, 0, sizeof(remote_sin));
if ((service_process = getservbyname(CPW_SNAME, "tcp")) == NULL) { if ((service_process = getservbyname(CPW_SNAME, "tcp")) == NULL) {
fprintf(stderr, "passwd: Unable to find Service (%s) Check services file\n", warnx("Unable to find Service (%s) Check services file", CPW_SNAME);
CPW_SNAME);
return(1); return(1);
} }
@ -798,7 +783,7 @@ int * local_socket;
/* Identify all Hosts Associated with this Realm */ /* Identify all Hosts Associated with this Realm */
if ((retval = krb5_get_krbhst (realm_of_server, &hostlist))) { if ((retval = krb5_get_krbhst (realm_of_server, &hostlist))) {
fprintf(stderr, "passwd: Unable to Determine Server Name\n"); warnx("Unable to Determine Server Name");
return(1); return(1);
} }
@ -808,7 +793,7 @@ int * local_socket;
if (count == 0) { if (count == 0) {
host_count = 0; host_count = 0;
fprintf(stderr, "passwd: No hosts found\n"); warnx("No hosts found");
return(1); return(1);
} }
@ -830,12 +815,12 @@ int * local_socket;
/* open a TCP socket */ /* open a TCP socket */
*local_socket = socket(PF_INET, SOCK_STREAM, 0); *local_socket = socket(PF_INET, SOCK_STREAM, 0);
if (*local_socket < 0) { if (*local_socket < 0) {
fprintf(stderr, "passwd: Cannot Open Socket\n"); warnx("Cannot Open Socket");
return(1); return(1);
} }
/* connect to the server */ /* connect to the server */
if (connect(*local_socket, (struct sockaddr *)&remote_sin, sizeof(remote_sin)) < 0) { if (connect(*local_socket, (struct sockaddr *)&remote_sin, sizeof(remote_sin)) < 0) {
fprintf(stderr, "passwd: Cannot Connect to Socket\n"); warnx("Cannot Connect to Socket");
close(*local_socket); close(*local_socket);
return(1); return(1);
} }
@ -844,7 +829,7 @@ int * local_socket;
namelen = sizeof(local_sin); namelen = sizeof(local_sin);
if (getsockname(*local_socket, if (getsockname(*local_socket,
(struct sockaddr *) &local_sin, &namelen) < 0) { (struct sockaddr *) &local_sin, &namelen) < 0) {
fprintf(stderr, "passwd: Cannot Perform getsockname\n"); warnx("Cannot Perform getsockname");
close(*local_socket); close(*local_socket);
return(1); return(1);
} }
@ -957,7 +942,7 @@ char *username,*tmpname;
endutent(); endutent();
return(1); return(1);
} }
bcopy((char *)&retutent, (char *)tmpptr, sizeof(struct utmp)); memmove((char *)tmpptr, (char *)&retutent, sizeof(struct utmp));
endutent(); endutent();
#ifdef DEBUG #ifdef DEBUG
#ifdef NO_UT_HOST #ifdef NO_UT_HOST

View File

@ -1,4 +1,4 @@
/* $NetBSD: local_passwd.c,v 1.13 1997/07/24 08:53:48 phil Exp $ */ /* $NetBSD: local_passwd.c,v 1.14 1997/10/19 12:29:51 lukem Exp $ */
/*- /*-
* Copyright (c) 1990, 1993, 1994 * Copyright (c) 1990, 1993, 1994
@ -33,26 +33,32 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94"; static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
#else #else
static char rcsid[] = "$NetBSD: local_passwd.c,v 1.13 1997/07/24 08:53:48 phil Exp $"; __RCSID("$NetBSD: local_passwd.c,v 1.14 1997/10/19 12:29:51 lukem Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <pwd.h> #include <ctype.h>
#include <err.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h>
#include <util.h> #include <util.h>
#include "extern.h" #include "extern.h"
static char *getnewpasswd __P((struct passwd *));
static uid_t uid; static uid_t uid;
char *tempname; char *tempname;
@ -72,13 +78,13 @@ to64(s, v, n)
} }
} }
char * static char *
getnewpasswd(pw) getnewpasswd(pw)
struct passwd *pw; struct passwd *pw;
{ {
int tries; int tries;
char *p, *t; char *p, *t;
char buf[_PASSWORD_LEN+1], salt[9], *crypt(), *getpass(); char buf[_PASSWORD_LEN+1], salt[9];
(void)printf("Changing local password for %s.\n", pw->pw_name); (void)printf("Changing local password for %s.\n", pw->pw_name);
@ -131,7 +137,6 @@ local_passwd(uname)
struct passwd *pw; struct passwd *pw;
struct passwd old_pw; struct passwd old_pw;
int pfd, tfd; int pfd, tfd;
char *getnewpasswd();
if (!(pw = getpwnam(uname))) { if (!(pw = getpwnam(uname))) {
warnx("unknown user %s", uname); warnx("unknown user %s", uname);

View File

@ -1,4 +1,4 @@
.\" $NetBSD: passwd.1,v 1.8 1997/01/07 04:08:17 tls Exp $ .\" $NetBSD: passwd.1,v 1.9 1997/10/19 12:29:55 lukem Exp $
.\" .\"
.\" Copyright (c) 1990, 1993 .\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -40,14 +40,14 @@
.Nm passwd .Nm passwd
.Nd modify a user's password .Nd modify a user's password
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm passwd .Nm
.Op Fl l .Op Fl l
.Op Fl y .Op Fl y
.Op Ar user .Op Ar user
.Nm yppasswd .Nm yppasswd
.Op Ar user .Op Ar user
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm Passwd .Nm
changes the user's local or YP password. First, the user is prompted changes the user's local or YP password. First, the user is prompted
for their current password. for their current password.
If the current password is correctly typed, a new password is If the current password is correctly typed, a new password is
@ -74,7 +74,7 @@ the user has an entry in the local database. The
daemon should be running on the YP master server. daemon should be running on the YP master server.
.Nm yppasswd .Nm yppasswd
is the equivalent of is the equivalent of
.Nm passwd .Nm
with the with the
.Fl y .Fl y
flag. flag.
@ -107,6 +107,6 @@ Temporary copy of the password file
.Re .Re
.Sh HISTORY .Sh HISTORY
A A
.Nm passwd .Nm
command appeared in command appeared in
.At v6 . .At v6 .

View File

@ -1,4 +1,4 @@
/* $NetBSD: passwd.c,v 1.11 1997/01/07 04:08:18 tls Exp $ */ /* $NetBSD: passwd.c,v 1.12 1997/10/19 12:30:00 lukem Exp $ */
/* /*
* Copyright (c) 1988, 1993, 1994 * Copyright (c) 1988, 1993, 1994
@ -33,17 +33,17 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#ifndef lint #ifndef lint
static char copyright[] = __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\n\
"@(#) Copyright (c) 1988, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n");
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "from: @(#)passwd.c 8.3 (Berkeley) 4/2/94"; static char sccsid[] = "from: @(#)passwd.c 8.3 (Berkeley) 4/2/94";
#else #else
static char rcsid[] = "$NetBSD: passwd.c,v 1.11 1997/01/07 04:08:18 tls Exp $"; __RCSID("$NetBSD: passwd.c,v 1.12 1997/10/19 12:30:00 lukem Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -70,10 +70,13 @@ int yflag;
extern char *__progname; /* from crt0.o */ extern char *__progname; /* from crt0.o */
int main __P((int, char **));
#ifdef YP #ifdef YP
extern int _yp_check __P((char **)); /* buried deep inside libc */ extern int _yp_check __P((char **)); /* buried deep inside libc */
#endif #endif
int
main(argc, argv) main(argc, argv)
int argc; int argc;
char **argv; char **argv;
@ -81,9 +84,9 @@ main(argc, argv)
extern int optind; extern int optind;
int ch; int ch;
char *username; char *username;
#if defined(KERBEROS) || defined(KERBEROS5)
char *iflag = 0, *rflag = 0, *uflag = 0; char *iflag = 0, *rflag = 0, *uflag = 0;
#if defined(KERBEROS) || defined(KERBEROS5)
if (strcmp(__progname, "kpasswd") == 0) if (strcmp(__progname, "kpasswd") == 0)
use_kerberos = 1; use_kerberos = 1;
else else

View File

@ -1,4 +1,4 @@
/* $NetBSD: yp_passwd.c,v 1.14 1997/05/21 02:09:51 lukem Exp $ */ /* $NetBSD: yp_passwd.c,v 1.15 1997/10/19 12:30:07 lukem Exp $ */
/* /*
* Copyright (c) 1988, 1990, 1993, 1994 * Copyright (c) 1988, 1990, 1993, 1994
@ -33,26 +33,34 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94"; static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
#else #else
static char rcsid[] = "$NetBSD: yp_passwd.c,v 1.14 1997/05/21 02:09:51 lukem Exp $"; __RCSID("$NetBSD: yp_passwd.c,v 1.15 1997/10/19 12:30:07 lukem Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#ifdef YP #ifdef YP
#include <ctype.h>
#include <err.h> #include <err.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <time.h>
#include <pwd.h>
#include <errno.h> #include <errno.h>
#include <netdb.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <rpc/rpc.h> #include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h> #include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h> #include <rpcsvc/ypclnt.h>
#include "extern.h"
#define passwd yp_passwd_rec #define passwd yp_passwd_rec
#include <rpcsvc/yppasswd.h> #include <rpcsvc/yppasswd.h>
#undef passwd #undef passwd
@ -65,26 +73,21 @@ extern char *__progname; /* from crt0.o */
extern int yflag, yppwd; extern int yflag, yppwd;
static char *getnewpasswd(); static char *getnewpasswd __P((struct passwd *, char **));
static struct passwd *ypgetpwnam(); static struct passwd *interpret __P((struct passwd *, char *));
static struct passwd *ypgetpwnam __P((char *));
static void pw_error __P((char *, int, int));
static uid_t uid; static uid_t uid;
char *domain; char *domain;
static static void
pw_error(name, err, eval) pw_error(name, err, eval)
char *name; char *name;
int err, eval; int err, eval;
{ {
int sverrno; if (err)
warn("%s", name ? name : "");
if (err) {
sverrno = errno;
(void)fprintf(stderr, "%s: ", __progname);
if (name)
(void)fprintf(stderr, "%s: ", name);
(void)fprintf(stderr, "%s\n", strerror(sverrno));
}
errx(eval, "YP passwd database unchanged"); errx(eval, "YP passwd database unchanged");
} }
@ -93,7 +96,6 @@ yp_passwd(username)
char *username; char *username;
{ {
char *master; char *master;
char *pp;
int r, rpcport, status; int r, rpcport, status;
struct yppasswd yppasswd; struct yppasswd yppasswd;
struct passwd *pw; struct passwd *pw;
@ -105,7 +107,7 @@ yp_passwd(username)
/* /*
* Get local domain * Get local domain
*/ */
if (r = yp_get_default_domain(&domain)) if ((r = yp_get_default_domain(&domain)) != NULL)
errx(1, "can't get local YP domain. Reason: %s", errx(1, "can't get local YP domain. Reason: %s",
yperr_string(r)); yperr_string(r));
@ -191,7 +193,7 @@ getnewpasswd(pw, old_pass)
int tries; int tries;
char *p, *t; char *p, *t;
static char buf[_PASSWORD_LEN+1]; static char buf[_PASSWORD_LEN+1];
char salt[9], *crypt(), *getpass(); char salt[9];
(void)printf("Changing YP password for %s.\n", pw->pw_name); (void)printf("Changing YP password for %s.\n", pw->pw_name);
@ -255,11 +257,12 @@ pwskip(char *p)
return (p); return (p);
} }
struct passwd * static struct passwd *
interpret(struct passwd *pwent, char *line) interpret(pwent, line)
struct passwd *pwent;
char *line;
{ {
char *p = line; char *p = line;
int c;
pwent->pw_passwd = "*"; pwent->pw_passwd = "*";
pwent->pw_uid = 0; pwent->pw_uid = 0;