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
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 .
*/
2001-09-17 04:52:45 +00:00
# ifndef SAFE_FREE
# define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
# endif
2000-05-09 11:43:00 +00: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 07:32:51 +00:00
# define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lockdir() to hold the 'privileged' pipe */
2000-06-14 09:58:12 +00:00
# define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */
# define WINBINDD_DONT_ENV "_NO_WINBINDD"
2000-05-09 11:43:00 +00:00
2002-01-10 11:28:14 +00:00
/* Update this when you change the interface. */
2002-01-10 23:45:29 +00:00
2004-04-06 16:45:38 +00:00
# define WINBIND_INTERFACE_VERSION 10
2002-01-10 23:45:29 +00:00
/* Socket commands */
2002-01-10 11:28:14 +00:00
2000-05-09 11:43:00 +00:00
enum winbindd_cmd {
2000-06-14 09:58:12 +00:00
2002-01-10 23:45:29 +00:00
WINBINDD_INTERFACE_VERSION , /* Always a well known value */
2000-06-14 09:58:12 +00:00
/* Get users and groups */
2002-01-10 06:20:03 +00:00
WINBINDD_GETPWNAM ,
WINBINDD_GETPWUID ,
WINBINDD_GETGRNAM ,
WINBINDD_GETGRGID ,
2000-10-11 05:45:06 +00:00
WINBINDD_GETGROUPS ,
2000-06-14 09:58:12 +00: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 20:02:02 +00:00
WINBINDD_PAM_AUTH_CRAP ,
2000-06-14 09:58:12 +00:00
WINBINDD_PAM_CHAUTHTOK ,
/* List various things */
2001-11-14 20:02:02 +00:00
WINBINDD_LIST_USERS , /* List w/o rid->id mapping */
WINBINDD_LIST_GROUPS , /* Ditto */
2000-06-14 09:58:12 +00:00
WINBINDD_LIST_TRUSTDOM ,
/* SID conversion */
WINBINDD_LOOKUPSID ,
WINBINDD_LOOKUPNAME ,
2001-11-14 20:02:02 +00:00
/* Lookup functions */
2000-06-14 09:58:12 +00:00
WINBINDD_SID_TO_UID ,
WINBINDD_SID_TO_GID ,
WINBINDD_UID_TO_SID ,
WINBINDD_GID_TO_SID ,
/* Miscellaneous other stuff */
WINBINDD_CHECK_MACHACC , /* Check machine account pw works */
2002-01-10 10:23:54 +00:00
WINBINDD_PING , /* Just tell me winbind is running */
2002-01-10 11:28:14 +00:00
WINBINDD_INFO , /* Various bit of info. Currently just tidbits */
2002-01-26 09:55:38 +00:00
WINBINDD_DOMAIN_NAME , /* The domain this winbind server is a member of (lp_workgroup()) */
2000-06-14 09:58:12 +00:00
2004-01-04 11:51:31 +00:00
WINBINDD_DOMAIN_INFO , /* Most of what we know from
struct winbindd_domain */
2002-01-31 11:49:29 +00:00
WINBINDD_SHOW_SEQUENCE , /* display sequence numbers of domains */
2002-03-29 15:37:39 +00:00
/* WINS commands */
WINBINDD_WINS_BYIP ,
WINBINDD_WINS_BYNAME ,
2003-07-09 16:44:47 +00:00
/* account management commands */
WINBINDD_CREATE_USER ,
WINBINDD_CREATE_GROUP ,
WINBINDD_ADD_USER_TO_GROUP ,
WINBINDD_REMOVE_USER_FROM_GROUP ,
WINBINDD_SET_USER_PRIMARY_GROUP ,
WINBINDD_DELETE_USER ,
WINBINDD_DELETE_GROUP ,
2002-07-15 10:35:28 +00:00
/* this is like GETGRENT but gives an empty group list */
WINBINDD_GETGRLST ,
2003-01-28 12:07:02 +00:00
WINBINDD_NETBIOS_NAME , /* The netbios name of the server */
2000-06-14 09:58:12 +00:00
/* Placeholder for end of cmd list */
2003-04-07 07:32:51 +00:00
/* find the location of our privileged pipe */
2003-03-24 09:54:13 +00:00
WINBINDD_PRIV_PIPE_DIR ,
2003-11-19 08:11:14 +00:00
/* return a list of group sids for a user sid */
WINBINDD_GETUSERSIDS ,
2000-06-14 09:58:12 +00:00
WINBINDD_NUM_CMDS
2000-05-09 11:43:00 +00:00
} ;
2003-07-09 16:44:47 +00: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 ;
int num_gr_mem ;
int gr_mem_ofs ; /* offset to group membership */
char * * gr_mem ;
} WINBINDD_GR ;
2003-07-07 05:11:10 +00:00
# define WBFLAG_PAM_INFO3_NDR 0x0001
# define WBFLAG_PAM_INFO3_TEXT 0x0002
2004-04-06 08:11:16 +00:00
# define WBFLAG_PAM_USER_SESSION_KEY 0x0004
2003-07-07 05:11:10 +00:00
# define WBFLAG_PAM_LMKEY 0x0008
# define WBFLAG_PAM_CONTACT_TRUSTDOM 0x0010
# define WBFLAG_QUERY_ONLY 0x0020
2003-07-11 05:33:40 +00:00
# define WBFLAG_ALLOCATE_RID 0x0040
2003-12-30 13:20:39 +00:00
# define WBFLAG_PAM_UNIX_NAME 0x0080
2004-04-01 12:31:50 +00:00
# define WBFLAG_PAM_AFS_TOKEN 0x0100
2004-04-06 16:44:24 +00:00
# define WBFLAG_PAM_NT_STATUS_SQUASH 0x0200
2002-08-17 17:00:51 +00:00
2000-05-09 11:43:00 +00:00
/* Winbind request structure */
struct winbindd_request {
2002-01-10 23:45:29 +00:00
uint32 length ;
2000-05-09 11:43:00 +00:00
enum winbindd_cmd cmd ; /* Winbindd command to execute */
pid_t pid ; /* pid of calling process */
2003-07-07 05:11:10 +00:00
uint32 flags ; /* flags relavant to a given request */
2003-08-10 22:01:11 +00:00
fstring domain_name ; /* name of domain for which the request applies */
2000-05-09 11:43:00 +00:00
union {
2002-03-29 15:37:39 +00:00
fstring winsreq ; /* WINS request */
2000-06-14 09:58:12 +00:00
fstring username ; /* getpwnam */
fstring groupname ; /* getgrnam */
uid_t uid ; /* getpwuid, uid_to_sid */
gid_t gid ; /* getgrgid, gid_to_sid */
2000-05-09 11:43:00 +00:00
struct {
2002-09-25 15:19:00 +00:00
/* We deliberatedly don't split into domain/user to
avoid having the client know what the separator
character is . */
2000-05-09 11:43:00 +00:00
fstring user ;
fstring pass ;
2004-04-06 16:44:24 +00:00
fstring required_membership_sid ;
2000-06-14 09:58:12 +00:00
} auth ; /* pam_winbind auth module */
2001-08-22 02:48:16 +00:00
struct {
2001-09-05 07:55:54 +00:00
unsigned char chal [ 8 ] ;
2001-08-22 02:48:16 +00:00
fstring user ;
2002-01-10 10:23:54 +00:00
fstring domain ;
2001-08-22 02:48:16 +00:00
fstring lm_resp ;
uint16 lm_resp_len ;
fstring nt_resp ;
uint16 nt_resp_len ;
2002-08-17 17:00:51 +00:00
fstring workstation ;
2004-04-06 16:44:24 +00:00
fstring required_membership_sid ;
2001-08-22 02:48:16 +00:00
} auth_crap ;
2000-06-14 09:58:12 +00:00
struct {
fstring user ;
fstring oldpass ;
fstring newpass ;
} chauthtok ; /* pam_winbind passwd module */
fstring sid ; /* lookupsid, sid_to_[ug]id */
2002-01-26 09:55:38 +00:00
struct {
fstring dom_name ; /* lookupname */
fstring name ;
} name ;
2000-06-30 06:48:47 +00:00
uint32 num_entries ; /* getpwent, getgrent */
2003-07-09 16:44:47 +00:00
struct {
fstring username ;
fstring groupname ;
} acct_mgt ;
2000-05-09 11:43:00 +00:00
} data ;
2002-12-20 01:25:27 +00:00
char null_term ;
2000-05-09 11:43:00 +00:00
} ;
/* Response values */
enum winbindd_result {
2000-06-14 09:58:12 +00:00
WINBINDD_ERROR ,
WINBINDD_OK
2000-05-09 11:43:00 +00:00
} ;
/* Winbind response structure */
struct winbindd_response {
2000-06-14 09:58:12 +00:00
/* Header information */
2000-05-09 11:43:00 +00:00
2002-01-10 23:45:29 +00:00
uint32 length ; /* Length of response */
2000-06-14 09:58:12 +00:00
enum winbindd_result result ; /* Result code */
2000-05-09 11:43:00 +00:00
2000-06-14 09:58:12 +00:00
/* Fixed length return data */
union {
2002-01-10 11:28:14 +00:00
int interface_version ; /* Try to ensure this is always in the same spot... */
2000-06-14 09:58:12 +00:00
2002-03-29 15:37:39 +00:00
fstring winsresp ; /* WINS response */
2000-06-30 06:48:47 +00:00
/* getpwnam, getpwuid */
2000-06-14 09:58:12 +00:00
2003-07-09 16:44:47 +00:00
struct winbindd_pw pw ;
2000-06-14 09:58:12 +00:00
2000-06-30 06:48:47 +00:00
/* getgrnam, getgrgid */
2000-06-14 09:58:12 +00:00
2003-07-09 16:44:47 +00:00
struct winbindd_gr gr ;
2000-06-14 09:58:12 +00:00
2000-06-30 06:48:47 +00:00
uint32 num_entries ; /* getpwent, getgrent */
2001-11-21 08:36:43 +00:00
struct winbindd_sid {
2000-07-05 11:24:26 +00:00
fstring sid ; /* lookupname, [ug]id_to_sid */
int type ;
} sid ;
2001-11-21 08:36:43 +00:00
struct winbindd_name {
2002-01-26 09:55:38 +00:00
fstring dom_name ; /* lookupsid */
fstring name ;
2000-06-14 09:58:12 +00:00
int type ;
} name ;
uid_t uid ; /* sid_to_uid */
gid_t gid ; /* sid_to_gid */
2002-01-10 11:28:14 +00:00
struct winbindd_info {
char winbind_separator ;
fstring samba_version ;
} info ;
2002-01-26 09:55:38 +00:00
fstring domain_name ;
2003-01-28 12:07:02 +00:00
fstring netbios_name ;
2002-02-05 09:40:36 +00:00
struct auth_reply {
uint32 nt_status ;
fstring nt_status_string ;
fstring error_string ;
int pam_error ;
2004-04-06 08:11:16 +00:00
char user_session_key [ 16 ] ;
2002-08-17 17:00:51 +00:00
char first_8_lm_hash [ 8 ] ;
2002-02-05 09:40:36 +00:00
} auth ;
2003-07-11 05:33:40 +00:00
uint32 rid ; /* create user or group */
2004-01-04 11:51:31 +00:00
struct {
fstring name ;
fstring alt_name ;
fstring sid ;
BOOL native_mode ;
2004-01-08 08:19:18 +00:00
BOOL active_directory ;
2004-01-04 11:51:31 +00:00
BOOL primary ;
uint32 sequence_number ;
} domain_info ;
2000-06-14 09:58:12 +00:00
} data ;
2000-05-09 11:43:00 +00:00
2000-06-14 09:58:12 +00:00
/* Variable length return data */
2000-05-09 11:43:00 +00:00
2000-06-14 09:58:12 +00:00
void * extra_data ; /* getgrnam, getgrgid, getgrent */
2000-05-09 11:43:00 +00:00
} ;
# endif