2000-05-09 15:43:00 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2000-05-09 15:43:00 +04:00
Winbind daemon for ntdom nss module
Copyright ( C ) Tim Potter 2000
2003-04-23 15:54:56 +04:00
Copyright ( C ) Anthony Liguori 2003
2000-05-09 15:43:00 +04:00
This library is free software ; you can redistribute it and / or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation ; either
version 2 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 Library General Public
License along with this library ; if not , write to the
Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
# ifndef _WINBINDD_H
# define _WINBINDD_H
# include "includes.h"
# include "nterr.h"
2000-05-10 18:17:21 +04:00
# include "winbindd_nss.h"
2000-05-09 15:43:00 +04:00
2002-07-15 14:35:28 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_WINBIND
2000-05-09 15:43:00 +04:00
/* Client state structure */
struct winbindd_cli_state {
2003-02-28 03:25:55 +03:00
struct winbindd_cli_state * prev , * next ; /* Linked list pointers */
int sock ; /* Open socket from client */
pid_t pid ; /* pid of client */
int read_buf_len , write_buf_len ; /* Indexes in request/response */
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) */
2003-04-07 11:32:51 +04:00
BOOL privileged ; /* Is the client 'privileged' */
2003-03-24 12:54:13 +03:00
2003-02-28 03:25:55 +03:00
struct winbindd_request request ; /* Request from client */
struct winbindd_response response ; /* Respose to client */
struct getent_state * getpwent_state ; /* State for getpwent() */
struct getent_state * getgrent_state ; /* State for getgrent() */
2000-05-09 15:43:00 +04:00
} ;
2001-05-07 08:32:40 +04:00
/* State between get{pw,gr}ent() calls */
2000-05-09 15:43:00 +04:00
struct getent_state {
2001-05-07 08:32:40 +04:00
struct getent_state * prev , * next ;
void * sam_entries ;
uint32 sam_entry_index , num_sam_entries ;
2001-12-11 04:04:13 +03:00
BOOL got_sam_entries ;
2002-01-11 08:33:45 +03:00
fstring domain_name ;
2001-05-07 08:32:40 +04:00
} ;
/* Storage for cached getpwent() user entries */
struct getpwent_user {
fstring name ; /* Account name */
fstring gecos ; /* User information */
2003-04-23 15:54:56 +04:00
DOM_SID user_sid ; /* NT user and primary group SIDs */
DOM_SID group_sid ;
2000-05-09 15:43:00 +04:00
} ;
/* Server state structure */
struct winbindd_state {
2001-10-05 04:20:06 +04:00
2000-05-09 15:43:00 +04:00
/* User and group id pool */
2001-10-05 04:20:06 +04:00
2000-05-09 15:43:00 +04:00
uid_t uid_low , uid_high ; /* Range of uids to allocate */
gid_t gid_low , gid_high ; /* Range of gids to allocate */
} ;
extern struct winbindd_state server_state ; /* Server information */
2001-12-01 15:31:43 +03:00
typedef struct {
char * acct_name ;
char * full_name ;
2003-04-23 15:54:56 +04:00
DOM_SID * user_sid ; /* NT user and primary group SIDs */
DOM_SID * group_sid ;
2001-12-03 14:32:55 +03:00
} WINBIND_USERINFO ;
2001-12-01 15:31:43 +03:00
2002-01-11 08:33:45 +03:00
/* Structures to hold per domain information */
struct winbindd_domain {
fstring name ; /* Domain name */
2002-08-17 21:00:51 +04:00
fstring alt_name ; /* alt Domain name (if any) */
2002-01-11 08:33:45 +03:00
DOM_SID sid ; /* SID for this domain */
2002-10-05 01:42:04 +04:00
BOOL native_mode ; /* is this a win2k domain in native mode ? */
2002-01-11 08:33:45 +03:00
/* Lookup methods for this domain (LDAP or RPC) */
struct winbindd_methods * methods ;
2003-06-10 07:50:38 +04:00
/* the backend methods are used by the cache layer to find the right
backend */
struct winbindd_methods * backend ;
2002-01-11 08:33:45 +03:00
/* Private data for the backends (used for connection cache) */
void * private ;
/* Sequence number stuff */
time_t last_seq_check ;
uint32 sequence_number ;
/* Linked list info */
struct winbindd_domain * prev , * next ;
} ;
2001-12-01 15:31:43 +03:00
/* per-domain methods. This is how LDAP vs RPC is selected
*/
struct winbindd_methods {
2001-12-10 09:05:21 +03:00
/* does this backend provide a consistent view of the data? (ie. is the primary group
always correct ) */
BOOL consistent ;
2001-12-05 07:48:51 +03:00
/* get a list of users, returning a WINBIND_USERINFO for each one */
2001-12-03 14:32:55 +03:00
NTSTATUS ( * query_user_list ) ( struct winbindd_domain * domain ,
2001-12-01 15:31:43 +03:00
TALLOC_CTX * mem_ctx ,
2001-12-11 03:03:58 +03:00
uint32 * num_entries ,
2001-12-03 14:32:55 +03:00
WINBIND_USERINFO * * info ) ;
2001-12-01 15:31:43 +03:00
2002-10-08 22:32:42 +04:00
/* get a list of domain groups */
2001-12-03 04:23:42 +03:00
NTSTATUS ( * enum_dom_groups ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2001-12-11 04:04:13 +03:00
uint32 * num_entries ,
2001-12-03 04:23:42 +03:00
struct acct_info * * info ) ;
2001-12-03 11:17:46 +03:00
2002-10-08 22:32:42 +04: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 ) ;
2001-12-05 07:48:51 +03:00
/* convert one user or group name to a sid */
2001-12-03 11:17:46 +03:00
NTSTATUS ( * name_to_sid ) ( struct winbindd_domain * domain ,
2003-04-23 15:54:56 +04:00
TALLOC_CTX * mem_ctx ,
2001-12-03 11:17:46 +03:00
const char * name ,
DOM_SID * sid ,
enum SID_NAME_USE * type ) ;
2001-12-03 14:11:14 +03:00
2001-12-05 07:48:51 +03:00
/* convert a sid to a user or group name */
2001-12-03 14:11:14 +03:00
NTSTATUS ( * sid_to_name ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
DOM_SID * sid ,
char * * name ,
enum SID_NAME_USE * type ) ;
2001-12-04 09:17:39 +03:00
2003-04-23 15:54:56 +04:00
/* lookup user info for a given SID */
2001-12-04 09:17:39 +03:00
NTSTATUS ( * query_user ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2003-04-23 15:54:56 +04:00
DOM_SID * user_sid ,
2001-12-04 09:17:39 +03:00
WINBIND_USERINFO * user_info ) ;
2001-12-04 09:46:53 +03:00
2001-12-05 07:48:51 +03: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 09:46:53 +03:00
NTSTATUS ( * lookup_usergroups ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2003-04-23 15:54:56 +04:00
DOM_SID * user_sid ,
uint32 * num_groups , DOM_SID * * * user_gids ) ;
2001-12-05 07:48:51 +03:00
/* find all members of the group with the specified group_rid */
NTSTATUS ( * lookup_groupmem ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
2003-04-23 15:54:56 +04:00
DOM_SID * group_sid ,
uint32 * num_names ,
DOM_SID * * * sid_mem , char * * * names ,
2001-12-05 07:48:51 +03:00
uint32 * * name_types ) ;
2001-12-05 10:52:44 +03:00
/* return the current global sequence number */
2001-12-10 02:59:42 +03:00
NTSTATUS ( * sequence_number ) ( struct winbindd_domain * domain , uint32 * seq ) ;
2001-12-10 05:25:19 +03:00
/* enumerate trusted domains */
NTSTATUS ( * trusted_domains ) ( struct winbindd_domain * domain ,
TALLOC_CTX * mem_ctx ,
uint32 * num_domains ,
char * * * names ,
2002-08-17 21:00:51 +04:00
char * * * alt_names ,
2001-12-10 05:25:19 +03:00
DOM_SID * * dom_sids ) ;
/* find the domain sid */
NTSTATUS ( * domain_sid ) ( struct winbindd_domain * domain ,
DOM_SID * sid ) ;
2002-08-17 21:00:51 +04:00
/* setup the list of alternate names for the domain, if any */
NTSTATUS ( * alternate_name ) ( struct winbindd_domain * domain ) ;
2001-12-01 15:31:43 +03:00
} ;
2001-10-05 04:20:06 +04:00
/* Used to glue a policy handle and cli_state together */
typedef struct {
struct cli_state * cli ;
POLICY_HND pol ;
} CLI_POLICY_HND ;
2003-04-23 15:54:56 +04:00
/* Filled out by IDMAP backends */
struct winbindd_idmap_methods {
/* Called when backend is first loaded */
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_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 ) ;
/* Called to dump backend status */
void ( * status ) ( void ) ;
} ;
2003-05-23 05:59:43 +04:00
# include "../nsswitch/winbindd_proto.h"
2000-05-09 15:43:00 +04:00
# include "rpc_parse.h"
2001-05-07 08:32:40 +04:00
# include "rpc_client.h"
2000-05-09 15:43:00 +04:00
# define WINBINDD_ESTABLISH_LOOP 30
2002-08-17 21:00:51 +04:00
# define WINBINDD_RESCAN_FREQ 300
2000-05-09 15:43:00 +04:00
# define DOM_SEQUENCE_NONE ((uint32)-1)
# endif /* _WINBINDD_H */