2000-05-09 11:43:00 +00:00
/*
2002-01-30 06:08:46 +00:00
Unix SMB / CIFS implementation .
2000-05-09 11:43:00 +00:00
Winbind daemon for ntdom nss module
Copyright ( C ) Tim Potter 2000
2003-08-01 15:30:44 +00:00
Copyright ( C ) Jim McDonough < jmcd @ us . ibm . com > 2003
2009-07-31 22:59:30 +02:00
2000-05-09 11:43:00 +00:00
This library is free software ; you can redistribute it and / or
2007-07-10 04:04:46 +00:00
modify it under the terms of the GNU Lesser General Public
2000-05-09 11:43:00 +00:00
License as published by the Free Software Foundation ; either
2007-07-10 02:31:50 +00:00
version 3 of the License , or ( at your option ) any later version .
2009-07-31 22:59:30 +02:00
2000-05-09 11:43:00 +00:00
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 .
2009-07-31 22:59:30 +02:00
2007-07-10 04:04:46 +00:00
You should have received a copy of the GNU Lesser General Public License
2007-07-10 02:31:50 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2000-05-09 11:43:00 +00:00
*/
# ifndef _WINBINDD_H
# define _WINBINDD_H
2007-09-14 08:06:03 +00:00
# include "nsswitch/winbind_struct_protocol.h"
2008-05-13 12:58:52 -05:00
# include "nsswitch/libwbclient/wbclient.h"
2009-08-09 07:31:31 -04:00
# include "librpc/gen_ndr/wbint.h"
2000-05-09 11:43:00 +00:00
2010-08-18 19:05:59 +02:00
# include "talloc_dict.h"
2006-03-13 15:13:35 +00:00
# ifdef HAVE_LIBNSCD
2007-09-14 08:06:03 +00:00
# include <libnscd.h>
2006-03-13 15:13:35 +00:00
# endif
2006-05-16 14:29:39 +00:00
# ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
# endif
2002-07-15 10:35:28 +00:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_WINBIND
2007-03-16 17:54:10 +00:00
# define WB_REPLACE_CHAR '_'
2005-09-30 17:13:37 +00:00
struct sid_ctr {
2010-05-21 11:25:01 +10:00
struct dom_sid * sid ;
2007-10-18 17:40:25 -07:00
bool finished ;
2005-09-30 17:13:37 +00:00
const char * domain ;
const char * name ;
2006-09-08 14:28:06 +00:00
enum lsa_SidType type ;
2005-09-30 17:13:37 +00:00
} ;
2000-05-09 11:43:00 +00:00
struct winbindd_cli_state {
2003-02-28 00:25:55 +00:00
struct winbindd_cli_state * prev , * next ; /* Linked list pointers */
int sock ; /* Open socket from client */
pid_t pid ; /* pid of client */
time_t last_access ; /* Time of last access (read or write) */
2007-10-18 17:40:25 -07:00
bool privileged ; /* Is the client 'privileged' */
2003-03-24 09:54:13 +00:00
2005-06-08 22:10:34 +00:00
TALLOC_CTX * mem_ctx ; /* memory per request */
2010-03-05 11:16:12 +01:00
const char * cmd_name ;
2009-07-31 16:16:24 +02:00
NTSTATUS ( * recv_fn ) ( struct tevent_req * req ,
struct winbindd_response * presp ) ;
2009-05-07 22:46:27 +02:00
struct winbindd_request * request ; /* Request from client */
2009-05-09 20:04:27 +02:00
struct tevent_queue * out_queue ;
2009-06-14 12:58:19 +02:00
struct winbindd_response * response ; /* Respose to client */
2007-10-18 17:40:25 -07:00
bool getpwent_initialized ; /* Has getpwent_state been
2005-06-08 22:10:34 +00:00
* initialized ? */
2007-10-18 17:40:25 -07:00
bool getgrent_initialized ; /* Has getgrent_state been
2005-06-08 22:10:34 +00:00
* initialized ? */
2009-08-17 23:13:48 +02:00
struct getpwent_state * pwent_state ; /* State for getpwent() */
2009-08-27 21:53:15 +02:00
struct getgrent_state * grent_state ; /* State for getgrent() */
2000-05-09 11:43:00 +00:00
} ;
2009-08-17 22:50:39 +02:00
struct getpwent_state {
struct winbindd_domain * domain ;
int next_user ;
int num_users ;
struct wbint_userinfo * users ;
} ;
2009-08-27 21:53:15 +02:00
struct getgrent_state {
struct winbindd_domain * domain ;
int next_group ;
int num_groups ;
struct wbint_Principal * groups ;
} ;
2001-05-07 04:32:40 +00:00
/* Storage for cached getpwent() user entries */
struct getpwent_user {
fstring name ; /* Account name */
fstring gecos ; /* User information */
2005-06-29 14:03:53 +00:00
fstring homedir ; /* User Home Directory */
fstring shell ; /* User Login Shell */
2010-05-21 11:25:01 +10:00
struct dom_sid user_sid ; /* NT user and primary group SIDs */
struct dom_sid group_sid ;
2000-05-09 11:43:00 +00:00
} ;
2005-06-08 22:10:34 +00:00
/* Our connection to the DC */
struct winbindd_cm_conn {
struct cli_state * cli ;
struct rpc_pipe_client * samr_pipe ;
2009-03-18 22:49:41 +01:00
struct policy_handle sam_connect_handle , sam_domain_handle ;
2005-06-08 22:10:34 +00:00
struct rpc_pipe_client * lsa_pipe ;
2009-09-12 23:30:39 +02:00
struct rpc_pipe_client * lsa_pipe_tcp ;
2009-03-18 22:49:41 +01:00
struct policy_handle lsa_policy ;
2005-06-08 22:10:34 +00:00
struct rpc_pipe_client * netlogon_pipe ;
} ;
/* Async child */
2007-10-08 12:25:57 +00:00
struct winbindd_domain ;
struct winbindd_child_dispatch_table {
2007-12-07 16:00:45 +01:00
const char * name ;
enum winbindd_cmd struct_cmd ;
enum winbindd_result ( * struct_fn ) ( struct winbindd_domain * domain ,
struct winbindd_cli_state * state ) ;
2007-10-08 12:25:57 +00:00
} ;
2005-06-08 22:10:34 +00:00
struct winbindd_child {
struct winbindd_child * next , * prev ;
pid_t pid ;
struct winbindd_domain * domain ;
2007-12-03 17:57:46 -08:00
char * logfilename ;
2005-06-08 22:10:34 +00:00
2009-05-10 10:49:53 +02:00
int sock ;
struct tevent_queue * queue ;
2010-08-12 15:12:11 +02:00
struct dcerpc_binding_handle * binding_handle ;
2009-05-10 10:49:53 +02:00
2006-03-17 10:14:33 +00:00
struct timed_event * lockout_policy_event ;
2008-08-21 01:20:22 +02:00
struct timed_event * machine_password_change_event ;
2007-10-08 12:25:57 +00:00
const struct winbindd_child_dispatch_table * table ;
2005-06-08 22:10:34 +00:00
} ;
2002-01-11 05:33:45 +00:00
/* Structures to hold per domain information */
struct winbindd_domain {
2007-05-06 21:15:45 +00:00
fstring name ; /* Domain name (NetBIOS) */
fstring alt_name ; /* alt Domain name, if any (FQDN for ADS) */
2007-01-02 21:48:47 +00:00
fstring forest_name ; /* Name of the AD forest we're in */
2010-05-21 11:25:01 +10:00
struct dom_sid sid ; /* SID for this domain */
2008-01-29 17:49:38 +01:00
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 */
2007-10-18 17:40:25 -07:00
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 ? */
2010-09-10 21:36:20 +02:00
time_t startup_time ; /* When we set "startup" true. monotonic clock */
2007-10-18 17:40:25 -07:00
bool startup ; /* are we in the first 30 seconds after startup_time ? */
2002-01-11 05:33:45 +00:00
2008-03-19 16:09:37 +01:00
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 . */
2009-09-17 09:43:36 +02:00
bool can_do_ncacn_ip_tcp ;
2002-01-11 05:33:45 +00:00
/* Lookup methods for this domain (LDAP or RPC) */
struct winbindd_methods * methods ;
2003-06-10 03:50:38 +00:00
/* the backend methods are used by the cache layer to find the right
backend */
struct winbindd_methods * backend ;
2002-01-11 05:33:45 +00:00
/* Private data for the backends (used for connection cache) */
2007-12-03 17:57:46 -08:00
void * private_data ;
2002-01-11 05:33:45 +00:00
2008-07-13 12:07:40 +02:00
/*
* 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 ;
2004-11-18 11:57:49 +00:00
/* A working DC */
2008-08-20 16:24:22 -07:00
pid_t dc_probe_pid ; /* Child we're using to detect the DC. */
2004-11-18 11:57:49 +00:00
fstring dcname ;
2007-10-24 14:16:54 -07:00
struct sockaddr_storage dcaddr ;
2004-11-18 11:57:49 +00:00
2002-01-11 05:33:45 +00:00
/* Sequence number stuff */
time_t last_seq_check ;
uint32 sequence_number ;
2003-06-21 04:05:01 +00:00
NTSTATUS last_status ;
2002-01-11 05:33:45 +00:00
2005-06-08 22:10:34 +00:00
/* The smb connection */
struct winbindd_cm_conn conn ;
/* The child pid we're talking to */
struct winbindd_child child ;
2006-09-06 21:43:31 +00:00
/* Callback we use to try put us back online. */
2006-12-06 23:14:15 +00:00
uint32 check_online_timeout ;
2006-09-06 21:43:31 +00:00
struct timed_event * check_online_event ;
2002-01-11 05:33:45 +00:00
/* Linked list info */
struct winbindd_domain * prev , * next ;
} ;
2001-12-01 12:31:43 +00:00
/* per-domain methods. This is how LDAP vs RPC is selected
*/
struct winbindd_methods {
2001-12-10 06:05:21 +00:00
/* does this backend provide a consistent view of the data? (ie. is the primary group
always correct ) */
2007-10-18 17:40:25 -07:00
bool consistent ;
2001-12-10 06:05:21 +00:00
2009-08-09 07:31:31 -04:00
/* get a list of users, returning a wbint_userinfo for each one */
2001-12-03 11:32:55 +00:00
NTSTATUS ( * query_user_list ) ( struct winbindd_domain * domain ,
2001-12-01 12:31:43 +00:00
TALLOC_CTX * mem_ctx ,
2001-12-11 00:03:58 +00:00
uint32 * num_entries ,
2009-08-09 07:31:31 -04:00
struct wbint_userinfo * * info ) ;
2001-12-01 12:31:43 +00:00
2002-10-08 18:32:42 +00:00
/* get a list of domain groups */
2001-12-03 01:23:42 +00:00
NTSTATUS ( * enum_dom_groups ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2001-12-11 01:04:13 +00:00
uint32 * num_entries ,
2001-12-03 01:23:42 +00:00
struct acct_info * * info ) ;
2001-12-03 08:17:46 +00:00
2002-10-08 18:32:42 +00:00
/* get a list of domain local groups */
NTSTATUS ( * enum_local_groups ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
uint32 * num_entries ,
struct acct_info * * info ) ;
2009-07-31 22:59:30 +02:00
2001-12-05 04:48:51 +00:00
/* convert one user or group name to a sid */
2001-12-03 08:17:46 +00:00
NTSTATUS ( * name_to_sid ) ( struct winbindd_domain * domain ,
2003-04-23 11:54:56 +00:00
TALLOC_CTX * mem_ctx ,
2004-04-20 02:37:49 +00:00
const char * domain_name ,
2001-12-03 08:17:46 +00:00
const char * name ,
2009-08-02 10:43:05 +02:00
uint32_t flags ,
2010-05-21 11:25:01 +10:00
struct dom_sid * sid ,
2006-09-08 14:28:06 +00:00
enum lsa_SidType * type ) ;
2001-12-03 11:11:14 +00:00
2001-12-05 04:48:51 +00:00
/* convert a sid to a user or group name */
2001-12-03 11:11:14 +00:00
NTSTATUS ( * sid_to_name ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2010-05-21 11:25:01 +10:00
const struct dom_sid * sid ,
2004-04-20 02:37:49 +00:00
char * * domain_name ,
2001-12-03 11:11:14 +00:00
char * * name ,
2006-09-08 14:28:06 +00:00
enum lsa_SidType * type ) ;
2001-12-04 06:17:39 +00:00
2006-07-11 18:01:26 +00:00
NTSTATUS ( * rids_to_names ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2010-05-21 11:25:01 +10:00
const struct dom_sid * domain_sid ,
2006-07-11 18:01:26 +00:00
uint32 * rids ,
size_t num_rids ,
char * * domain_name ,
char * * * names ,
2006-09-08 14:28:06 +00:00
enum lsa_SidType * * types ) ;
2006-07-11 18:01:26 +00:00
2003-04-23 11:54:56 +00:00
/* lookup user info for a given SID */
2001-12-04 06:17:39 +00:00
NTSTATUS ( * query_user ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2010-05-21 11:25:01 +10:00
const struct dom_sid * user_sid ,
2009-08-09 07:31:31 -04:00
struct wbint_userinfo * user_info ) ;
2001-12-04 06:46:53 +00:00
2001-12-05 04:48:51 +00:00
/* lookup all groups that a user is a member of. The backend
can also choose to lookup by username or rid for this
function */
2001-12-04 06:46:53 +00:00
NTSTATUS ( * lookup_usergroups ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2010-05-21 11:25:01 +10:00
const struct dom_sid * user_sid ,
uint32 * num_groups , struct dom_sid * * user_gids ) ;
2001-12-05 04:48:51 +00:00
2005-01-15 19:00:18 +00:00
/* Lookup all aliases that the sids delivered are member of. This is
* to implement ' domain local groups ' correctly */
NTSTATUS ( * lookup_useraliases ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2005-06-08 22:10:34 +00:00
uint32 num_sids ,
2010-05-21 11:25:01 +10:00
const struct dom_sid * sids ,
2005-01-15 19:00:18 +00:00
uint32 * num_aliases ,
uint32 * * alias_rids ) ;
2001-12-05 04:48:51 +00:00
/* find all members of the group with the specified group_rid */
NTSTATUS ( * lookup_groupmem ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2010-05-21 11:25:01 +10:00
const struct dom_sid * group_sid ,
2009-08-28 14:25:11 +02:00
enum lsa_SidType type ,
2003-04-23 11:54:56 +00:00
uint32 * num_names ,
2010-05-21 11:25:01 +10:00
struct dom_sid * * sid_mem , char * * * names ,
2001-12-05 04:48:51 +00:00
uint32 * * name_types ) ;
2001-12-05 07:52:44 +00:00
/* return the current global sequence number */
2001-12-09 23:59:42 +00:00
NTSTATUS ( * sequence_number ) ( struct winbindd_domain * domain , uint32 * seq ) ;
2001-12-10 02:25:19 +00:00
2006-02-03 22:19:41 +00:00
/* return the lockout policy */
2008-02-05 17:25:07 +01:00
NTSTATUS ( * lockout_policy ) ( struct winbindd_domain * domain ,
2006-02-03 22:19:41 +00:00
TALLOC_CTX * mem_ctx ,
2008-02-05 17:25:07 +01:00
struct samr_DomInfo12 * lockout_policy ) ;
2006-02-03 22:19:41 +00:00
/* return the lockout policy */
2008-02-05 17:25:07 +01:00
NTSTATUS ( * password_policy ) ( struct winbindd_domain * domain ,
2006-02-03 22:19:41 +00:00
TALLOC_CTX * mem_ctx ,
2008-02-05 17:25:07 +01:00
struct samr_DomInfo1 * password_policy ) ;
2001-12-10 02:25:19 +00:00
/* enumerate trusted domains */
NTSTATUS ( * trusted_domains ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2009-12-28 15:51:36 +01:00
struct netr_DomainTrustList * trusts ) ;
2001-12-01 12:31:43 +00:00
} ;
2003-04-23 11:54:56 +00:00
/* Filled out by IDMAP backends */
struct winbindd_idmap_methods {
/* Called when backend is first loaded */
2007-10-18 17:40:25 -07:00
bool ( * init ) ( void ) ;
2003-04-23 11:54:56 +00:00
2010-05-21 11:25:01 +10:00
bool ( * get_sid_from_uid ) ( uid_t uid , struct dom_sid * sid ) ;
bool ( * get_sid_from_gid ) ( gid_t gid , struct dom_sid * sid ) ;
2003-04-23 11:54:56 +00:00
2010-05-21 11:25:01 +10:00
bool ( * get_uid_from_sid ) ( struct dom_sid * sid , uid_t * uid ) ;
bool ( * get_gid_from_sid ) ( struct dom_sid * sid , gid_t * gid ) ;
2003-04-23 11:54:56 +00:00
/* Called when backend is unloaded */
2007-10-18 17:40:25 -07:00
bool ( * close ) ( void ) ;
2003-04-23 11:54:56 +00:00
/* Called to dump backend status */
void ( * status ) ( void ) ;
} ;
2007-05-06 18:39:31 +00:00
/* Data structures for dealing with the trusted domain cache */
struct winbindd_tdc_domain {
const char * domain_name ;
const char * dns_name ;
2010-05-21 11:25:01 +10:00
struct dom_sid sid ;
2007-05-06 18:39:31 +00:00
uint32 trust_flags ;
uint32 trust_attribs ;
uint32 trust_type ;
} ;
2008-06-26 14:02:39 -07:00
/* Switch for listing users or groups */
enum ent_type {
LIST_USERS = 0 ,
LIST_GROUPS ,
} ;
2008-12-30 09:32:31 +01:00
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 ;
} ;
2007-09-14 12:03:58 +00:00
# include "winbindd/winbindd_proto.h"
2000-05-09 11:43:00 +00:00
# define WINBINDD_ESTABLISH_LOOP 30
2007-05-06 19:17:30 +00:00
# define WINBINDD_RESCAN_FREQ lp_winbind_cache_time()
2006-02-03 22:19:41 +00:00
# define WINBINDD_PAM_AUTH_KRB5_RENEW_TIME 2592000 /* one month */
2000-05-09 11:43:00 +00:00
# define DOM_SEQUENCE_NONE ((uint32)-1)
2010-06-10 11:55:27 -04:00
# define winbind_event_context server_event_context
# define winbind_messaging_context server_messaging_context
2000-05-09 11:43:00 +00:00
# endif /* _WINBINDD_H */