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"
33 #define DBGC_CLASS DBGC_WINBIND
35 /* Client state structure */
37 struct winbindd_cli_state {
38 struct winbindd_cli_state *prev, *next; /* Linked list pointers */
39 int sock; /* Open socket from client */
40 pid_t pid; /* pid of client */
41 int read_buf_len, write_buf_len; /* Indexes in request/response */
42 BOOL finished; /* Can delete from list */
43 BOOL write_extra_data; /* Write extra_data field */
44 struct winbindd_request request; /* Request from client */
45 struct winbindd_response response; /* Respose to client */
46 struct getent_state *getpwent_state; /* State for getpwent() */
47 struct getent_state *getgrent_state; /* State for getgrent() */
50 /* State between get{pw,gr}ent() calls */
53 struct getent_state *prev, *next;
55 uint32 sam_entry_index, num_sam_entries;
60 /* Storage for cached getpwent() user entries */
62 struct getpwent_user {
63 fstring name; /* Account name */
64 fstring gecos; /* User information */
65 uint32 user_rid, group_rid; /* NT user and group rids */
68 /* Server state structure */
70 struct winbindd_state {
72 /* User and group id pool */
74 uid_t uid_low, uid_high; /* Range of uids to allocate */
75 gid_t gid_low, gid_high; /* Range of gids to allocate */
78 extern struct winbindd_state server_state; /* Server information */
84 uint32 group_rid; /* primary group */
87 /* Structures to hold per domain information */
89 struct winbindd_domain {
90 fstring name; /* Domain name */
91 fstring alt_name; /* alt Domain name (if any) */
92 DOM_SID sid; /* SID for this domain */
94 /* Lookup methods for this domain (LDAP or RPC) */
96 struct winbindd_methods *methods;
98 /* Private data for the backends (used for connection cache) */
102 /* Sequence number stuff */
104 time_t last_seq_check;
105 uint32 sequence_number;
107 /* Linked list info */
109 struct winbindd_domain *prev, *next;
112 /* per-domain methods. This is how LDAP vs RPC is selected
114 struct winbindd_methods {
115 /* does this backend provide a consistent view of the data? (ie. is the primary group
119 /* get a list of users, returning a WINBIND_USERINFO for each one */
120 NTSTATUS (*query_user_list)(struct winbindd_domain *domain,
123 WINBIND_USERINFO **info);
125 /* get a list of groups */
126 NTSTATUS (*enum_dom_groups)(struct winbindd_domain *domain,
129 struct acct_info **info);
131 /* convert one user or group name to a sid */
132 NTSTATUS (*name_to_sid)(struct winbindd_domain *domain,
135 enum SID_NAME_USE *type);
137 /* convert a sid to a user or group name */
138 NTSTATUS (*sid_to_name)(struct winbindd_domain *domain,
142 enum SID_NAME_USE *type);
144 /* lookup user info for a given rid */
145 NTSTATUS (*query_user)(struct winbindd_domain *domain,
148 WINBIND_USERINFO *user_info);
150 /* lookup all groups that a user is a member of. The backend
151 can also choose to lookup by username or rid for this
153 NTSTATUS (*lookup_usergroups)(struct winbindd_domain *domain,
156 uint32 *num_groups, uint32 **user_gids);
158 /* find all members of the group with the specified group_rid */
159 NTSTATUS (*lookup_groupmem)(struct winbindd_domain *domain,
161 uint32 group_rid, uint32 *num_names,
162 uint32 **rid_mem, char ***names,
163 uint32 **name_types);
165 /* return the current global sequence number */
166 NTSTATUS (*sequence_number)(struct winbindd_domain *domain, uint32 *seq);
168 /* enumerate trusted domains */
169 NTSTATUS (*trusted_domains)(struct winbindd_domain *domain,
176 /* find the domain sid */
177 NTSTATUS (*domain_sid)(struct winbindd_domain *domain,
180 /* setup the list of alternate names for the domain, if any */
181 NTSTATUS (*alternate_name)(struct winbindd_domain *domain);
184 /* Used to glue a policy handle and cli_state together */
187 struct cli_state *cli;
191 #include "winbindd_proto.h"
193 #include "rpc_parse.h"
194 #include "rpc_client.h"
196 #define WINBINDD_ESTABLISH_LOOP 30
197 #define WINBINDD_RESCAN_FREQ 300
199 #define DOM_SEQUENCE_NONE ((uint32)-1)
203 #define SETENV(name, value, overwrite) setenv(name,value,overwrite)
205 #define SETENV(name, value, overwrite) \
208 slprintf(envvar, sizeof(fstring), "%s=%s", name, value); \
212 #define SETENV(name, value, overwrite) ;
215 #endif /* _WINBINDD_H */