File: wrap_pwd.c

package info (click to toggle)
sup 20100519-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, squeeze, stretch, wheezy
  • size: 716 kB
  • ctags: 941
  • sloc: ansic: 8,334; makefile: 109
file content (36 lines) | stat: -rw-r--r-- 780 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* wrap_pwd.c: Copyright (C) TOYODA Eizi, 1997 */
/* In the public domain. */

#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <shadow.h>

#define _WRAP_PWD_NO_MACROS
#include "wrap_pwd.h"

static struct passwd  pw;

      struct passwd *
wrap_getpwnam(const char *name)
{
      struct passwd   *xpw;
      struct spwd     *shadow;
      pw = *(xpw = getpwnam(name));
      if ((shadow = getspnam(name)) != NULL) {
              pw.pw_passwd = shadow->sp_pwdp;
      }
      return &pw;
}

      struct passwd *
wrap_getpwuid(uid_t uid)
{
      struct passwd   *xpw;
      struct spwd     *shadow;
      pw = *(xpw = getpwuid(uid));
      if ((shadow = getspnam(pw.pw_name)) != NULL) {
              pw.pw_passwd = shadow->sp_pwdp;
      }
      return &pw;
}