1/* 2 * $Id: local.c,v 1.1.1.1 2008/10/15 03:30:50 james26_jang Exp $ 3 * 4 * Copyright (C) 1996 Lars Fenneberg 5 * 6 * See the file COPYRIGHT for the respective terms and conditions. 7 * If the file is missing contact me at lf@elemental.net 8 * and I'll send you a copy. 9 * 10 */ 11 12#include <config.h> 13#include <includes.h> 14#include <radiusclient.h> 15#include <messages.h> 16#include <radlogin.h> 17 18extern ENV *env; 19 20LFUNC auth_local(char *username, char *passwd) 21{ 22 struct passwd *pw; 23 char *xpasswd; 24#ifdef SHADOW_PASSWORD 25 struct spwd *spw; 26#endif 27 28 if ((pw = getpwnam(username)) == NULL) { 29 endpwent(); 30 rc_log(LOG_NOTICE, "authentication FAILED, type local, username %s", username); 31 printf(SC_LOCAL_FAILED); 32 return NULL; 33 } 34 endpwent(); 35 36#ifdef SHADOW_PASSWORD 37 if((spw = getspnam(pw->pw_name)) == NULL) { 38 endspent(); 39 rc_log(LOG_NOTICE, "authentication FAILED, type local, username %s", username); 40 printf(SC_LOCAL_FAILED); 41 return NULL; 42 } 43 else 44 { 45 pw->pw_passwd = spw->sp_pwdp; 46 } 47 endspent(); 48#endif /* SHADOW_PASSWORD */ 49 50 xpasswd = crypt(passwd, pw->pw_passwd); 51 52 if (*pw->pw_passwd == '\0' || strcmp(xpasswd, pw->pw_passwd)) { 53 rc_log(LOG_NOTICE, "authentication FAILED, type local, username %s", username); 54 printf(SC_LOCAL_FAILED); 55 return NULL; 56 } 57 58 rc_log(LOG_NOTICE, "authentication OK, type local, username %s", username); 59 printf(SC_LOCAL_OK); 60 61 return local_login; 62} 63 64void 65local_login(char *username) 66{ 67 char *login_local = rc_conf_str("login_local"); 68 69 /* login should spot this... but who knows what old /bin/logins 70 * may be still around 71 */ 72 if (*username == '-') { 73 rc_log(LOG_WARNING, "username can't start with a dash"); 74 exit(ERROR_RC); 75 } 76 /* the new shadow login seems to require either a -r or a -h 77 * flag for -f to work (so source code, lmain.c) so we supply 78 * it here. shouldn't hurt on other systems, -lf, 03/13/96 79 */ 80 execle(login_local, login_local, "-h", "localhost", "-f", username, NULL, env->env); 81 rc_log(LOG_ERR, "couldn't execute %s: %s", login_local, strerror(errno)); 82 sleep(1); /* give the user time to read */ 83 exit(ERROR_RC); 84} 85