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
2006-07-19 00:19:55 +04:00
Copyright ( C ) Gerald Carter 2006
2000-05-09 15:43:00 +04:00
2004-12-18 01:16:30 +03:00
You are free to use this interface definition in any way you see
fit , including without restriction , using this header in your own
products . You do not need to give any attribution .
2000-05-09 15:43:00 +04:00
*/
2005-05-07 19:03:00 +04:00
# ifndef CONST_DISCARD
# define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
# endif
# ifndef CONST_ADD
# define CONST_ADD(type, ptr) ((type) ((const void *) (ptr)))
# endif
2001-09-17 08:52:45 +04:00
# ifndef SAFE_FREE
2005-05-31 17:46:45 +04:00
# define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
2001-09-17 08:52:45 +04:00
# endif
2000-05-09 15:43:00 +04:00
# ifndef _WINBINDD_NTDOM_H
# define _WINBINDD_NTDOM_H
# define WINBINDD_SOCKET_NAME "pipe" /* Name of PF_UNIX socket */
# define WINBINDD_SOCKET_DIR " / tmp / .winbindd" /* Name of PF_UNIX dir */
2003-04-07 11:32:51 +04:00
# define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lockdir() to hold the 'privileged' pipe */
2000-06-14 13:58:12 +04:00
# define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */
# define WINBINDD_DONT_ENV "_NO_WINBINDD"
2000-05-09 15:43:00 +04:00
2002-01-10 14:28:14 +03:00
/* Update this when you change the interface. */
2002-01-11 02:45:29 +03:00
2006-08-19 05:04:54 +04:00
# define WINBIND_INTERFACE_VERSION 17
2002-01-11 02:45:29 +03:00
2006-07-19 00:19:55 +04:00
/* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
On a 64 bit Linux box , we have to support a constant structure size
between / lib / libnss_winbind . so .2 and / li64 / libnss_winbind . so .2 .
The easiest way to do this is to always use 8 byte values for time_t . */
# if defined(uint64)
# define SMB_TIME_T uint64
# else
2006-07-21 00:23:04 +04:00
# define SMB_TIME_T time_t
2006-07-19 00:19:55 +04:00
# endif
2002-01-11 02:45:29 +03:00
/* Socket commands */
2002-01-10 14:28:14 +03:00
2000-05-09 15:43:00 +04:00
enum winbindd_cmd {
2000-06-14 13:58:12 +04:00
2002-01-11 02:45:29 +03:00
WINBINDD_INTERFACE_VERSION , /* Always a well known value */
2000-06-14 13:58:12 +04:00
/* Get users and groups */
2002-01-10 09:20:03 +03:00
WINBINDD_GETPWNAM ,
WINBINDD_GETPWUID ,
WINBINDD_GETGRNAM ,
WINBINDD_GETGRGID ,
2000-10-11 09:45:06 +04:00
WINBINDD_GETGROUPS ,
2000-06-14 13:58:12 +04:00
/* Enumerate users and groups */
WINBINDD_SETPWENT ,
WINBINDD_ENDPWENT ,
WINBINDD_GETPWENT ,
WINBINDD_SETGRENT ,
WINBINDD_ENDGRENT ,
WINBINDD_GETGRENT ,
/* PAM authenticate and password change */
WINBINDD_PAM_AUTH ,
2001-11-14 23:02:02 +03:00
WINBINDD_PAM_AUTH_CRAP ,
2000-06-14 13:58:12 +04:00
WINBINDD_PAM_CHAUTHTOK ,
2006-02-04 01:19:41 +03:00
WINBINDD_PAM_LOGOFF ,
2006-07-13 13:29:25 +04:00
WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP ,
2000-06-14 13:58:12 +04:00
/* List various things */
2001-11-14 23:02:02 +03:00
WINBINDD_LIST_USERS , /* List w/o rid->id mapping */
WINBINDD_LIST_GROUPS , /* Ditto */
2000-06-14 13:58:12 +04:00
WINBINDD_LIST_TRUSTDOM ,
/* SID conversion */
WINBINDD_LOOKUPSID ,
WINBINDD_LOOKUPNAME ,
2006-07-11 22:01:26 +04:00
WINBINDD_LOOKUPRIDS ,
2000-06-14 13:58:12 +04:00
2001-11-14 23:02:02 +03:00
/* Lookup functions */
2000-06-14 13:58:12 +04:00
WINBINDD_SID_TO_UID ,
WINBINDD_SID_TO_GID ,
WINBINDD_UID_TO_SID ,
WINBINDD_GID_TO_SID ,
2006-02-04 01:19:41 +03:00
WINBINDD_ALLOCATE_UID ,
WINBINDD_ALLOCATE_GID ,
2000-06-14 13:58:12 +04:00
/* Miscellaneous other stuff */
WINBINDD_CHECK_MACHACC , /* Check machine account pw works */
2002-01-10 13:23:54 +03:00
WINBINDD_PING , /* Just tell me winbind is running */
2002-01-10 14:28:14 +03:00
WINBINDD_INFO , /* Various bit of info. Currently just tidbits */
2002-01-26 12:55:38 +03:00
WINBINDD_DOMAIN_NAME , /* The domain this winbind server is a member of (lp_workgroup()) */
2000-06-14 13:58:12 +04:00
2004-01-04 14:51:31 +03:00
WINBINDD_DOMAIN_INFO , /* Most of what we know from
struct winbindd_domain */
2005-06-09 02:10:34 +04:00
WINBINDD_GETDCNAME , /* Issue a GetDCName Request */
2004-01-04 14:51:31 +03:00
2002-01-31 14:49:29 +03:00
WINBINDD_SHOW_SEQUENCE , /* display sequence numbers of domains */
2002-03-29 18:37:39 +03:00
/* WINS commands */
WINBINDD_WINS_BYIP ,
WINBINDD_WINS_BYNAME ,
2002-07-15 14:35:28 +04:00
/* this is like GETGRENT but gives an empty group list */
WINBINDD_GETGRLST ,
2003-01-28 15:07:02 +03:00
WINBINDD_NETBIOS_NAME , /* The netbios name of the server */
2000-06-14 13:58:12 +04:00
2003-04-07 11:32:51 +04:00
/* find the location of our privileged pipe */
2003-03-24 12:54:13 +03:00
WINBINDD_PRIV_PIPE_DIR ,
2003-11-19 11:11:14 +03:00
/* return a list of group sids for a user sid */
2005-06-09 02:10:34 +04:00
WINBINDD_GETUSERSIDS ,
2006-02-04 01:19:41 +03:00
/* Various group queries */
2005-06-09 02:10:34 +04:00
WINBINDD_GETUSERDOMGROUPS ,
/* Initialize connection in a child */
WINBINDD_INIT_CONNECTION ,
/* Blocking calls that are not allowed on the main winbind pipe, only
* between parent and children */
WINBINDD_DUAL_SID2UID ,
WINBINDD_DUAL_SID2GID ,
2006-08-08 19:33:09 +04:00
WINBINDD_DUAL_UID2SID ,
WINBINDD_DUAL_GID2SID ,
2005-06-09 02:10:34 +04:00
WINBINDD_DUAL_IDMAPSET ,
/* Wrapper around possibly blocking unix nss calls */
WINBINDD_DUAL_UID2NAME ,
WINBINDD_DUAL_NAME2UID ,
WINBINDD_DUAL_GID2NAME ,
WINBINDD_DUAL_NAME2GID ,
WINBINDD_DUAL_USERINFO ,
WINBINDD_DUAL_GETSIDALIASES ,
2003-11-19 11:11:14 +03:00
2006-08-19 05:04:54 +04:00
/* Complete the challenge phase of the NTLM authentication
protocol using cached password . */
WINBINDD_CCACHE_NTLMAUTH ,
2000-06-14 13:58:12 +04:00
WINBINDD_NUM_CMDS
2000-05-09 15:43:00 +04:00
} ;
2003-07-09 20:44:47 +04:00
typedef struct winbindd_pw {
fstring pw_name ;
fstring pw_passwd ;
uid_t pw_uid ;
gid_t pw_gid ;
fstring pw_gecos ;
fstring pw_dir ;
fstring pw_shell ;
} WINBINDD_PW ;
typedef struct winbindd_gr {
fstring gr_name ;
fstring gr_passwd ;
gid_t gr_gid ;
2006-04-12 18:10:39 +04:00
uint32 num_gr_mem ;
uint32 gr_mem_ofs ; /* offset to group membership */
2003-07-09 20:44:47 +04:00
} WINBINDD_GR ;
2003-07-07 09:11:10 +04:00
# define WBFLAG_PAM_INFO3_NDR 0x0001
# define WBFLAG_PAM_INFO3_TEXT 0x0002
2004-04-06 12:11:16 +04:00
# define WBFLAG_PAM_USER_SESSION_KEY 0x0004
2003-07-07 09:11:10 +04:00
# define WBFLAG_PAM_LMKEY 0x0008
# define WBFLAG_PAM_CONTACT_TRUSTDOM 0x0010
# define WBFLAG_QUERY_ONLY 0x0020
2003-12-30 16:20:39 +03:00
# define WBFLAG_PAM_UNIX_NAME 0x0080
2004-04-01 16:31:50 +04:00
# define WBFLAG_PAM_AFS_TOKEN 0x0100
2004-04-06 20:44:24 +04:00
# define WBFLAG_PAM_NT_STATUS_SQUASH 0x0200
2002-08-17 21:00:51 +04:00
2005-06-09 02:10:34 +04:00
/* This is a flag that can only be sent from parent to child */
# define WBFLAG_IS_PRIVILEGED 0x0400
2005-09-19 22:49:18 +04:00
/* Flag to say this is a winbindd internal send - don't recurse. */
# define WBFLAG_RECURSE 0x0800
2005-06-09 02:10:34 +04:00
2006-02-04 01:19:41 +03:00
# define WBFLAG_PAM_KRB5 0x1000
# define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x2000
# define WBFLAG_PAM_CACHED_LOGIN 0x4000
2006-03-17 02:54:05 +03:00
# define WBFLAG_PAM_GET_PWD_POLICY 0x8000
2006-02-04 01:19:41 +03:00
2005-09-30 21:13:37 +04:00
# define WINBINDD_MAX_EXTRA_DATA (128*1024)
2000-05-09 15:43:00 +04:00
/* Winbind request structure */
2006-07-19 00:19:55 +04:00
/*******************************************************************************
* This structure MUST be the same size in the 32 bit and 64 bit builds
* for compatibility between / lib64 / libnss_winbind . so and / lib / libnss_winbind . so
*
* DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32 BIT NSS LIB AGAINST
* A 64 BIT WINBINDD - - jerry
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2000-05-09 15:43:00 +04:00
struct winbindd_request {
2002-01-11 02:45:29 +03:00
uint32 length ;
2000-05-09 15:43:00 +04:00
enum winbindd_cmd cmd ; /* Winbindd command to execute */
pid_t pid ; /* pid of calling process */
2003-07-07 09:11:10 +04:00
uint32 flags ; /* flags relavant to a given request */
2003-08-11 02:01:11 +04:00
fstring domain_name ; /* name of domain for which the request applies */
2000-05-09 15:43:00 +04:00
union {
2002-03-29 18:37:39 +03:00
fstring winsreq ; /* WINS request */
2000-06-14 13:58:12 +04:00
fstring username ; /* getpwnam */
fstring groupname ; /* getgrnam */
uid_t uid ; /* getpwuid, uid_to_sid */
gid_t gid ; /* getgrgid, gid_to_sid */
2000-05-09 15:43:00 +04:00
struct {
2002-09-25 19:19:00 +04:00
/* We deliberatedly don't split into domain/user to
avoid having the client know what the separator
character is . */
2000-05-09 15:43:00 +04:00
fstring user ;
fstring pass ;
2004-10-01 07:28:39 +04:00
fstring require_membership_of_sid ;
2006-02-04 01:19:41 +03:00
fstring krb5_cc_type ;
uid_t uid ;
2000-06-14 13:58:12 +04:00
} auth ; /* pam_winbind auth module */
2001-08-22 06:48:16 +04:00
struct {
2001-09-05 11:55:54 +04:00
unsigned char chal [ 8 ] ;
2005-11-08 09:19:34 +03:00
uint32 logon_parameters ;
2001-08-22 06:48:16 +04:00
fstring user ;
2002-01-10 13:23:54 +03:00
fstring domain ;
2001-08-22 06:48:16 +04:00
fstring lm_resp ;
2006-07-19 00:19:55 +04:00
uint32 lm_resp_len ;
2001-08-22 06:48:16 +04:00
fstring nt_resp ;
2006-07-19 00:19:55 +04:00
uint32 nt_resp_len ;
2002-08-17 21:00:51 +04:00
fstring workstation ;
2004-10-01 07:28:39 +04:00
fstring require_membership_of_sid ;
2001-08-22 06:48:16 +04:00
} auth_crap ;
2000-06-14 13:58:12 +04:00
struct {
fstring user ;
fstring oldpass ;
fstring newpass ;
} chauthtok ; /* pam_winbind passwd module */
2006-07-13 13:29:25 +04:00
struct {
fstring user ;
fstring domain ;
unsigned char new_nt_pswd [ 516 ] ;
uint16 new_nt_pswd_len ;
unsigned char old_nt_hash_enc [ 16 ] ;
uint16 old_nt_hash_enc_len ;
unsigned char new_lm_pswd [ 516 ] ;
uint16 new_lm_pswd_len ;
unsigned char old_lm_hash_enc [ 16 ] ;
uint16 old_lm_hash_enc_len ;
} chng_pswd_auth_crap ; /* pam_winbind passwd module */
2006-02-04 01:19:41 +03:00
struct {
fstring user ;
fstring krb5ccname ;
uid_t uid ;
} logoff ; /* pam_winbind session module */
2000-06-14 13:58:12 +04:00
fstring sid ; /* lookupsid, sid_to_[ug]id */
2002-01-26 12:55:38 +03:00
struct {
fstring dom_name ; /* lookupname */
fstring name ;
} name ;
2000-06-30 10:48:47 +04:00
uint32 num_entries ; /* getpwent, getgrent */
2003-07-09 20:44:47 +04:00
struct {
fstring username ;
fstring groupname ;
} acct_mgt ;
2005-06-09 02:10:34 +04:00
struct {
BOOL is_primary ;
fstring dcname ;
} init_conn ;
struct {
fstring sid ;
fstring name ;
BOOL alloc ;
} dual_sid2id ;
struct {
int type ;
uid_t uid ;
gid_t gid ;
fstring sid ;
} dual_idmapset ;
2006-02-04 01:19:41 +03:00
BOOL list_all_domains ;
2006-07-19 00:19:55 +04:00
2006-08-19 05:04:54 +04:00
struct {
uid_t uid ;
fstring user ;
/* the effective uid of the client, must be the uid for 'user'.
This is checked by the main daemon , trusted by children . */
/* if the blobs are length zero, then this doesn't
produce an actual challenge response . It merely
succeeds if there are cached credentials available
that could be used . */
uint32 initial_blob_len ; /* blobs in extra_data */
uint32 challenge_blob_len ;
} ccache_ntlm_auth ;
2006-07-19 00:19:55 +04:00
/* padding -- needed to fix alignment between 32bit and 64bit libs.
2006-08-19 05:04:54 +04:00
The size is the sizeof the union without the padding aligned on
2006-07-19 00:19:55 +04:00
an 8 byte boundary . - - jerry */
char padding [ 1560 ] ;
2000-05-09 15:43:00 +04:00
} data ;
2006-04-12 18:10:39 +04:00
union {
2006-07-19 00:19:55 +04:00
SMB_TIME_T padding ;
2006-04-12 18:10:39 +04:00
char * data ;
} extra_data ;
uint32 extra_len ;
2002-12-20 04:25:27 +03:00
char null_term ;
2000-05-09 15:43:00 +04:00
} ;
/* Response values */
enum winbindd_result {
2000-06-14 13:58:12 +04:00
WINBINDD_ERROR ,
2005-06-09 02:10:34 +04:00
WINBINDD_PENDING ,
2000-06-14 13:58:12 +04:00
WINBINDD_OK
2000-05-09 15:43:00 +04:00
} ;
/* Winbind response structure */
2006-07-19 00:19:55 +04:00
/*******************************************************************************
* This structure MUST be the same size in the 32 bit and 64 bit builds
* for compatibility between / lib64 / libnss_winbind . so and / lib / libnss_winbind . so
*
* DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32 BIT NSS LIB AGAINST
* A 64 BIT WINBINDD - - jerry
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2000-05-09 15:43:00 +04:00
struct winbindd_response {
2000-06-14 13:58:12 +04:00
/* Header information */
2000-05-09 15:43:00 +04:00
2002-01-11 02:45:29 +03:00
uint32 length ; /* Length of response */
2000-06-14 13:58:12 +04:00
enum winbindd_result result ; /* Result code */
2000-05-09 15:43:00 +04:00
2000-06-14 13:58:12 +04:00
/* Fixed length return data */
union {
2002-01-10 14:28:14 +03:00
int interface_version ; /* Try to ensure this is always in the same spot... */
2000-06-14 13:58:12 +04:00
2002-03-29 18:37:39 +03:00
fstring winsresp ; /* WINS response */
2000-06-30 10:48:47 +04:00
/* getpwnam, getpwuid */
2000-06-14 13:58:12 +04:00
2003-07-09 20:44:47 +04:00
struct winbindd_pw pw ;
2000-06-14 13:58:12 +04:00
2000-06-30 10:48:47 +04:00
/* getgrnam, getgrgid */
2000-06-14 13:58:12 +04:00
2003-07-09 20:44:47 +04:00
struct winbindd_gr gr ;
2000-06-14 13:58:12 +04:00
2000-06-30 10:48:47 +04:00
uint32 num_entries ; /* getpwent, getgrent */
2001-11-21 11:36:43 +03:00
struct winbindd_sid {
2000-07-05 15:24:26 +04:00
fstring sid ; /* lookupname, [ug]id_to_sid */
int type ;
} sid ;
2001-11-21 11:36:43 +03:00
struct winbindd_name {
2002-01-26 12:55:38 +03:00
fstring dom_name ; /* lookupsid */
fstring name ;
2000-06-14 13:58:12 +04:00
int type ;
} name ;
uid_t uid ; /* sid_to_uid */
gid_t gid ; /* sid_to_gid */
2002-01-10 14:28:14 +03:00
struct winbindd_info {
char winbind_separator ;
fstring samba_version ;
} info ;
2002-01-26 12:55:38 +03:00
fstring domain_name ;
2003-01-28 15:07:02 +03:00
fstring netbios_name ;
2005-06-09 02:10:34 +04:00
fstring dc_name ;
2002-02-05 12:40:36 +03:00
struct auth_reply {
uint32 nt_status ;
fstring nt_status_string ;
fstring error_string ;
int pam_error ;
2004-04-06 12:11:16 +04:00
char user_session_key [ 16 ] ;
2002-08-17 21:00:51 +04:00
char first_8_lm_hash [ 8 ] ;
2006-02-04 01:19:41 +03:00
fstring krb5ccname ;
2006-07-19 00:19:55 +04:00
uint32 reject_reason ;
uint32 padding ;
2006-02-04 01:19:41 +03:00
struct policy_settings {
2006-07-19 00:19:55 +04:00
uint32 min_length_password ;
uint32 password_history ;
2006-02-04 01:19:41 +03:00
uint32 password_properties ;
2006-07-19 00:19:55 +04:00
uint32 padding ;
SMB_TIME_T expire ;
SMB_TIME_T min_passwordage ;
2006-02-04 01:19:41 +03:00
} policy ;
struct info3_text {
2006-07-19 00:19:55 +04:00
SMB_TIME_T logon_time ;
SMB_TIME_T logoff_time ;
SMB_TIME_T kickoff_time ;
SMB_TIME_T pass_last_set_time ;
SMB_TIME_T pass_can_change_time ;
SMB_TIME_T pass_must_change_time ;
uint32 logon_count ;
uint32 bad_pw_count ;
2006-02-07 20:18:29 +03:00
uint32 user_rid ;
uint32 group_rid ;
2006-02-04 01:19:41 +03:00
uint32 num_groups ;
uint32 user_flgs ;
uint32 acct_flags ;
uint32 num_other_sids ;
2006-07-19 00:19:55 +04:00
fstring dom_sid ;
2006-02-04 01:19:41 +03:00
fstring user_name ;
fstring full_name ;
fstring logon_script ;
fstring profile_path ;
fstring home_dir ;
fstring dir_drive ;
fstring logon_srv ;
fstring logon_dom ;
} info3 ;
2002-02-05 12:40:36 +03:00
} auth ;
2004-01-04 14:51:31 +03:00
struct {
fstring name ;
fstring alt_name ;
fstring sid ;
BOOL native_mode ;
2004-01-08 11:19:18 +03:00
BOOL active_directory ;
2004-01-04 14:51:31 +03:00
BOOL primary ;
uint32 sequence_number ;
} domain_info ;
2005-06-09 02:10:34 +04:00
struct {
fstring acct_name ;
fstring full_name ;
2005-06-29 18:03:53 +04:00
fstring homedir ;
fstring shell ;
2005-06-09 02:10:34 +04:00
uint32 group_rid ;
} user_info ;
2006-08-19 05:04:54 +04:00
struct {
uint32 auth_blob_len ; /* blob in extra_data */
} ccache_ntlm_auth ;
2000-06-14 13:58:12 +04:00
} data ;
2000-05-09 15:43:00 +04:00
2000-06-14 13:58:12 +04:00
/* Variable length return data */
2000-05-09 15:43:00 +04:00
2006-04-12 18:10:39 +04:00
union {
2006-07-19 00:19:55 +04:00
SMB_TIME_T padding ;
2006-04-12 18:10:39 +04:00
void * data ;
} extra_data ;
2000-05-09 15:43:00 +04:00
} ;
2006-02-04 01:19:41 +03:00
struct WINBINDD_CCACHE_ENTRY {
const char * principal_name ;
const char * ccname ;
const char * service ;
const char * username ;
const char * sid_string ;
2006-08-20 05:25:26 +04:00
unsigned char * nt_hash ; /* Base pointer for the following 2 */
unsigned char * lm_hash ;
2006-05-16 18:29:39 +04:00
char * pass ;
2006-02-04 01:19:41 +03:00
uid_t uid ;
time_t create_time ;
time_t renew_until ;
BOOL refresh_tgt ;
time_t refresh_time ;
struct timed_event * event ;
struct WINBINDD_CCACHE_ENTRY * next , * prev ;
} ;
2000-05-09 15:43:00 +04:00
# endif