2 Unix SMB/Netbios implementation.
5 Winbind daemon for ntdom nss module
7 Copyright (C) Tim Potter 2000
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"
33 /* Client state structure */
35 struct winbindd_cli_state
{
36 struct winbindd_cli_state
*prev
, *next
; /* Linked list pointers */
37 int sock
; /* Open socket from client */
38 pid_t pid
; /* pid of client */
39 int read_buf_len
, write_buf_len
; /* Indexes in request/response */
40 BOOL finished
; /* Can delete from list */
41 BOOL write_extra_data
; /* Write extra_data field */
42 struct winbindd_request request
; /* Request from client */
43 struct winbindd_response response
; /* Respose to client */
44 struct getent_state
*getpwent_state
; /* State for getpwent() */
45 struct getent_state
*getgrent_state
; /* State for getgrent() */
48 /* State between get{pw,gr}ent() calls */
51 struct getent_state
*prev
, *next
;
53 uint32 sam_entry_index
, num_sam_entries
;
55 struct winbindd_domain
*domain
;
58 /* Storage for cached getpwent() user entries */
60 struct getpwent_user
{
61 fstring name
; /* Account name */
62 fstring gecos
; /* User information */
63 uint32 user_rid
, group_rid
; /* NT user and group rids */
66 /* Server state structure */
68 struct winbindd_state
{
70 /* User and group id pool */
72 uid_t uid_low
, uid_high
; /* Range of uids to allocate */
73 gid_t gid_low
, gid_high
; /* Range of gids to allocate */
76 extern struct winbindd_state server_state
; /* Server information */
82 uint32 group_rid
; /* primary group */
85 /* per-domain methods. This is how LDAP vs RPC is selected
87 struct winbindd_methods
{
88 /* does this backend provide a consistent view of the data? (ie. is the primary group
92 /* get a list of users, returning a WINBIND_USERINFO for each one */
93 NTSTATUS (*query_user_list
)(struct winbindd_domain
*domain
,
96 WINBIND_USERINFO
**info
);
98 /* get a list of groups */
99 NTSTATUS (*enum_dom_groups
)(struct winbindd_domain
*domain
,
102 struct acct_info
**info
);
104 /* convert one user or group name to a sid */
105 NTSTATUS (*name_to_sid
)(struct winbindd_domain
*domain
,
108 enum SID_NAME_USE
*type
);
110 /* convert a sid to a user or group name */
111 NTSTATUS (*sid_to_name
)(struct winbindd_domain
*domain
,
115 enum SID_NAME_USE
*type
);
117 /* lookup user info for a given rid */
118 NTSTATUS (*query_user
)(struct winbindd_domain
*domain
,
121 WINBIND_USERINFO
*user_info
);
123 /* lookup all groups that a user is a member of. The backend
124 can also choose to lookup by username or rid for this
126 NTSTATUS (*lookup_usergroups
)(struct winbindd_domain
*domain
,
129 uint32
*num_groups
, uint32
**user_gids
);
131 /* find all members of the group with the specified group_rid */
132 NTSTATUS (*lookup_groupmem
)(struct winbindd_domain
*domain
,
134 uint32 group_rid
, uint32
*num_names
,
135 uint32
**rid_mem
, char ***names
,
136 uint32
**name_types
);
138 /* return the current global sequence number */
139 NTSTATUS (*sequence_number
)(struct winbindd_domain
*domain
, uint32
*seq
);
141 /* enumerate trusted domains */
142 NTSTATUS (*trusted_domains
)(struct winbindd_domain
*domain
,
148 /* find the domain sid */
149 NTSTATUS (*domain_sid
)(struct winbindd_domain
*domain
,
153 /* Structures to hold per domain information */
154 struct winbindd_domain
{
155 fstring name
; /* Domain name */
156 fstring full_name
; /* full Domain name (realm) */
157 DOM_SID sid
; /* SID for this domain */
158 struct winbindd_methods
*methods
; /* lookup methods for
161 void *private; /* private data for the backends (used for connection cache) */
162 time_t last_seq_check
;
163 uint32 sequence_number
;
164 struct winbindd_domain
*prev
, *next
; /* Linked list info */
167 extern struct winbindd_domain
*domain_list
; /* List of domains we know */
169 /* Used to glue a policy handle and cli_state together */
172 struct cli_state
*cli
;
176 #include "winbindd_proto.h"
178 #include "rpc_parse.h"
179 #include "rpc_client.h"
181 #define WINBINDD_ESTABLISH_LOOP 30
182 #define DOM_SEQUENCE_NONE ((uint32)-1)
186 #define SETENV(name, value, overwrite) setenv(name,value,overwrite)
188 #define SETENV(name, value, overwrite) \
191 slprintf(envvar, sizeof(fstring), "%s=%s", name, value); \
195 #define SETENV(name, value, overwrite) ;
198 /* Authenticated user info is stored in secrets.tdb under these keys */
200 #define SECRETS_AUTH_USER "SECRETS/AUTH_USER"
201 #define SECRETS_AUTH_PASSWORD "SECRETS/AUTH_PASSWORD"
203 #endif /* _WINBINDD_H */