1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | uid/user handling
|
---|
4 | Copyright (C) Andrew Tridgell 1992-1998
|
---|
5 | Copyright (C) Gerald (Jerry) Carter 2003
|
---|
6 | Copyright (C) Volker Lendecke 2005
|
---|
7 |
|
---|
8 | This program is free software; you can redistribute it and/or modify
|
---|
9 | it under the terms of the GNU General Public License as published by
|
---|
10 | the Free Software Foundation; either version 3 of the License, or
|
---|
11 | (at your option) any later version.
|
---|
12 |
|
---|
13 | This program is distributed in the hope that it will be useful,
|
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | GNU General Public License for more details.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU General Public License
|
---|
19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | #ifndef _PASSDB_LOOKUP_SID_H_
|
---|
24 | #define _PASSDB_LOOKUP_SID_H_
|
---|
25 |
|
---|
26 | #include "../librpc/gen_ndr/lsa.h"
|
---|
27 | #include "nsswitch/libwbclient/wbclient.h"
|
---|
28 |
|
---|
29 | #define LOOKUP_NAME_NONE 0x00000000
|
---|
30 | #define LOOKUP_NAME_ISOLATED 0x00000001 /* Look up unqualified names */
|
---|
31 | #define LOOKUP_NAME_REMOTE 0x00000002 /* Ask others */
|
---|
32 | #define LOOKUP_NAME_GROUP 0x00000004 /* (unused) This is a NASTY hack for
|
---|
33 | valid users = @foo where foo also
|
---|
34 | exists in as user. */
|
---|
35 | #define LOOKUP_NAME_NO_NSS 0x00000008 /* no NSS calls to avoid
|
---|
36 | winbind recursions */
|
---|
37 | #define LOOKUP_NAME_BUILTIN 0x00000010 /* builtin names */
|
---|
38 | #define LOOKUP_NAME_WKN 0x00000020 /* well known names */
|
---|
39 | #define LOOKUP_NAME_DOMAIN 0x00000040 /* only lookup own domain */
|
---|
40 | #define LOOKUP_NAME_LOCAL (LOOKUP_NAME_ISOLATED\
|
---|
41 | |LOOKUP_NAME_BUILTIN\
|
---|
42 | |LOOKUP_NAME_WKN\
|
---|
43 | |LOOKUP_NAME_DOMAIN)
|
---|
44 | #define LOOKUP_NAME_ALL (LOOKUP_NAME_ISOLATED\
|
---|
45 | |LOOKUP_NAME_REMOTE\
|
---|
46 | |LOOKUP_NAME_BUILTIN\
|
---|
47 | |LOOKUP_NAME_WKN\
|
---|
48 | |LOOKUP_NAME_DOMAIN)
|
---|
49 |
|
---|
50 | struct lsa_dom_info {
|
---|
51 | bool valid;
|
---|
52 | struct dom_sid sid;
|
---|
53 | const char *name;
|
---|
54 | int num_idxs;
|
---|
55 | int *idxs;
|
---|
56 | };
|
---|
57 |
|
---|
58 | struct lsa_name_info {
|
---|
59 | uint32 rid;
|
---|
60 | enum lsa_SidType type;
|
---|
61 | const char *name;
|
---|
62 | int dom_idx;
|
---|
63 | };
|
---|
64 |
|
---|
65 | /* The following definitions come from passdb/lookup_sid.c */
|
---|
66 |
|
---|
67 | bool lookup_name(TALLOC_CTX *mem_ctx,
|
---|
68 | const char *full_name, int flags,
|
---|
69 | const char **ret_domain, const char **ret_name,
|
---|
70 | struct dom_sid *ret_sid, enum lsa_SidType *ret_type);
|
---|
71 | bool lookup_name_smbconf(TALLOC_CTX *mem_ctx,
|
---|
72 | const char *full_name, int flags,
|
---|
73 | const char **ret_domain, const char **ret_name,
|
---|
74 | struct dom_sid *ret_sid, enum lsa_SidType *ret_type);
|
---|
75 | NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
|
---|
76 | const struct dom_sid **sids, int level,
|
---|
77 | struct lsa_dom_info **ret_domains,
|
---|
78 | struct lsa_name_info **ret_names);
|
---|
79 | bool lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
|
---|
80 | const char **ret_domain, const char **ret_name,
|
---|
81 | enum lsa_SidType *ret_type);
|
---|
82 | void store_uid_sid_cache(const struct dom_sid *psid, uid_t uid);
|
---|
83 | void store_gid_sid_cache(const struct dom_sid *psid, gid_t gid);
|
---|
84 | void uid_to_sid(struct dom_sid *psid, uid_t uid);
|
---|
85 | void gid_to_sid(struct dom_sid *psid, gid_t gid);
|
---|
86 | bool sids_to_unix_ids(const struct dom_sid *sids, uint32_t num_sids,
|
---|
87 | struct wbcUnixId *ids);
|
---|
88 | bool sid_to_uid(const struct dom_sid *psid, uid_t *puid);
|
---|
89 | bool sid_to_gid(const struct dom_sid *psid, gid_t *pgid);
|
---|
90 | NTSTATUS get_primary_group_sid(TALLOC_CTX *mem_ctx,
|
---|
91 | const char *username,
|
---|
92 | struct passwd **_pwd,
|
---|
93 | struct dom_sid **_group_sid);
|
---|
94 | bool delete_uid_cache(uid_t uid);
|
---|
95 | bool delete_gid_cache(gid_t gid);
|
---|
96 | bool delete_sid_cache(const struct dom_sid* psid);
|
---|
97 | void flush_uid_cache(void);
|
---|
98 | void flush_gid_cache(void);
|
---|
99 |
|
---|
100 | #endif /* _PASSDB_LOOKUP_SID_H_ */
|
---|