imapext-2007

view src/osdep/unix/ckp_os4.c @ 0:ada5e610ab86

imap-2007e
author yuuji@gentei.org
date Mon, 14 Sep 2009 15:17:45 +0900
parents
children
line source
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 */
14 /*
15 * Program: OSF/1 (Digital UNIX) 4 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 */
29 /* Dummy collection routine
30 * Accepts: how long to wait for user
31 * how to run parameter collection
32 * title
33 * number of prompts
34 * prompts
35 * Returns: collection status
36 *
37 * Because Spider Boardman, who wrote SIA, says that it's needed for buggy SIA
38 * mechanisms, that's why.
39 */
41 static int checkpw_collect (int timeout,int rendition,uchar_t *title,
42 int nprompts,prompt_t *prompts)
43 {
44 switch (rendition) {
45 case SIAONELINER: case SIAINFO: case SIAWARNING: return SIACOLSUCCESS;
46 }
47 return SIACOLABORT; /* another else is bogus */
48 }
51 /* Check password
52 * Accepts: login passwd struct
53 * password string
54 * argument count
55 * argument vector
56 * Returns: passwd struct if password validated, NIL otherwise
57 */
59 struct passwd *checkpw (struct passwd *pw,char *pass,int argc,char *argv[])
60 {
61 int i;
62 char *s;
63 char *name = cpystr (pw->pw_name);
64 char *host = cpystr (tcp_clienthost ());
65 struct passwd *ret = NIL;
66 /* tie off address */
67 if (s = strchr (host,' ')) *s = '\0';
68 if (*host == '[') { /* convert [a.b.c.d] to a.b.c.d */
69 memmove (host,host+1,i = strlen (host + 2));
70 host[i] = '\0';
71 }
72 /* validate password */
73 if (sia_validate_user (checkpw_collect,argc,argv,host,name,NIL,NIL,NIL,pass)
74 == SIASUCCESS) ret = getpwnam (name);
75 fs_give ((void **) &name);
76 fs_give ((void **) &host);
77 return ret;
78 }

UW-IMAP'd extensions by yuuji