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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
/*
SSSD
System Database Header
Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SYS_DB_H__
#define __SYS_DB_H__
#include "ldb.h"
#include "ldb_errors.h"
#define SYSDB_CONF_SECTION "config/sysdb"
#define SYSDB_FILE "sssd.ldb"
#define SYSDB_BASE "cn=sysdb"
#define SYSDB_DOM_BASE "cn=%s,cn=sysdb"
#define SYSDB_TMPL_USER_BASE "cn=users,cn=%s,"SYSDB_BASE
#define SYSDB_TMPL_GROUP_BASE "cn=groups,cn=%s,"SYSDB_BASE
#define SYSDB_PWNAM_FILTER "(&(objectclass=user)(uid=%s))"
#define SYSDB_PWUID_FILTER "(&(objectclass=user)(uidNumber=%lu))"
#define SYSDB_PWENT_FILTER "(objectclass=user)"
#define SYSDB_GRNAM_FILTER "(&(objectclass=group)(gid=%s))"
#define SYSDB_GRNA2_FILTER "(&(objectclass=user)(memberof=%s))"
#define SYSDB_GRGID_FILTER "(&(objectclass=group)(gidNumber=%lu))"
#define SYSDB_GRENT_FILTER "(objectclass=group)"
#define SYSDB_INITGR_FILTER "(&(objectclass=group)(gidNumber=*))"
#define SYSDB_INITGR_LEGACY_FILTER "(&(objectclass=group)(memberUid=%s))"
#define SYSDB_PW_NAME "uid"
#define SYSDB_PW_PWD "userPassword"
#define SYSDB_PW_UIDNUM "uidNumber"
#define SYSDB_PW_GIDNUM "gidNumber"
#define SYSDB_PW_FULLNAME "fullName"
#define SYSDB_PW_HOMEDIR "homeDirectory"
#define SYSDB_PW_SHELL "loginShell"
#define SYSDB_PW_MEMBEROF "memberOf"
#define SYSDB_GR_NAME "gid"
#define SYSDB_GR_GIDNUM "gidNumber"
#define SYSDB_GR_MEMBER "member"
#define SYSDB_LEGACY_MEMBER "memberUid"
#define SYSDB_LAST_UPDATE "lastUpdate"
#define SYSDB_PW_ATTRS {SYSDB_PW_NAME, SYSDB_PW_UIDNUM, \
SYSDB_PW_GIDNUM, SYSDB_PW_FULLNAME, \
SYSDB_PW_HOMEDIR, SYSDB_PW_SHELL, \
SYSDB_LAST_UPDATE, \
NULL}
#define SYSDB_GRNAM_ATTRS {SYSDB_GR_NAME, SYSDB_GR_GIDNUM, \
SYSDB_LAST_UPDATE, SYSDB_LEGACY_MEMBER, \
NULL}
#define SYSDB_GRPW_ATTRS {SYSDB_PW_NAME, SYSDB_LAST_UPDATE, \
NULL}
#define SYSDB_INITGR_ATTR "memberof"
#define SYSDB_INITGR_ATTRS {SYSDB_GR_GIDNUM, SYSDB_LAST_UPDATE, \
NULL}
struct sysdb_ctx {
struct ldb_context *ldb;
char *ldb_file;
};
struct confdb_ctx;
typedef void (*sysdb_callback_t)(void *, int, struct ldb_result *);
int sysdb_init(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct confdb_ctx *cdb,
const char *alt_db_path,
struct sysdb_ctx **dbctx);
int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct sysdb_ctx *ctx,
const char *domain,
const char *name,
bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct sysdb_ctx *ctx,
const char *domain,
uid_t uid,
bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_enumpwent(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct sysdb_ctx *ctx,
const char *domain,
bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct sysdb_ctx *ctx,
const char *domain,
const char *name,
bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct sysdb_ctx *ctx,
const char *domain,
gid_t gid,
bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct sysdb_ctx *ctx,
const char *domain,
bool legacy,
sysdb_callback_t fn, void *ptr);
int sysdb_initgroups(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct sysdb_ctx *ctx,
const char *domain,
const char *name,
bool legacy,
sysdb_callback_t fn, void *ptr);
/* the following are all SYNCHRONOUS calls
* TODO: make these asynchronous */
int sysdb_add_group_member(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
struct ldb_dn *member_dn,
struct ldb_dn *group_dn);
int sysdb_remove_group_member(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
struct ldb_dn *member_dn,
struct ldb_dn *group_dn);
int sysdb_delete_user(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
const char *domain, const char *name);
int sysdb_delete_user_by_uid(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
const char *domain, uid_t uid);
int sysdb_add_user_to_group(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
const char *domain,
const char *group,
const char *username);
int sysdb_remove_user_from_group(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
const char *domain,
const char *group,
const char *username);
int sysdb_delete_group(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
const char *domain, const char *name);
int sysdb_delete_group_by_gid(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
const char *domain, gid_t gid);
/* legacy synchronous functions for proxy providers */
int sysdb_legacy_store_user(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
const char *domain,
const char *name, const char *pwd,
uid_t uid, gid_t gid, const char *gecos,
const char *homedir, const char *shell);
int sysdb_legacy_store_group(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
const char *domain,
const char *name, gid_t gid,
char **members);
#endif /* __SYS_DB_H__ */
|