sra.c (76339) | sra.c (76610) |
---|---|
1/* $FreeBSD: head/contrib/telnet/libtelnet/sra.c 76339 2001-05-07 20:42:02Z nsayer $ */ | 1/* $FreeBSD: head/contrib/telnet/libtelnet/sra.c 76610 2001-05-15 04:47:14Z nsayer $ */ |
2 3#ifdef SRA 4#include <sys/types.h> 5#include <arpa/telnet.h> 6#include <stdio.h> 7#ifdef __STDC__ 8#include <stdlib.h> 9#endif 10#ifdef NO_STRING_H 11#include <strings.h> 12#else 13#include <string.h> 14#endif 15 16#if !defined(NOPAM) 17#include <security/pam_appl.h> 18#endif 19 | 2 3#ifdef SRA 4#include <sys/types.h> 5#include <arpa/telnet.h> 6#include <stdio.h> 7#ifdef __STDC__ 8#include <stdlib.h> 9#endif 10#ifdef NO_STRING_H 11#include <strings.h> 12#else 13#include <string.h> 14#endif 15 16#if !defined(NOPAM) 17#include <security/pam_appl.h> 18#endif 19 |
20#include <ttyent.h> 21 |
|
20#include "auth.h" 21#include "misc.h" 22#include "encrypt.h" 23#include "pk.h" 24 25char pka[HEXKEYBYTES+1], ska[HEXKEYBYTES+1], pkb[HEXKEYBYTES+1]; 26char *user,*pass,*xuser,*xpass; 27DesData ck; 28IdeaData ik; 29 30extern int auth_debug_mode; | 22#include "auth.h" 23#include "misc.h" 24#include "encrypt.h" 25#include "pk.h" 26 27char pka[HEXKEYBYTES+1], ska[HEXKEYBYTES+1], pkb[HEXKEYBYTES+1]; 28char *user,*pass,*xuser,*xpass; 29DesData ck; 30IdeaData ik; 31 32extern int auth_debug_mode; |
33extern char *line; 34 |
|
31static sra_valid = 0; 32static passwd_sent = 0; 33 34static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, 35 AUTHTYPE_SRA, }; 36 37#define SRA_KEY 0 38#define SRA_USER 1 --- 407 unchanged lines hidden (view full) --- 446 sp = getspnam(name); 447 free(save.pw_passwd); 448 save.pw_passwd = sgetsave(sp->sp_pwdp); 449 } 450#endif 451 return (&save); 452} 453 | 35static sra_valid = 0; 36static passwd_sent = 0; 37 38static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, 39 AUTHTYPE_SRA, }; 40 41#define SRA_KEY 0 42#define SRA_USER 1 --- 407 unchanged lines hidden (view full) --- 450 sp = getspnam(name); 451 free(save.pw_passwd); 452 save.pw_passwd = sgetsave(sp->sp_pwdp); 453 } 454#endif 455 return (&save); 456} 457 |
458static int 459isroot(user) 460char *user; 461{ 462 struct passwd *pw; 463 464 if ((pw=getpwnam(user))==NULL) 465 return 0; 466 return (!pw->pw_uid); 467} 468 469static int 470rootterm(ttyn) 471char *ttyn; 472{ 473 struct ttyent *t; 474 475 return ((t = getttynam(ttyn)) && t->ty_status & TTY_SECURE); 476} 477 |
|
454#ifdef NOPAM 455char *crypt(); 456 457int check_user(name, pass) 458char *name; 459char *pass; 460{ 461 register char *cp; 462 char *xpasswd, *salt; 463 | 478#ifdef NOPAM 479char *crypt(); 480 481int check_user(name, pass) 482char *name; 483char *pass; 484{ 485 register char *cp; 486 char *xpasswd, *salt; 487 |
488 if (isroot(name) && !rootterm(line)) 489 { 490 crypt("AA","*"); /* Waste some time to simulate success */ 491 return(0); 492 } 493 |
|
464 if (pw = sgetpwnam(name)) { 465 if (pw->pw_shell == NULL) { 466 pw = (struct passwd *) NULL; 467 return(0); 468 } 469 470 salt = pw->pw_passwd; 471 xpasswd = crypt(pass, salt); --- 108 unchanged lines hidden (view full) --- 580 * back as a changed value of the PAM_USER item. 581 */ 582 if ((e = pam_get_item(pamh, PAM_USER, &item)) == 583 PAM_SUCCESS) { 584 strcpy(user, (const char *) item); 585 } else 586 syslog(LOG_ERR, "Couldn't get PAM_USER: %s", 587 pam_strerror(pamh, e)); | 494 if (pw = sgetpwnam(name)) { 495 if (pw->pw_shell == NULL) { 496 pw = (struct passwd *) NULL; 497 return(0); 498 } 499 500 salt = pw->pw_passwd; 501 xpasswd = crypt(pass, salt); --- 108 unchanged lines hidden (view full) --- 610 * back as a changed value of the PAM_USER item. 611 */ 612 if ((e = pam_get_item(pamh, PAM_USER, &item)) == 613 PAM_SUCCESS) { 614 strcpy(user, (const char *) item); 615 } else 616 syslog(LOG_ERR, "Couldn't get PAM_USER: %s", 617 pam_strerror(pamh, e)); |
588 rval = 1; | 618 if (isroot(user) && !rootterm(line)) 619 rval = 0; 620 else 621 rval = 1; |
589 break; 590 591 case PAM_AUTH_ERR: 592 case PAM_USER_UNKNOWN: 593 case PAM_MAXTRIES: 594 rval = 0; 595 break; 596 --- 17 unchanged lines hidden --- | 622 break; 623 624 case PAM_AUTH_ERR: 625 case PAM_USER_UNKNOWN: 626 case PAM_MAXTRIES: 627 rval = 0; 628 break; 629 --- 17 unchanged lines hidden --- |