about summary refs log tree commit diff
path: root/src/nsssd/nsssd-unix.c
blob: 6cbb3f27f95b988758fcbcff399fab5512eb19c1 (plain) (blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* ISC license. */

#include <skalibs/strerr2.h>
#include <nsss/pwd-unix.h>
#include <nsss/grp-unix.h>
#include <nsss/shadow-unix.h>
#include <nsss/nsssd.h>

void *nsssd_handle_init (void)
{
  return 0 ;
}

int nsssd_handle_start (void *handle, char const *const *argv, char const *const *envp)
{
  (void)handle ;
  (void)argv ;
  (void)envp ;
  return 1 ;
}

void nsssd_handle_end (void *handle)
{
  (void)handle ;
}

int nsssd_pwd_start (void *handle)
{
  (void)handle ;
  return 1 ;
}

int nsssd_pwd_rewind (void *handle)
{
  nsss_unix_setpwent() ;
  (void)handle ;
  return 1 ;
}

int nsssd_pwd_get (void *handle, struct passwd *pw)
{
  struct passwd *pw2 = nsss_unix_getpwent() ;
  if (!pw2) return 0 ;
  *pw = *pw2 ;
  (void)handle ;
  return 1 ;
}

int nsssd_pwd_getbyuid (void *handle, struct passwd *pw, uid_t uid)
{
  struct passwd *pw2 = nsss_unix_getpwuid(uid) ;
  if (!pw2) return 0 ;
  *pw = *pw2 ;
  (void)handle ;
  return 1 ;
}

int nsssd_pwd_getbyname (void *handle, struct passwd *pw, char const *name)
{
  struct passwd *pw2 = nsss_unix_getpwnam(name) ;
  if (!pw2) return 0 ;
  *pw = *pw2 ;
  (void)handle ;
  return 1 ;
}

void nsssd_pwd_end (void *handle)
{
  nsss_unix_endpwent() ;
  (void)handle ;
}

void nsssd_grp_handle_init (void *handle)
{
  (void)handle ;
}

int nsssd_grp_start (void *handle)
{
  (void)handle ;
  return 1 ;
}

int nsssd_grp_rewind (void *handle)
{
  nsss_unix_setgrent() ;
  (void)handle ;
  return 1 ;
}

int nsssd_grp_get (void *handle, struct group *gr)
{
  struct group *gr2 = nsss_unix_getgrent() ;
  if (!gr2) return 0 ;
  *gr = *gr2 ;
  (void)handle ;
  return 1 ;
}

int nsssd_grp_getbygid (void *handle, struct group *gr, gid_t gid)
{
  struct group *gr2 = nsss_unix_getgrgid(gid) ;
  if (!gr2) return 0 ;
  *gr = *gr2 ;
  (void)handle ;
  return 1 ;
}

int nsssd_grp_getbyname (void *handle, struct group *gr, char const *name)
{
  struct group *gr2 = nsss_unix_getgrnam(name) ;
  if (!gr2) return 0 ;
  *gr = *gr2 ;
  (void)handle ;
  return 1 ;
}

int nsssd_grp_getlist (void *handle, char const *user, gid_t *gids, size_t n, size_t *r)
{
  (void)handle ;
  return nsss_unix_getgrouplist_preadjust(user, gids, n, r) ;
}

void nsssd_grp_end (void *handle)
{
  nsss_unix_endgrent() ;
  (void)handle ;
}

void nsssd_shadow_handle_init (void *handle)
{
  (void)handle ;
}

int nsssd_shadow_start (void *handle)
{
  (void)handle ;
  return 1 ;
}

int nsssd_shadow_rewind (void *handle)
{
  nsss_unix_setspent() ;
  (void)handle ;
  return 1 ;
}

int nsssd_shadow_get (void *handle, struct spwd *sp)
{
  struct spwd *sp2 = nsss_unix_getspent() ;
  if (!sp2) return 0 ;
  *sp = *sp2 ;
  (void)handle ;
  return 1 ;
}

int nsssd_shadow_getbyname (void *handle, struct spwd *sp, char const *name)
{
  struct spwd *sp2 = nsss_unix_getspnam(name) ;
  if (!sp2) return 0 ;
  *sp = *sp2 ;
  (void)handle ;
  return 1 ;
}

void nsssd_shadow_end (void *handle)
{
  nsss_unix_endspent() ;
  (void)handle ;
}

int main (int argc, char const *const *argv, char const *const *envp)
{
  PROG = "nsssd-unix" ;
  return nsssd_main(argv+1, envp) ;
}