x
[heimdal.git] / appl / login / osfc2.c
blobaacb7ea978294bf907e053c729f9ce8bc9ad68a4
1 /*
2 * Copyright (c) 1998 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by Kungliga Tekniska
20 * Högskolan and its contributors.
22 * 4. Neither the name of the Institute nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
39 #include "bsd_locl.h"
40 RCSID("$Id$");
42 int
43 do_osfc2_magic(uid_t uid)
45 #ifdef HAVE_OSFC2
46 struct es_passwd *epw;
47 char *argv[2];
49 /* fake */
50 argv[0] = (char*)__progname;
51 argv[1] = NULL;
52 set_auth_parameters(1, argv);
54 epw = getespwuid(uid);
55 if(epw == NULL) {
56 syslog(LOG_AUTHPRIV|LOG_NOTICE,
57 "getespwuid failed for %d", uid);
58 printf("Sorry.\n");
59 return 1;
61 /* We don't check for auto-retired, foo-retired,
62 bar-retired, or any other kind of retired accounts
63 here; neither do we check for time-locked accounts, or
64 any other kind of serious C2 mumbo-jumbo. We do,
65 however, call setluid, since failing to do so is not
66 very good (take my word for it). */
68 if(!epw->uflg->fg_uid) {
69 syslog(LOG_AUTHPRIV|LOG_NOTICE,
70 "attempted login by %s (has no uid)", epw->ufld->fd_name);
71 printf("Sorry.\n");
72 return 1;
74 setluid(epw->ufld->fd_uid);
75 if(getluid() != epw->ufld->fd_uid) {
76 syslog(LOG_AUTHPRIV|LOG_NOTICE,
77 "failed to set LUID for %s (%d)",
78 epw->ufld->fd_name, epw->ufld->fd_uid);
79 printf("Sorry.\n");
80 return 1;
82 #endif /* HAVE_OSFC2 */
83 return 0;