[BACK]Return to passwd.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / passwd

Diff for /src/usr.bin/passwd/passwd.c between version 1.25 and 1.26

version 1.25, 2009/10/27 23:59:41 version 1.26, 2014/05/19 15:05:13
Line 36 
Line 36 
 #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
Line 69 
Line 65 
 #ifdef  YP  #ifdef  YP
         int status = 0;          int status = 0;
 #endif  #endif
 #if defined(KRB5)  
         char *ccfile;  
         struct stat sb;  
   
         if (!(ccfile = getenv("KRB5CCNAME")))  
                 if (asprintf(&ccfile, "/tmp/krb5cc_%u", (unsigned)getuid()) ==  
                     -1)  
                         errx(1, "out of memory");  
   
         if ((stat(ccfile, &sb) == 0) && (sb.st_uid == getuid()))  
                 use_kerberos = 1;  
 #endif  
 #ifdef  YP  #ifdef  YP
         use_yp = _yp_check(NULL);          use_yp = _yp_check(NULL);
         if (use_yp) {          if (use_yp) {
Line 92 
Line 76 
 #endif  #endif
   
         /* Process args and options */          /* Process args and options */
         while ((ch = getopt(argc, argv, "lyK")) != -1)          while ((ch = getopt(argc, argv, "ly")) != -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':  
 #if defined(KRB5)  
                         /* Skip programname and '-K' option */  
                         argc -= 2;  
                         argv += 2;  
                         exit(krb5_passwd(argc, argv));  
 #else  
                         errx(1, "KerberosV support not enabled");  
                         break;  
 #endif  
                 case 'y':               /* change YP password */                  case 'y':               /* change YP password */
 #ifdef  YP  #ifdef  YP
                         if (!use_yp) {                          if (!use_yp) {
Line 145 
Line 119 
                 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));
Line 161 
Line 131 
 void  void
 usage(int retval)  usage(int retval)
 {  {
         fprintf(stderr, "usage: passwd [-K | -l | -y] [user]\n");          fprintf(stderr, "usage: passwd [-l | -y] [user]\n");
         exit(retval);          exit(retval);
 }  }

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26