~ubuntu-branches/debian/stretch/alpine/stretch

1 by Asheesh Laroia
Import upstream version 0.82+dfsg
1
/* ========================================================================
2
 * Copyright 1988-2006 University of Washington
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * 
11
 * ========================================================================
12
 */
13
14
/*
15
 * Program:	Cygwin check password
16
 *
17
 * Author:	Mark Crispin
18
 *		Networks and Distributed Computing
19
 *		Computing & Communications
20
 *		University of Washington
21
 *		Administration Building, AG-44
22
 *		Seattle, WA  98195
23
 *		Internet: MRC@CAC.Washington.EDU
24
 *
25
 * Date:	1 August 1988
26
 * Last Edited:	30 August 2006
27
 */
28
29
/* This module is against my better judgement.  If you want to run an imapd
30
 * or ipop[23]d you should use the native NT or W2K ports intead of this
31
 * Cygwin port.  There is no surety that this module works right or will work
32
 * right in the future.
33
 */
34

35
#undef ERROR
1.1.10 by Asheesh Laroia
Import upstream version 2.10+dfsg
36
#define NOCRYPT
1 by Asheesh Laroia
Import upstream version 0.82+dfsg
37
#include <windows.h>
38
#include <sys/cygwin.h>
39
40
41
/* Check password
42
 * Accepts: login passwd struct
43
 *	    password string
44
 *	    argument count
45
 *	    argument vector
46
 * Returns: passwd struct if password validated, NIL otherwise
47
 */
48
49
static char *cyg_user = NIL;
50
static HANDLE cyg_hdl = NIL;
51
52
struct passwd *checkpw (struct passwd *pw,char *pass,int argc,char *argv[])
53
{
54
				/* flush last pw-checked user */
55
  if (cyg_user) fs_give ((void **) &cyg_user);
56
				/* forbid if UID 0 or SYSTEM uid */
57
  if (!pw->pw_uid || (pw->pw_uid == SYSTEMUID) ||
58
      ((cyg_hdl = cygwin_logon_user (pw,pass)) == INVALID_HANDLE_VALUE))
59
    return NIL;			/* bad UID or password */
60
				/* remember user for this handle */
61
  cyg_user = cpystr (pw->pw_name);
62
  return pw;
63
}
64