File indexing completed on 2025-05-11 08:24:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifdef HAVE_CONFIG_H
0022 #include "config.h"
0023 #endif
0024
0025 #include "pwdgrp.h"
0026
0027
0028
0029
0030 static FILE *passwd_fp;
0031 static char pwbuf[200];
0032 static struct passwd pwent;
0033
0034 struct passwd *getpwnam(
0035 const char *name
0036 )
0037 {
0038 struct passwd *p;
0039
0040 if(getpwnam_r(name, &pwent, pwbuf, sizeof pwbuf, &p))
0041 return NULL;
0042 return p;
0043 }
0044
0045 struct passwd *getpwuid(
0046 uid_t uid
0047 )
0048 {
0049 struct passwd *p;
0050
0051 if(getpwuid_r(uid, &pwent, pwbuf, sizeof pwbuf, &p))
0052 return NULL;
0053 return p;
0054 }
0055
0056 struct passwd *getpwent(void)
0057 {
0058 if (passwd_fp == NULL)
0059 return NULL;
0060 if (!_libcsupport_scanpw(passwd_fp, &pwent, pwbuf, sizeof pwbuf))
0061 return NULL;
0062 return &pwent;
0063 }
0064
0065 void setpwent(void)
0066 {
0067 _libcsupport_pwdgrp_init();
0068
0069 if (passwd_fp != NULL)
0070 fclose(passwd_fp);
0071 passwd_fp = fopen("/etc/passwd", "r");
0072 }
0073
0074 void endpwent(void)
0075 {
0076 if (passwd_fp != NULL)
0077 fclose(passwd_fp);
0078 }