* Do not define _BSD_SOURCE but define _DEFAULT_SOURCE instead.
[alpine.git] / imap / src / osdep / unix / ckp_os4.c
blob765bb14626093bdcce095f73ecddab0b98d63bd6
1 /* ========================================================================
2 * Copyright 1988-2006 University of Washington
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
8 * http://www.apache.org/licenses/LICENSE-2.0
11 * ========================================================================
15 * Program: OSF/1 (Digital UNIX) 4 check password
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
25 * Date: 1 August 1988
26 * Last Edited: 30 August 2006
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
37 * Because Spider Boardman, who wrote SIA, says that it's needed for buggy SIA
38 * mechanisms, that's why.
41 static int checkpw_collect (int timeout,int rendition,uchar_t *title,
42 int nprompts,prompt_t *prompts)
44 switch (rendition) {
45 case SIAONELINER: case SIAINFO: case SIAWARNING: return SIACOLSUCCESS;
47 return SIACOLABORT; /* another else is bogus */
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
59 struct passwd *checkpw (struct passwd *pw,char *pass,int argc,char *argv[])
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';
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;