2 Unix SMB/CIFS implementation.
4 Winbind daemon for ntdom nss module
6 Copyright (C) Tim Potter 2000
7 Copyright (C) Anthony Liguori 2003
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public
20 License along with this library; if not, write to the
21 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.
31 #include "winbindd_nss.h"
34 #define DBGC_CLASS DBGC_WINBIND
36 /* Client state structure */
38 struct winbindd_cli_state
{
39 struct winbindd_cli_state
*prev
, *next
; /* Linked list pointers */
40 int sock
; /* Open socket from client */
41 pid_t pid
; /* pid of client */
42 int read_buf_len
, write_buf_len
; /* Indexes in request/response */
43 BOOL finished
; /* Can delete from list */
44 BOOL write_extra_data
; /* Write extra_data field */
45 time_t last_access
; /* Time of last access (read or write) */
46 struct winbindd_request request
; /* Request from client */
47 struct winbindd_response response
; /* Respose to client */
48 struct getent_state
*getpwent_state
; /* State for getpwent() */
49 struct getent_state
*getgrent_state
; /* State for getgrent() */
52 /* State between get{pw,gr}ent() calls */
55 struct getent_state
*prev
, *next
;
57 uint32 sam_entry_index
, num_sam_entries
;
62 /* Storage for cached getpwent() user entries */
64 struct getpwent_user
{
65 fstring name
; /* Account name */
66 fstring gecos
; /* User information */
67 DOM_SID user_sid
; /* NT user and primary group SIDs */
71 /* Server state structure */
73 struct winbindd_state
{
75 /* User and group id pool */
77 uid_t uid_low
, uid_high
; /* Range of uids to allocate */
78 gid_t gid_low
, gid_high
; /* Range of gids to allocate */
81 extern struct winbindd_state server_state
; /* Server information */
86 DOM_SID
*user_sid
; /* NT user and primary group SIDs */
90 /* Structures to hold per domain information */
92 struct winbindd_domain
{
93 fstring name
; /* Domain name */
94 fstring alt_name
; /* alt Domain name (if any) */
95 DOM_SID sid
; /* SID for this domain */
96 BOOL native_mode
; /* is this a win2k domain in native mode ? */
98 /* Lookup methods for this domain (LDAP or RPC) */
100 struct winbindd_methods
*methods
;
102 /* Private data for the backends (used for connection cache) */
106 /* Sequence number stuff */
108 time_t last_seq_check
;
109 uint32 sequence_number
;
111 /* Linked list info */
113 struct winbindd_domain
*prev
, *next
;
116 /* per-domain methods. This is how LDAP vs RPC is selected
118 struct winbindd_methods
{
119 /* does this backend provide a consistent view of the data? (ie. is the primary group
123 /* get a list of users, returning a WINBIND_USERINFO for each one */
124 NTSTATUS (*query_user_list
)(struct winbindd_domain
*domain
,
127 WINBIND_USERINFO
**info
);
129 /* get a list of domain groups */
130 NTSTATUS (*enum_dom_groups
)(struct winbindd_domain
*domain
,
133 struct acct_info
**info
);
135 /* get a list of domain local groups */
136 NTSTATUS (*enum_local_groups
)(struct winbindd_domain
*domain
,
139 struct acct_info
**info
);
141 /* convert one user or group name to a sid */
142 NTSTATUS (*name_to_sid
)(struct winbindd_domain
*domain
,
146 enum SID_NAME_USE
*type
);
148 /* convert a sid to a user or group name */
149 NTSTATUS (*sid_to_name
)(struct winbindd_domain
*domain
,
153 enum SID_NAME_USE
*type
);
155 /* lookup user info for a given SID */
156 NTSTATUS (*query_user
)(struct winbindd_domain
*domain
,
159 WINBIND_USERINFO
*user_info
);
161 /* lookup all groups that a user is a member of. The backend
162 can also choose to lookup by username or rid for this
164 NTSTATUS (*lookup_usergroups
)(struct winbindd_domain
*domain
,
167 uint32
*num_groups
, DOM_SID
***user_gids
);
169 /* find all members of the group with the specified group_rid */
170 NTSTATUS (*lookup_groupmem
)(struct winbindd_domain
*domain
,
174 DOM_SID
***sid_mem
, char ***names
,
175 uint32
**name_types
);
177 /* return the current global sequence number */
178 NTSTATUS (*sequence_number
)(struct winbindd_domain
*domain
, uint32
*seq
);
180 /* enumerate trusted domains */
181 NTSTATUS (*trusted_domains
)(struct winbindd_domain
*domain
,
188 /* find the domain sid */
189 NTSTATUS (*domain_sid
)(struct winbindd_domain
*domain
,
192 /* setup the list of alternate names for the domain, if any */
193 NTSTATUS (*alternate_name
)(struct winbindd_domain
*domain
);
196 /* Used to glue a policy handle and cli_state together */
199 struct cli_state
*cli
;
203 /* Filled out by IDMAP backends */
204 struct idmap_methods
{
205 /* Called when backend is first loaded */
208 BOOL (*get_sid_from_uid
)(uid_t uid
, DOM_SID
*sid
);
209 BOOL (*get_sid_from_gid
)(gid_t gid
, DOM_SID
*sid
);
211 BOOL (*get_uid_from_sid
)(DOM_SID
*sid
, uid_t
*uid
);
212 BOOL (*get_gid_from_sid
)(DOM_SID
*sid
, gid_t
*gid
);
214 /* Called when backend is unloaded */
216 /* Called to dump backend status */
217 void (*status
)(void);
220 #include "winbindd_proto.h"
222 #include "rpc_parse.h"
223 #include "rpc_client.h"
225 #define WINBINDD_ESTABLISH_LOOP 30
226 #define WINBINDD_RESCAN_FREQ 300
228 #define DOM_SEQUENCE_NONE ((uint32)-1)
230 #endif /* _WINBINDD_H */