mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
Makefile client.c clientutil.c clitar.c nmbsync.c :
redid the split that i did a year ago, taking the functions in client.c
out into clientutil.c. guess what? we could now do encrypted password
NetServerEnum2 calls in nmbd, if we wanted to.
i can now use cli_call_api() to send to different pipes. i hope.
pipenetlog.c:
allow adding to users group _and_ to admin group. if adding to
guest group, don't allow adding to users or admin as well.
smb.h :
added some pipe #defines (\PIPE\NETLOGON \PIPE\srvsvc ...)
proto.h :
usual.
(This used to be commit 6ee065ce6e
)
This commit is contained in:
parent
2e8cedba64
commit
5897f0493d
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -461,7 +461,7 @@ static int do_setrattr(char *fname, int attr, int setit)
|
||||
set_message(outbuf,0,2 + strlen(fname),True);
|
||||
CVAL(outbuf,smb_com) = SMBgetatr;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
p = smb_buf(outbuf);
|
||||
*p++ = 4;
|
||||
@ -497,7 +497,7 @@ static int do_setrattr(char *fname, int attr, int setit)
|
||||
set_message(outbuf,8,4 + strlen(fname),True);
|
||||
CVAL(outbuf,smb_com) = SMBsetatr;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
SSVAL(outbuf,smb_vwv0,attr);
|
||||
|
||||
@ -537,7 +537,7 @@ static BOOL smbcreat(file_info finfo, int *fnum, char *inbuf, char *outbuf)
|
||||
set_message(outbuf,3,2 + strlen(finfo.name),True);
|
||||
CVAL(outbuf,smb_com) = SMBcreate;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
SSVAL(outbuf,smb_vwv0,finfo.mode);
|
||||
put_dos_date3(outbuf,smb_vwv1,finfo.mtime);
|
||||
@ -576,7 +576,7 @@ static BOOL smbwrite(int fnum, int n, int low, int high, int left,
|
||||
set_message(outbuf,5,n + 3, False);
|
||||
CVAL(outbuf,smb_com) = SMBwrite;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
SSVAL(outbuf,smb_vwv0,fnum);
|
||||
SSVAL(outbuf,smb_vwv1,n);
|
||||
@ -615,7 +615,7 @@ static BOOL smbshut(file_info finfo, int fnum, char *inbuf, char *outbuf)
|
||||
set_message(outbuf,3,0,True);
|
||||
CVAL(outbuf,smb_com) = SMBclose;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
SSVAL(outbuf,smb_vwv0,fnum);
|
||||
put_dos_date3(outbuf,smb_vwv1,finfo.mtime);
|
||||
@ -648,7 +648,7 @@ static BOOL smbchkpath(char *fname, char *inbuf, char *outbuf)
|
||||
set_message(outbuf,0,4 + strlen(fname),True);
|
||||
CVAL(outbuf,smb_com) = SMBchkpth;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
p = smb_buf(outbuf);
|
||||
*p++ = 4;
|
||||
@ -675,7 +675,7 @@ static BOOL smbmkdir(char *fname, char *inbuf, char *outbuf)
|
||||
|
||||
CVAL(outbuf,smb_com) = SMBmkdir;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
p = smb_buf(outbuf);
|
||||
*p++ = 4;
|
||||
@ -798,7 +798,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
|
||||
|
||||
CVAL(outbuf,smb_com) = SMBopenX;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
SSVAL(outbuf,smb_vwv0,0xFF);
|
||||
SSVAL(outbuf,smb_vwv2,1);
|
||||
@ -834,7 +834,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
|
||||
{
|
||||
if (CVAL(inbuf,smb_rcls) == ERRSRV &&
|
||||
SVAL(inbuf,smb_err) == ERRnoresource &&
|
||||
reopen_connection(inbuf,outbuf))
|
||||
cli_reopen_connection(inbuf,outbuf))
|
||||
{
|
||||
do_atar(rname,lname,finfo1);
|
||||
free(inbuf);free(outbuf);
|
||||
@ -930,7 +930,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
|
||||
set_message(outbuf,10,0,True);
|
||||
CVAL(outbuf,smb_com) = SMBreadX;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
if (close_done)
|
||||
{
|
||||
@ -996,7 +996,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
|
||||
set_message(outbuf,8,0,True);
|
||||
CVAL(outbuf,smb_com) = SMBreadbraw;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
SSVAL(outbuf,smb_vwv0,fnum);
|
||||
SIVAL(outbuf,smb_vwv1,nread);
|
||||
SSVAL(outbuf,smb_vwv3,MIN(finfo.size-nread,readbraw_size));
|
||||
@ -1048,7 +1048,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
|
||||
set_message(outbuf,5,0,True);
|
||||
CVAL(outbuf,smb_com) = SMBread;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
SSVAL(outbuf,smb_vwv0,fnum);
|
||||
SSVAL(outbuf,smb_vwv1,MIN(max_xmit-200,finfo.size - nread));
|
||||
@ -1111,7 +1111,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
|
||||
set_message(outbuf,3,0,True);
|
||||
CVAL(outbuf,smb_com) = SMBclose;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
setup_pkt(outbuf);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
SSVAL(outbuf,smb_vwv0,fnum);
|
||||
SIVALS(outbuf,smb_vwv1,-1);
|
||||
|
@ -36,11 +36,8 @@ BOOL chgpasswd(char *name,char *oldpass,char *newpass);
|
||||
|
||||
/*The following definitions come from client.c */
|
||||
|
||||
void setup_pkt(char *outbuf);
|
||||
void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(),BOOL recurse_dir);
|
||||
void cmd_help(void);
|
||||
BOOL reopen_connection(char *inbuf,char *outbuf);
|
||||
char *smb_errstr(char *inbuf);
|
||||
|
||||
/*The following definitions come from clientgen.c */
|
||||
|
||||
@ -62,12 +59,24 @@ void cli_shutdown(struct cli_state *cli);
|
||||
|
||||
/*The following definitions come from clientutil.c */
|
||||
|
||||
BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setup);
|
||||
void cli_send_logout(void);
|
||||
BOOL cli_call_api(int prcnt,int drcnt,int mprcnt,int mdrcnt,int *rprcnt,
|
||||
int *rdrcnt, char *param,char *data,
|
||||
char **rparam, char **rdata);
|
||||
BOOL cli_open_sockets(int port);
|
||||
void cli_setup_pkt(char *outbuf);
|
||||
BOOL cli_call_api(char *pipe_name, int prcnt,int drcnt,
|
||||
int mprcnt,int mdrcnt,
|
||||
int *rprcnt,int *rdrcnt,
|
||||
char *param,char *data,
|
||||
char **rparam,char **rdata);
|
||||
BOOL cli_receive_trans_response(char *inbuf,int trans,
|
||||
int *data_len,int *param_len,
|
||||
char **data,char **param);
|
||||
BOOL cli_send_trans_request(char *outbuf,int trans,
|
||||
char *name,int fid,int flags,
|
||||
char *data,char *param,uint16 *setup,
|
||||
int ldata,int lparam,int lsetup,
|
||||
int mdata,int mparam,int msetup);
|
||||
BOOL cli_send_session_request(char *inbuf,char *outbuf);
|
||||
BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup);
|
||||
void cli_send_logout(void );
|
||||
BOOL cli_open_sockets(int port );
|
||||
BOOL cli_reopen_connection(char *inbuf,char *outbuf);
|
||||
char *smb_errstr(char *inbuf);
|
||||
|
||||
|
@ -260,6 +260,12 @@ typedef char fstring[128];
|
||||
typedef fstring string;
|
||||
|
||||
|
||||
/* pipe strings */
|
||||
#define PIPE_LANMAN "\\PIPE\\LANMAN"
|
||||
#define PIPE_SRVSVC "\\PIPE\\srvsvc"
|
||||
#define PIPE_NETLOGON "\\PIPE\\NETLOGON"
|
||||
#define PIPE_NTLSA "\\PIPE\\ntlsa"
|
||||
|
||||
/* NETLOGON opcodes and data structures */
|
||||
|
||||
#define NET_QUERYFORPDC 7 /* Query for PDC */
|
||||
|
@ -82,7 +82,8 @@ static BOOL add_info(struct subnet_record *d, struct work_record *work, int serv
|
||||
pstrcpy(p, work->work_group);
|
||||
p = skip_string(p,1);
|
||||
|
||||
if (cli_call_api(PTR_DIFF(p,param),0, 8,BUFFER_SIZE - SAFETY_MARGIN,
|
||||
if (cli_call_api(PIPE_LANMAN, PTR_DIFF(p,param),0, 8,
|
||||
BUFFER_SIZE - SAFETY_MARGIN,
|
||||
&rprcnt,&rdrcnt, param,NULL,
|
||||
&rparam,&rdata))
|
||||
{
|
||||
|
@ -516,6 +516,7 @@ static void api_lsa_sam_logon( user_struct *vuser,
|
||||
pstring domain_groups;
|
||||
pstring dom_sid;
|
||||
pstring other_sids;
|
||||
fstring tmp;
|
||||
extern pstring myname;
|
||||
uint32 r_uid;
|
||||
uint32 r_gid;
|
||||
@ -545,22 +546,28 @@ static void api_lsa_sam_logon( user_struct *vuser,
|
||||
/* any additional groups this user is in. e.g power users */
|
||||
pstrcpy(domain_groups, lp_domain_groups());
|
||||
|
||||
/* one RID group always added: 512 (Admin); 513 (Users); 514 (Guests) */
|
||||
|
||||
/* can only be a user or a guest. cannot be guest _and_ admin */
|
||||
if (user_in_list(samlogon_user, lp_domain_guest_users()))
|
||||
{
|
||||
DEBUG(3,("domain guest access granted\n"));
|
||||
strcat(domain_groups, " 514/7 ");
|
||||
}
|
||||
else if (user_in_list(samlogon_user, lp_domain_admin_users()))
|
||||
{
|
||||
DEBUG(3,("domain admin access granted\n"));
|
||||
strcat(domain_groups, " 512/7 ");
|
||||
sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS);
|
||||
strcat(domain_groups, tmp);
|
||||
|
||||
DEBUG(3,("domain guest access %s granted\n", tmp));
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(3,("domain user access granted\n"));
|
||||
strcat(domain_groups, " 513/7 ");
|
||||
sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_USERS);
|
||||
strcat(domain_groups, tmp);
|
||||
|
||||
DEBUG(3,("domain user access %s granted\n", tmp));
|
||||
|
||||
if (user_in_list(samlogon_user, lp_domain_admin_users()))
|
||||
{
|
||||
sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS);
|
||||
strcat(domain_groups, tmp);
|
||||
|
||||
DEBUG(3,("domain admin access %s granted\n", tmp));
|
||||
}
|
||||
}
|
||||
|
||||
num_gids = make_dom_gids(domain_groups, gids);
|
||||
|
Loading…
Reference in New Issue
Block a user