Copyright (C) Tim Potter 2000
Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _WINBINDD_H
#include "nsswitch/winbind_struct_protocol.h"
+#include "nsswitch/libwbclient/wbclient.h"
+#include "librpc/gen_ndr/wbint.h"
#ifdef HAVE_LIBNSCD
#include <libnscd.h>
#define WB_REPLACE_CHAR '_'
-/* bits for fd_event.flags */
-#define EVENT_FD_READ 1
-#define EVENT_FD_WRITE 2
-
-struct fd_event {
- struct fd_event *next, *prev;
- int fd;
- int flags; /* see EVENT_FD_* flags */
- void (*handler)(struct fd_event *fde, int flags);
- void *data;
- size_t length, done;
- void (*finished)(void *private_data, BOOL success);
- void *private_data;
-};
-
struct sid_ctr {
DOM_SID *sid;
- BOOL finished;
+ bool finished;
const char *domain;
const char *name;
enum lsa_SidType type;
struct winbindd_cli_state {
struct winbindd_cli_state *prev, *next; /* Linked list pointers */
int sock; /* Open socket from client */
- struct fd_event fd_event;
pid_t pid; /* pid of client */
- BOOL finished; /* Can delete from list */
- BOOL write_extra_data; /* Write extra_data field */
time_t last_access; /* Time of last access (read or write) */
- BOOL privileged; /* Is the client 'privileged' */
+ bool privileged; /* Is the client 'privileged' */
TALLOC_CTX *mem_ctx; /* memory per request */
- struct winbindd_request request; /* Request from client */
- struct winbindd_response response; /* Respose to client */
- BOOL getpwent_initialized; /* Has getpwent_state been
+ NTSTATUS (*recv_fn)(struct tevent_req *req,
+ struct winbindd_response *presp);
+ struct winbindd_request *request; /* Request from client */
+ struct tevent_queue *out_queue;
+ struct winbindd_response *response; /* Respose to client */
+ bool getpwent_initialized; /* Has getpwent_state been
* initialized? */
- BOOL getgrent_initialized; /* Has getgrent_state been
+ bool getgrent_initialized; /* Has getgrent_state been
* initialized? */
- struct getent_state *getpwent_state; /* State for getpwent() */
struct getent_state *getgrent_state; /* State for getgrent() */
+
+ struct getpwent_state *pwent_state; /* State for getpwent() */
+ struct getgrent_state *grent_state; /* State for getgrent() */
};
/* State between get{pw,gr}ent() calls */
struct getent_state *prev, *next;
void *sam_entries;
uint32 sam_entry_index, num_sam_entries;
- BOOL got_sam_entries;
+ bool got_sam_entries;
fstring domain_name;
};
+struct getpwent_state {
+ struct winbindd_domain *domain;
+ int next_user;
+ int num_users;
+ struct wbint_userinfo *users;
+};
+
+struct getgrent_state {
+ struct winbindd_domain *domain;
+ int next_group;
+ int num_groups;
+ struct wbint_Principal *groups;
+};
+
/* Storage for cached getpwent() user entries */
struct getpwent_user {
DOM_SID group_sid;
};
-/* Server state structure */
-
-typedef struct {
- char *acct_name;
- char *full_name;
- char *homedir;
- char *shell;
- gid_t primary_gid; /* allow the nss_info
- backend to set the primary group */
- DOM_SID user_sid; /* NT user and primary group SIDs */
- DOM_SID group_sid;
-} WINBIND_USERINFO;
-
/* Our connection to the DC */
struct winbindd_cm_conn {
struct cli_state *cli;
struct rpc_pipe_client *samr_pipe;
- POLICY_HND sam_connect_handle, sam_domain_handle;
+ struct policy_handle sam_connect_handle, sam_domain_handle;
struct rpc_pipe_client *lsa_pipe;
- POLICY_HND lsa_policy;
+ struct rpc_pipe_client *lsa_pipe_tcp;
+ struct policy_handle lsa_policy;
struct rpc_pipe_client *netlogon_pipe;
};
/* Async child */
+struct winbindd_domain;
+
+struct winbindd_child_dispatch_table {
+ const char *name;
+ enum winbindd_cmd struct_cmd;
+ enum winbindd_result (*struct_fn)(struct winbindd_domain *domain,
+ struct winbindd_cli_state *state);
+};
+
struct winbindd_child {
struct winbindd_child *next, *prev;
pid_t pid;
struct winbindd_domain *domain;
- pstring logfilename;
+ char *logfilename;
+
+ int sock;
+ struct tevent_queue *queue;
+ struct rpc_pipe_client *rpccli;
- struct fd_event event;
struct timed_event *lockout_policy_event;
- struct winbindd_async_request *requests;
+ struct timed_event *machine_password_change_event;
+
+ const struct winbindd_child_dispatch_table *table;
};
/* Structures to hold per domain information */
fstring alt_name; /* alt Domain name, if any (FQDN for ADS) */
fstring forest_name; /* Name of the AD forest we're in */
DOM_SID sid; /* SID for this domain */
- uint32 domain_flags; /* Domain flags from rpc_ds.h */
- uint32 domain_type; /* Domain type from rpc_ds.h */
- uint32 domain_trust_attribs; /* Trust attribs from rpc_ds.h */
- BOOL initialized; /* Did we already ask for the domain mode? */
- BOOL native_mode; /* is this a win2k domain in native mode ? */
- BOOL active_directory; /* is this a win2k active directory ? */
- BOOL primary; /* is this our primary domain ? */
- BOOL internal; /* BUILTIN and member SAM */
- BOOL online; /* is this domain available ? */
+ uint32 domain_flags; /* Domain flags from netlogon.h */
+ uint32 domain_type; /* Domain type from netlogon.h */
+ uint32 domain_trust_attribs; /* Trust attribs from netlogon.h */
+ bool initialized; /* Did we already ask for the domain mode? */
+ bool native_mode; /* is this a win2k domain in native mode ? */
+ bool active_directory; /* is this a win2k active directory ? */
+ bool primary; /* is this our primary domain ? */
+ bool internal; /* BUILTIN and member SAM */
+ bool online; /* is this domain available ? */
time_t startup_time; /* When we set "startup" true. */
- BOOL startup; /* are we in the first 30 seconds after startup_time ? */
+ bool startup; /* are we in the first 30 seconds after startup_time ? */
+
+ bool can_do_samlogon_ex; /* Due to the lack of finer control what type
+ * of DC we have, let us try to do a
+ * credential-chain less samlogon_ex call
+ * with AD and schannel. If this fails with
+ * DCERPC_FAULT_OP_RNG_ERROR, then set this
+ * to False. This variable is around so that
+ * we don't have to try _ex every time. */
/* Lookup methods for this domain (LDAP or RPC) */
struct winbindd_methods *methods;
/* Private data for the backends (used for connection cache) */
- void *private_data;
+ void *private_data;
+
+ /*
+ * idmap config settings, used to tell the idmap child which
+ * special domain config to use for a mapping
+ */
+ bool have_idmap_config;
+ uint32_t id_range_low, id_range_high;
/* A working DC */
+ pid_t dc_probe_pid; /* Child we're using to detect the DC. */
fstring dcname;
- struct sockaddr_in dcaddr;
+ struct sockaddr_storage dcaddr;
/* Sequence number stuff */
struct winbindd_methods {
/* does this backend provide a consistent view of the data? (ie. is the primary group
always correct) */
- BOOL consistent;
+ bool consistent;
- /* get a list of users, returning a WINBIND_USERINFO for each one */
+ /* get a list of users, returning a wbint_userinfo for each one */
NTSTATUS (*query_user_list)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
uint32 *num_entries,
- WINBIND_USERINFO **info);
+ struct wbint_userinfo **info);
/* get a list of domain groups */
NTSTATUS (*enum_dom_groups)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
uint32 *num_entries,
struct acct_info **info);
-
+
/* convert one user or group name to a sid */
NTSTATUS (*name_to_sid)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- enum winbindd_cmd orig_cmd,
const char *domain_name,
const char *name,
+ uint32_t flags,
DOM_SID *sid,
enum lsa_SidType *type);
NTSTATUS (*query_user)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *user_sid,
- WINBIND_USERINFO *user_info);
+ struct wbint_userinfo *user_info);
/* lookup all groups that a user is a member of. The backend
can also choose to lookup by username or rid for this
NTSTATUS (*lookup_groupmem)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *group_sid,
+ enum lsa_SidType type,
uint32 *num_names,
DOM_SID **sid_mem, char ***names,
uint32 **name_types);
NTSTATUS (*sequence_number)(struct winbindd_domain *domain, uint32 *seq);
/* return the lockout policy */
- NTSTATUS (*lockout_policy)(struct winbindd_domain *domain,
+ NTSTATUS (*lockout_policy)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_12 *lockout_policy);
-
+ struct samr_DomInfo12 *lockout_policy);
+
/* return the lockout policy */
- NTSTATUS (*password_policy)(struct winbindd_domain *domain,
+ NTSTATUS (*password_policy)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_1 *password_policy);
-
+ struct samr_DomInfo1 *password_policy);
+
/* enumerate trusted domains */
NTSTATUS (*trusted_domains)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
DOM_SID **dom_sids);
};
-/* Used to glue a policy handle and cli_state together */
-
-typedef struct {
- struct cli_state *cli;
- POLICY_HND pol;
-} CLI_POLICY_HND;
-
/* Filled out by IDMAP backends */
struct winbindd_idmap_methods {
/* Called when backend is first loaded */
- BOOL (*init)(void);
+ bool (*init)(void);
- BOOL (*get_sid_from_uid)(uid_t uid, DOM_SID *sid);
- BOOL (*get_sid_from_gid)(gid_t gid, DOM_SID *sid);
+ bool (*get_sid_from_uid)(uid_t uid, DOM_SID *sid);
+ bool (*get_sid_from_gid)(gid_t gid, DOM_SID *sid);
- BOOL (*get_uid_from_sid)(DOM_SID *sid, uid_t *uid);
- BOOL (*get_gid_from_sid)(DOM_SID *sid, gid_t *gid);
+ bool (*get_uid_from_sid)(DOM_SID *sid, uid_t *uid);
+ bool (*get_gid_from_sid)(DOM_SID *sid, gid_t *gid);
/* Called when backend is unloaded */
- BOOL (*close)(void);
+ bool (*close)(void);
/* Called to dump backend status */
void (*status)(void);
};
uint32 trust_type;
};
+/* Switch for listing users or groups */
+enum ent_type {
+ LIST_USERS = 0,
+ LIST_GROUPS,
+};
+
+struct WINBINDD_MEMORY_CREDS {
+ struct WINBINDD_MEMORY_CREDS *next, *prev;
+ const char *username; /* lookup key. */
+ uid_t uid;
+ int ref_count;
+ size_t len;
+ uint8_t *nt_hash; /* Base pointer for the following 2 */
+ uint8_t *lm_hash;
+ char *pass;
+};
+
+struct WINBINDD_CCACHE_ENTRY {
+ struct WINBINDD_CCACHE_ENTRY *next, *prev;
+ const char *principal_name;
+ const char *ccname;
+ const char *service;
+ const char *username;
+ const char *realm;
+ struct WINBINDD_MEMORY_CREDS *cred_ptr;
+ int ref_count;
+ uid_t uid;
+ time_t create_time;
+ time_t renew_until;
+ time_t refresh_time;
+ struct timed_event *event;
+};
#include "winbindd/winbindd_proto.h"
#define IS_DOMAIN_OFFLINE(x) ( lp_winbind_offline_logon() && \
( get_global_winbindd_state_offline() \
|| !(x)->online ) )
+#define IS_DOMAIN_ONLINE(x) (!IS_DOMAIN_OFFLINE(x))
+
#endif /* _WINBINDD_H */