osfc2.c revision 178826
1246149Ssjg/* 2246149Ssjg * Copyright (c) 1998 Kungliga Tekniska H�gskolan 3246149Ssjg * (Royal Institute of Technology, Stockholm, Sweden). 4246149Ssjg * All rights reserved. 5246149Ssjg * 6246149Ssjg * Redistribution and use in source and binary forms, with or without 7246149Ssjg * modification, are permitted provided that the following conditions 8246149Ssjg * are met: 9246149Ssjg * 10246149Ssjg * 1. Redistributions of source code must retain the above copyright 11246149Ssjg * notice, this list of conditions and the following disclaimer. 12246149Ssjg * 13246149Ssjg * 2. Redistributions in binary form must reproduce the above copyright 14246149Ssjg * notice, this list of conditions and the following disclaimer in the 15246149Ssjg * documentation and/or other materials provided with the distribution. 16246149Ssjg * 17246149Ssjg * 3. Neither the name of the Institute nor the names of its contributors 18246149Ssjg * may be used to endorse or promote products derived from this software 19246149Ssjg * without specific prior written permission. 20246149Ssjg * 21246149Ssjg * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22246149Ssjg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23246149Ssjg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24246149Ssjg * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25246149Ssjg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26246149Ssjg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27246149Ssjg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28246149Ssjg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29246149Ssjg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30246149Ssjg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31246149Ssjg * SUCH DAMAGE. 32246149Ssjg */ 33246149Ssjg 34246149Ssjg#include "login_locl.h" 35246149SsjgRCSID("$Id: osfc2.c 9704 2001-02-20 01:44:56Z assar $"); 36246149Ssjg 37246149Ssjgint 38246149Ssjgdo_osfc2_magic(uid_t uid) 39246149Ssjg{ 40246149Ssjg#ifdef HAVE_OSFC2 41246149Ssjg struct es_passwd *epw; 42246149Ssjg char *argv[2]; 43246149Ssjg 44246149Ssjg /* fake */ 45246149Ssjg argv[0] = (char*)getprogname(); 46246149Ssjg argv[1] = NULL; 47246149Ssjg set_auth_parameters(1, argv); 48246149Ssjg 49246149Ssjg epw = getespwuid(uid); 50246149Ssjg if(epw == NULL) { 51246149Ssjg syslog(LOG_AUTHPRIV|LOG_NOTICE, 52246149Ssjg "getespwuid failed for %d", uid); 53246149Ssjg printf("Sorry.\n"); 54246149Ssjg return 1; 55246149Ssjg } 56246149Ssjg /* We don't check for auto-retired, foo-retired, 57246149Ssjg bar-retired, or any other kind of retired accounts 58246149Ssjg here; neither do we check for time-locked accounts, or 59246149Ssjg any other kind of serious C2 mumbo-jumbo. We do, 60246149Ssjg however, call setluid, since failing to do so is not 61246149Ssjg very good (take my word for it). */ 62246149Ssjg 63246149Ssjg if(!epw->uflg->fg_uid) { 64246149Ssjg syslog(LOG_AUTHPRIV|LOG_NOTICE, 65246149Ssjg "attempted login by %s (has no uid)", epw->ufld->fd_name); 66246149Ssjg printf("Sorry.\n"); 67 return 1; 68 } 69 setluid(epw->ufld->fd_uid); 70 if(getluid() != epw->ufld->fd_uid) { 71 syslog(LOG_AUTHPRIV|LOG_NOTICE, 72 "failed to set LUID for %s (%d)", 73 epw->ufld->fd_name, epw->ufld->fd_uid); 74 printf("Sorry.\n"); 75 return 1; 76 } 77#endif /* HAVE_OSFC2 */ 78 return 0; 79} 80