1 | /*
|
---|
2 | LDB nsswitch module
|
---|
3 |
|
---|
4 | Copyright (C) Simo Sorce 2006
|
---|
5 |
|
---|
6 | This library is free software; you can redistribute it and/or
|
---|
7 | modify it under the terms of the GNU Lesser General Public
|
---|
8 | License as published by the Free Software Foundation; either
|
---|
9 | version 3 of the License, or (at your option) any later version.
|
---|
10 |
|
---|
11 | This library is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | Library General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU Lesser General Public License
|
---|
17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef _LDB_NSS
|
---|
21 | #define _LDB_NSS
|
---|
22 |
|
---|
23 | #include "includes.h"
|
---|
24 | #include "ldb/include/includes.h"
|
---|
25 |
|
---|
26 | #include <nss.h>
|
---|
27 | #include <pwd.h>
|
---|
28 | #include <grp.h>
|
---|
29 |
|
---|
30 | #define _LDB_NSS_URL "etc/users.ldb"
|
---|
31 | #define _LDB_NSS_BASEDN "CN=Users,CN=System"
|
---|
32 | #define _LDB_NSS_PWENT_FILTER "(&(objectClass=posixAccount)(!(uidNumber=0))(!(gidNumber=0)))"
|
---|
33 | #define _LDB_NSS_PWUID_FILTER "(&(objectClass=posixAccount)(uidNumber=%d)(!(gidNumber=0)))"
|
---|
34 | #define _LDB_NSS_PWNAM_FILTER "(&(objectClass=posixAccount)(uid=%s)(!(uidNumber=0))(!(gidNumber=0)))"
|
---|
35 |
|
---|
36 | #define _LDB_NSS_GRENT_FILTER "(&(objectClass=posixGroup)(!(gidNumber=0)))"
|
---|
37 | #define _LDB_NSS_GRGID_FILTER "(&(objectClass=posixGroup)(gidNumber=%d)))"
|
---|
38 | #define _LDB_NSS_GRNAM_FILTER "(&(objectClass=posixGroup)(cn=%s)(!(gidNumber=0)))"
|
---|
39 |
|
---|
40 | typedef enum nss_status NSS_STATUS;
|
---|
41 |
|
---|
42 | struct _ldb_nss_context {
|
---|
43 |
|
---|
44 | pid_t pid;
|
---|
45 |
|
---|
46 | struct ldb_context *ldb;
|
---|
47 | struct ldb_dn *base;
|
---|
48 |
|
---|
49 | int pw_cur;
|
---|
50 | struct ldb_result *pw_res;
|
---|
51 |
|
---|
52 | int gr_cur;
|
---|
53 | struct ldb_result *gr_res;
|
---|
54 | };
|
---|
55 |
|
---|
56 | NSS_STATUS _ldb_nss_init(void);
|
---|
57 |
|
---|
58 | NSS_STATUS _ldb_nss_fill_passwd(struct passwd *result,
|
---|
59 | char *buffer,
|
---|
60 | int buflen,
|
---|
61 | int *errnop,
|
---|
62 | struct ldb_message *msg);
|
---|
63 |
|
---|
64 | NSS_STATUS _ldb_nss_fill_group(struct group *result,
|
---|
65 | char *buffer,
|
---|
66 | int buflen,
|
---|
67 | int *errnop,
|
---|
68 | struct ldb_message *group,
|
---|
69 | struct ldb_result *members);
|
---|
70 |
|
---|
71 | NSS_STATUS _ldb_nss_fill_initgr(gid_t group,
|
---|
72 | long int limit,
|
---|
73 | long int *start,
|
---|
74 | long int *size,
|
---|
75 | gid_t **groups,
|
---|
76 | int *errnop,
|
---|
77 | struct ldb_result *grlist);
|
---|
78 |
|
---|
79 | NSS_STATUS _ldb_nss_group_request(struct ldb_result **res,
|
---|
80 | struct ldb_dn *group_dn,
|
---|
81 | const char * const *attrs,
|
---|
82 | const char *mattr);
|
---|
83 |
|
---|
84 | #endif /* _LDB_NSS */
|
---|