2 Unix SMB/CIFS implementation.
4 Winbind daemon for ntdom nss module
6 Copyright (C) Tim Potter 2000
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
13 This library 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 GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with this library; if not, write to the
20 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.
30 #include "winbindd_nss.h"
32 /* Client state structure */
34 struct winbindd_cli_state
{
35 struct winbindd_cli_state
*prev
, *next
; /* Linked list pointers */
36 int sock
; /* Open socket from client */
37 pid_t pid
; /* pid of client */
38 int read_buf_len
, write_buf_len
; /* Indexes in request/response */
39 BOOL finished
; /* Can delete from list */
40 BOOL write_extra_data
; /* Write extra_data field */
41 struct winbindd_request request
; /* Request from client */
42 struct winbindd_response response
; /* Respose to client */
43 struct getent_state
*getpwent_state
; /* State for getpwent() */
44 struct getent_state
*getgrent_state
; /* State for getgrent() */
47 /* State between get{pw,gr}ent() calls */
50 struct getent_state
*prev
, *next
;
52 uint32 sam_entry_index
, num_sam_entries
;
57 /* Storage for cached getpwent() user entries */
59 struct getpwent_user
{
60 fstring name
; /* Account name */
61 fstring gecos
; /* User information */
62 uint32 user_rid
, group_rid
; /* NT user and group rids */
65 /* Server state structure */
67 struct winbindd_state
{
69 /* User and group id pool */
71 uid_t uid_low
, uid_high
; /* Range of uids to allocate */
72 gid_t gid_low
, gid_high
; /* Range of gids to allocate */
75 extern struct winbindd_state server_state
; /* Server information */
81 uint32 group_rid
; /* primary group */
84 /* Structures to hold per domain information */
86 struct winbindd_domain
{
87 fstring name
; /* Domain name */
88 fstring full_name
; /* full Domain name (realm) */
89 DOM_SID sid
; /* SID for this domain */
91 /* Lookup methods for this domain (LDAP or RPC) */
93 struct winbindd_methods
*methods
;
95 /* Private data for the backends (used for connection cache) */
99 /* Sequence number stuff */
101 time_t last_seq_check
;
102 uint32 sequence_number
;
104 /* Linked list info */
106 struct winbindd_domain
*prev
, *next
;
109 /* per-domain methods. This is how LDAP vs RPC is selected
111 struct winbindd_methods
{
112 /* does this backend provide a consistent view of the data? (ie. is the primary group
116 /* get a list of users, returning a WINBIND_USERINFO for each one */
117 NTSTATUS (*query_user_list
)(struct winbindd_domain
*domain
,
120 WINBIND_USERINFO
**info
);
122 /* get a list of groups */
123 NTSTATUS (*enum_dom_groups
)(struct winbindd_domain
*domain
,
126 struct acct_info
**info
);
128 /* convert one user or group name to a sid */
129 NTSTATUS (*name_to_sid
)(struct winbindd_domain
*domain
,
132 enum SID_NAME_USE
*type
);
134 /* convert a sid to a user or group name */
135 NTSTATUS (*sid_to_name
)(struct winbindd_domain
*domain
,
139 enum SID_NAME_USE
*type
);
141 /* lookup user info for a given rid */
142 NTSTATUS (*query_user
)(struct winbindd_domain
*domain
,
145 WINBIND_USERINFO
*user_info
);
147 /* lookup all groups that a user is a member of. The backend
148 can also choose to lookup by username or rid for this
150 NTSTATUS (*lookup_usergroups
)(struct winbindd_domain
*domain
,
153 uint32
*num_groups
, uint32
**user_gids
);
155 /* find all members of the group with the specified group_rid */
156 NTSTATUS (*lookup_groupmem
)(struct winbindd_domain
*domain
,
158 uint32 group_rid
, uint32
*num_names
,
159 uint32
**rid_mem
, char ***names
,
160 uint32
**name_types
);
162 /* return the current global sequence number */
163 NTSTATUS (*sequence_number
)(struct winbindd_domain
*domain
, uint32
*seq
);
165 /* enumerate trusted domains */
166 NTSTATUS (*trusted_domains
)(struct winbindd_domain
*domain
,
172 /* find the domain sid */
173 NTSTATUS (*domain_sid
)(struct winbindd_domain
*domain
,
177 /* Used to glue a policy handle and cli_state together */
180 struct cli_state
*cli
;
184 #include "winbindd_proto.h"
186 #include "rpc_parse.h"
187 #include "rpc_client.h"
189 #define WINBINDD_ESTABLISH_LOOP 30
190 #define DOM_SEQUENCE_NONE ((uint32)-1)
194 #define SETENV(name, value, overwrite) setenv(name,value,overwrite)
196 #define SETENV(name, value, overwrite) \
199 slprintf(envvar, sizeof(fstring), "%s=%s", name, value); \
203 #define SETENV(name, value, overwrite) ;
206 #endif /* _WINBINDD_H */