verify.c revision 178826
1249259Sdim/* 2249259Sdim * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H�gskolan 3249259Sdim * (Royal Institute of Technology, Stockholm, Sweden). 4249259Sdim * All rights reserved. 5249259Sdim * 6249259Sdim * Redistribution and use in source and binary forms, with or without 7249259Sdim * modification, are permitted provided that the following conditions 8249259Sdim * are met: 9249259Sdim * 10249259Sdim * 1. Redistributions of source code must retain the above copyright 11249259Sdim * notice, this list of conditions and the following disclaimer. 12249259Sdim * 13249259Sdim * 2. Redistributions in binary form must reproduce the above copyright 14249259Sdim * notice, this list of conditions and the following disclaimer in the 15249259Sdim * documentation and/or other materials provided with the distribution. 16249259Sdim * 17249259Sdim * 3. Neither the name of the Institute nor the names of its contributors 18249259Sdim * may be used to endorse or promote products derived from this software 19249259Sdim * without specific prior written permission. 20249259Sdim * 21249259Sdim * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22249259Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23249259Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24249259Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25249259Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26249259Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27249259Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28249259Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29249259Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30249259Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31249259Sdim * SUCH DAMAGE. 32249259Sdim */ 33249259Sdim 34249259Sdim#ifdef HAVE_CONFIG_H 35249259Sdim#include <config.h> 36249259SdimRCSID("$Id: verify.c 14773 2005-04-12 11:29:18Z lha $"); 37249259Sdim#endif 38249259Sdim 39249259Sdim#include <stdio.h> 40249259Sdim#ifdef HAVE_UNISTD_H 41249259Sdim#include <unistd.h> 42249259Sdim#endif 43249259Sdim#ifdef HAVE_CRYPT_H 44249259Sdim#include <crypt.h> 45249259Sdim#endif 46249259Sdim#include "roken.h" 47249259Sdim 48249259Sdimint ROKEN_LIB_FUNCTION 49249259Sdimunix_verify_user(char *user, char *password) 50249259Sdim{ 51249259Sdim struct passwd *pw; 52249259Sdim 53249259Sdim pw = k_getpwnam(user); 54249259Sdim if(pw == NULL) 55249259Sdim return -1; 56249259Sdim if(strlen(pw->pw_passwd) == 0 && strlen(password) == 0) 57249259Sdim return 0; 58249259Sdim if(strcmp(crypt(password, pw->pw_passwd), pw->pw_passwd) == 0) 59249259Sdim return 0; 60249259Sdim return -1; 61249259Sdim} 62249259Sdim 63249259Sdim