svn commit: samba r25484 - in branches: SAMBA_3_2/source/rpc_server
SAMBA_3_2_0/source/rpc_server
vlendec at samba.org
vlendec at samba.org
Wed Oct 3 18:37:59 GMT 2007
Author: vlendec
Date: 2007-10-03 18:37:57 +0000 (Wed, 03 Oct 2007)
New Revision: 25484
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25484
Log:
Fix srvsrc_NetFileEnum listing only for one user
Modified:
branches/SAMBA_3_2/source/rpc_server/srv_srvsvc_nt.c
branches/SAMBA_3_2_0/source/rpc_server/srv_srvsvc_nt.c
Changeset:
Modified: branches/SAMBA_3_2/source/rpc_server/srv_srvsvc_nt.c
===================================================================
--- branches/SAMBA_3_2/source/rpc_server/srv_srvsvc_nt.c 2007-10-03 13:34:44 UTC (rev 25483)
+++ branches/SAMBA_3_2/source/rpc_server/srv_srvsvc_nt.c 2007-10-03 18:37:57 UTC (rev 25484)
@@ -37,6 +37,7 @@
struct file_enum_count {
TALLOC_CTX *ctx;
+ const char *username;
uint32 count;
struct srvsvc_NetFileInfo3 *info;
};
@@ -55,56 +56,64 @@
{
struct pipe_open_rec prec;
struct file_enum_count *fenum = (struct file_enum_count *)p;
+ struct srvsvc_NetFileInfo3 *f;
+ int i = fenum->count;
+ pstring fullpath;
+ const char *username;
if (rec->value.dsize != sizeof(struct pipe_open_rec))
return 0;
memcpy(&prec, rec->value.dptr, sizeof(struct pipe_open_rec));
- if ( process_exists(prec.pid) ) {
- struct srvsvc_NetFileInfo3 *f;
- int i = fenum->count;
- pstring fullpath;
+ if ( !process_exists(prec.pid) ) {
+ return 0;
+ }
+
+ username = uidtoname(prec.uid);
+
+ if ((fenum->username != NULL)
+ && !strequal(username, fenum->username)) {
+ return 0;
+ }
- snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name );
+ snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name );
- f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 );
- if ( !f ) {
- DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
- return 1;
- }
+ f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info,
+ struct srvsvc_NetFileInfo3, i+1 );
+ if ( !f ) {
+ DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
+ return 1;
+ }
- fenum->info = f;
+ fenum->info = f;
- fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum);
- fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA);
- fenum->info[i].num_locks = 0;
- if (!(fenum->info[i].user = talloc_strdup(
- fenum->ctx, uidtoname(prec.uid)))) {
- /* There's not much we can do here. */
- fenum->info[i].user = "";
- }
- if (!(fenum->info[i].path = talloc_strdup(
- fenum->ctx, fullpath))) {
- /* There's not much we can do here. */
- fenum->info[i].path = "";
- }
-
- fenum->count++;
+ fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum);
+ fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA);
+ fenum->info[i].num_locks = 0;
+ fenum->info[i].user = talloc_move(fenum->ctx, &username);
+ if (!(fenum->info[i].path = talloc_strdup(
+ fenum->ctx, fullpath))) {
+ /* There's not much we can do here. */
+ fenum->info[i].path = "";
}
+ fenum->count++;
+
return 0;
}
/*******************************************************************
********************************************************************/
-static WERROR net_enum_pipes( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info,
+static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username,
+ struct srvsvc_NetFileInfo3 **info,
uint32 *count, uint32 *resume )
{
struct file_enum_count fenum;
fenum.ctx = ctx;
+ fenum.username = username;
fenum.info = *info;
fenum.count = *count;
@@ -137,12 +146,20 @@
int num_locks = 0;
pstring fullpath;
uint32 permissions;
+ const char *username;
/* If the pid was not found delete the entry from connections.tdb */
if (!process_exists(e->pid)) {
return;
}
+
+ username = uidtoname(e->uid);
+
+ if ((fenum->username != NULL)
+ && !strequal(username, fenum->username)) {
+ return;
+ }
f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info,
struct srvsvc_NetFileInfo3, i+1 );
@@ -175,11 +192,7 @@
fenum->info[i].fid = e->share_file_id;
fenum->info[i].permissions = permissions;
fenum->info[i].num_locks = num_locks;
- if (!(fenum->info[i].user = talloc_strdup(
- fenum->ctx, uidtoname(e->uid)))) {
- /* There's not much we can do here. */
- fenum->info[i].user = "";
- }
+ fenum->info[i].user = talloc_move(fenum->ctx, &username);
if (!(fenum->info[i].path = talloc_strdup(
fenum->ctx, fullpath))) {
/* There's not much we can do here. */
@@ -192,12 +205,14 @@
/*******************************************************************
********************************************************************/
-static WERROR net_enum_files( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info,
+static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username,
+ struct srvsvc_NetFileInfo3 **info,
uint32 *count, uint32 *resume )
{
struct file_enum_count f_enum_cnt;
f_enum_cnt.ctx = ctx;
+ f_enum_cnt.username = username;
f_enum_cnt.count = *count;
f_enum_cnt.info = *info;
@@ -1047,7 +1062,9 @@
makes a SRV_R_NET_FILE_ENUM structure.
********************************************************************/
-static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uint32 *resume_hnd, uint32 *num_entries )
+static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr,
+ uint32 *resume_hnd, const char *username,
+ uint32 *num_entries )
{
WERROR status;
@@ -1057,11 +1074,13 @@
ctr->ctr3 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetFileCtr3);
- status = net_enum_files(p->mem_ctx, &ctr->ctr3->array, num_entries, resume_hnd );
+ status = net_enum_files(p->mem_ctx, username, &ctr->ctr3->array,
+ num_entries, resume_hnd );
if ( !W_ERROR_IS_OK(status))
return status;
- status = net_enum_pipes(p->mem_ctx, &ctr->ctr3->array, num_entries, resume_hnd );
+ status = net_enum_pipes(p->mem_ctx, username, &ctr->ctr3->array,
+ num_entries, resume_hnd );
if ( !W_ERROR_IS_OK(status))
return status;
@@ -1077,7 +1096,8 @@
{
switch ( *r->in.level ) {
case 3:
- return net_file_enum_3(p, r->in.ctr, r->in.resume_handle, r->out.totalentries );
+ return net_file_enum_3(p, r->in.ctr, r->in.resume_handle,
+ r->in.user, r->out.totalentries );
default:
return WERR_UNKNOWN_LEVEL;
}
Modified: branches/SAMBA_3_2_0/source/rpc_server/srv_srvsvc_nt.c
===================================================================
--- branches/SAMBA_3_2_0/source/rpc_server/srv_srvsvc_nt.c 2007-10-03 13:34:44 UTC (rev 25483)
+++ branches/SAMBA_3_2_0/source/rpc_server/srv_srvsvc_nt.c 2007-10-03 18:37:57 UTC (rev 25484)
@@ -33,6 +33,7 @@
struct file_enum_count {
TALLOC_CTX *ctx;
+ const char *username;
int count;
FILE_INFO_3 *info;
};
@@ -51,36 +52,43 @@
{
struct pipe_open_rec prec;
struct file_enum_count *fenum = (struct file_enum_count *)p;
+ FILE_INFO_3 *f;
+ int i = fenum->count;
+ pstring fullpath;
+ const char *username;
if (rec->value.dsize != sizeof(struct pipe_open_rec))
return 0;
memcpy(&prec, rec->value.dptr, sizeof(struct pipe_open_rec));
- if ( process_exists(prec.pid) ) {
- FILE_INFO_3 *f;
- int i = fenum->count;
- pstring fullpath;
+ if ( !process_exists(prec.pid) ) {
+ return 0;
+ }
+
+ username = uidtoname(prec.uid);
+
+ if ((fenum->username != NULL)
+ && !strequal(username, fenum->username)) {
+ return 0;
+ }
- snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name );
+ snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name );
- f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 );
- if ( !f ) {
- DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
- return 1;
- }
- fenum->info = f;
+ f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 );
+ if ( !f ) {
+ DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
+ return 1;
+ }
+ fenum->info = f;
-
- init_srv_file_info3( &fenum->info[i],
- (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum),
- (FILE_READ_DATA|FILE_WRITE_DATA),
- 0,
- uidtoname( prec.uid ),
- fullpath );
+ init_srv_file_info3(
+ &fenum->info[i],
+ (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum),
+ (FILE_READ_DATA|FILE_WRITE_DATA),
+ 0, username, fullpath);
- fenum->count++;
- }
+ fenum->count++;
return 0;
}
@@ -88,12 +96,14 @@
/*******************************************************************
********************************************************************/
-static WERROR net_enum_pipes( TALLOC_CTX *ctx, FILE_INFO_3 **info,
+static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username,
+ FILE_INFO_3 **info,
uint32 *count, uint32 resume )
{
struct file_enum_count fenum;
fenum.ctx = ctx;
+ fenum.username = username;
fenum.count = *count;
fenum.info = *info;
@@ -126,12 +136,20 @@
int num_locks = 0;
pstring fullpath;
uint32 permissions;
+ const char *username;
/* If the pid was not found delete the entry from connections.tdb */
if ( !process_exists(e->pid) ) {
return;
}
+
+ username = uidtoname(e->uid);
+
+ if ((fenum->username != NULL)
+ && !strequal(username, fenum->username)) {
+ return;
+ }
f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 );
if ( !f ) {
@@ -165,7 +183,7 @@
e->share_file_id,
permissions,
num_locks,
- uidtoname(e->uid),
+ username,
fullpath );
fenum->count++;
@@ -174,12 +192,14 @@
/*******************************************************************
********************************************************************/
-static WERROR net_enum_files( TALLOC_CTX *ctx, FILE_INFO_3 **info,
+static WERROR net_enum_files( TALLOC_CTX *ctx, const char **username,
+ FILE_INFO_3 **info,
uint32 *count, uint32 resume )
{
struct file_enum_count f_enum_cnt;
f_enum_cnt.ctx = ctx;
+ f_enum_cnt.username = username;
f_enum_cnt.count = *count;
f_enum_cnt.info = *info;
@@ -1112,7 +1132,8 @@
makes a SRV_R_NET_FILE_ENUM structure.
********************************************************************/
-static WERROR net_file_enum_3( SRV_R_NET_FILE_ENUM *r, uint32 resume_hnd )
+static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r,
+ uint32 resume_hnd )
{
TALLOC_CTX *ctx = talloc_tos();
SRV_FILE_INFO_CTR *ctr = &r->ctr;
@@ -1121,11 +1142,13 @@
(b) active pipes
(c) open directories and files */
- r->status = net_enum_files( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd );
+ r->status = net_enum_files( ctx, username, &ctr->file.info3,
+ &ctr->num_entries, resume_hnd );
if ( !W_ERROR_IS_OK(r->status))
goto done;
- r->status = net_enum_pipes( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd );
+ r->status = net_enum_pipes( ctx, username, &ctr->file.info3,
+ &ctr->num_entries, resume_hnd );
if ( !W_ERROR_IS_OK(r->status))
goto done;
@@ -1153,7 +1176,8 @@
{
switch ( q_u->level ) {
case 3:
- return net_file_enum_3( r_u, get_enum_hnd(&q_u->enum_hnd) );
+ return net_file_enum_3( q_u->username, r_u,
+ get_enum_hnd(&q_u->enum_hnd) );
default:
return WERR_UNKNOWN_LEVEL;
}
More information about the samba-cvs
mailing list