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 uint32 grp_query_start_ndx;
56 BOOL got_all_sam_entries, got_sam_entries;
57 struct winbindd_domain *domain;
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 /* per-domain methods. This is how LDAP vs RPC is selected
88 This will eventually be the sole entry point to all the methods,
89 I'm just starting small
91 struct winbindd_methods {
92 /* get a list of users, returning a WINBIND_USERINFO for each one */
93 NTSTATUS (*query_user_list)(struct winbindd_domain *domain,
95 uint32 *start_ndx, uint32 *num_entries,
96 WINBIND_USERINFO **info);
98 /* get a list of groups */
99 NTSTATUS (*enum_dom_groups)(struct winbindd_domain *domain,
101 uint32 *start_ndx, uint32 *num_entries,
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 uint32 (*sequence_number)(struct winbindd_domain *domain);
142 /* Structures to hold per domain information */
143 struct winbindd_domain {
144 fstring name; /* Domain name */
145 DOM_SID sid; /* SID for this domain */
146 struct winbindd_methods *methods; /* lookup methods for
149 void *private; /* private data for the backends (used for connection cache) */
150 struct winbindd_domain *prev, *next; /* Linked list info */
153 extern struct winbindd_domain *domain_list; /* List of domains we know */
155 /* Used to glue a policy handle and cli_state together */
158 struct cli_state *cli;
162 #include "winbindd_proto.h"
164 #include "rpc_parse.h"
165 #include "rpc_client.h"
167 #define WINBINDD_ESTABLISH_LOOP 30
168 #define DOM_SEQUENCE_NONE ((uint32)-1)
172 #define SETENV(name, value, overwrite) setenv(name,value,overwrite)
174 #define SETENV(name, value, overwrite) \
177 slprintf(envvar, sizeof(fstring), "%s=%s", name, value); \
181 #define SETENV(name, value, overwrite) ;
184 #endif /* _WINBINDD_H */