mirror of
https://github.com/samba-team/samba.git
synced 2025-12-14 20:23:54 +03:00
Makefile :
added srvparse.o and pipesrvsvc.o smb.h : mods to the Net Share Enum stuff srvparse.c : Net Share Enum parsing support. more srvsvc pipe parsing to go here... pipenetlog.c util.c: modified standard_sub_basic() so that you can set a global boolean and use a different string for the %U username substitution. proto.h: the usual.
This commit is contained in:
@@ -651,6 +651,9 @@ BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len);
|
||||
|
||||
/*The following definitions come from pipesrvsvc.c */
|
||||
|
||||
BOOL api_srvsvcTNP(int cnum,int uid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
@@ -884,6 +887,12 @@ struct smb_passwd *get_smbpwnam(char *name);
|
||||
/*The following definitions come from smbrun.c */
|
||||
|
||||
|
||||
/*The following definitions come from srvparse.c */
|
||||
|
||||
char* srv_io_q_net_share_enum(BOOL io, SRV_Q_NET_SHARE_ENUM *q_n, char *q, char *base, int align, int depth);
|
||||
char* srv_io_r_net_share_enum(BOOL io, SRV_R_NET_SHARE_ENUM *r_n, char *q, char *base, int align, int depth);
|
||||
char* srv_io_q_net_share_enum(BOOL io, SRV_Q_NET_SHARE_ENUM *q_n, char *q, char *base, int align, int depth);
|
||||
|
||||
/*The following definitions come from status.c */
|
||||
|
||||
void Ucrit_addUsername(pstring username);
|
||||
|
||||
@@ -565,6 +565,7 @@ typedef struct lsa_r_query_info
|
||||
{
|
||||
DOM_QUERY_3 id3;
|
||||
DOM_QUERY_5 id5;
|
||||
|
||||
} dom;
|
||||
|
||||
uint32 status; /* return code */
|
||||
@@ -840,17 +841,17 @@ typedef struct lsa_r_sam_logoff_info
|
||||
/* SH_INFO_1 (pointers to level 1 share info strings) */
|
||||
typedef struct ptr_share_info1
|
||||
{
|
||||
uint32 ptr_shi1_netname; /* pointer to net name. */
|
||||
uint32 shi1_type; /* type of share. 0 - undocumented. */
|
||||
uint32 ptr_shi1_remark; /* pointer to comment. */
|
||||
uint32 ptr_netname; /* pointer to net name. */
|
||||
uint32 type; /* type of share. 0 - undocumented. */
|
||||
uint32 ptr_remark; /* pointer to comment. */
|
||||
|
||||
} SH_INFO_1;
|
||||
|
||||
/* SH_INFO_1_STR (level 1 share info strings) */
|
||||
typedef struct str_share_info1
|
||||
{
|
||||
UNISTR2 uni_shi1_netname; /* unicode string of net name */
|
||||
UNISTR2 uni_shi1_remark; /* unicode string of comment. */
|
||||
UNISTR2 uni_netname; /* unicode string of net name */
|
||||
UNISTR2 uni_remark; /* unicode string of comment. */
|
||||
|
||||
} SH_INFO_1_STR;
|
||||
|
||||
@@ -879,8 +880,13 @@ typedef struct q_net_share_enum_info
|
||||
uint32 share_level; /* share level */
|
||||
uint32 switch_value; /* switch value */
|
||||
|
||||
uint32* ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
|
||||
SHARE_INFO_1_CTR share_info; /* share info with 0 entries */
|
||||
uint32 ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
|
||||
|
||||
union
|
||||
{
|
||||
SHARE_INFO_1_CTR info1; /* share info with 0 entries */
|
||||
|
||||
} share;
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
|
||||
@@ -893,8 +899,12 @@ typedef struct r_net_share_enum_info
|
||||
uint32 share_level; /* share level */
|
||||
uint32 switch_value; /* switch value */
|
||||
|
||||
uint32* ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
|
||||
SHARE_INFO_1_CTR share_info; /* share info with 0 entries */
|
||||
uint32 ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
|
||||
union
|
||||
{
|
||||
SHARE_INFO_1_CTR info1; /* share info container */
|
||||
|
||||
} share;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
|
||||
@@ -72,7 +72,12 @@ static enum remote_arch_types ra_type = RA_UNKNOWN;
|
||||
fstring remote_proto="UNKNOWN";
|
||||
pstring myhostname="";
|
||||
pstring user_socket_options="";
|
||||
|
||||
pstring sesssetup_user="";
|
||||
pstring samlogon_user="";
|
||||
|
||||
BOOL sam_logon_in_ssb = False;
|
||||
|
||||
pstring myname = "";
|
||||
fstring myworkgroup = "";
|
||||
char **my_netbios_names;
|
||||
@@ -3603,38 +3608,49 @@ Rewritten by Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu> and
|
||||
Paul Rippin <pr3245@nopc.eurostat.cec.be>
|
||||
********************************************************************/
|
||||
void standard_sub_basic(char *str)
|
||||
{
|
||||
char *s, *p;
|
||||
char pidstr[10];
|
||||
struct passwd *pass;
|
||||
{
|
||||
char *s, *p;
|
||||
char pidstr[10];
|
||||
struct passwd *pass;
|
||||
char *username = sam_logon_in_ssb ? samlogon_user : sesssetup_user;
|
||||
|
||||
for (s = str ; (p = strchr(s,'%')) != NULL ; s = p )
|
||||
{
|
||||
switch (*(p+1))
|
||||
{
|
||||
case 'G' : if ((pass = Get_Pwnam(sesssetup_user,False))!=NULL)
|
||||
string_sub(p,"%G",gidtoname(pass->pw_gid));
|
||||
else
|
||||
p += 2;
|
||||
break;
|
||||
case 'I' : string_sub(p,"%I",client_addr()); break;
|
||||
case 'L' : string_sub(p,"%L",local_machine); break;
|
||||
case 'M' : string_sub(p,"%M",client_name()); break;
|
||||
case 'R' : string_sub(p,"%R",remote_proto); break;
|
||||
case 'T' : string_sub(p,"%T",timestring()); break;
|
||||
case 'U' : string_sub(p,"%U",sesssetup_user); break;
|
||||
case 'a' : string_sub(p,"%a",remote_arch); break;
|
||||
case 'd' : sprintf(pidstr,"%d",(int)getpid());
|
||||
string_sub(p,"%d",pidstr);
|
||||
break;
|
||||
case 'h' : string_sub(p,"%h",myhostname); break;
|
||||
case 'm' : string_sub(p,"%m",remote_machine); break;
|
||||
case 'v' : string_sub(p,"%v",VERSION); break;
|
||||
case '\0' : p++; break; /* don't run off end if last character is % */
|
||||
default : p+=2; break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
for (s = str ; (p = strchr(s,'%')) != NULL ; s = p )
|
||||
{
|
||||
switch (*(p+1))
|
||||
{
|
||||
case 'G' :
|
||||
{
|
||||
if ((pass = Get_Pwnam(sesssetup_user,False))!=NULL)
|
||||
{
|
||||
string_sub(p,"%G",gidtoname(pass->pw_gid));
|
||||
}
|
||||
else
|
||||
{
|
||||
p += 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'I' : string_sub(p,"%I", client_addr()); break;
|
||||
case 'L' : string_sub(p,"%L", local_machine); break;
|
||||
case 'M' : string_sub(p,"%M", client_name()); break;
|
||||
case 'R' : string_sub(p,"%R", remote_proto); break;
|
||||
case 'T' : string_sub(p,"%T", timestring()); break;
|
||||
case 'U' : string_sub(p,"%U", username); break;
|
||||
case 'a' : string_sub(p,"%a", remote_arch); break;
|
||||
case 'd' :
|
||||
{
|
||||
sprintf(pidstr,"%d",(int)getpid());
|
||||
string_sub(p,"%d", pidstr);
|
||||
break;
|
||||
}
|
||||
case 'h' : string_sub(p,"%h", myhostname); break;
|
||||
case 'm' : string_sub(p,"%m", remote_machine); break;
|
||||
case 'v' : string_sub(p,"%v", VERSION); break;
|
||||
case '\0': p++; break; /* don't run off end if last character is % */
|
||||
default : p+=2; break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
extern BOOL sam_logon_in_ssb;
|
||||
extern pstring samlogon_user;
|
||||
|
||||
#ifdef NTDOMAIN
|
||||
|
||||
@@ -505,7 +507,6 @@ static void api_lsa_sam_logon( user_struct *vuser,
|
||||
pstring my_name;
|
||||
pstring my_workgroup;
|
||||
pstring dom_sid;
|
||||
pstring username;
|
||||
extern pstring myname;
|
||||
|
||||
dummy_time.low = 0xffffffff;
|
||||
@@ -513,12 +514,16 @@ static void api_lsa_sam_logon( user_struct *vuser,
|
||||
|
||||
get_myname(myname, NULL);
|
||||
|
||||
pstrcpy(samlogon_user, unistr2(q_l.sam_id.auth.id1.uni_user_name.buffer));
|
||||
|
||||
/* hack to get standard_sub_basic() to use the sam logon username */
|
||||
sam_logon_in_ssb = True;
|
||||
|
||||
pstrcpy(logon_script, lp_logon_script());
|
||||
pstrcpy(profile_path, lp_logon_path ());
|
||||
pstrcpy(dom_sid , lp_domainsid ());
|
||||
pstrcpy(my_workgroup, lp_workgroup ());
|
||||
|
||||
pstrcpy(username, unistr2(q_l.sam_id.auth.id1.uni_user_name.buffer));
|
||||
pstrcpy(my_name , myname );
|
||||
strupper(my_name);
|
||||
|
||||
@@ -528,8 +533,10 @@ static void api_lsa_sam_logon( user_struct *vuser,
|
||||
pstrcpy(home_dir , vuser->home_share);
|
||||
#else
|
||||
pstrcpy(home_dir , "\\\\%L\\%U");
|
||||
standard_sub_basic(home_dir);
|
||||
#endif
|
||||
standard_sub_basic(home_dir);
|
||||
|
||||
sam_logon_in_ssb = False;
|
||||
|
||||
make_lsa_user_info(&usr_info,
|
||||
|
||||
@@ -540,7 +547,7 @@ static void api_lsa_sam_logon( user_struct *vuser,
|
||||
&dummy_time, /* pass_can_change_time */
|
||||
&dummy_time, /* pass_must_change_time */
|
||||
|
||||
username, /* user_name */
|
||||
samlogon_user, /* user_name */
|
||||
vuser->real_name, /* full_name */
|
||||
logon_script, /* logon_script */
|
||||
profile_path, /* profile_path */
|
||||
|
||||
199
source/srvparse.c
Normal file
199
source/srvparse.c
Normal file
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
Copyright (C) Luke Leighton 1996 - 1997 Paul Ashton 1997
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
char* srv_io_share_info1_str(BOOL io, SH_INFO_1_STR *sh1, char *q, char *base, int align, int depth)
|
||||
{
|
||||
if (sh1 == NULL) return NULL;
|
||||
|
||||
DEBUG(5,("%s%04x srv_io_share_info1_str\n", tab_depth(depth), PTR_DIFF(q, base)));
|
||||
depth++;
|
||||
|
||||
q = align_offset(q, base, align);
|
||||
|
||||
q = smb_io_unistr2(io, &(sh1->uni_netname), q, base, align, depth);
|
||||
q = smb_io_unistr2(io, &(sh1->uni_remark ), q, base, align, depth);
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
char* srv_io_share_info1(BOOL io, SH_INFO_1 *sh1, char *q, char *base, int align, int depth)
|
||||
{
|
||||
if (sh1 == NULL) return NULL;
|
||||
|
||||
DEBUG(5,("%s%04x srv_io_share_info1\n", tab_depth(depth), PTR_DIFF(q, base)));
|
||||
depth++;
|
||||
|
||||
q = align_offset(q, base, align);
|
||||
|
||||
DBG_RW_IVAL("ptr_netname", depth, base, io, q, sh1->ptr_netname); q += 4;
|
||||
DBG_RW_IVAL("type ", depth, base, io, q, sh1->type ); q += 4;
|
||||
DBG_RW_IVAL("ptr_remark ", depth, base, io, q, sh1->ptr_remark); q += 4;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
char* srv_io_share_1_ctr(BOOL io, SHARE_INFO_1_CTR *ctr, char *q, char *base, int align, int depth)
|
||||
{
|
||||
if (ctr == NULL) return NULL;
|
||||
|
||||
DEBUG(5,("%s%04x srv_io_share_1_ctr\n", tab_depth(depth), PTR_DIFF(q, base)));
|
||||
depth++;
|
||||
|
||||
q = align_offset(q, base, align);
|
||||
|
||||
DBG_RW_IVAL("num_entries_read", depth, base, io, q, ctr->num_entries_read); q += 4;
|
||||
DBG_RW_IVAL("ptr_share_info", depth, base, io, q, ctr->ptr_share_info); q += 4;
|
||||
|
||||
if (ctr->ptr_share_info != 0)
|
||||
{
|
||||
int i;
|
||||
int max_entries = ctr->num_entries_read;
|
||||
if (max_entries > MAX_SHARE_ENTRIES)
|
||||
{
|
||||
max_entries = MAX_SHARE_ENTRIES; /* report this! */
|
||||
}
|
||||
|
||||
for (i = 0; i < max_entries; i++)
|
||||
{
|
||||
q = srv_io_share_info1(io, &(ctr->info_1[i]), q, base, align, depth);
|
||||
}
|
||||
|
||||
for (i = 0; i < max_entries; i++)
|
||||
{
|
||||
q = srv_io_share_info1_str(io, &(ctr->info_1_str[i]), q, base, align, depth);
|
||||
}
|
||||
|
||||
DBG_RW_IVAL("num_entries_read2", depth, base, io, q, ctr->num_entries_read); q += 4;
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
char* srv_io_q_net_share_enum(BOOL io, SRV_Q_NET_SHARE_ENUM *q_n, char *q, char *base, int align, int depth)
|
||||
{
|
||||
if (q_n == NULL) return NULL;
|
||||
|
||||
DEBUG(5,("%s%04x srv_io_q_net_share_enum\n", tab_depth(depth), PTR_DIFF(q, base)));
|
||||
depth++;
|
||||
|
||||
q = align_offset(q, base, align);
|
||||
|
||||
DBG_RW_IVAL("ptr_srv_name", depth, base, io, q, q_n->ptr_srv_name); q += 4;
|
||||
q = smb_io_unistr2(io, &(q_n->uni_srv_name), q, base, align, depth);
|
||||
|
||||
q = align_offset(q, base, align);
|
||||
|
||||
DBG_RW_IVAL("share_level ", depth, base, io, q, q_n->share_level); q += 4;
|
||||
DBG_RW_IVAL("switch_value ", depth, base, io, q, q_n->switch_value); q += 4;
|
||||
|
||||
DBG_RW_IVAL("ptr_share_info", depth, base, io, q, q_n->ptr_share_info); q += 4;
|
||||
if (q_n->ptr_share_info != 0)
|
||||
{
|
||||
switch (q_n->switch_value)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
q = srv_io_share_1_ctr(io, &(q_n->share.info1), q, base, align, depth);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DEBUG(5,("%s% no share info at switch_value %d\n",
|
||||
tab_depth(depth), q_n->switch_value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DBG_RW_IVAL("preferred_len ", depth, base, io, q, q_n->preferred_len); q += 4;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
char* srv_io_r_net_share_enum(BOOL io, SRV_R_NET_SHARE_ENUM *r_n, char *q, char *base, int align, int depth)
|
||||
{
|
||||
if (r_n == NULL) return NULL;
|
||||
|
||||
DEBUG(5,("%s%04x srv_io_q_net_share_enum\n", tab_depth(depth), PTR_DIFF(q, base)));
|
||||
depth++;
|
||||
|
||||
q = align_offset(q, base, align);
|
||||
|
||||
DBG_RW_IVAL("share_level ", depth, base, io, q, r_n->share_level); q += 4;
|
||||
DBG_RW_IVAL("switch_value ", depth, base, io, q, r_n->switch_value); q += 4;
|
||||
|
||||
DBG_RW_IVAL("ptr_share_info", depth, base, io, q, r_n->ptr_share_info); q += 4;
|
||||
if (r_n->ptr_share_info != 0)
|
||||
{
|
||||
switch (r_n->switch_value)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
q = srv_io_share_1_ctr(io, &(r_n->share.info1), q, base, align, depth);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DEBUG(5,("%s% no share info at switch_value %d\n",
|
||||
tab_depth(depth), r_n->switch_value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DBG_RW_IVAL("status ", depth, base, io, q, r_n->status); q += 4;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*******************************************************************
|
||||
reads or writes a structure.
|
||||
********************************************************************/
|
||||
char* lsa_io_(BOOL io, *, char *q, char *base, int align, int depth)
|
||||
{
|
||||
if (== NULL) return NULL;
|
||||
|
||||
q = align_offset(q, base, align);
|
||||
|
||||
DBG_RW_IVAL("", depth, base, io, q, ); q += 4;
|
||||
|
||||
return q;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user