1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

r17039: Eliminate snum from enumshares and getshareinfo. Get rid of some pstrings.

Volker
(This used to be commit c5e393d5ed)
This commit is contained in:
Volker Lendecke 2006-07-14 22:06:38 +00:00 committed by Gerald (Jerry) Carter
parent 5b474afa74
commit 2203228c79
5 changed files with 242 additions and 125 deletions

View File

@ -544,6 +544,10 @@ struct share_params {
int service; int service;
}; };
struct share_iterator {
int next_id;
};
typedef struct connection_struct { typedef struct connection_struct {
struct connection_struct *next, *prev; struct connection_struct *next, *prev;
TALLOC_CTX *mem_ctx; TALLOC_CTX *mem_ctx;

View File

@ -665,7 +665,7 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
/**************************************************************************** /****************************************************************************
****************************************************************************/ ****************************************************************************/
char *alloc_sub_advanced(const char *servicename, const char *user, static char *alloc_sub_advanced(const char *servicename, const char *user,
const char *connectpath, gid_t gid, const char *connectpath, gid_t gid,
const char *smb_name, const char *domain_name, const char *smb_name, const char *domain_name,
const char *str) const char *str)
@ -731,6 +731,29 @@ char *alloc_sub_advanced(const char *servicename, const char *user,
return ret_string; return ret_string;
} }
/*
* This obviously is inefficient and needs to be merged into
* alloc_sub_advanced...
*/
char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
const char *servicename, const char *user,
const char *connectpath, gid_t gid,
const char *smb_name, const char *domain_name,
const char *str)
{
char *a, *t;
if (!(a = alloc_sub_advanced(servicename, user, connectpath, gid,
smb_name, domain_name, str))) {
return NULL;
}
t = talloc_strdup(mem_ctx, a);
SAFE_FREE(a);
return t;
}
void standard_sub_advanced(const char *servicename, const char *user, void standard_sub_advanced(const char *servicename, const char *user,
const char *connectpath, gid_t gid, const char *connectpath, gid_t gid,
const char *smb_name, const char *domain_name, const char *smb_name, const char *domain_name,

View File

@ -386,7 +386,7 @@ static int recycle_unlink(vfs_handle_struct *handle, const char *file_name)
BOOL exist; BOOL exist;
int rc = -1; int rc = -1;
repository = alloc_sub_advanced(lp_servicename(SNUM(conn)), repository = talloc_sub_advanced(NULL, lp_servicename(SNUM(conn)),
conn->user, conn->user,
conn->connectpath, conn->gid, conn->connectpath, conn->gid,
get_current_username(), get_current_username(),
@ -534,7 +534,7 @@ done:
SAFE_FREE(path_name); SAFE_FREE(path_name);
SAFE_FREE(temp_name); SAFE_FREE(temp_name);
SAFE_FREE(final_name); SAFE_FREE(final_name);
SAFE_FREE(repository); TALLOC_FREE(repository);
return rc; return rc;
} }

View File

@ -5137,6 +5137,65 @@ BOOL share_defined(const char *service_name)
return (lp_servicenumber(service_name) != -1); return (lp_servicenumber(service_name) != -1);
} }
struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
const char *sharename)
{
struct share_params *result;
fstring sname;
int snum;
fstrcpy(sname, sharename);
snum = find_service(sname);
if (snum < 0) {
return NULL;
}
if (!(result = TALLOC_P(mem_ctx, struct share_params))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
result->service = snum;
return result;
}
struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx)
{
struct share_iterator *result;
if (!(result = TALLOC_P(mem_ctx, struct share_iterator))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
result->next_id = 0;
return result;
}
struct share_params *next_share(struct share_iterator *list)
{
struct share_params *result;
while (!lp_snum_ok(list->next_id) &&
(list->next_id < lp_numservices())) {
list->next_id += 1;
}
if (list->next_id >= lp_numservices()) {
return NULL;
}
if (!(result = TALLOC_P(list, struct share_params))) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
result->service = list->next_id;
list->next_id += 1;
return result;
}
/******************************************************************* /*******************************************************************
A useful volume label function. A useful volume label function.
********************************************************************/ ********************************************************************/

View File

@ -200,19 +200,19 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, FILE_INFO_3 **info,
} }
/******************************************************************* /*******************************************************************
Utility function to get the 'type' of a share from an snum. Utility function to get the 'type' of a share from a share definition.
********************************************************************/ ********************************************************************/
static uint32 get_share_type(int snum) static uint32 get_share_type(const struct share_params *params)
{ {
char *net_name = lp_servicename(snum); char *net_name = lp_servicename(params->service);
int len_net_name = strlen(net_name); int len_net_name = strlen(net_name);
/* work out the share type */ /* work out the share type */
uint32 type = STYPE_DISKTREE; uint32 type = STYPE_DISKTREE;
if (lp_print_ok(snum)) if (lp_print_ok(params->service))
type = STYPE_PRINTQ; type = STYPE_PRINTQ;
if (strequal(lp_fstype(snum), "IPC")) if (strequal(lp_fstype(params->service), "IPC"))
type = STYPE_IPC; type = STYPE_IPC;
if (net_name[len_net_name] == '$') if (net_name[len_net_name] == '$')
type |= STYPE_HIDDEN; type |= STYPE_HIDDEN;
@ -224,12 +224,10 @@ static uint32 get_share_type(int snum)
Fill in a share info level 0 structure. Fill in a share info level 0 structure.
********************************************************************/ ********************************************************************/
static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum) static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0,
const struct share_params *params)
{ {
pstring net_name; char *net_name = lp_servicename(params->service);
pstrcpy(net_name, lp_servicename(snum));
init_srv_share_info0(&sh0->info_0, net_name); init_srv_share_info0(&sh0->info_0, net_name);
init_srv_share_info0_str(&sh0->info_0_str, net_name); init_srv_share_info0_str(&sh0->info_0_str, net_name);
} }
@ -238,20 +236,21 @@ static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int sn
Fill in a share info level 1 structure. Fill in a share info level 1 structure.
********************************************************************/ ********************************************************************/
static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1,
const struct share_params *params)
{ {
connection_struct *conn = p->conn; connection_struct *conn = p->conn;
pstring remark; char *net_name = lp_servicename(params->service);
char *remark;
char *net_name = lp_servicename(snum); remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
pstrcpy(remark, lp_comment(snum)); conn->user, conn->connectpath, conn->gid,
standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, get_current_username(),
conn->connectpath, conn->gid, current_user_info.domain,
get_current_username(), lp_comment(params->service));
current_user_info.domain,
remark, sizeof(remark));
init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark); init_srv_share_info1(&sh1->info_1, net_name, get_share_type(params),
remark);
init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); init_srv_share_info1_str(&sh1->info_1_str, net_name, remark);
} }
@ -259,40 +258,37 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn
Fill in a share info level 2 structure. Fill in a share info level 2 structure.
********************************************************************/ ********************************************************************/
static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2,
const struct share_params *params)
{ {
connection_struct *conn = p->conn; connection_struct *conn = p->conn;
pstring remark; char *remark;
pstring path; char *path;
pstring passwd; int max_connections = lp_max_connections(params->service);
int max_connections = lp_max_connections(snum);
uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff;
int count = 0; int count = 0;
char *net_name = lp_servicename(snum); char *net_name = lp_servicename(params->service);
pstrcpy(remark, lp_comment(snum)); remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, conn->user, conn->connectpath, conn->gid,
conn->connectpath, conn->gid, get_current_username(),
get_current_username(), current_user_info.domain,
current_user_info.domain, lp_comment(params->service));
remark, sizeof(remark)); path = talloc_asprintf(p->mem_ctx, "C:%s",
pstrcpy(path, "C:"); lp_pathname(params->service));
pstrcat(path, lp_pathname(snum));
/* /*
* Change / to \\ so that win2k will see it as a valid path. This was added to * Change / to \\ so that win2k will see it as a valid path. This was
* enable use of browsing in win2k add share dialog. * added to enable use of browsing in win2k add share dialog.
*/ */
string_replace(path, '/', '\\'); string_replace(path, '/', '\\');
pstrcpy(passwd, "");
count = count_current_connections( net_name, False ); count = count_current_connections( net_name, False );
init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), init_srv_share_info2(&sh2->info_2, net_name, get_share_type(params),
remark, 0, max_uses, count, path, passwd); remark, 0, max_uses, count, path, "");
init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, "");
} }
/******************************************************************* /*******************************************************************
@ -361,20 +357,22 @@ out:
Fill in a share info level 501 structure. Fill in a share info level 501 structure.
********************************************************************/ ********************************************************************/
static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501,
const struct share_params *params)
{ {
connection_struct *conn = p->conn; connection_struct *conn = p->conn;
pstring remark; char *remark;
const char *net_name = lp_servicename(params->service);
const char *net_name = lp_servicename(snum); remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
pstrcpy(remark, lp_comment(snum)); conn->user, conn->connectpath, conn->gid,
standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, get_current_username(),
conn->connectpath, conn->gid, current_user_info.domain,
get_current_username(), lp_comment(params->service));
current_user_info.domain,
remark, sizeof(remark));
init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); init_srv_share_info501(&sh501->info_501, net_name,
get_share_type(params), remark,
(lp_csc_policy(params->service) << 4));
init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); init_srv_share_info501_str(&sh501->info_501_str, net_name, remark);
} }
@ -382,13 +380,13 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501,
Fill in a share info level 502 structure. Fill in a share info level 502 structure.
********************************************************************/ ********************************************************************/
static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum) static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502,
const struct share_params *params)
{ {
connection_struct *conn = p->conn; connection_struct *conn = p->conn;
pstring net_name; char *net_name;
pstring remark; char *remark;
pstring path; char *path;
pstring passwd;
SEC_DESC *sd; SEC_DESC *sd;
size_t sd_size; size_t sd_size;
TALLOC_CTX *ctx = p->mem_ctx; TALLOC_CTX *ctx = p->mem_ctx;
@ -396,46 +394,50 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502,
ZERO_STRUCTP(sh502); ZERO_STRUCTP(sh502);
pstrcpy(net_name, lp_servicename(snum)); net_name = lp_servicename(params->service);
pstrcpy(remark, lp_comment(snum));
standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
conn->connectpath, conn->gid, conn->user, conn->connectpath, conn->gid,
get_current_username(), get_current_username(),
current_user_info.domain, current_user_info.domain,
remark, sizeof(remark)); lp_comment(params->service));
pstrcpy(path, "C:");
pstrcat(path, lp_pathname(snum)); path = talloc_asprintf(p->mem_ctx, "C:%s",
lp_pathname(params->service));
/* /*
* Change / to \\ so that win2k will see it as a valid path. This was added to * Change / to \\ so that win2k will see it as a valid path. This was
* enable use of browsing in win2k add share dialog. * added to enable use of browsing in win2k add share dialog.
*/ */
string_replace(path, '/', '\\'); string_replace(path, '/', '\\');
pstrcpy(passwd, ""); sd = get_share_security(ctx, lp_servicename(params->service),
&sd_size);
sd = get_share_security(ctx, lp_servicename(snum), &sd_size); init_srv_share_info502(&sh502->info_502, net_name,
get_share_type(params), remark, 0, 0xffffffff,
init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); 1, path, "", sd, sd_size);
init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); init_srv_share_info502_str(&sh502->info_502_str, net_name, remark,
path, "", sd, sd_size);
} }
/*************************************************************************** /***************************************************************************
Fill in a share info level 1004 structure. Fill in a share info level 1004 structure.
***************************************************************************/ ***************************************************************************/
static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) static void init_srv_share_info_1004(pipes_struct *p,
SRV_SHARE_INFO_1004* sh1004,
const struct share_params *params)
{ {
connection_struct *conn = p->conn; connection_struct *conn = p->conn;
pstring remark; char *remark;
pstrcpy(remark, lp_comment(snum)); remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)),
standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, conn->user, conn->connectpath, conn->gid,
conn->connectpath, conn->gid, get_current_username(),
get_current_username(), current_user_info.domain,
current_user_info.domain, lp_comment(params->service));
remark, sizeof(remark));
ZERO_STRUCTP(sh1004); ZERO_STRUCTP(sh1004);
@ -447,21 +449,25 @@ static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh100
Fill in a share info level 1005 structure. Fill in a share info level 1005 structure.
***************************************************************************/ ***************************************************************************/
static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum) static void init_srv_share_info_1005(pipes_struct *p,
SRV_SHARE_INFO_1005* sh1005,
const struct share_params *params)
{ {
sh1005->share_info_flags = 0; sh1005->share_info_flags = 0;
if(lp_host_msdfs() && lp_msdfs_root(snum)) if(lp_host_msdfs() && lp_msdfs_root(params->service))
sh1005->share_info_flags |= sh1005->share_info_flags |=
SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT;
sh1005->share_info_flags |= sh1005->share_info_flags |=
lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT; lp_csc_policy(params->service) << SHARE_1005_CSC_POLICY_SHIFT;
} }
/*************************************************************************** /***************************************************************************
Fill in a share info level 1006 structure. Fill in a share info level 1006 structure.
***************************************************************************/ ***************************************************************************/
static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum) static void init_srv_share_info_1006(pipes_struct *p,
SRV_SHARE_INFO_1006* sh1006,
const struct share_params *params)
{ {
sh1006->max_uses = -1; sh1006->max_uses = -1;
} }
@ -470,22 +476,28 @@ static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh100
Fill in a share info level 1007 structure. Fill in a share info level 1007 structure.
***************************************************************************/ ***************************************************************************/
static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum) static void init_srv_share_info_1007(pipes_struct *p,
SRV_SHARE_INFO_1007* sh1007,
const struct share_params *params)
{ {
pstring alternate_directory_name = ""; pstring alternate_directory_name = "";
uint32 flags = 0; uint32 flags = 0;
ZERO_STRUCTP(sh1007); ZERO_STRUCTP(sh1007);
init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name); init_srv_share_info1007(&sh1007->info_1007, flags,
init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name); alternate_directory_name);
init_srv_share_info1007_str(&sh1007->info_1007_str,
alternate_directory_name);
} }
/******************************************************************* /*******************************************************************
Fill in a share info level 1501 structure. Fill in a share info level 1501 structure.
********************************************************************/ ********************************************************************/
static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum) static void init_srv_share_info_1501(pipes_struct *p,
SRV_SHARE_INFO_1501 *sh1501,
const struct share_params *params)
{ {
SEC_DESC *sd; SEC_DESC *sd;
size_t sd_size; size_t sd_size;
@ -493,7 +505,8 @@ static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh150
ZERO_STRUCTP(sh1501); ZERO_STRUCTP(sh1501);
sd = get_share_security(ctx, lp_servicename(snum), &sd_size); sd = get_share_security(ctx, lp_servicename(params->service),
&sd_size);
sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
} }
@ -502,11 +515,11 @@ static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh150
True if it ends in '$'. True if it ends in '$'.
********************************************************************/ ********************************************************************/
static BOOL is_hidden_share(int snum) static BOOL is_hidden_share(const struct share_params *params)
{ {
const char *net_name = lp_servicename(snum); const char *net_name = lp_servicename(params->service);
return (net_name[strlen(net_name) - 1] == '$') ? True : False; return (net_name[strlen(net_name) - 1] == '$');
} }
/******************************************************************* /*******************************************************************
@ -519,9 +532,9 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
uint32 *total_entries, BOOL all_shares) uint32 *total_entries, BOOL all_shares)
{ {
int num_entries = 0; int num_entries = 0;
int num_services = 0;
int snum;
TALLOC_CTX *ctx = p->mem_ctx; TALLOC_CTX *ctx = p->mem_ctx;
struct share_iterator *shares;
struct share_params *share;
DEBUG(5,("init_srv_share_info_ctr\n")); DEBUG(5,("init_srv_share_info_ctr\n"));
@ -532,18 +545,23 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
/* Ensure all the usershares are loaded. */ /* Ensure all the usershares are loaded. */
become_root(); become_root();
num_services = load_usershare_shares(); load_usershare_shares();
unbecome_root(); unbecome_root();
num_entries = 0; num_entries = 0;
ZERO_STRUCT(ctr->share); ZERO_STRUCT(ctr->share);
for (snum = *resume_hnd; snum < num_services; snum++) { if (!(shares = share_list_all(ctx))) {
if (!lp_snum_ok(snum) || !lp_browseable(snum)) { DEBUG(5, ("Could not list shares\n"));
return WERR_ACCESS_DENIED;
}
while ((share = next_share(shares)) != NULL) {
if (!lp_browseable(share->service)) {
continue; continue;
} }
if (!all_shares && is_hidden_share(snum)) { if (!all_shares && is_hidden_share(share)) {
continue; continue;
} }
@ -551,7 +569,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 0: case 0:
{ {
SRV_SHARE_INFO_0 i; SRV_SHARE_INFO_0 i;
init_srv_share_info_0(p, &i, snum); init_srv_share_info_0(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_0, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_0, i,
&ctr->share.info0, &num_entries); &ctr->share.info0, &num_entries);
if (ctr->share.info0 == NULL) { if (ctr->share.info0 == NULL) {
@ -563,7 +581,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 1: case 1:
{ {
SRV_SHARE_INFO_1 i; SRV_SHARE_INFO_1 i;
init_srv_share_info_1(p, &i, snum); init_srv_share_info_1(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1, i,
&ctr->share.info1, &num_entries); &ctr->share.info1, &num_entries);
if (ctr->share.info1 == NULL) { if (ctr->share.info1 == NULL) {
@ -575,7 +593,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 2: case 2:
{ {
SRV_SHARE_INFO_2 i; SRV_SHARE_INFO_2 i;
init_srv_share_info_2(p, &i, snum); init_srv_share_info_2(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_2, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_2, i,
&ctr->share.info2, &num_entries); &ctr->share.info2, &num_entries);
if (ctr->share.info2 == NULL) { if (ctr->share.info2 == NULL) {
@ -587,7 +605,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 501: case 501:
{ {
SRV_SHARE_INFO_501 i; SRV_SHARE_INFO_501 i;
init_srv_share_info_501(p, &i, snum); init_srv_share_info_501(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_501, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_501, i,
&ctr->share.info501, &num_entries); &ctr->share.info501, &num_entries);
if (ctr->share.info501 == NULL) { if (ctr->share.info501 == NULL) {
@ -599,7 +617,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 502: case 502:
{ {
SRV_SHARE_INFO_502 i; SRV_SHARE_INFO_502 i;
init_srv_share_info_502(p, &i, snum); init_srv_share_info_502(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_502, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_502, i,
&ctr->share.info502, &num_entries); &ctr->share.info502, &num_entries);
if (ctr->share.info502 == NULL) { if (ctr->share.info502 == NULL) {
@ -614,7 +632,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 1004: case 1004:
{ {
SRV_SHARE_INFO_1004 i; SRV_SHARE_INFO_1004 i;
init_srv_share_info_1004(p, &i, snum); init_srv_share_info_1004(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1004, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1004, i,
&ctr->share.info1004, &num_entries); &ctr->share.info1004, &num_entries);
if (ctr->share.info1004 == NULL) { if (ctr->share.info1004 == NULL) {
@ -626,7 +644,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 1005: case 1005:
{ {
SRV_SHARE_INFO_1005 i; SRV_SHARE_INFO_1005 i;
init_srv_share_info_1005(p, &i, snum); init_srv_share_info_1005(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1005, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1005, i,
&ctr->share.info1005, &num_entries); &ctr->share.info1005, &num_entries);
if (ctr->share.info1005 == NULL) { if (ctr->share.info1005 == NULL) {
@ -638,7 +656,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 1006: case 1006:
{ {
SRV_SHARE_INFO_1006 i; SRV_SHARE_INFO_1006 i;
init_srv_share_info_1006(p, &i, snum); init_srv_share_info_1006(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1006, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1006, i,
&ctr->share.info1006, &num_entries); &ctr->share.info1006, &num_entries);
if (ctr->share.info1006 == NULL) { if (ctr->share.info1006 == NULL) {
@ -650,7 +668,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 1007: case 1007:
{ {
SRV_SHARE_INFO_1007 i; SRV_SHARE_INFO_1007 i;
init_srv_share_info_1007(p, &i, snum); init_srv_share_info_1007(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1007, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1007, i,
&ctr->share.info1007, &num_entries); &ctr->share.info1007, &num_entries);
if (ctr->share.info1007 == NULL) { if (ctr->share.info1007 == NULL) {
@ -662,7 +680,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
case 1501: case 1501:
{ {
SRV_SHARE_INFO_1501 i; SRV_SHARE_INFO_1501 i;
init_srv_share_info_1501(p, &i, snum); init_srv_share_info_1501(p, &i, share);
ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1501, i, ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1501, i,
&ctr->share.info1501, &num_entries); &ctr->share.info1501, &num_entries);
if (ctr->share.info1501 == NULL) { if (ctr->share.info1501 == NULL) {
@ -675,6 +693,8 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p,
"value %d\n", info_level)); "value %d\n", info_level));
return WERR_UNKNOWN_LEVEL; return WERR_UNKNOWN_LEVEL;
} }
TALLOC_FREE(share);
} }
*total_entries = num_entries; *total_entries = num_entries;
@ -708,52 +728,63 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I
char *share_name, uint32 info_level) char *share_name, uint32 info_level)
{ {
WERROR status = WERR_OK; WERROR status = WERR_OK;
int snum; const struct share_params *params;
DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__));
r_n->info.switch_value = info_level; r_n->info.switch_value = info_level;
snum = find_service(share_name); params = get_share_params(p->mem_ctx, share_name);
if (snum >= 0) { if (params != NULL) {
switch (info_level) { switch (info_level) {
case 0: case 0:
init_srv_share_info_0(p, &r_n->info.share.info0, snum); init_srv_share_info_0(p, &r_n->info.share.info0,
params);
break; break;
case 1: case 1:
init_srv_share_info_1(p, &r_n->info.share.info1, snum); init_srv_share_info_1(p, &r_n->info.share.info1,
params);
break; break;
case 2: case 2:
init_srv_share_info_2(p, &r_n->info.share.info2, snum); init_srv_share_info_2(p, &r_n->info.share.info2,
params);
break; break;
case 501: case 501:
init_srv_share_info_501(p, &r_n->info.share.info501, snum); init_srv_share_info_501(p, &r_n->info.share.info501,
params);
break; break;
case 502: case 502:
init_srv_share_info_502(p, &r_n->info.share.info502, snum); init_srv_share_info_502(p, &r_n->info.share.info502,
params);
break; break;
/* here for completeness */ /* here for completeness */
case 1004: case 1004:
init_srv_share_info_1004(p, &r_n->info.share.info1004, snum); init_srv_share_info_1004(p, &r_n->info.share.info1004,
params);
break; break;
case 1005: case 1005:
init_srv_share_info_1005(p, &r_n->info.share.info1005, snum); init_srv_share_info_1005(p, &r_n->info.share.info1005,
params);
break; break;
/* here for completeness 1006 - 1501 */ /* here for completeness 1006 - 1501 */
case 1006: case 1006:
init_srv_share_info_1006(p, &r_n->info.share.info1006, snum); init_srv_share_info_1006(p, &r_n->info.share.info1006,
params);
break; break;
case 1007: case 1007:
init_srv_share_info_1007(p, &r_n->info.share.info1007, snum); init_srv_share_info_1007(p, &r_n->info.share.info1007,
params);
break; break;
case 1501: case 1501:
init_srv_share_info_1501(p, &r_n->info.share.info1501, snum); init_srv_share_info_1501(p, &r_n->info.share.info1501,
params);
break; break;
default: default:
DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); DEBUG(5,("init_srv_net_share_get_info: unsupported "
"switch value %d\n", info_level));
status = WERR_UNKNOWN_LEVEL; status = WERR_UNKNOWN_LEVEL;
break; break;
} }