version 1.17, 2003/07/10 00:06:51 |
version 1.18, 2003/08/04 07:29:22 |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <err.h> |
#include <err.h> |
#ifdef KERBEROS |
|
#include <kerberosIV/krb.h> |
|
#endif |
|
|
|
/* |
/* |
* Note on configuration: |
* Note on configuration: |
|
|
|
|
extern int local_passwd(char *, int); |
extern int local_passwd(char *, int); |
extern int yp_passwd(char *); |
extern int yp_passwd(char *); |
extern int krb_passwd(int, char **); |
|
extern int krb5_passwd(int, char **); |
extern int krb5_passwd(int, char **); |
extern int _yp_check(char **); |
extern int _yp_check(char **); |
void usage(int retval); |
void usage(int retval); |
|
|
int status = 0; |
int status = 0; |
#endif |
#endif |
|
|
#if defined(KERBEROS) || defined(KERBEROS5) |
#if defined(KERBEROS5) |
extern char realm[]; |
extern char realm[]; |
|
|
if (krb_get_lrealm(realm,1) == KSUCCESS) |
if (krb_get_lrealm(realm,1) == KSUCCESS) |
|
|
#endif |
#endif |
|
|
/* Process args and options */ |
/* Process args and options */ |
while ((ch = getopt(argc, argv, "lykK")) != -1) |
while ((ch = getopt(argc, argv, "lyK")) != -1) |
switch (ch) { |
switch (ch) { |
case 'l': /* change local password file */ |
case 'l': /* change local password file */ |
use_kerberos = 0; |
use_kerberos = 0; |
use_yp = 0; |
use_yp = 0; |
break; |
break; |
case 'k': /* change Kerberos password */ |
|
#if defined(KERBEROS) |
|
use_kerberos = 1; |
|
use_yp = 0; |
|
exit(krb_passwd(argc, argv)); |
|
break; |
|
#else |
|
fprintf(stderr, "passwd: Kerberos not compiled in\n"); |
|
exit(1); |
|
#endif |
|
case 'K': |
case 'K': |
#ifdef KRB5 |
#ifdef KRB5 |
/* Skip programname and '-K' option */ |
/* Skip programname and '-K' option */ |
|
|
case 0: |
case 0: |
break; |
break; |
case 1: |
case 1: |
#if defined(KERBEROS) || defined(KERBEROS5) |
#if defined(KERBEROS5) |
if (use_kerberos && strcmp(argv[0], username)) { |
if (use_kerberos && strcmp(argv[0], username)) { |
(void)fprintf(stderr, "passwd: %s\n\t%s\n%s\n", |
(void)fprintf(stderr, "passwd: %s\n\t%s\n%s\n", |
"to change another user's Kerberos password, do", |
"to change another user's Kerberos password, do", |
"\"passwd -k -u <user>\";", |
"\"passwd -K -u <user>\";", |
"to change a user's local passwd, use \"passwd -l <user>\""); |
"to change a user's local passwd, use \"passwd -l <user>\""); |
exit(1); |
exit(1); |
} |
} |
|
|
default: |
default: |
usage(1); |
usage(1); |
} |
} |
|
|
#if defined(KERBEROS) || defined(KERBEROS5) |
|
if (use_kerberos) |
|
exit(krb_passwd(argc, argv)); |
|
#endif |
|
|
|
#ifdef YP |
#ifdef YP |
if (force_yp || ((status = local_passwd(username, 0)) && use_yp)) |
if (force_yp || ((status = local_passwd(username, 0)) && use_yp)) |