version 1.22, 2005/12/18 12:29:26 |
version 1.23, 2006/01/22 06:04:28 |
|
|
#include <err.h> |
#include <err.h> |
#include <rpcsvc/ypclnt.h> |
#include <rpcsvc/ypclnt.h> |
|
|
|
#if defined(KRB5) |
|
#include <sys/stat.h> |
|
#endif |
|
|
/* |
/* |
* Note on configuration: |
* Note on configuration: |
* Generally one would not use both Kerberos and YP |
* Generally one would not use both Kerberos and YP |
|
|
#ifdef YP |
#ifdef YP |
int status = 0; |
int status = 0; |
#endif |
#endif |
|
#if defined(KRB5) |
|
char *ccfile; |
|
struct stat sb; |
|
|
#if defined(KERBEROS5) |
if (!(ccfile = getenv("KRB5CCNAME"))) |
extern char realm[]; |
if (asprintf(&ccfile, "/tmp/krb5cc_%u", (unsigned)getuid()) == |
|
-1) |
|
errx(1, "out of memory"); |
|
|
if (krb_get_lrealm(realm,1) == KSUCCESS) |
if ((stat(ccfile, &sb) == 0) && (sb.st_uid == getuid())) |
use_kerberos = 1; |
use_kerberos = 1; |
#endif |
#endif |
#ifdef YP |
#ifdef YP |
|
|
use_yp = 0; |
use_yp = 0; |
break; |
break; |
case 'K': |
case 'K': |
#ifdef KRB5 |
#if defined(KRB5) |
/* Skip programname and '-K' option */ |
/* Skip programname and '-K' option */ |
argc -= 2; |
argc -= 2; |
argv += 2; |
argv += 2; |
|
|
usage(1); |
usage(1); |
} |
} |
|
|
|
#if defined(KRB5) |
|
if (use_kerberos) |
|
exit(krb5_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)) |
exit(yp_passwd(username)); |
exit(yp_passwd(username)); |