imapext-2007
diff src/osdep/unix/ckp_afs.c @ 0:ada5e610ab86
imap-2007e
author | yuuji@gentei.org |
---|---|
date | Mon, 14 Sep 2009 15:17:45 +0900 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/osdep/unix/ckp_afs.c Mon Sep 14 15:17:45 2009 +0900 1.3 @@ -0,0 +1,71 @@ 1.4 +/* ======================================================================== 1.5 + * Copyright 1988-2006 University of Washington 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * 1.14 + * ======================================================================== 1.15 + */ 1.16 + 1.17 +/* 1.18 + * Program: AFS check password 1.19 + * 1.20 + * Author: Mark Crispin 1.21 + * Networks and Distributed Computing 1.22 + * Computing & Communications 1.23 + * University of Washington 1.24 + * Administration Building, AG-44 1.25 + * Seattle, WA 98195 1.26 + * Internet: MRC@CAC.Washington.EDU 1.27 + * 1.28 + * Date: 1 August 1988 1.29 + * Last Edited: 30 August 2006 1.30 + */ 1.31 + 1.32 +/* AFS cleanup 1.33 + * Accepts: data 1.34 + */ 1.35 + 1.36 +void checkpw_cleanup (void *data) 1.37 +{ 1.38 + ktc_ForgetAllTokens (); 1.39 +} 1.40 + 1.41 + 1.42 +/* Check password 1.43 + * Accepts: login passwd struct 1.44 + * password string 1.45 + * argument count 1.46 + * argument vector 1.47 + * Returns: passwd struct if password validated, NIL otherwise 1.48 + */ 1.49 + 1.50 +#undef INIT 1.51 +#define min AFS_MIN 1.52 +#define max AFS_MAX 1.53 +#include <afs/param.h> 1.54 +#include <afs/kautils.h> 1.55 + 1.56 +struct passwd *checkpw (struct passwd *pw,char *pass,int argc,char *argv[]) 1.57 +{ 1.58 + char *reason; 1.59 + /* faster validation for POP servers */ 1.60 + if (!strcmp ((char *) mail_parameters (NIL,GET_SERVICENAME,NIL),"pop")) { 1.61 + struct ktc_encryptionKey key; 1.62 + struct ktc_token token; 1.63 + /* just check the password */ 1.64 + ka_StringToKey (pass,NIL,&key); 1.65 + if (ka_GetAdminToken (pw->pw_name,"","",&key,600,&token,1)) return NIL; 1.66 + } 1.67 + /* check password and get AFS token */ 1.68 + else if (ka_UserAuthenticateGeneral 1.69 + (KA_USERAUTH_VERSION + KA_USERAUTH_DOSETPAG,pw->pw_name,NIL,NIL, 1.70 + pass,0,0,0,&reason)) return NIL; 1.71 + /* arm hook to delete credentials */ 1.72 + mail_parameters (NIL,SET_LOGOUTHOOK,(void *) checkpw_cleanup); 1.73 + return pw; 1.74 +}