k_getpwuid.c revision 178825
1139804Simp/*
21541Srgrimes * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H�gskolan
31541Srgrimes * (Royal Institute of Technology, Stockholm, Sweden).
41541Srgrimes * All rights reserved.
51541Srgrimes *
61541Srgrimes * Redistribution and use in source and binary forms, with or without
71541Srgrimes * modification, are permitted provided that the following conditions
81541Srgrimes * are met:
91541Srgrimes *
101541Srgrimes * 1. Redistributions of source code must retain the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer.
121541Srgrimes *
131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer in the
151541Srgrimes *    documentation and/or other materials provided with the distribution.
161541Srgrimes *
171541Srgrimes * 3. Neither the name of the Institute nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes */
331541Srgrimes
341541Srgrimes#ifdef HAVE_CONFIG_H
351541Srgrimes#include <config.h>
361541SrgrimesRCSID("$Id: k_getpwuid.c 14773 2005-04-12 11:29:18Z lha $");
37116182Sobrien#endif /* HAVE_CONFIG_H */
38116182Sobrien
391541Srgrimes#include "roken.h"
401541Srgrimes#ifdef HAVE_SHADOW_H
412112Swollman#include <shadow.h>
422946Swollman#endif
43138350Sphk
441541Srgrimesstruct passwd * ROKEN_LIB_FUNCTION
45138350Sphkk_getpwuid (uid_t uid)
46159590Sjhb{
4738869Sbde     struct passwd *p;
481541Srgrimes
491541Srgrimes     p = getpwuid (uid);
501541Srgrimes#if defined(HAVE_GETSPNAM) && defined(HAVE_STRUCT_SPWD)
51141634Sphk     if (p)
52141634Sphk     {
5312577Sbde	  struct spwd *spwd;
5430354Sphk
5530354Sphk	  spwd = getspnam (p->pw_name);
5610358Sjulian	  if (spwd)
5769664Speter	       p->pw_passwd = spwd->sp_pwdp;
5829653Sdyson	  endspent ();
5969664Speter     }
6091690Seivind#else
6191690Seivind     endpwent ();
6291690Seivind#endif
6391690Seivind     return p;
6491690Seivind}
65132710Sphk