diff options
author | Jeremy Allison <jra@samba.org> | 1998-09-29 20:24:17 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-09-29 20:24:17 +0000 |
commit | 9066025a8a4afe1f7f559c455d86fc023792ed17 (patch) | |
tree | 6ced773fa584a81c9a0fe957cac357c1f8a9aa2d /source3 | |
parent | 282eb4f3e8ea2f19c5609bc498d24a68a1ca48a5 (diff) | |
download | samba-9066025a8a4afe1f7f559c455d86fc023792ed17.tar.gz samba-9066025a8a4afe1f7f559c455d86fc023792ed17.tar.bz2 samba-9066025a8a4afe1f7f559c455d86fc023792ed17.zip |
Got very strict about the differences and uses of
uid_t, gid_t and vuid. Added sys_getgroups() to get
around the int * return problem. Set correct datatypes
for all uid, gid and vuid variables.
Jeremy.
(This used to be commit e570db46fc3a78e499523fd342e9a34cebb18998)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/client/client.c | 61 | ||||
-rw-r--r-- | source3/client/clientutil.c | 17 | ||||
-rw-r--r-- | source3/client/smbmount.c | 17 | ||||
-rw-r--r-- | source3/include/client.h | 8 | ||||
-rw-r--r-- | source3/include/ntdomain.h | 4 | ||||
-rw-r--r-- | source3/include/proto.h | 19 | ||||
-rw-r--r-- | source3/include/smb.h | 35 | ||||
-rw-r--r-- | source3/lib/system.c | 50 | ||||
-rw-r--r-- | source3/lib/util.c | 14 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 76 | ||||
-rw-r--r-- | source3/libsmb/smbencrypt.c | 2 | ||||
-rw-r--r-- | source3/lsarpcd/srv_lsa.c | 70 | ||||
-rw-r--r-- | source3/rpc_server/srv_lsa.c | 70 | ||||
-rw-r--r-- | source3/rpc_server/srv_netlog.c | 30 | ||||
-rw-r--r-- | source3/rpc_server/srv_pipe_hnd.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_reg.c | 8 | ||||
-rw-r--r-- | source3/rpc_server/srv_samr.c | 34 | ||||
-rw-r--r-- | source3/rpc_server/srv_srvsvc.c | 12 | ||||
-rw-r--r-- | source3/rpc_server/srv_util.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_wkssvc.c | 2 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.c | 2 | ||||
-rw-r--r-- | source3/smbd/ipc.c | 2 | ||||
-rw-r--r-- | source3/smbd/password.c | 35 | ||||
-rw-r--r-- | source3/smbd/service.c | 2 | ||||
-rw-r--r-- | source3/smbd/uid.c | 38 |
25 files changed, 356 insertions, 256 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 0d27039cb9..c94c3ccb8c 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -71,12 +71,10 @@ extern int DEBUGLEVEL; BOOL translation = False; -extern int cnum; -extern int mid; -extern int pid; -extern int tid; -extern int gid; -extern int uid; +extern uint16 cnum; +extern uint16 mid; +extern uint16 pid; +extern uint16 vuid; extern BOOL have_ip; extern int max_xmit; @@ -805,17 +803,18 @@ static int do_short_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void ( /**************************************************************************** do a directory listing, calling fn on each file found ****************************************************************************/ -void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(file_info *),BOOL recurse_dir, BOOL dirstoo) +void do_dir(char *inbuf,char *outbuf,char *mask,int attribute,void (*fn)(file_info *),BOOL recurse_dir, BOOL dirstoo) { - DEBUG(5,("do_dir(%s,%x,%s)\n",Mask,attribute,BOOLSTR(recurse_dir))); + dos_format(mask); + DEBUG(5,("do_dir(%s,%x,%s)\n",mask,attribute,BOOLSTR(recurse_dir))); if (Protocol >= PROTOCOL_LANMAN2) { - if (do_long_dir(inbuf,outbuf,Mask,attribute,fn,recurse_dir,dirstoo) > 0) + if (do_long_dir(inbuf,outbuf,mask,attribute,fn,recurse_dir,dirstoo) > 0) return; } - expand_mask(Mask,False); - do_short_dir(inbuf,outbuf,Mask,attribute,fn,recurse_dir,dirstoo); + expand_mask(mask,False); + do_short_dir(inbuf,outbuf,mask,attribute,fn,recurse_dir,dirstoo); return; } @@ -1051,13 +1050,13 @@ static void cmd_dir(char *inbuf,char *outbuf) if(mask[strlen(mask)-1]!='\\') pstrcat(mask,"\\"); - if (next_token(NULL,buf,NULL,sizeof(buf))) - { - if (*p == '\\') - pstrcpy(mask,p); - else - pstrcat(mask,p); - } + if (next_token(NULL,buf,NULL,sizeof(buf))) { + dos_format(p); + if (*p == '\\') + pstrcpy(mask,p); + else + pstrcat(mask,p); + } else { pstrcat(mask,"*"); } @@ -1086,12 +1085,13 @@ static void cmd_du(char *inbuf,char *outbuf) pstrcat(mask,"\\"); if (next_token(NULL,buf,NULL,sizeof(buf))) - { - if (*p == '\\') - pstrcpy(mask,p); - else - pstrcat(mask,p); - } + { + dos_format(p); + if (*p == '\\') + pstrcpy(mask,p); + else + pstrcat(mask,p); + } else { pstrcat(mask,"*"); } @@ -1135,10 +1135,10 @@ static void do_get(char *rname,char *lname,file_info *finfo1) outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); if (!inbuf || !outbuf) - { - DEBUG(0,("out of memory\n")); - return; - } + { + DEBUG(0,("out of memory\n")); + return; + } bzero(outbuf,smb_size); set_message(outbuf,15,1 + strlen(rname),True); @@ -3807,9 +3807,8 @@ static void usage(char *pname) pstrcpy(workgroup,lp_workgroup()); load_interfaces(); - pid = getpid(); - uid = getuid(); - gid = getgid(); + pid = (uint16)getpid(); + vuid = (uint16)getuid(); mid = pid + 100; myumask = umask(0); umask(myumask); diff --git a/source3/client/clientutil.c b/source3/client/clientutil.c index 7f5943cb01..8b61567485 100644 --- a/source3/client/clientutil.c +++ b/source3/client/clientutil.c @@ -57,11 +57,10 @@ BOOL writebraw_supported = False; extern int DEBUGLEVEL; -int cnum = 0; -int pid = 0; -int gid = 0; -int uid = 0; -int mid = 0; +uint16 cnum = 0; +uint16 pid = 0; +uint16 vuid = 0; +uint16 mid = 0; int max_xmit = BUFFER_SIZE; @@ -80,7 +79,7 @@ setup basics in a outgoing packet void cli_setup_pkt(char *outbuf) { SSVAL(outbuf,smb_pid,pid); - SSVAL(outbuf,smb_uid,uid); + SSVAL(outbuf,smb_uid,vuid); SSVAL(outbuf,smb_mid,mid); if (Protocol > PROTOCOL_COREPLUS) { @@ -726,10 +725,10 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup, } /* use the returned uid from now on */ - if (SVAL(inbuf,smb_uid) != uid) + if (SVAL(inbuf,smb_uid) != vuid) DEBUG(3,("Server gave us a UID of %d. We gave %d\n", - SVAL(inbuf,smb_uid),uid)); - opt.server_uid = uid = SVAL(inbuf,smb_uid); + SVAL(inbuf,smb_uid),(int)vuid)); + opt.server_vuid = vuid = SVAL(inbuf,smb_uid); } if (opt.sec_mode & 1) { diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c index dadccc819d..60ee0605db 100644 --- a/source3/client/smbmount.c +++ b/source3/client/smbmount.c @@ -80,12 +80,10 @@ extern int DEBUGLEVEL; BOOL translation = False; -extern int cnum; -extern int mid; -extern int pid; -extern int tid; -extern int gid; -extern int uid; +extern uint16 cnum; +extern uint16 mid; +extern uint16 pid; +extern uint16 vuid; extern BOOL have_ip; extern int max_xmit; @@ -97,7 +95,7 @@ extern BOOL tar_reset; /* clitar bits end */ -int myumask = 0755; +mode_t myumask = 0755; extern pstring scope; @@ -642,9 +640,8 @@ static void usage(char *pname) TimeInit(); charset_initialise(); - pid = getpid(); - uid = getuid(); - gid = getgid(); + pid = (uint16)getpid(); + uid = (uint16)getuid(); mid = pid + 100; myumask = umask(0); umask(myumask); diff --git a/source3/include/client.h b/source3/include/client.h index dde377f484..2b71b37524 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -58,10 +58,10 @@ struct pwd_info struct cli_state { int fd; - int cnum; - int pid; - int mid; - int uid; + uint16 cnum; + uint16 pid; + uint16 mid; + uint16 vuid; int protocol; int sec_mode; int rap_error; diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h index efe7e663a0..8362dcb73f 100644 --- a/source3/include/ntdomain.h +++ b/source3/include/ntdomain.h @@ -58,7 +58,7 @@ typedef struct pipes_struct struct pipes_struct *next, *prev; int pnum; connection_struct *conn; - int uid; + uint16 vuid; BOOL open; /* open connection */ uint16 device_state; fstring name; @@ -88,7 +88,7 @@ struct api_struct { char *name; uint8 opnum; - void (*fn) (int uid, prs_struct*, prs_struct*); + void (*fn) (uint16 vuid, prs_struct*, prs_struct*); }; struct mem_desc diff --git a/source3/include/proto.h b/source3/include/proto.h index 38d02becea..4f29b3ae20 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5,7 +5,7 @@ /*The following definitions come from client/client.c */ -void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(file_info *),BOOL recurse_dir, BOOL dirstoo); +void do_dir(char *inbuf,char *outbuf,char *mask,int attribute,void (*fn)(file_info *),BOOL recurse_dir, BOOL dirstoo); char *complete_cmd_null(char *text, int state); void complete_process_file(file_info *f); char *complete_remote_file(char *text, int state); @@ -180,13 +180,14 @@ int dos_utime(char *fname,struct utimbuf *times); int dos_rename(char *from, char *to); int dos_chmod(char *fname,mode_t mode); char *dos_getwd(char *s); -int sys_chown(char *fname,int uid,int gid); +int sys_chown(char *fname,uid_t uid,gid_t gid); int sys_chroot(char *dname); struct hostent *sys_gethostbyname(char *name); BOOL set_process_capability( uint32 cap_flag, BOOL enable ); BOOL set_inherited_process_capability( uint32 cap_flag, BOOL enable ); long sys_random(void); void sys_srandom(unsigned int seed); +int sys_getgroups(int setlen, gid_t *gidset); /*The following definitions come from lib/time.c */ @@ -227,7 +228,7 @@ BOOL next_token(char **ptr,char *buff,char *sep, int bufsize); char **toktocliplist(int *ctok, char *sep); void set_socket_options(int fd, char *options); void close_sockets(void ); -BOOL in_group(gid_t group, int current_gid, int ngroups, GID_T *groups); +BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups); char *StrCpy(char *dest,char *src); char *StrnCpy(char *dest,char *src,int n); void putip(void *dest,void *src); @@ -315,8 +316,8 @@ BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask); int PutUniCode(char *dst,char *src); struct hostent *Get_Hostbyname(char *name); BOOL process_exists(int pid); -char *uidtoname(int uid); -char *gidtoname(int gid); +char *uidtoname(uid_t uid); +char *gidtoname(gid_t gid); void smb_panic(char *why); char *readdirname(void *p); BOOL is_in_path(char *name, name_compare_entry *namelist); @@ -400,7 +401,7 @@ BOOL cli_initialise(struct cli_state *cli); void cli_shutdown(struct cli_state *cli); void cli_error(struct cli_state *cli, int *eclass, int *num); void cli_sockopt(struct cli_state *cli, char *options); -int cli_setpid(struct cli_state *cli, int pid); +uint16 cli_setpid(struct cli_state *cli, uint16 pid); BOOL cli_reestablish_connection(struct cli_state *cli); BOOL cli_establish_connection(struct cli_state *cli, char *dest_host, struct in_addr *dest_ip, @@ -482,7 +483,7 @@ void SamOEMhash( unsigned char *data, unsigned char *key, int val); void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24); void E_md4hash(uchar *passwd, uchar *p16); void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]); -void SMBOWFencrypt(uchar passwd[16], char *c8, uchar p24[24]); +void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]); void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24); /*The following definitions come from libsmb/smberr.c */ @@ -2036,8 +2037,8 @@ BOOL set_challenge(unsigned char *challenge); user_struct *get_valid_user_struct(uint16 vuid); void invalidate_vuid(uint16 vuid); char *validated_username(uint16 vuid); -int setup_groups(char *user, int uid, int gid, int *p_ngroups, GID_T **p_groups); -uint16 register_vuid(int uid,int gid, char *unix_name, char *requested_name, BOOL guest); +int setup_groups(char *user, uid_t uid, gid_t gid, int *p_ngroups, gid_t **p_groups); +uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, BOOL guest); void add_session_user(char *user); BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned char *c8); BOOL smb_password_ok(struct smb_passwd *smb_pass, diff --git a/source3/include/smb.h b/source3/include/smb.h index f42951ec59..56b0e3bc24 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -345,8 +345,8 @@ struct sam_passwd char *unknown_str ; /* don't know what this is, yet. */ char *munged_dial ; /* munged path name and dial-back tel number */ - int smb_userid; /* this is actually the unix uid_t */ - int smb_grpid; /* this is actually the unix gid_t */ + uid_t smb_userid; /* this is actually the unix uid_t */ + gid_t smb_grpid; /* this is actually the unix gid_t */ uint32 user_rid; /* Primary User ID */ uint32 group_rid; /* Primary Group ID */ @@ -366,7 +366,7 @@ struct sam_passwd struct smb_passwd { - int smb_userid; /* this is actually the unix uid_t */ + uid_t smb_userid; /* this is actually the unix uid_t */ char *smb_name; /* username string */ unsigned char *smb_passwd; /* Null if no password */ @@ -447,7 +447,7 @@ typedef struct struct uid_cache { int entries; - int list[UID_CACHE_SIZE]; + uid_t list[UID_CACHE_SIZE]; }; typedef struct @@ -472,8 +472,8 @@ typedef struct connection_struct char *connectpath; char *origpath; char *user; /* name of user who *opened* this connection */ - int uid; /* uid of user who *opened* this connection */ - int gid; /* gid of user who *opened* this connection */ + uid_t uid; /* uid of user who *opened* this connection */ + gid_t gid; /* gid of user who *opened* this connection */ uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */ @@ -481,7 +481,7 @@ typedef struct connection_struct /* This groups info is valid for the user that *opened* the connection */ int ngroups; - GID_T *groups; + gid_t *groups; time_t lastused; BOOL used; @@ -494,10 +494,11 @@ typedef struct connection_struct struct current_user { connection_struct *conn; - int vuid; - int uid, gid; + uint16 vuid; + uid_t uid; + gid_t gid; int ngroups; - GID_T *groups; + gid_t *groups; }; typedef struct files_struct @@ -509,7 +510,7 @@ typedef struct files_struct SMB_OFF_T pos; SMB_OFF_T size; mode_t mode; - int vuid; + uint16 vuid; char *mmap_ptr; SMB_OFF_T mmap_size; write_bmpx_struct *wbmpx_ptr; @@ -542,8 +543,8 @@ struct dcinfo typedef struct { - int uid; /* uid of a validated user */ - int gid; /* gid of a validated user */ + uid_t uid; /* uid of a validated user */ + gid_t gid; /* gid of a validated user */ fstring requested_name; /* user name from the client */ fstring name; /* unix user name of a validated user */ @@ -553,7 +554,7 @@ typedef struct /* following groups stuff added by ih */ /* This groups info is needed for when we become_user() for this uid */ int n_groups; - GID_T *groups; + gid_t *groups; int n_sids; int *sids; @@ -714,8 +715,8 @@ struct connect_record int magic; int pid; int cnum; - int uid; - int gid; + uid_t uid; + gid_t gid; char name[24]; char addr[24]; char machine[128]; @@ -727,7 +728,7 @@ struct connection_options { int protocol; /* Connection-Options */ uint32 max_xmit; - uint16 server_uid; + uint16 server_vuid; uint16 tid; /* The following are LANMAN 1.0 options */ uint16 sec_mode; diff --git a/source3/lib/system.c b/source3/lib/system.c index f474633dd1..cae688eb4c 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -464,7 +464,7 @@ char *dos_getwd(char *s) /******************************************************************* chown isn't used much but OS/2 doesn't have it ********************************************************************/ -int sys_chown(char *fname,int uid,int gid) +int sys_chown(char *fname,uid_t uid,gid_t gid) { #ifndef HAVE_CHOWN static int done; @@ -634,3 +634,51 @@ void sys_srandom(unsigned int seed) exit(1); #endif } + +/************************************************************************** + Wrapper for getgroups. Deals with broken (int) case. +****************************************************************************/ + +int sys_getgroups(int setlen, gid_t *gidset) +{ +#if !defined(HAVE_BROKEN_GETGROUPS) + return getgroups(setlen, gidset); +#else + + GID_T gid; + GID_T *group_list; + int i, ngroups; + + if(setlen == 0) { + return getgroups(setlen, &gid); + } + + /* + * Broken case. We need to allocate a + * GID_T array of size setlen. + */ + + if(setlen < 0) { + errno = EINVAL; + return -1; + } + + if((group_list = (GID_T *)malloc(setlen * sizoef(GID_T))) == NULL) { + DEBUG(0,("sys_getgroups: Malloc fail.\n")); + return -1; + } + + if((ngroups = getgroups(setlen, group_list)) < 0) { + int saved_errno = errno; + free((char *)group_list); + errno = saved_errno; + return -1; + } + + for(i = 0; i < ngroups; i++) + gidset[i] = (gid_t)group_list[i]; + + free((char *)group_list); + return ngroups; +#endif /* HAVE_BROKEN_GETGROUPS */ +} diff --git a/source3/lib/util.c b/source3/lib/util.c index 8561c4f3f4..37c7a5519e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -346,7 +346,8 @@ void close_sockets(void ) /**************************************************************************** determine whether we are in the specified group ****************************************************************************/ -BOOL in_group(gid_t group, int current_gid, int ngroups, GID_T *groups) + +BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups) { int i; @@ -4033,6 +4034,7 @@ struct hostent *Get_Hostbyname(char *name) /**************************************************************************** check if a process exists. Does this work on all unixes? ****************************************************************************/ + BOOL process_exists(int pid) { return(kill(pid,0) == 0 || errno != ESRCH); @@ -4042,24 +4044,26 @@ BOOL process_exists(int pid) /******************************************************************* turn a uid into a user name ********************************************************************/ -char *uidtoname(int uid) + +char *uidtoname(uid_t uid) { static char name[40]; struct passwd *pass = getpwuid(uid); if (pass) return(pass->pw_name); - slprintf(name, sizeof(name) - 1, "%d",uid); + slprintf(name, sizeof(name) - 1, "%d",(int)uid); return(name); } /******************************************************************* turn a gid into a group name ********************************************************************/ -char *gidtoname(int gid) + +char *gidtoname(gid_t gid) { static char name[40]; struct group *grp = getgrgid(gid); if (grp) return(grp->gr_name); - slprintf(name,sizeof(name) - 1, "%d",gid); + slprintf(name,sizeof(name) - 1, "%d",(int)gid); return(name); } diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 214f6c4445..d77c58e00a 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -118,7 +118,7 @@ static void cli_setup_packet(struct cli_state *cli) cli->rap_error = 0; cli->nt_error = 0; SSVAL(cli->outbuf,smb_pid,cli->pid); - SSVAL(cli->outbuf,smb_uid,cli->uid); + SSVAL(cli->outbuf,smb_uid,cli->vuid); SSVAL(cli->outbuf,smb_mid,cli->mid); if (cli->protocol > PROTOCOL_CORE) { SCVAL(cli->outbuf,smb_flg,0x8); @@ -393,7 +393,10 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) p += 2; pstrcpy(p,user); strupper(p); - p += 21; p++; p += 15; p++; + p += 21; + p++; + p += 15; + p++; pstrcpy(p, workstation); strupper(p); p += 16; @@ -420,8 +423,10 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) } } - if (rparam) free(rparam); - if (rdata) free(rdata); + if (rparam) + free(rparam); + if (rdata) + free(rdata); return (cli->rap_error == 0); } @@ -476,8 +481,10 @@ BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(char *, uint32, char *) } } - if (rparam) free(rparam); - if (rdata) free(rdata); + if (rparam) + free(rparam); + if (rdata) + free(rdata); return(count>0); } @@ -547,8 +554,10 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, } } - if (rparam) free(rparam); - if (rdata) free(rdata); + if (rparam) + free(rparam); + if (rdata) + free(rdata); return(count > 0); } @@ -665,8 +674,8 @@ BOOL cli_session_setup(struct cli_state *cli, return False; } - /* use the returned uid from now on */ - cli->uid = SVAL(cli->inbuf,smb_uid); + /* use the returned vuid from now on */ + cli->vuid = SVAL(cli->inbuf,smb_uid); return True; } @@ -1690,21 +1699,23 @@ initialise a client structure ****************************************************************************/ BOOL cli_initialise(struct cli_state *cli) { - if (cli->initialised) cli_shutdown(cli); + if (cli->initialised) + cli_shutdown(cli); memset(cli, 0, sizeof(*cli)); cli->fd = -1; cli->cnum = -1; - cli->pid = getpid(); + cli->pid = (uint16)getpid(); cli->mid = 1; - cli->uid = getuid(); + cli->vuid = UID_FIELD_INVALID; cli->protocol = PROTOCOL_NT1; cli->timeout = 20000; cli->bufsize = 0x10000; cli->max_xmit = cli->bufsize - 4; cli->outbuf = (char *)malloc(cli->bufsize); cli->inbuf = (char *)malloc(cli->bufsize); - if (!cli->outbuf || !cli->inbuf) return False; + if (!cli->outbuf || !cli->inbuf) + return False; cli->initialised = 1; return True; } @@ -1714,12 +1725,16 @@ shutdown a client structure ****************************************************************************/ void cli_shutdown(struct cli_state *cli) { - if (cli->outbuf) free(cli->outbuf); - if (cli->inbuf) free(cli->inbuf); + if (cli->outbuf) + free(cli->outbuf); + if (cli->inbuf) + free(cli->inbuf); #ifdef WITH_SSL - if (cli->fd != -1) sslutil_disconnect(cli->fd); + if (cli->fd != -1) + sslutil_disconnect(cli->fd); #endif /* WITH_SSL */ - if (cli->fd != -1) close(cli->fd); + if (cli->fd != -1) + close(cli->fd); memset(cli, 0, sizeof(*cli)); } @@ -1743,9 +1758,9 @@ void cli_sockopt(struct cli_state *cli, char *options) /**************************************************************************** set the PID to use for smb messages. Return the old pid. ****************************************************************************/ -int cli_setpid(struct cli_state *cli, int pid) +uint16 cli_setpid(struct cli_state *cli, uint16 pid) { - int ret = cli->pid; + uint16 ret = cli->pid; cli->pid = pid; return ret; } @@ -1826,14 +1841,16 @@ BOOL cli_establish_connection(struct cli_state *cli, if (!cli_session_request(cli, calling, called)) { DEBUG(1,("failed session request\n")); - if (do_shutdown) cli_shutdown(cli); + if (do_shutdown) + cli_shutdown(cli); return False; } if (!cli_negprot(cli)) { DEBUG(1,("failed negprot\n")); - if (do_shutdown) cli_shutdown(cli); + if (do_shutdown) + cli_shutdown(cli); return False; } @@ -1852,7 +1869,8 @@ BOOL cli_establish_connection(struct cli_state *cli, cli->domain)) { DEBUG(1,("failed session setup\n")); - if (do_shutdown) cli_shutdown(cli); + if (do_shutdown) + cli_shutdown(cli); return False; } if (do_tcon) @@ -1861,7 +1879,8 @@ BOOL cli_establish_connection(struct cli_state *cli, (char*)passwd, strlen(passwd))) { DEBUG(1,("failed tcon_X\n")); - if (do_shutdown) cli_shutdown(cli); + if (do_shutdown) + cli_shutdown(cli); return False; } } @@ -1883,7 +1902,8 @@ BOOL cli_establish_connection(struct cli_state *cli, cli->domain)) { DEBUG(1,("failed session setup\n")); - if (do_shutdown) cli_shutdown(cli); + if (do_shutdown) + cli_shutdown(cli); return False; } @@ -1893,13 +1913,15 @@ BOOL cli_establish_connection(struct cli_state *cli, (char*)nt_sess_pwd, sizeof(nt_sess_pwd))) { DEBUG(1,("failed tcon_X\n")); - if (do_shutdown) cli_shutdown(cli); + if (do_shutdown) + cli_shutdown(cli); return False; } } } - if (do_shutdown) cli_shutdown(cli); + if (do_shutdown) + cli_shutdown(cli); return True; } diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c index 045008fac9..5a946e22c9 100644 --- a/source3/libsmb/smbencrypt.c +++ b/source3/libsmb/smbencrypt.c @@ -121,7 +121,7 @@ void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]) } /* Does the des encryption from the NT or LM MD4 hash. */ -void SMBOWFencrypt(uchar passwd[16], char *c8, uchar p24[24]) +void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]) { uchar p21[21]; diff --git a/source3/lsarpcd/srv_lsa.c b/source3/lsarpcd/srv_lsa.c index 35ceeace04..85e10275b8 100644 --- a/source3/lsarpcd/srv_lsa.c +++ b/source3/lsarpcd/srv_lsa.c @@ -286,7 +286,7 @@ static void lsa_reply_lookup_rids(prs_struct *rdata, /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static void api_lsa_open_policy( int uid, prs_struct *data, +static void api_lsa_open_policy( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL q_o; @@ -305,7 +305,7 @@ static void api_lsa_open_policy( int uid, prs_struct *data, /*************************************************************************** api_lsa_enum_trust_dom ***************************************************************************/ -static void api_lsa_enum_trust_dom( int uid, prs_struct *data, +static void api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_ENUM_TRUST_DOM q_e; @@ -316,14 +316,13 @@ static void api_lsa_enum_trust_dom( int uid, prs_struct *data, lsa_io_q_enum_trust_dom("", &q_e, data, 0); /* construct reply. return status is always 0x0 */ - lsa_reply_enum_trust_dom(&q_e, rdata, - 0, NULL, NULL); + lsa_reply_enum_trust_dom(&q_e, rdata, 0, NULL, NULL); } /*************************************************************************** api_lsa_query_info ***************************************************************************/ -static void api_lsa_query_info( int uid, prs_struct *data, +static void api_lsa_query_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_QUERY_INFO q_i; @@ -343,7 +342,7 @@ static void api_lsa_query_info( int uid, prs_struct *data, /*************************************************************************** api_lsa_lookup_sids ***************************************************************************/ -static void api_lsa_lookup_sids( int uid, prs_struct *data, +static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_SIDS q_l; @@ -363,20 +362,20 @@ static void api_lsa_lookup_sids( int uid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); /* construct reply. return status is always 0x0 */ - lsa_reply_lookup_sids(rdata, - q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ - dom_name, &global_machine_sid, /* domain name, domain SID */ - &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ + lsa_reply_lookup_sids(rdata, + q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ + dom_name, &global_machine_sid, /* domain name, domain SID */ + &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ } /*************************************************************************** api_lsa_lookup_names ***************************************************************************/ -static void api_lsa_lookup_names( int uid, prs_struct *data, +static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata ) { int i; @@ -400,8 +399,8 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); SMB_ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); @@ -437,18 +436,24 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, /*************************************************************************** api_lsa_close ***************************************************************************/ -static void api_lsa_close( int uid, prs_struct *data, +static void api_lsa_close( uint16 vuid, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ char *q = mem_data(&(rdata->data), rdata->offset); - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; rdata->offset += 24; } @@ -456,18 +461,24 @@ static void api_lsa_close( int uid, prs_struct *data, /*************************************************************************** api_lsa_open_secret ***************************************************************************/ -static void api_lsa_open_secret( int uid, prs_struct *data, +static void api_lsa_open_secret( uint16 vuid, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ char *q = mem_data(&(rdata->data), rdata->offset); - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); + q += 4; rdata->offset += 24; } @@ -494,4 +505,3 @@ BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data); } - diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 35ceeace04..85e10275b8 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -286,7 +286,7 @@ static void lsa_reply_lookup_rids(prs_struct *rdata, /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static void api_lsa_open_policy( int uid, prs_struct *data, +static void api_lsa_open_policy( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL q_o; @@ -305,7 +305,7 @@ static void api_lsa_open_policy( int uid, prs_struct *data, /*************************************************************************** api_lsa_enum_trust_dom ***************************************************************************/ -static void api_lsa_enum_trust_dom( int uid, prs_struct *data, +static void api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_ENUM_TRUST_DOM q_e; @@ -316,14 +316,13 @@ static void api_lsa_enum_trust_dom( int uid, prs_struct *data, lsa_io_q_enum_trust_dom("", &q_e, data, 0); /* construct reply. return status is always 0x0 */ - lsa_reply_enum_trust_dom(&q_e, rdata, - 0, NULL, NULL); + lsa_reply_enum_trust_dom(&q_e, rdata, 0, NULL, NULL); } /*************************************************************************** api_lsa_query_info ***************************************************************************/ -static void api_lsa_query_info( int uid, prs_struct *data, +static void api_lsa_query_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_QUERY_INFO q_i; @@ -343,7 +342,7 @@ static void api_lsa_query_info( int uid, prs_struct *data, /*************************************************************************** api_lsa_lookup_sids ***************************************************************************/ -static void api_lsa_lookup_sids( int uid, prs_struct *data, +static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_SIDS q_l; @@ -363,20 +362,20 @@ static void api_lsa_lookup_sids( int uid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); /* construct reply. return status is always 0x0 */ - lsa_reply_lookup_sids(rdata, - q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ - dom_name, &global_machine_sid, /* domain name, domain SID */ - &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ + lsa_reply_lookup_sids(rdata, + q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ + dom_name, &global_machine_sid, /* domain name, domain SID */ + &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ } /*************************************************************************** api_lsa_lookup_names ***************************************************************************/ -static void api_lsa_lookup_names( int uid, prs_struct *data, +static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata ) { int i; @@ -400,8 +399,8 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); SMB_ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); @@ -437,18 +436,24 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, /*************************************************************************** api_lsa_close ***************************************************************************/ -static void api_lsa_close( int uid, prs_struct *data, +static void api_lsa_close( uint16 vuid, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ char *q = mem_data(&(rdata->data), rdata->offset); - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; rdata->offset += 24; } @@ -456,18 +461,24 @@ static void api_lsa_close( int uid, prs_struct *data, /*************************************************************************** api_lsa_open_secret ***************************************************************************/ -static void api_lsa_open_secret( int uid, prs_struct *data, +static void api_lsa_open_secret( uint16 vuid, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ char *q = mem_data(&(rdata->data), rdata->offset); - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); + q += 4; rdata->offset += 24; } @@ -494,4 +505,3 @@ BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data); } - diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index cb22cfddf0..17a534b6f0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -267,7 +267,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) /************************************************************************* api_net_req_chal: *************************************************************************/ -static void api_net_req_chal( int uid, +static void api_net_req_chal( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -279,9 +279,10 @@ static void api_net_req_chal( int uid, user_struct *vuser; - DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, uid)); + DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid)); - if ((vuser = get_valid_user_struct(uid)) == NULL) return; + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; /* grab the challenge... */ net_io_q_req_chal("", &q_r, data, 0); @@ -327,7 +328,7 @@ static void api_net_req_chal( int uid, /************************************************************************* api_net_auth_2: *************************************************************************/ -static void api_net_auth_2( int uid, +static void api_net_auth_2( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -339,7 +340,8 @@ static void api_net_auth_2( int uid, user_struct *vuser; - if ((vuser = get_valid_user_struct(uid)) == NULL) return; + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; srv_time.time = 0; @@ -371,7 +373,7 @@ static void api_net_auth_2( int uid, /************************************************************************* api_net_srv_pwset: *************************************************************************/ -static void api_net_srv_pwset( int uid, +static void api_net_srv_pwset( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -383,7 +385,8 @@ static void api_net_srv_pwset( int uid, BOOL ret; user_struct *vuser; - if ((vuser = get_valid_user_struct(uid)) == NULL) return; + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; /* grab the challenge and encrypted password ... */ net_io_q_srv_pwset("", &q_a, data, 0); @@ -452,7 +455,7 @@ static void api_net_srv_pwset( int uid, /************************************************************************* api_net_sam_logoff: *************************************************************************/ -static void api_net_sam_logoff( int uid, +static void api_net_sam_logoff( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -463,7 +466,8 @@ static void api_net_sam_logoff( int uid, user_struct *vuser; - if ((vuser = get_valid_user_struct(uid)) == NULL) return; + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; /* the DOM_ID_INFO_1 structure is a bit big. plus we might want to dynamically allocate it inside net_io_q_sam_logon, at some point */ @@ -572,7 +576,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, /************************************************************************* api_net_sam_logon: *************************************************************************/ -static void api_net_sam_logon( int uid, +static void api_net_sam_logon( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -586,7 +590,7 @@ static void api_net_sam_logon( int uid, user_struct *vuser = NULL; - if ((vuser = get_valid_user_struct(uid)) == NULL) + if ((vuser = get_valid_user_struct(vuid)) == NULL) return; q_l.sam_id.ctr = &ctr; @@ -795,7 +799,7 @@ static void api_net_sam_logon( int uid, /************************************************************************* api_net_trust_dom_list: *************************************************************************/ -static void api_net_trust_dom_list( int uid, +static void api_net_trust_dom_list( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -825,7 +829,7 @@ static void api_net_trust_dom_list( int uid, /************************************************************************* api_net_logon_ctrl2: *************************************************************************/ -static void api_net_logon_ctrl2( int uid, +static void api_net_logon_ctrl2( uint16 vuid, prs_struct *data, prs_struct *rdata) { diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index cf7fc9334e..301510730b 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -112,7 +112,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->open = True; p->device_state = 0; p->conn = conn; - p->uid = vuid; + p->vuid = vuid; p->rhdr.data = NULL; p->rdata.data = NULL; diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 3f9cdc20f4..c153a78ee1 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -61,7 +61,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static void api_reg_close( int uid, prs_struct *data, +static void api_reg_close( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_CLOSE q_r; @@ -100,7 +100,7 @@ static void reg_reply_open(REG_Q_OPEN_POLICY *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static void api_reg_open( int uid, prs_struct *data, +static void api_reg_open( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_POLICY q_u; @@ -160,7 +160,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static void api_reg_open_entry( int uid, prs_struct *data, +static void api_reg_open_entry( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_ENTRY q_u; @@ -205,7 +205,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static void api_reg_info( int uid, prs_struct *data, +static void api_reg_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_INFO q_u; diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c2140db36f..2516637599 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -131,7 +131,7 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, /******************************************************************* api_samr_close_hnd ********************************************************************/ -static void api_samr_close_hnd( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_close_hnd( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CLOSE_HND q_u; @@ -190,7 +190,7 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, /******************************************************************* api_samr_open_domain ********************************************************************/ -static void api_samr_open_domain( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_domain( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_DOMAIN q_u; @@ -266,7 +266,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, /******************************************************************* api_samr_unknown_3 ********************************************************************/ -static void api_samr_unknown_3( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_3( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_3 q_u; @@ -318,7 +318,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, /******************************************************************* api_samr_enum_dom_users ********************************************************************/ -static void api_samr_enum_dom_users( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_users( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_USERS q_e; @@ -373,7 +373,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, /******************************************************************* api_samr_enum_dom_groups ********************************************************************/ -static void api_samr_enum_dom_groups( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_groups( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_GROUPS q_e; @@ -428,7 +428,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, /******************************************************************* api_samr_enum_dom_aliases ********************************************************************/ -static void api_samr_enum_dom_aliases( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_aliases( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_ALIASES q_e; @@ -512,7 +512,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, /******************************************************************* api_samr_query_dispinfo ********************************************************************/ -static void api_samr_query_dispinfo( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DISPINFO q_e; @@ -565,7 +565,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, /******************************************************************* api_samr_query_aliasinfo ********************************************************************/ -static void api_samr_query_aliasinfo( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_aliasinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASINFO q_e; @@ -642,7 +642,7 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, /******************************************************************* api_samr_lookup_ids ********************************************************************/ -static void api_samr_lookup_ids( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_ids( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_IDS q_u; @@ -701,7 +701,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, /******************************************************************* api_samr_lookup_names ********************************************************************/ -static void api_samr_lookup_names( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_NAMES q_u; @@ -762,7 +762,7 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, /******************************************************************* api_samr_unknown_12 ********************************************************************/ -static void api_samr_unknown_12( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_12( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_12 q_u; @@ -836,7 +836,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, /******************************************************************* api_samr_open_user ********************************************************************/ -static void api_samr_open_user( int rid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_user( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_USER q_u; @@ -1004,7 +1004,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, /******************************************************************* api_samr_query_userinfo ********************************************************************/ -static void api_samr_query_userinfo( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_userinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERINFO q_u; @@ -1082,7 +1082,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /******************************************************************* api_samr_query_usergroups ********************************************************************/ -static void api_samr_query_usergroups( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_usergroups( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERGROUPS q_u; /* grab the samr unknown 32 */ @@ -1128,7 +1128,7 @@ static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, /******************************************************************* api_samr_unknown_32 ********************************************************************/ -static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdata) { uint32 status = 0; struct sam_passwd *sam_pass; @@ -1211,7 +1211,7 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, /******************************************************************* api_samr_connect ********************************************************************/ -static void api_samr_connect( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_connect( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT q_u; @@ -1264,7 +1264,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, /******************************************************************* api_samr_open_alias ********************************************************************/ -static void api_samr_open_alias( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_ALIAS q_u; diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index a4ae3fa0ef..c7aeee9b11 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -904,7 +904,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, /******************************************************************* ********************************************************************/ -static void api_srv_net_srv_get_info( int uid, prs_struct *data, +static void api_srv_net_srv_get_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SRV_GET_INFO q_n; @@ -919,7 +919,7 @@ static void api_srv_net_srv_get_info( int uid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_file_enum( int uid, prs_struct *data, +static void api_srv_net_file_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_FILE_ENUM q_n; @@ -937,7 +937,7 @@ static void api_srv_net_file_enum( int uid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_conn_enum( int uid, prs_struct *data, +static void api_srv_net_conn_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_CONN_ENUM q_n; @@ -955,7 +955,7 @@ static void api_srv_net_conn_enum( int uid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_sess_enum( int uid, prs_struct *data, +static void api_srv_net_sess_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SESS_ENUM q_n; @@ -973,7 +973,7 @@ static void api_srv_net_sess_enum( int uid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_share_enum( int uid, prs_struct *data, +static void api_srv_net_share_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SHARE_ENUM q_n; @@ -1029,7 +1029,7 @@ static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, } /******************************************************************* ********************************************************************/ -static void api_srv_net_remote_tod( int uid, prs_struct *data, +static void api_srv_net_remote_tod( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_REMOTE_TOD q_n; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 3c0fc9271e..fc78c656fd 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -246,7 +246,7 @@ static BOOL api_rpc_command(pipes_struct *p, /* do the actual command */ p->rdata.offset = 0; - api_rpc_cmds[fn_num].fn(p->uid, data, &(p->rdata)); + api_rpc_cmds[fn_num].fn(p->vuid, data, &(p->rdata)); if (p->rdata.data == NULL || p->rdata.offset == 0) { diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 5bea006b2c..acb5cde831 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -80,7 +80,7 @@ static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, /******************************************************************* api_wks_query_info ********************************************************************/ -static void api_wks_query_info( int uid, prs_struct *data, +static void api_wks_query_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { WKS_Q_QUERY_INFO q_u; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 2921144108..4918610d88 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -739,7 +739,7 @@ enum client_action { case CLIENT_IPC: { - process(&cli_info, cmd_str) ? 0 : 1; + process(&cli_info, cmd_str); break; } diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index ec126c89ff..db6ee62f91 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -2383,7 +2383,7 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param Don't depend on vuser being non-null !!. JRA */ user_struct *vuser = get_valid_user_struct(vuid); if(vuser != NULL) - DEBUG(3,(" Username of UID %d is %s\n", vuser->uid, vuser->name)); + DEBUG(3,(" Username of UID %d is %s\n", (int)vuser->uid, vuser->name)); *rparam_len = 6; *rparam = REALLOC(*rparam,*rparam_len); diff --git a/source3/smbd/password.c b/source3/smbd/password.c index f542dbe608..5a7e20e47e 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -107,7 +107,7 @@ user_struct *get_valid_user_struct(uint16 vuid) return NULL; vuid -= VUID_OFFSET; if ((vuid >= (uint16)num_validated_users) || - (validated_users[vuid].uid == -1) || (validated_users[vuid].gid == -1)) + (validated_users[vuid].uid == (uid_t)-1) || (validated_users[vuid].gid == (gid_t)-1)) return NULL; return &validated_users[vuid]; } @@ -121,17 +121,19 @@ void invalidate_vuid(uint16 vuid) if (vuser == NULL) return; - vuser->uid = -1; - vuser->gid = -1; + vuser->uid = (uid_t)-1; + vuser->gid = (gid_t)-1; vuser->n_sids = 0; /* same number of igroups as groups */ vuser->n_groups = 0; - if (vuser->groups) free(vuser->groups); + if (vuser->groups) + free((char *)vuser->groups); - if (vuser->sids) free(vuser->sids); + if (vuser->sids) + free((char *)vuser->sids); vuser->sids = NULL; vuser->groups = NULL; @@ -153,11 +155,11 @@ char *validated_username(uint16 vuid) /**************************************************************************** Setup the groups a user belongs to. ****************************************************************************/ -int setup_groups(char *user, int uid, int gid, int *p_ngroups, GID_T **p_groups) +int setup_groups(char *user, uid_t uid, gid_t gid, int *p_ngroups, gid_t **p_groups) { int i,ngroups; - GID_T *groups; - GID_T grp = 0; + gid_t grp = 0; + gid_t *groups = NULL; if (-1 == initgroups(user,gid)) { if (getuid() == 0) { @@ -170,15 +172,18 @@ int setup_groups(char *user, int uid, int gid, int *p_ngroups, GID_T **p_groups) return -1; } - ngroups = getgroups(0,&grp); - if (ngroups <= 0) ngroups = 32; + ngroups = sys_getgroups(0,&grp); + if (ngroups <= 0) + ngroups = 32; - groups = (GID_T *)malloc(sizeof(groups[0])*ngroups); + if((groups = (gid_t *)malloc(sizeof(gid_t)*ngroups)) == NULL) { + DEBUG(0,("setup_groups malloc fail !\n")); + return -1; + } - ngroups = getgroups(ngroups,(gid_t *)groups); + ngroups = sys_getgroups(ngroups,groups); (*p_ngroups) = ngroups; - (*p_groups) = groups; DEBUG( 3, ( "%s is in %d groups: ", user, ngroups ) ); @@ -196,7 +201,7 @@ register a uid/name pair as being valid and that a valid password has been given. vuid is biased by an offset. This allows us to tell random client vuid's (normally zero) from valid vuids. ****************************************************************************/ -uint16 register_vuid(int uid,int gid, char *unix_name, char *requested_name, BOOL guest) +uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, BOOL guest) { user_struct *vuser; struct passwd *pwfile; /* for getting real name from passwd file */ @@ -258,7 +263,7 @@ uint16 register_vuid(int uid,int gid, char *unix_name, char *requested_name, BOO &vuser->n_groups, &vuser->groups); - DEBUG(3,("uid %d registered to name %s\n",uid,unix_name)); + DEBUG(3,("uid %d registered to name %s\n",(int)uid,unix_name)); DEBUG(3, ("Clearing default real name\n")); fstrcpy(vuser->real_name, "<Full Name>\0"); diff --git a/source3/smbd/service.c b/source3/smbd/service.c index b0c74aa53e..ee195e12ec 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -485,7 +485,7 @@ connection_struct *make_connection(char *service,char *user,char *password, int dbgtext( "%s (%s) ", remote_machine, client_addr(Client) ); dbgtext( "connect to service %s ", lp_servicename(SNUM(conn)) ); dbgtext( "as user %s ", user ); - dbgtext( "(uid=%d, gid=%d) ", conn->uid, conn->gid ); + dbgtext( "(uid=%d, gid=%d) ", (int)conn->uid, (int)conn->gid ); dbgtext( "(pid %d)\n", (int)getpid() ); } diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 4ffec90521..7cd8c8673c 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -23,8 +23,8 @@ extern int DEBUGLEVEL; -static int initial_uid; -static int initial_gid; +static uid_t initial_uid; +static gid_t initial_gid; /* what user is current? */ extern struct current_user current_user; @@ -61,17 +61,16 @@ void init_uid(void) /**************************************************************************** become the specified uid ****************************************************************************/ -static BOOL become_uid(int uid) +static BOOL become_uid(uid_t uid) { if (initial_uid != 0) { return(True); } - if (uid == -1 || uid == 65535) { + if (uid == (uid_t)-1 || ((sizeof(uid_t) == 2) && (uid == (uid_t)65535))) { static int done; if (!done) { - DEBUG(1,("WARNING: using uid %d is a security risk\n", - uid)); + DEBUG(1,("WARNING: using uid %d is a security risk\n",(int)uid)); done=1; } } @@ -79,9 +78,9 @@ static BOOL become_uid(int uid) #ifdef HAVE_TRAPDOOR_UID #ifdef HAVE_SETUIDX /* AIX3 has setuidx which is NOT a trapoor function (tridge) */ - if (setuidx(ID_EFFECTIVE, (uid_t)uid) != 0) { - if (seteuid((uid_t)uid) != 0) { - DEBUG(1,("Can't set uid (setuidx)\n")); + if (setuidx(ID_EFFECTIVE, uid) != 0) { + if (seteuid(uid) != 0) { + DEBUG(1,("Can't set uid %d (setuidx)\n", (int)uid)); return False; } } @@ -96,14 +95,14 @@ static BOOL become_uid(int uid) #endif { DEBUG(0,("Couldn't set uid %d currently set to (%d,%d)\n", - uid,(int)getuid(), (int)geteuid())); - if (uid > 32000) { + (int)uid,(int)getuid(), (int)geteuid())); + if (uid > (uid_t)32000) { DEBUG(0,("Looks like your OS doesn't like high uid values - try using a different account\n")); } return(False); } - if (((uid == -1) || (uid == 65535)) && geteuid() != uid) { + if (((uid == (uid_t)-1) || ((sizeof(uid_t) == 2) && (uid == 65535))) && (geteuid() != uid)) { DEBUG(0,("Invalid uid -1. perhaps you have a account with uid 65535?\n")); return(False); } @@ -117,13 +116,13 @@ static BOOL become_uid(int uid) /**************************************************************************** become the specified gid ****************************************************************************/ -static BOOL become_gid(int gid) +static BOOL become_gid(gid_t gid) { if (initial_uid != 0) return(True); - if (gid == -1 || gid == 65535) { - DEBUG(1,("WARNING: using gid %d is a security risk\n",gid)); + if (gid == (gid_t)-1 || ((sizeof(gid_t) == 2) && (gid == (gid_t)65535))) { + DEBUG(1,("WARNING: using gid %d is a security risk\n",(int)gid)); } #ifdef HAVE_SETRESUID @@ -133,7 +132,7 @@ static BOOL become_gid(int gid) #endif { DEBUG(0,("Couldn't set gid %d currently set to (%d,%d)\n", - gid,(int)getgid(),(int)getegid())); + (int)gid,(int)getgid(),(int)getegid())); if (gid > 32000) { DEBUG(0,("Looks like your OS doesn't like high gid values - try using a different account\n")); } @@ -149,7 +148,7 @@ static BOOL become_gid(int gid) /**************************************************************************** become the specified uid and gid ****************************************************************************/ -static BOOL become_id(int uid,int gid) +static BOOL become_id(uid_t uid,gid_t gid) { return(become_gid(gid) && become_uid(uid)); } @@ -213,8 +212,9 @@ static BOOL check_user_ok(connection_struct *conn, user_struct *vuser,int snum) BOOL become_user(connection_struct *conn, uint16 vuid) { user_struct *vuser = get_valid_user_struct(vuid); - int snum,gid; - int uid; + int snum; + gid_t gid; + uid_t uid; /* * We need a separate check in security=share mode due to vuid |