k_getpwnam.c revision 256281
138774Snsouch/*
293023Snsouch * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska H��gskolan
338774Snsouch * (Royal Institute of Technology, Stockholm, Sweden).
438774Snsouch * All rights reserved.
538774Snsouch *
638774Snsouch * Redistribution and use in source and binary forms, with or without
738774Snsouch * modification, are permitted provided that the following conditions
838774Snsouch * are met:
938774Snsouch *
1038774Snsouch * 1. Redistributions of source code must retain the above copyright
1138774Snsouch *    notice, this list of conditions and the following disclaimer.
1238774Snsouch *
1338774Snsouch * 2. Redistributions in binary form must reproduce the above copyright
1438774Snsouch *    notice, this list of conditions and the following disclaimer in the
1538774Snsouch *    documentation and/or other materials provided with the distribution.
1638774Snsouch *
1738774Snsouch * 3. Neither the name of the Institute nor the names of its contributors
1838774Snsouch *    may be used to endorse or promote products derived from this software
1938774Snsouch *    without specific prior written permission.
2038774Snsouch *
2138774Snsouch * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
2238774Snsouch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2338774Snsouch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2438774Snsouch * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
2538774Snsouch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2638774Snsouch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27119418Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28119418Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29119418Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3038774Snsouch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3138774Snsouch * SUCH DAMAGE.
3238774Snsouch */
3338774Snsouch
3438774Snsouch#include <config.h>
3538774Snsouch
3638774Snsouch#include "roken.h"
37181304Sjhb#ifdef HAVE_SHADOW_H
38167856Simp#include <shadow.h>
3938774Snsouch#endif
40181304Sjhb
41282674SloosROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL
42274641Siank_getpwnam (const char *user)
43289656Sdumbbell{
4438774Snsouch     struct passwd *p;
4538774Snsouch
4638774Snsouch     p = getpwnam (user);
4738774Snsouch#if defined(HAVE_GETSPNAM) && defined(HAVE_STRUCT_SPWD)
4838774Snsouch     if(p)
4938774Snsouch     {
50129152Sjoerg	  struct spwd *spwd;
51129152Sjoerg
52129152Sjoerg	  spwd = getspnam (user);
5340782Snsouch	  if (spwd)
5440782Snsouch	       p->pw_passwd = spwd->sp_pwdp;
5540782Snsouch	  endspent ();
56160372Simp     }
5742442Snsouch#else
58186833Snwhitehorn     endpwent ();
59186833Snwhitehorn#endif
60187457Snwhitehorn     return p;
6140782Snsouch}
6240782Snsouch