imapext-2007
diff src/osdep/unix/ckp_cyg.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_cyg.c Mon Sep 14 15:17:45 2009 +0900 1.3 @@ -0,0 +1,63 @@ 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: Cygwin 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 +/* This module is against my better judgement. If you want to run an imapd 1.33 + * or ipop[23]d you should use the native NT or W2K ports intead of this 1.34 + * Cygwin port. There is no surety that this module works right or will work 1.35 + * right in the future. 1.36 + */ 1.37 + 1.38 +#undef ERROR 1.39 +#include <windows.h> 1.40 +#include <sys/cygwin.h> 1.41 + 1.42 + 1.43 +/* Check password 1.44 + * Accepts: login passwd struct 1.45 + * password string 1.46 + * argument count 1.47 + * argument vector 1.48 + * Returns: passwd struct if password validated, NIL otherwise 1.49 + */ 1.50 + 1.51 +static char *cyg_user = NIL; 1.52 +static HANDLE cyg_hdl = NIL; 1.53 + 1.54 +struct passwd *checkpw (struct passwd *pw,char *pass,int argc,char *argv[]) 1.55 +{ 1.56 + /* flush last pw-checked user */ 1.57 + if (cyg_user) fs_give ((void **) &cyg_user); 1.58 + /* forbid if UID 0 or SYSTEM uid */ 1.59 + if (!pw->pw_uid || (pw->pw_uid == SYSTEMUID) || 1.60 + ((cyg_hdl = cygwin_logon_user (pw,pass)) == INVALID_HANDLE_VALUE)) 1.61 + return NIL; /* bad UID or password */ 1.62 + /* remember user for this handle */ 1.63 + cyg_user = cpystr (pw->pw_name); 1.64 + return pw; 1.65 +} 1.66 +