2008-03-04 23:46:09 +03:00
/*
2006-01-14 00:22:25 +03:00
* Unix SMB / CIFS implementation .
2001-02-27 21:22:39 +03:00
* RPC Pipe client / server routines
* Copyright ( C ) Andrew Tridgell 1992 - 1997 ,
2006-01-23 17:34:26 +03:00
* Copyright ( C ) Jeremy Allison 2001.
* Copyright ( C ) Nigel Williams 2001.
2006-07-11 22:01:26 +04:00
* Copyright ( C ) Gerald ( Jerry ) Carter 2006.
2008-03-04 23:46:09 +03:00
*
2001-02-27 21:22:39 +03:00
* 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
2007-07-09 23:25:36 +04:00
* the Free Software Foundation ; either version 3 of the License , or
2001-02-27 21:22:39 +03:00
* ( at your option ) any later version .
2008-03-04 23:46:09 +03:00
*
2001-02-27 21:22:39 +03:00
* 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 .
2008-03-04 23:46:09 +03:00
*
2001-02-27 21:22:39 +03:00
* You should have received a copy of the GNU General Public License
2007-07-10 09:23:25 +04:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2001-02-27 21:22:39 +03:00
*/
/* This is the implementation of the srvsvc pipe. */
# include "includes.h"
2007-10-06 01:41:17 +04:00
extern const struct generic_mapping file_generic_mapping ;
2005-04-06 20:28:04 +04:00
2002-07-15 14:35:28 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_RPC_SRV
2006-07-11 22:01:26 +04:00
/* Use for enumerating connections, pipes, & files */
struct file_enum_count {
TALLOC_CTX * ctx ;
2007-10-03 22:37:57 +04:00
const char * username ;
2007-10-11 00:34:30 +04:00
int count ;
FILE_INFO_3 * info ;
2006-07-11 22:01:26 +04:00
} ;
struct sess_file_count {
2007-05-07 19:31:12 +04:00
struct server_id pid ;
2006-07-11 22:01:26 +04:00
uid_t uid ;
int count ;
} ;
/****************************************************************************
Count the entries belonging to a service in the connection db .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-05-28 15:38:42 +04:00
static int pipe_enum_fn ( struct db_record * rec , void * p )
2006-07-11 22:01:26 +04:00
{
struct pipe_open_rec prec ;
struct file_enum_count * fenum = ( struct file_enum_count * ) p ;
2007-10-11 00:34:30 +04:00
FILE_INFO_3 * f ;
2007-10-03 22:37:57 +04:00
int i = fenum - > count ;
2007-11-28 01:35:30 +03:00
char * fullpath = NULL ;
2007-10-03 22:37:57 +04:00
const char * username ;
2007-11-28 01:35:30 +03:00
2007-05-28 15:38:42 +04:00
if ( rec - > value . dsize ! = sizeof ( struct pipe_open_rec ) )
2006-07-11 22:01:26 +04:00
return 0 ;
2007-05-28 15:38:42 +04:00
memcpy ( & prec , rec - > value . dptr , sizeof ( struct pipe_open_rec ) ) ;
2007-11-28 01:35:30 +03:00
2007-10-03 22:37:57 +04:00
if ( ! process_exists ( prec . pid ) ) {
return 0 ;
}
username = uidtoname ( prec . uid ) ;
if ( ( fenum - > username ! = NULL )
& & ! strequal ( username , fenum - > username ) ) {
return 0 ;
}
2007-11-28 01:35:30 +03:00
fullpath = talloc_asprintf ( fenum - > ctx , " \\ PIPE \\ %s " , prec . name ) ;
if ( ! fullpath ) {
return 1 ;
}
2007-10-11 00:34:30 +04:00
f = TALLOC_REALLOC_ARRAY ( fenum - > ctx , fenum - > info , FILE_INFO_3 , i + 1 ) ;
2007-10-03 22:37:57 +04:00
if ( ! f ) {
DEBUG ( 0 , ( " conn_enum_fn: realloc failed for %d items \n " , i + 1 ) ) ;
return 1 ;
}
fenum - > info = f ;
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
init_srv_file_info3 (
2007-11-28 01:35:30 +03:00
& fenum - > info [ i ] ,
2007-10-11 00:34:30 +04:00
( uint32 ) ( ( procid_to_pid ( & prec . pid ) < < 16 ) & prec . pnum ) ,
2007-11-28 01:35:30 +03:00
( FILE_READ_DATA | FILE_WRITE_DATA ) ,
2007-10-11 00:34:30 +04:00
0 , username , fullpath ) ;
2007-11-28 01:35:30 +03:00
TALLOC_FREE ( fullpath ) ;
2007-10-03 22:37:57 +04:00
fenum - > count + + ;
2006-07-11 22:01:26 +04:00
return 0 ;
}
/*******************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-03 22:37:57 +04:00
static WERROR net_enum_pipes ( TALLOC_CTX * ctx , const char * username ,
2008-03-04 23:46:09 +03:00
FILE_INFO_3 * * info ,
2007-10-11 00:34:30 +04:00
uint32 * count , uint32 resume )
2006-07-11 22:01:26 +04:00
{
struct file_enum_count fenum ;
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
fenum . ctx = ctx ;
2007-10-03 22:37:57 +04:00
fenum . username = username ;
2006-09-22 03:57:32 +04:00
fenum . count = * count ;
2007-10-11 00:34:30 +04:00
fenum . info = * info ;
2006-07-11 22:01:26 +04:00
2007-05-08 17:44:36 +04:00
if ( connections_traverse ( pipe_enum_fn , & fenum ) = = - 1 ) {
DEBUG ( 0 , ( " net_enum_pipes: traverse of connections.tdb "
" failed \n " ) ) ;
2006-07-11 22:01:26 +04:00
return WERR_NOMEM ;
}
2007-11-28 01:35:30 +03:00
2006-07-11 22:01:26 +04:00
* info = fenum . info ;
* count = fenum . count ;
2007-11-28 01:35:30 +03:00
2007-05-08 17:44:36 +04:00
return WERR_OK ;
}
2006-07-11 22:01:26 +04:00
/*******************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-11-28 01:35:30 +03:00
static void enum_file_fn ( const struct share_mode_entry * e ,
2006-07-21 18:13:30 +04:00
const char * sharepath , const char * fname ,
2007-05-28 15:38:42 +04:00
void * private_data )
2006-07-11 22:01:26 +04:00
{
2007-10-11 00:34:30 +04:00
struct file_enum_count * fenum =
( struct file_enum_count * ) private_data ;
2007-10-03 17:13:02 +04:00
2007-10-11 00:34:30 +04:00
FILE_INFO_3 * f ;
2007-10-03 17:13:02 +04:00
int i = fenum - > count ;
files_struct fsp ;
struct byte_range_lock * brl ;
int num_locks = 0 ;
2007-11-28 01:35:30 +03:00
char * fullpath = NULL ;
2007-10-03 17:13:02 +04:00
uint32 permissions ;
2007-10-03 22:37:57 +04:00
const char * username ;
2007-11-28 01:35:30 +03:00
2006-07-11 22:01:26 +04:00
/* If the pid was not found delete the entry from connections.tdb */
2007-10-11 00:34:30 +04:00
if ( ! process_exists ( e - > pid ) ) {
2007-10-03 17:13:02 +04:00
return ;
}
2007-10-03 22:37:57 +04:00
username = uidtoname ( e - > uid ) ;
if ( ( fenum - > username ! = NULL )
& & ! strequal ( username , fenum - > username ) ) {
return ;
}
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
f = TALLOC_REALLOC_ARRAY ( fenum - > ctx , fenum - > info , FILE_INFO_3 , i + 1 ) ;
2007-10-03 17:13:02 +04:00
if ( ! f ) {
DEBUG ( 0 , ( " conn_enum_fn: realloc failed for %d items \n " , i + 1 ) ) ;
return ;
}
fenum - > info = f ;
2006-07-11 22:01:26 +04:00
2007-10-03 17:13:02 +04:00
/* need to count the number of locks on a file */
2007-11-28 01:35:30 +03:00
ZERO_STRUCT ( fsp ) ;
2007-10-03 17:13:02 +04:00
fsp . file_id = e - > id ;
2007-11-28 01:35:30 +03:00
2008-01-06 18:15:45 +03:00
if ( ( brl = brl_get_locks ( talloc_tos ( ) , & fsp ) ) ! = NULL ) {
2007-10-03 17:13:02 +04:00
num_locks = brl - > num_locks ;
2007-11-28 01:35:30 +03:00
TALLOC_FREE ( brl ) ;
2007-10-03 17:13:02 +04:00
}
2007-11-28 01:35:30 +03:00
2007-10-03 17:13:02 +04:00
if ( strcmp ( fname , " . " ) = = 0 ) {
2007-11-28 01:35:30 +03:00
fullpath = talloc_asprintf ( fenum - > ctx , " C:%s " , sharepath ) ;
2007-10-03 17:13:02 +04:00
} else {
2007-11-28 01:35:30 +03:00
fullpath = talloc_asprintf ( fenum - > ctx , " C:%s/%s " ,
sharepath , fname ) ;
}
if ( ! fullpath ) {
return ;
2007-10-03 17:13:02 +04:00
}
string_replace ( fullpath , ' / ' , ' \\ ' ) ;
2007-11-28 01:35:30 +03:00
2007-10-03 17:13:02 +04:00
/* mask out create (what ever that is) */
permissions = e - > share_access & ( FILE_READ_DATA | FILE_WRITE_DATA ) ;
2007-10-11 00:34:30 +04:00
/* now fill in the FILE_INFO_3 struct */
2007-11-28 01:35:30 +03:00
init_srv_file_info3 ( & fenum - > info [ i ] ,
2007-10-11 00:34:30 +04:00
e - > share_file_id ,
permissions ,
num_locks ,
username ,
fullpath ) ;
2007-11-28 01:35:30 +03:00
TALLOC_FREE ( fullpath ) ;
2007-10-03 17:13:02 +04:00
fenum - > count + + ;
2006-07-11 22:01:26 +04:00
}
/*******************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-03 22:37:57 +04:00
static WERROR net_enum_files ( TALLOC_CTX * ctx , const char * username ,
2008-03-04 23:46:09 +03:00
FILE_INFO_3 * * info ,
2007-10-11 00:34:30 +04:00
uint32 * count , uint32 resume )
2006-07-11 22:01:26 +04:00
{
2007-05-28 15:38:42 +04:00
struct file_enum_count f_enum_cnt ;
2006-07-11 22:01:26 +04:00
f_enum_cnt . ctx = ctx ;
2007-10-03 22:37:57 +04:00
f_enum_cnt . username = username ;
2006-07-11 22:01:26 +04:00
f_enum_cnt . count = * count ;
f_enum_cnt . info = * info ;
2008-03-04 23:46:09 +03:00
2007-05-28 15:38:42 +04:00
share_mode_forall ( enum_file_fn , ( void * ) & f_enum_cnt ) ;
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
* info = f_enum_cnt . info ;
* count = f_enum_cnt . count ;
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
return WERR_OK ;
}
2002-08-17 19:34:15 +04:00
/*******************************************************************
2007-10-11 00:34:30 +04:00
Utility function to get the ' type ' of a share from an snum .
2002-08-17 19:34:15 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-11-28 01:35:30 +03:00
static uint32 get_share_type ( int snum )
2002-08-17 19:34:15 +04:00
{
/* work out the share type */
uint32 type = STYPE_DISKTREE ;
2007-10-11 00:34:30 +04:00
if ( lp_print_ok ( snum ) )
2002-08-17 19:34:15 +04:00
type = STYPE_PRINTQ ;
2007-10-11 00:34:30 +04:00
if ( strequal ( lp_fstype ( snum ) , " IPC " ) )
2002-08-17 19:34:15 +04:00
type = STYPE_IPC ;
2008-02-28 16:06:11 +03:00
if ( lp_administrative_share ( snum ) )
2002-08-17 19:34:15 +04:00
type | = STYPE_HIDDEN ;
return type ;
}
2007-11-28 01:35:30 +03:00
2002-08-17 19:34:15 +04:00
/*******************************************************************
Fill in a share info level 0 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_0 ( pipes_struct * p , struct srvsvc_NetShareInfo0 * r , int snum )
2002-08-17 19:34:15 +04:00
{
2007-11-28 01:35:30 +03:00
const char * net_name = lp_servicename ( snum ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
init_srvsvc_NetShareInfo0 ( r , net_name ) ;
2002-08-17 19:34:15 +04:00
}
2001-02-27 21:22:39 +03:00
/*******************************************************************
Fill in a share info level 1 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_1 ( pipes_struct * p , struct srvsvc_NetShareInfo1 * r , int snum )
2001-02-27 21:22:39 +03:00
{
2007-10-11 00:34:30 +04:00
char * net_name = lp_servicename ( snum ) ;
2007-11-28 01:35:30 +03:00
char * remark = talloc_strdup ( p - > mem_ctx , lp_comment ( snum ) ) ;
2001-02-27 21:22:39 +03:00
2007-11-28 01:35:30 +03:00
if ( remark ) {
remark = standard_sub_conn ( p - > mem_ctx ,
p - > conn ,
remark ) ;
}
2008-03-07 18:19:43 +03:00
init_srvsvc_NetShareInfo1 ( r , net_name ,
get_share_type ( snum ) ,
remark ? remark : " " ) ;
2001-02-27 21:22:39 +03:00
}
/*******************************************************************
Fill in a share info level 2 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_2 ( pipes_struct * p , struct srvsvc_NetShareInfo2 * r , int snum )
2001-02-27 21:22:39 +03:00
{
2007-11-28 01:35:30 +03:00
char * remark = NULL ;
char * path = NULL ;
2007-10-11 00:34:30 +04:00
int max_connections = lp_max_connections ( snum ) ;
2006-01-23 17:34:26 +03:00
uint32 max_uses = max_connections ! = 0 ? max_connections : 0xffffffff ;
2006-07-11 22:01:26 +04:00
int count = 0 ;
2007-10-11 00:34:30 +04:00
char * net_name = lp_servicename ( snum ) ;
2001-05-01 05:01:19 +04:00
2007-11-28 01:35:30 +03:00
remark = talloc_strdup ( p - > mem_ctx , lp_comment ( snum ) ) ;
if ( remark ) {
remark = standard_sub_conn ( p - > mem_ctx ,
p - > conn ,
remark ) ;
}
path = talloc_asprintf ( p - > mem_ctx ,
" C:%s " , lp_pathname ( snum ) ) ;
if ( path ) {
/*
* Change / to \ \ so that win2k will see it as a valid path .
* This was added to enable use of browsing in win2k add
* share dialog .
*/
string_replace ( path , ' / ' , ' \\ ' ) ;
}
count = count_current_connections ( net_name , false ) ;
2008-03-07 18:19:43 +03:00
init_srvsvc_NetShareInfo2 ( r , net_name ,
get_share_type ( snum ) ,
remark ? remark : " " ,
0 ,
max_uses ,
count ,
path ? path : " " ,
" " ) ;
2001-02-27 21:22:39 +03:00
}
2001-04-09 12:00:19 +04:00
/*******************************************************************
Map any generic bits to file specific bits .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-02-04 01:19:41 +03:00
static void map_generic_share_sd_bits ( SEC_DESC * psd )
2001-04-09 12:00:19 +04:00
{
int i ;
SEC_ACL * ps_dacl = NULL ;
if ( ! psd )
return ;
ps_dacl = psd - > dacl ;
if ( ! ps_dacl )
return ;
for ( i = 0 ; i < ps_dacl - > num_aces ; i + + ) {
2006-09-21 02:23:12 +04:00
SEC_ACE * psa = & ps_dacl - > aces [ i ] ;
uint32 orig_mask = psa - > access_mask ;
2001-04-09 12:00:19 +04:00
2006-09-21 02:23:12 +04:00
se_map_generic ( & psa - > access_mask , & file_generic_mapping ) ;
psa - > access_mask | = orig_mask ;
2007-11-28 01:35:30 +03:00
}
2001-04-09 12:00:19 +04:00
}
2002-04-10 05:04:13 +04:00
/*******************************************************************
Fill in a share info level 501 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_501 ( pipes_struct * p , struct srvsvc_NetShareInfo501 * r , int snum )
2002-04-10 05:04:13 +04:00
{
2007-10-11 00:34:30 +04:00
const char * net_name = lp_servicename ( snum ) ;
2007-11-28 01:35:30 +03:00
char * remark = talloc_strdup ( p - > mem_ctx , lp_comment ( snum ) ) ;
2006-07-15 02:06:38 +04:00
2007-11-28 01:35:30 +03:00
if ( remark ) {
remark = standard_sub_conn ( p - > mem_ctx , p - > conn , remark ) ;
}
2008-03-07 18:19:43 +03:00
init_srvsvc_NetShareInfo501 ( r , net_name ,
get_share_type ( snum ) ,
remark ? remark : " " ,
( lp_csc_policy ( snum ) < < 4 ) ) ;
2002-04-10 05:04:13 +04:00
}
2001-04-05 03:42:17 +04:00
/*******************************************************************
Fill in a share info level 502 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_502 ( pipes_struct * p , struct srvsvc_NetShareInfo502 * r , int snum )
2001-04-05 03:42:17 +04:00
{
2007-11-28 01:35:30 +03:00
const char * net_name = lp_servicename ( snum ) ;
char * path = NULL ;
SEC_DESC * sd = NULL ;
size_t sd_size = 0 ;
2001-08-22 20:10:28 +04:00
TALLOC_CTX * ctx = p - > mem_ctx ;
2007-11-28 01:35:30 +03:00
char * remark = talloc_strdup ( ctx , lp_comment ( snum ) ) ; ;
2001-04-05 03:42:17 +04:00
2007-11-28 01:35:30 +03:00
if ( remark ) {
remark = standard_sub_conn ( ctx , p - > conn , remark ) ;
}
path = talloc_asprintf ( ctx , " C:%s " , lp_pathname ( snum ) ) ;
if ( path ) {
/*
* Change / to \ \ so that win2k will see it as a valid path . This was added to
* enable use of browsing in win2k add share dialog .
*/
string_replace ( path , ' / ' , ' \\ ' ) ;
}
2007-10-11 00:34:30 +04:00
sd = get_share_security ( ctx , lp_servicename ( snum ) , & sd_size ) ;
2001-04-05 03:42:17 +04:00
2008-03-07 18:19:43 +03:00
init_srvsvc_NetShareInfo502 ( r , net_name ,
get_share_type ( snum ) ,
remark ? remark : " " ,
0 ,
0xffffffff ,
1 ,
path ? path : " " ,
" " ,
0 ,
sd ) ;
2002-08-17 19:34:15 +04:00
}
/***************************************************************************
Fill in a share info level 1004 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_1004 ( pipes_struct * p , struct srvsvc_NetShareInfo1004 * r , int snum )
2002-08-17 19:34:15 +04:00
{
2007-11-28 01:35:30 +03:00
char * remark = talloc_strdup ( p - > mem_ctx , lp_comment ( snum ) ) ;
2002-08-17 19:34:15 +04:00
2007-11-28 01:35:30 +03:00
if ( remark ) {
remark = standard_sub_conn ( p - > mem_ctx , p - > conn , remark ) ;
}
2002-08-17 19:34:15 +04:00
2008-03-07 18:19:43 +03:00
init_srvsvc_NetShareInfo1004 ( r , remark ? remark : " " ) ;
2001-04-05 03:42:17 +04:00
}
2001-02-27 21:22:39 +03:00
/***************************************************************************
Fill in a share info level 1005 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_1005 ( pipes_struct * p , struct srvsvc_NetShareInfo1005 * r , int snum )
2001-02-27 21:22:39 +03:00
{
2008-03-07 18:19:43 +03:00
uint32_t dfs_flags = 0 ;
if ( lp_host_msdfs ( ) & & lp_msdfs_root ( snum ) ) {
dfs_flags | = SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT ;
}
2001-02-27 21:22:39 +03:00
2008-03-07 18:19:43 +03:00
dfs_flags | = lp_csc_policy ( snum ) < < SHARE_1005_CSC_POLICY_SHIFT ;
init_srvsvc_NetShareInfo1005 ( r , dfs_flags ) ;
2001-02-27 21:22:39 +03:00
}
2008-03-07 18:19:43 +03:00
2002-08-17 19:34:15 +04:00
/***************************************************************************
Fill in a share info level 1006 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_1006 ( pipes_struct * p , struct srvsvc_NetShareInfo1006 * r , int snum )
2002-08-17 19:34:15 +04:00
{
2008-03-07 18:19:43 +03:00
init_srvsvc_NetShareInfo1006 ( r , 0xffffffff ) ;
2002-08-17 19:34:15 +04:00
}
/***************************************************************************
Fill in a share info level 1007 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_1007 ( pipes_struct * p , struct srvsvc_NetShareInfo1007 * r , int snum )
2002-08-17 19:34:15 +04:00
{
uint32 flags = 0 ;
2008-03-07 18:19:43 +03:00
init_srvsvc_NetShareInfo1007 ( r , flags , " " ) ;
2002-08-17 19:34:15 +04:00
}
/*******************************************************************
Fill in a share info level 1501 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static void init_srv_share_info_1501 ( pipes_struct * p , struct sec_desc_buf * r , int snum )
2002-08-17 19:34:15 +04:00
{
SEC_DESC * sd ;
size_t sd_size ;
TALLOC_CTX * ctx = p - > mem_ctx ;
2007-10-11 00:34:30 +04:00
sd = get_share_security ( ctx , lp_servicename ( snum ) , & sd_size ) ;
2002-08-17 19:34:15 +04:00
2008-03-07 18:19:43 +03:00
r = make_sec_desc_buf ( p - > mem_ctx , sd_size , sd ) ;
2002-08-17 19:34:15 +04:00
}
2001-02-27 21:22:39 +03:00
2001-04-06 05:39:12 +04:00
/*******************************************************************
True if it ends in ' $ ' .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
static bool is_hidden_share ( int snum )
2001-04-06 05:39:12 +04:00
{
2007-10-11 00:34:30 +04:00
const char * net_name = lp_servicename ( snum ) ;
2001-04-06 05:39:12 +04:00
2007-10-11 00:34:30 +04:00
return ( net_name [ strlen ( net_name ) - 1 ] = = ' $ ' ) ? True : False ;
2001-04-06 05:39:12 +04:00
}
2001-02-27 21:22:39 +03:00
/*******************************************************************
Fill in a share info structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
static WERROR init_srv_share_info_ctr ( pipes_struct * p ,
struct srvsvc_NetShareInfoCtr * info_ctr ,
uint32_t * resume_handle_p ,
uint32_t * total_entries ,
bool all_shares )
2001-02-27 21:22:39 +03:00
{
2007-10-11 00:34:30 +04:00
int num_entries = 0 ;
2008-03-07 18:19:43 +03:00
int alloc_entries = 0 ;
2007-10-11 00:34:30 +04:00
int num_services = 0 ;
int snum ;
2001-08-22 20:10:28 +04:00
TALLOC_CTX * ctx = p - > mem_ctx ;
2008-03-07 18:19:43 +03:00
int i = 0 ;
int valid_share_count = 0 ;
union srvsvc_NetShareCtr ctr ;
uint32_t resume_handle = resume_handle_p ? * resume_handle_p : 0 ;
2001-02-27 21:22:39 +03:00
DEBUG ( 5 , ( " init_srv_share_info_ctr \n " ) ) ;
2006-02-04 01:19:41 +03:00
/* Ensure all the usershares are loaded. */
become_root ( ) ;
2007-10-11 00:34:30 +04:00
num_services = load_usershare_shares ( ) ;
2006-11-30 10:38:40 +03:00
load_registry_shares ( ) ;
2006-02-04 01:19:41 +03:00
unbecome_root ( ) ;
2007-10-11 00:34:30 +04:00
/* Count the number of entries. */
for ( snum = 0 ; snum < num_services ; snum + + ) {
2008-03-07 18:19:43 +03:00
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) ) {
2007-10-11 00:34:30 +04:00
num_entries + + ;
2008-03-07 18:19:43 +03:00
}
2006-07-15 02:06:38 +04:00
}
2008-03-07 18:19:43 +03:00
if ( ! num_entries | | ( resume_handle > = num_entries ) ) {
return WERR_OK ;
}
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
/* Calculate alloc entries. */
alloc_entries = num_entries - resume_handle ;
switch ( info_ctr - > level ) {
2006-09-22 03:57:32 +04:00
case 0 :
2008-03-07 18:19:43 +03:00
ctr . ctr0 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr0 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr0 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr0 - > count = alloc_entries ;
ctr . ctr0 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo0 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr0 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_0 ( p , & ctr . ctr0 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
}
2006-09-22 03:57:32 +04:00
break ;
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
case 1 :
2008-03-07 18:19:43 +03:00
ctr . ctr1 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr1 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr1 - > count = alloc_entries ;
ctr . ctr1 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo1 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_1 ( p , & ctr . ctr1 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
2006-10-24 00:11:12 +04:00
}
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
break ;
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
case 2 :
2008-03-07 18:19:43 +03:00
ctr . ctr2 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr2 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr2 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr2 - > count = alloc_entries ;
ctr . ctr2 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo2 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr2 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_2 ( p , & ctr . ctr2 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
}
2006-09-22 03:57:32 +04:00
break ;
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
case 501 :
2008-03-07 18:19:43 +03:00
ctr . ctr501 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr501 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr501 ) ;
2008-03-04 23:46:09 +03:00
2008-03-07 18:19:43 +03:00
ctr . ctr501 - > count = alloc_entries ;
ctr . ctr501 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo501 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr501 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_501 ( p , & ctr . ctr501 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
2006-10-24 00:11:12 +04:00
}
2008-03-04 23:46:09 +03:00
2006-09-22 03:57:32 +04:00
break ;
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
case 502 :
2008-03-07 18:19:43 +03:00
ctr . ctr502 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr502 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr502 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr502 - > count = alloc_entries ;
ctr . ctr502 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo502 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr502 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_502 ( p , & ctr . ctr502 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
}
2006-09-22 03:57:32 +04:00
break ;
2008-03-04 23:46:09 +03:00
2006-09-22 03:57:32 +04:00
case 1004 :
2008-03-07 18:19:43 +03:00
ctr . ctr1004 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr1004 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1004 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr1004 - > count = alloc_entries ;
ctr . ctr1004 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo1004 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1004 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_1004 ( p , & ctr . ctr1004 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
2006-10-24 00:11:12 +04:00
}
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
break ;
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
case 1005 :
2008-03-07 18:19:43 +03:00
ctr . ctr1005 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr1005 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1005 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr1005 - > count = alloc_entries ;
ctr . ctr1005 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo1005 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1005 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_1005 ( p , & ctr . ctr1005 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
}
2006-09-22 03:57:32 +04:00
break ;
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
case 1006 :
2008-03-07 18:19:43 +03:00
ctr . ctr1006 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr1006 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1006 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr1006 - > count = alloc_entries ;
ctr . ctr1006 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo1006 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1006 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_1006 ( p , & ctr . ctr1006 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
}
2006-09-22 03:57:32 +04:00
break ;
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
case 1007 :
2008-03-07 18:19:43 +03:00
ctr . ctr1007 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr1007 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1007 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr1007 - > count = alloc_entries ;
ctr . ctr1007 - > array = TALLOC_ZERO_ARRAY ( ctx , struct srvsvc_NetShareInfo1007 , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1007 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_1007 ( p , & ctr . ctr1007 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
2006-10-24 00:11:12 +04:00
}
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
break ;
2007-10-11 00:34:30 +04:00
2006-09-22 03:57:32 +04:00
case 1501 :
2008-03-07 18:19:43 +03:00
ctr . ctr1501 = TALLOC_ZERO_P ( ctx , struct srvsvc_NetShareCtr1501 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1501 ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
ctr . ctr1501 - > count = alloc_entries ;
ctr . ctr1501 - > array = TALLOC_ZERO_ARRAY ( ctx , struct sec_desc_buf , alloc_entries ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr . ctr1501 - > array ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
for ( snum = 0 ; snum < num_services ; snum + + ) {
if ( lp_browseable ( snum ) & & lp_snum_ok ( snum ) & & ( all_shares | | ! is_hidden_share ( snum ) ) & &
( resume_handle < = ( i + valid_share_count + + ) ) ) {
init_srv_share_info_1501 ( p , & ctr . ctr1501 - > array [ i + + ] , snum ) ;
2007-10-11 00:34:30 +04:00
}
}
2006-09-22 03:57:32 +04:00
break ;
2008-03-07 18:19:43 +03:00
2006-09-22 03:57:32 +04:00
default :
2008-03-07 18:19:43 +03:00
DEBUG ( 5 , ( " init_srv_share_info_ctr: unsupported switch value %d \n " ,
info_ctr - > level ) ) ;
return WERR_UNKNOWN_LEVEL ;
2006-09-22 03:57:32 +04:00
}
2008-03-07 18:19:43 +03:00
* total_entries = alloc_entries ;
if ( resume_handle_p ) {
* resume_handle_p = num_entries ;
2007-10-11 00:34:30 +04:00
}
2008-03-07 18:19:43 +03:00
info_ctr - > ctr = ctr ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
return WERR_OK ;
2001-02-27 21:22:39 +03:00
}
/*******************************************************************
fill in a sess info level 0 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
static void init_srv_sess_info_0 ( pipes_struct * p , SRV_SESS_INFO_0 * ss0 , uint32 * snum , uint32 * stot )
2001-02-27 21:22:39 +03:00
{
2002-07-15 14:35:28 +04:00
struct sessionid * session_list ;
2001-02-27 21:22:39 +03:00
uint32 num_entries = 0 ;
2007-04-28 22:16:33 +04:00
( * stot ) = list_sessions ( p - > mem_ctx , & session_list ) ;
2001-02-27 21:22:39 +03:00
if ( ss0 = = NULL ) {
2006-08-28 08:52:36 +04:00
if ( snum ) {
( * snum ) = 0 ;
}
2001-02-27 21:22:39 +03:00
return ;
}
DEBUG ( 5 , ( " init_srv_sess_0_ss0 \n " ) ) ;
if ( snum ) {
2007-10-11 00:34:30 +04:00
for ( ; ( * snum ) < ( * stot ) & & num_entries < MAX_SESS_ENTRIES ; ( * snum ) + + ) {
init_srv_sess_info0 ( & ss0 - > info_0 [ num_entries ] , session_list [ ( * snum ) ] . remote_machine ) ;
2001-02-27 21:22:39 +03:00
num_entries + + ;
}
2007-10-11 00:34:30 +04:00
ss0 - > num_entries_read = num_entries ;
ss0 - > ptr_sess_info = num_entries > 0 ? 1 : 0 ;
ss0 - > num_entries_read2 = num_entries ;
2008-03-04 23:46:09 +03:00
2001-02-27 21:22:39 +03:00
if ( ( * snum ) > = ( * stot ) ) {
( * snum ) = 0 ;
}
} else {
2007-10-11 00:34:30 +04:00
ss0 - > num_entries_read = 0 ;
ss0 - > ptr_sess_info = 0 ;
ss0 - > num_entries_read2 = 0 ;
2001-02-27 21:22:39 +03:00
}
}
/*******************************************************************
2006-07-11 22:01:26 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-02-27 21:22:39 +03:00
2008-03-04 23:46:09 +03:00
static void sess_file_fn ( const struct share_mode_entry * e ,
2007-12-27 23:30:15 +03:00
const char * sharepath , const char * fname ,
void * data )
2001-02-27 21:22:39 +03:00
{
2007-12-27 23:30:15 +03:00
struct sess_file_count * sess = ( struct sess_file_count * ) data ;
2008-03-04 23:46:09 +03:00
2007-05-07 19:31:12 +04:00
if ( procid_equal ( & e - > pid , & sess - > pid ) & & ( sess - > uid = = e - > uid ) ) {
2006-07-11 22:01:26 +04:00
sess - > count + + ;
}
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
return ;
}
/*******************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-05-07 19:31:12 +04:00
static int net_count_files ( uid_t uid , struct server_id pid )
2006-07-11 22:01:26 +04:00
{
2007-12-27 23:30:15 +03:00
struct sess_file_count s_file_cnt ;
2006-07-11 22:01:26 +04:00
s_file_cnt . count = 0 ;
s_file_cnt . uid = uid ;
s_file_cnt . pid = pid ;
2008-03-04 23:46:09 +03:00
2007-12-27 23:30:15 +03:00
share_mode_forall ( sess_file_fn , & s_file_cnt ) ;
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
return s_file_cnt . count ;
2001-02-27 21:22:39 +03:00
}
/*******************************************************************
fill in a sess info level 1 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
static void init_srv_sess_info_1 ( pipes_struct * p , SRV_SESS_INFO_1 * ss1 , uint32 * snum , uint32 * stot )
2001-02-27 21:22:39 +03:00
{
2002-07-15 14:35:28 +04:00
struct sessionid * session_list ;
2001-02-27 21:22:39 +03:00
uint32 num_entries = 0 ;
2006-07-11 22:01:26 +04:00
time_t now = time ( NULL ) ;
2001-02-27 21:22:39 +03:00
2006-07-11 22:01:26 +04:00
if ( ! snum ) {
2007-10-11 00:34:30 +04:00
ss1 - > num_entries_read = 0 ;
ss1 - > ptr_sess_info = 0 ;
ss1 - > num_entries_read2 = 0 ;
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
( * stot ) = 0 ;
return ;
}
2008-03-04 23:46:09 +03:00
2001-02-27 21:22:39 +03:00
if ( ss1 = = NULL ) {
2007-10-11 00:34:30 +04:00
( * snum ) = 0 ;
2001-02-27 21:22:39 +03:00
return ;
}
2007-04-28 22:16:33 +04:00
( * stot ) = list_sessions ( p - > mem_ctx , & session_list ) ;
2008-03-04 23:46:09 +03:00
2007-10-11 00:34:30 +04:00
for ( ; ( * snum ) < ( * stot ) & & num_entries < MAX_SESS_ENTRIES ; ( * snum ) + + ) {
2006-07-11 22:01:26 +04:00
uint32 num_files ;
uint32 connect_time ;
struct passwd * pw = sys_getpwnam ( session_list [ * snum ] . username ) ;
2007-10-19 04:40:25 +04:00
bool guest ;
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
if ( ! pw ) {
DEBUG ( 10 , ( " init_srv_sess_info_1: failed to find owner: %s \n " ,
session_list [ * snum ] . username ) ) ;
continue ;
2001-02-27 21:22:39 +03:00
}
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
connect_time = ( uint32 ) ( now - session_list [ * snum ] . connect_start ) ;
num_files = net_count_files ( pw - > pw_uid , session_list [ * snum ] . pid ) ;
guest = strequal ( session_list [ * snum ] . username , lp_guestaccount ( ) ) ;
2008-03-04 23:46:09 +03:00
init_srv_sess_info1 ( & ss1 - > info_1 [ num_entries ] ,
2007-10-11 00:34:30 +04:00
session_list [ * snum ] . remote_machine ,
2008-03-04 23:46:09 +03:00
session_list [ * snum ] . username ,
2007-10-11 00:34:30 +04:00
num_files ,
connect_time ,
2008-03-04 23:46:09 +03:00
0 ,
2007-10-11 00:34:30 +04:00
guest ) ;
2006-07-11 22:01:26 +04:00
num_entries + + ;
}
2007-10-11 00:34:30 +04:00
ss1 - > num_entries_read = num_entries ;
ss1 - > ptr_sess_info = num_entries > 0 ? 1 : 0 ;
ss1 - > num_entries_read2 = num_entries ;
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
if ( ( * snum ) > = ( * stot ) ) {
( * snum ) = 0 ;
2001-02-27 21:22:39 +03:00
}
2007-10-11 00:34:30 +04:00
2001-02-27 21:22:39 +03:00
}
/*******************************************************************
makes a SRV_R_NET_SESS_ENUM structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
static WERROR init_srv_sess_info_ctr ( pipes_struct * p , SRV_SESS_INFO_CTR * ctr ,
2001-02-27 21:22:39 +03:00
int switch_value , uint32 * resume_hnd , uint32 * total_entries )
{
2002-03-05 05:12:00 +03:00
WERROR status = WERR_OK ;
2001-02-27 21:22:39 +03:00
DEBUG ( 5 , ( " init_srv_sess_info_ctr: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
ctr - > switch_value = switch_value ;
2001-02-27 21:22:39 +03:00
switch ( switch_value ) {
case 0 :
2007-10-11 00:34:30 +04:00
init_srv_sess_info_0 ( p , & ( ctr - > sess . info0 ) , resume_hnd , total_entries ) ;
ctr - > ptr_sess_ctr = 1 ;
2001-02-27 21:22:39 +03:00
break ;
case 1 :
2007-10-11 00:34:30 +04:00
init_srv_sess_info_1 ( p , & ( ctr - > sess . info1 ) , resume_hnd , total_entries ) ;
ctr - > ptr_sess_ctr = 1 ;
2001-02-27 21:22:39 +03:00
break ;
default :
DEBUG ( 5 , ( " init_srv_sess_info_ctr: unsupported switch value %d \n " , switch_value ) ) ;
2007-10-11 00:34:30 +04:00
( * resume_hnd ) = 0 ;
2001-02-27 21:22:39 +03:00
( * total_entries ) = 0 ;
2007-10-11 00:34:30 +04:00
ctr - > ptr_sess_ctr = 0 ;
2002-03-05 05:12:00 +03:00
status = WERR_UNKNOWN_LEVEL ;
2001-02-27 21:22:39 +03:00
break ;
}
return status ;
}
2007-10-11 00:34:30 +04:00
/*******************************************************************
makes a SRV_R_NET_SESS_ENUM structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void init_srv_r_net_sess_enum ( pipes_struct * p , SRV_R_NET_SESS_ENUM * r_n ,
2008-03-04 23:46:09 +03:00
uint32 resume_hnd , int sess_level , int switch_value )
2007-10-11 00:34:30 +04:00
{
DEBUG ( 5 , ( " init_srv_r_net_sess_enum: %d \n " , __LINE__ ) ) ;
r_n - > sess_level = sess_level ;
if ( sess_level = = - 1 )
r_n - > status = WERR_UNKNOWN_LEVEL ;
else
r_n - > status = init_srv_sess_info_ctr ( p , r_n - > ctr , switch_value , & resume_hnd , & r_n - > total_entries ) ;
if ( ! W_ERROR_IS_OK ( r_n - > status ) )
resume_hnd = 0 ;
init_enum_hnd ( & r_n - > enum_hnd , resume_hnd ) ;
}
2001-02-27 21:22:39 +03:00
/*******************************************************************
fill in a conn info level 0 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
static void init_srv_conn_info_0 ( SRV_CONN_INFO_0 * ss0 , uint32 * snum , uint32 * stot )
2001-02-27 21:22:39 +03:00
{
uint32 num_entries = 0 ;
( * stot ) = 1 ;
if ( ss0 = = NULL ) {
2007-10-11 00:34:30 +04:00
( * snum ) = 0 ;
2001-02-27 21:22:39 +03:00
return ;
}
DEBUG ( 5 , ( " init_srv_conn_0_ss0 \n " ) ) ;
if ( snum ) {
2007-10-11 00:34:30 +04:00
for ( ; ( * snum ) < ( * stot ) & & num_entries < MAX_CONN_ENTRIES ; ( * snum ) + + ) {
2001-02-27 21:22:39 +03:00
2007-10-11 00:34:30 +04:00
init_srv_conn_info0 ( & ss0 - > info_0 [ num_entries ] , ( * stot ) ) ;
2001-02-27 21:22:39 +03:00
/* move on to creating next connection */
/* move on to creating next conn */
num_entries + + ;
}
2007-10-11 00:34:30 +04:00
ss0 - > num_entries_read = num_entries ;
ss0 - > ptr_conn_info = num_entries > 0 ? 1 : 0 ;
ss0 - > num_entries_read2 = num_entries ;
2008-03-04 23:46:09 +03:00
2001-02-27 21:22:39 +03:00
if ( ( * snum ) > = ( * stot ) ) {
( * snum ) = 0 ;
}
} else {
2007-10-11 00:34:30 +04:00
ss0 - > num_entries_read = 0 ;
ss0 - > ptr_conn_info = 0 ;
ss0 - > num_entries_read2 = 0 ;
2001-02-27 21:22:39 +03:00
( * stot ) = 0 ;
}
}
/*******************************************************************
fill in a conn info level 1 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
static void init_srv_conn_1_info ( CONN_INFO_1 * se1 , CONN_INFO_1_STR * str1 ,
uint32 id , uint32 type ,
uint32 num_opens , uint32 num_users , uint32 open_time ,
const char * usr_name , const char * net_name )
{
init_srv_conn_info1 ( se1 , id , type , num_opens , num_users , open_time , usr_name , net_name ) ;
init_srv_conn_info1_str ( str1 , usr_name , net_name ) ;
}
/*******************************************************************
fill in a conn info level 1 structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void init_srv_conn_info_1 ( SRV_CONN_INFO_1 * ss1 , uint32 * snum , uint32 * stot )
2001-02-27 21:22:39 +03:00
{
uint32 num_entries = 0 ;
( * stot ) = 1 ;
if ( ss1 = = NULL ) {
2007-10-11 00:34:30 +04:00
( * snum ) = 0 ;
2001-02-27 21:22:39 +03:00
return ;
}
DEBUG ( 5 , ( " init_srv_conn_1_ss1 \n " ) ) ;
if ( snum ) {
2007-10-11 00:34:30 +04:00
for ( ; ( * snum ) < ( * stot ) & & num_entries < MAX_CONN_ENTRIES ; ( * snum ) + + ) {
init_srv_conn_1_info ( & ss1 - > info_1 [ num_entries ] ,
& ss1 - > info_1_str [ num_entries ] ,
( * stot ) , 0x3 , 1 , 1 , 3 , " dummy_user " , " IPC$ " ) ;
2001-02-27 21:22:39 +03:00
/* move on to creating next connection */
/* move on to creating next conn */
num_entries + + ;
}
2007-10-11 00:34:30 +04:00
ss1 - > num_entries_read = num_entries ;
ss1 - > ptr_conn_info = num_entries > 0 ? 1 : 0 ;
ss1 - > num_entries_read2 = num_entries ;
2008-03-04 23:46:09 +03:00
2001-02-27 21:22:39 +03:00
if ( ( * snum ) > = ( * stot ) ) {
( * snum ) = 0 ;
}
} else {
2007-10-11 00:34:30 +04:00
ss1 - > num_entries_read = 0 ;
ss1 - > ptr_conn_info = 0 ;
ss1 - > num_entries_read2 = 0 ;
2008-03-04 23:46:09 +03:00
2001-02-27 21:22:39 +03:00
( * stot ) = 0 ;
}
}
/*******************************************************************
makes a SRV_R_NET_CONN_ENUM structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
static WERROR init_srv_conn_info_ctr ( SRV_CONN_INFO_CTR * ctr ,
2001-02-27 21:22:39 +03:00
int switch_value , uint32 * resume_hnd , uint32 * total_entries )
{
2002-03-05 05:12:00 +03:00
WERROR status = WERR_OK ;
2001-02-27 21:22:39 +03:00
DEBUG ( 5 , ( " init_srv_conn_info_ctr: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
ctr - > switch_value = switch_value ;
2001-02-27 21:22:39 +03:00
switch ( switch_value ) {
case 0 :
2007-10-11 00:34:30 +04:00
init_srv_conn_info_0 ( & ctr - > conn . info0 , resume_hnd , total_entries ) ;
ctr - > ptr_conn_ctr = 1 ;
2001-02-27 21:22:39 +03:00
break ;
case 1 :
2007-10-11 00:34:30 +04:00
init_srv_conn_info_1 ( & ctr - > conn . info1 , resume_hnd , total_entries ) ;
ctr - > ptr_conn_ctr = 1 ;
2001-02-27 21:22:39 +03:00
break ;
default :
DEBUG ( 5 , ( " init_srv_conn_info_ctr: unsupported switch value %d \n " , switch_value ) ) ;
2007-10-11 00:34:30 +04:00
( * resume_hnd = 0 ) ;
2001-02-27 21:22:39 +03:00
( * total_entries ) = 0 ;
2007-10-11 00:34:30 +04:00
ctr - > ptr_conn_ctr = 0 ;
2002-03-05 05:12:00 +03:00
status = WERR_UNKNOWN_LEVEL ;
2001-02-27 21:22:39 +03:00
break ;
}
return status ;
}
2007-10-11 00:34:30 +04:00
/*******************************************************************
makes a SRV_R_NET_CONN_ENUM structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void init_srv_r_net_conn_enum ( SRV_R_NET_CONN_ENUM * r_n ,
2008-03-04 23:46:09 +03:00
uint32 resume_hnd , int conn_level , int switch_value )
2007-10-11 00:34:30 +04:00
{
DEBUG ( 5 , ( " init_srv_r_net_conn_enum: %d \n " , __LINE__ ) ) ;
r_n - > conn_level = conn_level ;
if ( conn_level = = - 1 )
r_n - > status = WERR_UNKNOWN_LEVEL ;
else
r_n - > status = init_srv_conn_info_ctr ( r_n - > ctr , switch_value , & resume_hnd , & r_n - > total_entries ) ;
if ( ! W_ERROR_IS_OK ( r_n - > status ) )
resume_hnd = 0 ;
init_enum_hnd ( & r_n - > enum_hnd , resume_hnd ) ;
}
2001-02-27 21:22:39 +03:00
/*******************************************************************
makes a SRV_R_NET_FILE_ENUM structure .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
static WERROR net_file_enum_3 ( const char * username , SRV_R_NET_FILE_ENUM * r ,
uint32 resume_hnd )
2001-02-27 21:22:39 +03:00
{
2007-10-11 00:34:30 +04:00
TALLOC_CTX * ctx = talloc_tos ( ) ;
SRV_FILE_INFO_CTR * ctr = & r - > ctr ;
2001-02-27 21:22:39 +03:00
2008-03-04 23:46:09 +03:00
/* TODO -- Windows enumerates
2006-07-11 22:01:26 +04:00
( b ) active pipes
( c ) open directories and files */
2007-10-11 00:34:30 +04:00
r - > status = net_enum_files ( ctx , username , & ctr - > file . info3 ,
& ctr - > num_entries , resume_hnd ) ;
if ( ! W_ERROR_IS_OK ( r - > status ) )
goto done ;
2008-03-04 23:46:09 +03:00
2007-10-11 00:34:30 +04:00
r - > status = net_enum_pipes ( ctx , username , & ctr - > file . info3 ,
& ctr - > num_entries , resume_hnd ) ;
if ( ! W_ERROR_IS_OK ( r - > status ) )
goto done ;
2008-03-04 23:46:09 +03:00
2007-10-11 00:34:30 +04:00
r - > level = ctr - > level = 3 ;
r - > total_entries = ctr - > num_entries ;
/* ctr->num_entries = r->total_entries - resume_hnd; */
ctr - > num_entries2 = ctr - > num_entries ;
ctr - > ptr_file_info = 1 ;
r - > status = WERR_OK ;
done :
2008-03-04 23:46:09 +03:00
if ( ctr - > num_entries > 0 )
2007-10-11 00:34:30 +04:00
ctr - > ptr_entries = 1 ;
init_enum_hnd ( & r - > enum_hnd , 0 ) ;
return r - > status ;
2001-02-27 21:22:39 +03:00
}
/*******************************************************************
2006-07-11 22:01:26 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-02-27 21:22:39 +03:00
2007-10-11 00:34:30 +04:00
WERROR _srv_net_file_enum ( pipes_struct * p , SRV_Q_NET_FILE_ENUM * q_u , SRV_R_NET_FILE_ENUM * r_u )
2001-02-27 21:22:39 +03:00
{
2008-02-28 12:14:26 +03:00
const char * username = NULL ;
2007-10-11 00:34:30 +04:00
switch ( q_u - > level ) {
2008-02-28 12:14:26 +03:00
case 3 :
if ( q_u - > username ) {
username = rpcstr_pull_unistr2_talloc (
p - > mem_ctx , q_u - > username ) ;
if ( ! username ) {
return WERR_NOMEM ;
}
2007-10-11 00:34:30 +04:00
}
return net_file_enum_3 ( username , r_u ,
get_enum_hnd ( & q_u - > enum_hnd ) ) ;
2006-07-11 22:01:26 +04:00
default :
return WERR_UNKNOWN_LEVEL ;
}
2008-03-04 23:46:09 +03:00
2006-07-11 22:01:26 +04:00
return WERR_OK ;
2001-02-27 21:22:39 +03:00
}
/*******************************************************************
2008-03-05 01:07:45 +03:00
_srvsvc_NetSrvGetInfo
2001-02-27 21:22:39 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-05 01:07:45 +03:00
WERROR _srvsvc_NetSrvGetInfo ( pipes_struct * p ,
struct srvsvc_NetSrvGetInfo * r )
2001-02-27 21:22:39 +03:00
{
2002-03-05 05:12:00 +03:00
WERROR status = WERR_OK ;
2001-02-27 21:22:39 +03:00
2008-03-05 01:07:45 +03:00
DEBUG ( 5 , ( " _srvsvc_NetSrvGetInfo: %d \n " , __LINE__ ) ) ;
2001-02-27 21:22:39 +03:00
2002-07-15 14:35:28 +04:00
if ( ! pipe_access_check ( p ) ) {
2008-03-05 01:07:45 +03:00
DEBUG ( 3 , ( " access denied to _srvsvc_NetSrvGetInfo \n " ) ) ;
2002-07-15 14:35:28 +04:00
return WERR_ACCESS_DENIED ;
}
2008-03-05 01:07:45 +03:00
switch ( r - > in . level ) {
2002-07-15 14:35:28 +04:00
/* Technically level 102 should only be available to
Administrators but there isn ' t anything super - secret
here , as most of it is made up . */
2008-03-05 01:07:45 +03:00
case 102 : {
struct srvsvc_NetSrvInfo102 * info102 ;
info102 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetSrvInfo102 ) ;
if ( ! info102 ) {
return WERR_NOMEM ;
}
init_srvsvc_NetSrvInfo102 ( info102 ,
PLATFORM_ID_NT ,
global_myname ( ) ,
lp_major_announce_version ( ) ,
lp_minor_announce_version ( ) ,
lp_default_server_announce ( ) ,
string_truncate ( lp_serverstring ( ) , MAX_SERVER_STRING_LENGTH ) ,
0xffffffff , /* users */
0xf , /* disc */
0 , /* hidden */
240 , /* announce */
3000 , /* announce delta */
100000 , /* licenses */
" c: \\ " ) ; /* user path */
r - > out . info - > info102 = info102 ;
2001-02-27 21:22:39 +03:00
break ;
2008-03-05 01:07:45 +03:00
}
case 101 : {
struct srvsvc_NetSrvInfo101 * info101 ;
info101 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetSrvInfo101 ) ;
if ( ! info101 ) {
return WERR_NOMEM ;
}
init_srvsvc_NetSrvInfo101 ( info101 ,
PLATFORM_ID_NT ,
global_myname ( ) ,
lp_major_announce_version ( ) ,
lp_minor_announce_version ( ) ,
lp_default_server_announce ( ) ,
string_truncate ( lp_serverstring ( ) , MAX_SERVER_STRING_LENGTH ) ) ;
r - > out . info - > info101 = info101 ;
2001-02-27 21:22:39 +03:00
break ;
2008-03-05 01:07:45 +03:00
}
case 100 : {
struct srvsvc_NetSrvInfo100 * info100 ;
info100 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetSrvInfo100 ) ;
if ( ! info100 ) {
return WERR_NOMEM ;
}
init_srvsvc_NetSrvInfo100 ( info100 ,
PLATFORM_ID_NT ,
global_myname ( ) ) ;
r - > out . info - > info100 = info100 ;
2001-03-11 03:32:10 +03:00
break ;
2008-03-05 01:07:45 +03:00
}
2001-02-27 21:22:39 +03:00
default :
2007-10-11 00:34:30 +04:00
status = WERR_UNKNOWN_LEVEL ;
2001-02-27 21:22:39 +03:00
break ;
}
2008-03-05 01:07:45 +03:00
DEBUG ( 5 , ( " _srvsvc_NetSrvGetInfo: %d \n " , __LINE__ ) ) ;
2001-02-27 21:22:39 +03:00
2008-03-05 01:07:45 +03:00
return status ;
2001-02-27 21:22:39 +03:00
}
2001-06-25 10:13:27 +04:00
/*******************************************************************
2008-03-05 01:40:25 +03:00
_srvsvc_NetSrvSetInfo
2001-06-25 10:13:27 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-05 01:40:25 +03:00
WERROR _srvsvc_NetSrvSetInfo ( pipes_struct * p ,
struct srvsvc_NetSrvSetInfo * r )
2001-06-25 10:13:27 +04:00
{
2007-10-11 00:34:30 +04:00
WERROR status = WERR_OK ;
2008-03-05 01:40:25 +03:00
DEBUG ( 5 , ( " _srvsvc_NetSrvSetInfo: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
2001-06-25 10:13:27 +04:00
/* Set up the net server set info structure. */
2007-10-11 00:34:30 +04:00
2008-03-05 01:40:25 +03:00
DEBUG ( 5 , ( " _srvsvc_NetSrvSetInfo: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
2008-03-05 01:40:25 +03:00
return status ;
2001-06-25 10:13:27 +04:00
}
2001-02-27 21:22:39 +03:00
/*******************************************************************
net conn enum
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
WERROR _srv_net_conn_enum ( pipes_struct * p , SRV_Q_NET_CONN_ENUM * q_u , SRV_R_NET_CONN_ENUM * r_u )
2001-02-27 21:22:39 +03:00
{
DEBUG ( 5 , ( " srv_net_conn_enum: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
r_u - > ctr = TALLOC_P ( p - > mem_ctx , SRV_CONN_INFO_CTR ) ;
if ( ! r_u - > ctr )
return WERR_NOMEM ;
ZERO_STRUCTP ( r_u - > ctr ) ;
2001-02-27 21:22:39 +03:00
/* set up the */
2007-10-11 00:34:30 +04:00
init_srv_r_net_conn_enum ( r_u ,
get_enum_hnd ( & q_u - > enum_hnd ) ,
q_u - > conn_level ,
q_u - > ctr - > switch_value ) ;
DEBUG ( 5 , ( " srv_net_conn_enum: %d \n " , __LINE__ ) ) ;
return r_u - > status ;
2001-02-27 21:22:39 +03:00
}
/*******************************************************************
net sess enum
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
WERROR _srv_net_sess_enum ( pipes_struct * p , SRV_Q_NET_SESS_ENUM * q_u , SRV_R_NET_SESS_ENUM * r_u )
2001-02-27 21:22:39 +03:00
{
DEBUG ( 5 , ( " _srv_net_sess_enum: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
r_u - > ctr = TALLOC_P ( p - > mem_ctx , SRV_SESS_INFO_CTR ) ;
if ( ! r_u - > ctr )
return WERR_NOMEM ;
ZERO_STRUCTP ( r_u - > ctr ) ;
2001-02-27 21:22:39 +03:00
/* set up the */
2007-10-11 00:34:30 +04:00
init_srv_r_net_sess_enum ( p , r_u ,
get_enum_hnd ( & q_u - > enum_hnd ) ,
q_u - > sess_level ,
q_u - > ctr - > switch_value ) ;
DEBUG ( 5 , ( " _srv_net_sess_enum: %d \n " , __LINE__ ) ) ;
return r_u - > status ;
2005-03-23 23:57:03 +03:00
}
/*******************************************************************
net sess del
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
WERROR _srv_net_sess_del ( pipes_struct * p , SRV_Q_NET_SESS_DEL * q_u , SRV_R_NET_SESS_DEL * r_u )
2005-03-23 23:57:03 +03:00
{
struct sessionid * session_list ;
2007-10-11 00:34:30 +04:00
struct current_user user ;
2005-07-19 07:54:01 +04:00
int num_sessions , snum ;
2007-10-11 00:34:30 +04:00
fstring username ;
fstring machine ;
2007-10-19 04:40:25 +04:00
bool not_root = False ;
2005-03-23 23:57:03 +03:00
2007-10-11 00:34:30 +04:00
rpcstr_pull_unistr2_fstring ( username , & q_u - > uni_user_name ) ;
rpcstr_pull_unistr2_fstring ( machine , & q_u - > uni_cli_name ) ;
2005-03-23 23:57:03 +03:00
/* strip leading backslashes if any */
while ( machine [ 0 ] = = ' \\ ' ) {
memmove ( machine , & machine [ 1 ] , strlen ( machine ) ) ;
}
2007-04-28 22:16:33 +04:00
num_sessions = list_sessions ( p - > mem_ctx , & session_list ) ;
2005-03-23 23:57:03 +03:00
DEBUG ( 5 , ( " _srv_net_sess_del: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
r_u - > status = WERR_ACCESS_DENIED ;
get_current_user ( & user , p ) ;
2005-03-23 23:57:03 +03:00
2005-03-24 17:40:35 +03:00
/* fail out now if you are not root or not a domain admin */
2008-03-04 23:46:09 +03:00
if ( ( user . ut . uid ! = sec_initial_uid ( ) ) & &
2005-03-24 03:01:56 +03:00
( ! nt_token_check_domain_rid ( p - > pipe_user . nt_user_token , DOMAIN_GROUP_RID_ADMINS ) ) ) {
goto done ;
}
2005-03-23 23:57:03 +03:00
for ( snum = 0 ; snum < num_sessions ; snum + + ) {
2007-10-11 00:34:30 +04:00
if ( ( strequal ( session_list [ snum ] . username , username ) | | username [ 0 ] = = ' \0 ' ) & &
strequal ( session_list [ snum ] . remote_machine , machine ) ) {
2007-05-15 14:50:44 +04:00
NTSTATUS ntstat ;
2008-03-04 23:46:09 +03:00
2007-10-11 00:34:30 +04:00
if ( user . ut . uid ! = sec_initial_uid ( ) ) {
not_root = True ;
become_root ( ) ;
}
2007-05-15 14:50:44 +04:00
ntstat = messaging_send ( smbd_messaging_context ( ) ,
session_list [ snum ] . pid ,
MSG_SHUTDOWN , & data_blob_null ) ;
2008-03-04 23:46:09 +03:00
2007-05-15 14:50:44 +04:00
if ( NT_STATUS_IS_OK ( ntstat ) )
2007-10-11 00:34:30 +04:00
r_u - > status = WERR_OK ;
2008-03-04 23:46:09 +03:00
if ( not_root )
2007-10-11 00:34:30 +04:00
unbecome_root ( ) ;
2005-03-23 23:57:03 +03:00
}
}
DEBUG ( 5 , ( " _srv_net_sess_del: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
2005-03-24 03:01:56 +03:00
done :
2007-10-11 00:34:30 +04:00
return r_u - > status ;
2001-02-27 21:22:39 +03:00
}
2001-04-06 05:39:12 +04:00
/*******************************************************************
2008-03-07 18:19:43 +03:00
_srvsvc_NetShareEnumAll
2001-04-06 05:39:12 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
WERROR _srvsvc_NetShareEnumAll ( pipes_struct * p ,
struct srvsvc_NetShareEnumAll * r )
2001-04-06 05:39:12 +04:00
{
2008-03-07 18:19:43 +03:00
WERROR werr ;
DEBUG ( 5 , ( " _srvsvc_NetShareEnumAll: %d \n " , __LINE__ ) ) ;
2001-04-06 05:39:12 +04:00
2002-07-15 14:35:28 +04:00
if ( ! pipe_access_check ( p ) ) {
2008-03-07 18:19:43 +03:00
DEBUG ( 3 , ( " access denied to _srvsvc_NetShareEnumAll \n " ) ) ;
2002-07-15 14:35:28 +04:00
return WERR_ACCESS_DENIED ;
}
2001-04-06 05:39:12 +04:00
/* Create the list of shares for the response. */
2008-03-07 18:19:43 +03:00
werr = init_srv_share_info_ctr ( p ,
r - > in . info_ctr ,
r - > in . resume_handle ,
r - > out . totalentries ,
true ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
DEBUG ( 5 , ( " _srvsvc_NetShareEnumAll: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
return werr ;
2001-04-06 05:39:12 +04:00
}
2001-02-27 21:22:39 +03:00
/*******************************************************************
2008-03-07 18:19:43 +03:00
_srvsvc_NetShareEnum
2001-02-27 21:22:39 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
WERROR _srvsvc_NetShareEnum ( pipes_struct * p ,
struct srvsvc_NetShareEnum * r )
2001-02-27 21:22:39 +03:00
{
2008-03-07 18:19:43 +03:00
WERROR werr ;
DEBUG ( 5 , ( " _srvsvc_NetShareEnum: %d \n " , __LINE__ ) ) ;
2001-02-27 21:22:39 +03:00
2002-07-15 14:35:28 +04:00
if ( ! pipe_access_check ( p ) ) {
2008-03-07 18:19:43 +03:00
DEBUG ( 3 , ( " access denied to _srvsvc_NetShareEnum \n " ) ) ;
2002-07-15 14:35:28 +04:00
return WERR_ACCESS_DENIED ;
}
2001-02-27 21:22:39 +03:00
/* Create the list of shares for the response. */
2008-03-07 18:19:43 +03:00
werr = init_srv_share_info_ctr ( p ,
r - > in . info_ctr ,
r - > in . resume_handle ,
r - > out . totalentries ,
false ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
DEBUG ( 5 , ( " _srvsvc_NetShareEnum: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
2008-03-07 18:19:43 +03:00
return werr ;
2001-02-27 21:22:39 +03:00
}
/*******************************************************************
2008-03-07 18:19:43 +03:00
_srvsvc_NetShareGetInfo
2001-02-27 21:22:39 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-07 18:19:43 +03:00
WERROR _srvsvc_NetShareGetInfo ( pipes_struct * p ,
struct srvsvc_NetShareGetInfo * r )
2001-02-27 21:22:39 +03:00
{
2008-03-07 18:19:43 +03:00
WERROR status = WERR_OK ;
2007-10-11 00:34:30 +04:00
fstring share_name ;
2008-03-07 18:19:43 +03:00
int snum ;
union srvsvc_NetShareInfo * info = r - > out . info ;
2001-02-27 21:22:39 +03:00
2008-03-07 18:19:43 +03:00
DEBUG ( 5 , ( " _srvsvc_NetShareGetInfo: %d \n " , __LINE__ ) ) ;
2001-02-27 21:22:39 +03:00
2008-03-07 18:19:43 +03:00
fstrcpy ( share_name , r - > in . share_name ) ;
2006-09-22 03:57:32 +04:00
2008-03-07 18:19:43 +03:00
snum = find_service ( share_name ) ;
if ( snum < 0 ) {
return WERR_INVALID_NAME ;
}
2001-02-27 21:22:39 +03:00
2008-03-07 18:19:43 +03:00
switch ( r - > in . level ) {
case 0 :
info - > info0 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo0 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info0 ) ;
init_srv_share_info_0 ( p , info - > info0 , snum ) ;
break ;
case 1 :
info - > info1 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo1 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info1 ) ;
init_srv_share_info_1 ( p , info - > info1 , snum ) ;
break ;
case 2 :
info - > info2 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo2 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info2 ) ;
init_srv_share_info_2 ( p , info - > info2 , snum ) ;
break ;
case 501 :
info - > info501 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo501 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info501 ) ;
init_srv_share_info_501 ( p , info - > info501 , snum ) ;
break ;
case 502 :
info - > info502 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo502 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info502 ) ;
init_srv_share_info_502 ( p , info - > info502 , snum ) ;
break ;
case 1004 :
info - > info1004 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo1004 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info1004 ) ;
init_srv_share_info_1004 ( p , info - > info1004 , snum ) ;
break ;
case 1005 :
info - > info1005 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo1005 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info1005 ) ;
init_srv_share_info_1005 ( p , info - > info1005 , snum ) ;
break ;
case 1006 :
info - > info1006 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo1006 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info1006 ) ;
init_srv_share_info_1006 ( p , info - > info1006 , snum ) ;
break ;
case 1007 :
info - > info1007 = TALLOC_P ( p - > mem_ctx , struct srvsvc_NetShareInfo1007 ) ;
W_ERROR_HAVE_NO_MEMORY ( info - > info1007 ) ;
init_srv_share_info_1007 ( p , info - > info1007 , snum ) ;
break ;
case 1501 :
init_srv_share_info_1501 ( p , info - > info1501 , snum ) ;
break ;
default :
DEBUG ( 5 , ( " _srvsvc_NetShareGetInfo: unsupported switch value %d \n " ,
r - > in . level ) ) ;
status = WERR_UNKNOWN_LEVEL ;
break ;
}
DEBUG ( 5 , ( " _srvsvc_NetShareGetInfo: %d \n " , __LINE__ ) ) ;
return status ;
2001-02-27 21:22:39 +03:00
}
2001-04-07 22:46:47 +04:00
/*******************************************************************
Check a given DOS pathname is valid for a share .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-11-16 01:19:52 +03:00
char * valid_share_pathname ( TALLOC_CTX * ctx , const char * dos_pathname )
2007-10-11 00:34:30 +04:00
{
2007-11-28 01:35:30 +03:00
char * ptr = NULL ;
if ( ! dos_pathname ) {
return NULL ;
}
2006-12-03 19:19:29 +03:00
2007-11-28 01:35:30 +03:00
ptr = talloc_strdup ( ctx , dos_pathname ) ;
2007-11-16 01:19:52 +03:00
if ( ! ptr ) {
return NULL ;
}
2007-10-11 00:34:30 +04:00
/* Convert any '\' paths to '/' */
2007-11-16 01:19:52 +03:00
unix_format ( ptr ) ;
2007-11-27 22:22:58 +03:00
ptr = unix_clean_name ( ctx , ptr ) ;
2007-11-16 01:19:52 +03:00
if ( ! ptr ) {
return NULL ;
}
2006-12-03 19:19:29 +03:00
2007-10-11 00:34:30 +04:00
/* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */
2007-11-16 01:19:52 +03:00
if ( strlen ( ptr ) > 2 & & ptr [ 1 ] = = ' : ' & & ptr [ 0 ] ! = ' / ' )
2007-10-11 00:34:30 +04:00
ptr + = 2 ;
2006-12-03 19:19:29 +03:00
2007-10-11 00:34:30 +04:00
/* Only absolute paths allowed. */
if ( * ptr ! = ' / ' )
return NULL ;
2006-12-03 19:19:29 +03:00
2007-10-11 00:34:30 +04:00
return ptr ;
2006-12-03 19:19:29 +03:00
}
2001-04-09 00:01:51 +04:00
/*******************************************************************
2008-03-05 03:26:39 +03:00
_srvsvc_NetShareSetInfo . Modify share details .
2001-04-09 00:01:51 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-05 03:26:39 +03:00
WERROR _srvsvc_NetShareSetInfo ( pipes_struct * p ,
struct srvsvc_NetShareSetInfo * r )
2001-04-09 00:01:51 +04:00
{
2007-10-11 00:34:30 +04:00
struct current_user user ;
2007-11-28 01:35:30 +03:00
char * command = NULL ;
char * share_name = NULL ;
char * comment = NULL ;
2008-03-05 03:26:39 +03:00
const char * pathname = NULL ;
2001-04-09 00:01:51 +04:00
int type ;
int snum ;
2007-10-11 00:34:30 +04:00
int ret ;
2007-11-28 01:35:30 +03:00
char * path = NULL ;
2001-04-09 10:36:38 +04:00
SEC_DESC * psd = NULL ;
2005-01-18 22:51:36 +03:00
SE_PRIV se_diskop = SE_DISK_OPERATOR ;
2007-10-19 04:40:25 +04:00
bool is_disk_op = False ;
2006-01-23 17:34:26 +03:00
int max_connections = 0 ;
2007-11-28 01:35:30 +03:00
TALLOC_CTX * ctx = p - > mem_ctx ;
2008-03-05 03:26:39 +03:00
union srvsvc_NetShareInfo * info = r - > in . info ;
2001-04-09 00:01:51 +04:00
2008-03-05 03:26:39 +03:00
DEBUG ( 5 , ( " _srvsvc_NetShareSetInfo: %d \n " , __LINE__ ) ) ;
2001-04-09 00:01:51 +04:00
2008-03-05 03:26:39 +03:00
share_name = talloc_strdup ( p - > mem_ctx , r - > in . share_name ) ;
2007-11-28 01:35:30 +03:00
if ( ! share_name ) {
2008-03-05 03:26:39 +03:00
return WERR_NOMEM ;
2007-11-28 01:35:30 +03:00
}
2001-04-09 00:01:51 +04:00
2008-03-05 03:26:39 +03:00
* r - > out . parm_error = 0 ;
2007-10-11 00:34:30 +04:00
2007-11-28 01:35:30 +03:00
if ( strequal ( share_name , " IPC$ " )
2007-10-11 00:34:30 +04:00
| | ( lp_enable_asu_support ( ) & & strequal ( share_name , " ADMIN$ " ) )
| | strequal ( share_name , " global " ) )
2005-05-23 20:25:31 +04:00
{
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2005-05-23 20:25:31 +04:00
}
2001-04-09 12:00:19 +04:00
2007-10-11 00:34:30 +04:00
snum = find_service ( share_name ) ;
2001-04-09 00:01:51 +04:00
/* Does this share exist ? */
if ( snum < 0 )
2005-06-15 16:43:36 +04:00
return WERR_NET_NAME_NOT_FOUND ;
2001-04-09 22:03:02 +04:00
/* No change to printer shares. */
if ( lp_print_ok ( snum ) )
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2001-04-09 00:01:51 +04:00
2007-10-11 00:34:30 +04:00
get_current_user ( & user , p ) ;
is_disk_op = user_has_privileges ( p - > pipe_user . nt_user_token , & se_diskop ) ;
2007-11-28 01:35:30 +03:00
2005-01-18 22:51:36 +03:00
/* fail out now if you are not root and not a disk op */
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
if ( user . ut . uid ! = sec_initial_uid ( ) & & ! is_disk_op )
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2001-04-09 00:01:51 +04:00
2008-03-05 03:26:39 +03:00
switch ( r - > in . level ) {
2001-04-09 00:01:51 +04:00
case 1 :
2007-11-28 01:35:30 +03:00
pathname = talloc_strdup ( ctx , lp_pathname ( snum ) ) ;
2008-03-05 03:26:39 +03:00
comment = talloc_strdup ( ctx , info - > info2 - > comment ) ;
type = info - > info2 - > type ;
2002-08-17 19:34:15 +04:00
psd = NULL ;
break ;
2001-04-09 00:01:51 +04:00
case 2 :
2008-03-05 03:26:39 +03:00
comment = talloc_strdup ( ctx , info - > info2 - > comment ) ;
pathname = info - > info2 - > path ;
type = info - > info2 - > type ;
max_connections = ( info - > info2 - > max_users = = 0xffffffff ) ?
0 : info - > info2 - > max_users ;
2002-08-17 19:34:15 +04:00
psd = NULL ;
break ;
2007-10-11 00:34:30 +04:00
#if 0
/* not supported on set but here for completeness */
case 501 :
2008-03-05 03:26:39 +03:00
comment = talloc_strdup ( ctx , info - > info501 - > comment ) ;
type = info - > info501 - > type ;
2007-10-11 00:34:30 +04:00
psd = NULL ;
break ;
# endif
2001-04-09 00:01:51 +04:00
case 502 :
2008-03-05 03:26:39 +03:00
comment = talloc_strdup ( ctx , info - > info502 - > comment ) ;
pathname = info - > info502 - > path ;
type = info - > info502 - > type ;
psd = info - > info502 - > sd ;
2001-04-09 12:00:19 +04:00
map_generic_share_sd_bits ( psd ) ;
2001-04-09 00:01:51 +04:00
break ;
2002-08-17 19:34:15 +04:00
case 1004 :
2007-11-28 01:35:30 +03:00
pathname = talloc_strdup ( ctx , lp_pathname ( snum ) ) ;
2008-03-05 03:26:39 +03:00
comment = talloc_strdup ( ctx , info - > info1004 - > comment ) ;
2002-08-17 19:34:15 +04:00
type = STYPE_DISKTREE ;
break ;
2001-04-09 00:01:51 +04:00
case 1005 :
2003-07-02 01:47:13 +04:00
/* XP re-sets the csc policy even if it wasn't changed by the
user , so we must compare it to see if it ' s what is set in
smb . conf , so that we can contine other ops like setting
ACLs on a share */
2008-03-05 03:26:39 +03:00
if ( ( ( info - > info1005 - > dfs_flags &
2003-07-02 01:47:13 +04:00
SHARE_1005_CSC_POLICY_MASK ) > >
SHARE_1005_CSC_POLICY_SHIFT ) = = lp_csc_policy ( snum ) )
return WERR_OK ;
else {
2008-03-05 03:26:39 +03:00
DEBUG ( 3 , ( " _srvsvc_NetShareSetInfo: client is trying to change csc policy from the network; must be done with smb.conf \n " ) ) ;
2003-07-02 01:47:13 +04:00
return WERR_ACCESS_DENIED ;
}
2002-08-17 19:34:15 +04:00
case 1006 :
case 1007 :
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2001-04-09 12:00:19 +04:00
case 1501 :
2007-11-28 01:35:30 +03:00
pathname = talloc_strdup ( ctx , lp_pathname ( snum ) ) ;
comment = talloc_strdup ( ctx , lp_comment ( snum ) ) ;
2008-03-05 03:26:39 +03:00
psd = info - > info1501 - > sd ;
2001-04-09 12:00:19 +04:00
map_generic_share_sd_bits ( psd ) ;
type = STYPE_DISKTREE ;
break ;
2001-04-09 00:01:51 +04:00
default :
2008-03-05 03:26:39 +03:00
DEBUG ( 5 , ( " _srvsvc_NetShareSetInfo: unsupported switch value %d \n " ,
r - > in . level ) ) ;
2002-03-05 05:12:00 +03:00
return WERR_UNKNOWN_LEVEL ;
2001-04-09 10:36:38 +04:00
}
/* We can only modify disk shares. */
if ( type ! = STYPE_DISKTREE )
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2007-11-28 01:35:30 +03:00
2001-04-09 10:36:38 +04:00
/* Check if the pathname is valid. */
2007-11-16 01:19:52 +03:00
if ( ! ( path = valid_share_pathname ( p - > mem_ctx , pathname ) ) )
2002-03-05 05:12:00 +03:00
return WERR_OBJECT_PATH_INVALID ;
2001-04-09 10:36:38 +04:00
2007-10-11 00:34:30 +04:00
/* Ensure share name, pathname and comment don't contain '"' characters. */
string_replace ( share_name , ' " ' , ' ' ) ;
2005-01-19 21:28:55 +03:00
string_replace ( path , ' " ' , ' ' ) ;
2007-11-28 01:35:30 +03:00
if ( comment ) {
string_replace ( comment , ' " ' , ' ' ) ;
}
2001-04-09 10:36:38 +04:00
2008-03-05 03:26:39 +03:00
DEBUG ( 10 , ( " _srvsvc_NetShareSetInfo: change share command = %s \n " ,
2007-10-11 00:34:30 +04:00
lp_change_share_cmd ( ) ? lp_change_share_cmd ( ) : " NULL " ) ) ;
2001-04-09 21:10:06 +04:00
2001-04-09 10:36:38 +04:00
/* Only call modify function if something changed. */
2007-11-28 01:35:30 +03:00
if ( strcmp ( path , lp_pathname ( snum ) ) | | strcmp ( comment , lp_comment ( snum ) )
| | ( lp_max_connections ( snum ) ! = max_connections ) ) {
2007-10-11 00:34:30 +04:00
if ( ! lp_change_share_cmd ( ) | | ! * lp_change_share_cmd ( ) ) {
2008-03-05 03:26:39 +03:00
DEBUG ( 10 , ( " _srvsvc_NetShareSetInfo: No change share command \n " ) ) ;
2007-10-11 00:34:30 +04:00
return WERR_ACCESS_DENIED ;
}
2001-04-09 10:36:38 +04:00
2007-11-28 01:35:30 +03:00
command = talloc_asprintf ( p - > mem_ctx ,
" %s \" %s \" \" %s \" \" %s \" \" %s \" %d " ,
lp_change_share_cmd ( ) ,
2007-12-10 22:30:37 +03:00
get_dyn_CONFIGFILE ( ) ,
2007-11-28 01:35:30 +03:00
share_name ,
path ,
comment ? comment : " " ,
max_connections ) ;
if ( ! command ) {
return WERR_NOMEM ;
}
2001-04-09 10:36:38 +04:00
2008-03-05 03:26:39 +03:00
DEBUG ( 10 , ( " _srvsvc_NetShareSetInfo: Running [%s] \n " , command ) ) ;
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
/********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
2007-11-28 01:35:30 +03:00
if ( is_disk_op )
2007-10-11 00:34:30 +04:00
become_root ( ) ;
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
if ( ( ret = smbrun ( command , NULL ) ) = = 0 ) {
/* Tell everyone we updated smb.conf. */
message_send_all ( smbd_messaging_context ( ) ,
MSG_SMB_CONF_UPDATED , NULL , 0 ,
NULL ) ;
2005-01-20 00:10:56 +03:00
}
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
if ( is_disk_op )
unbecome_root ( ) ;
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
/********* END SeDiskOperatorPrivilege BLOCK *********/
2008-03-05 03:26:39 +03:00
DEBUG ( 3 , ( " _srvsvc_NetShareSetInfo: Running [%s] returned (%d) \n " ,
command , ret ) ) ;
2007-11-28 01:35:30 +03:00
TALLOC_FREE ( command ) ;
2007-10-11 00:34:30 +04:00
if ( ret ! = 0 )
return WERR_ACCESS_DENIED ;
} else {
2008-03-05 03:26:39 +03:00
DEBUG ( 10 , ( " _srvsvc_NetShareSetInfo: No change to share name (%s) \n " ,
share_name ) ) ;
2001-04-09 10:36:38 +04:00
}
/* Replace SD if changed. */
if ( psd ) {
SEC_DESC * old_sd ;
size_t sd_size ;
2007-10-11 00:34:30 +04:00
old_sd = get_share_security ( p - > mem_ctx , lp_servicename ( snum ) , & sd_size ) ;
2001-04-09 10:36:38 +04:00
if ( old_sd & & ! sec_desc_equal ( old_sd , psd ) ) {
2007-10-11 00:34:30 +04:00
if ( ! set_share_security ( share_name , psd ) )
2008-03-05 03:26:39 +03:00
DEBUG ( 0 , ( " _srvsvc_NetShareSetInfo: Failed to change security info in share %s. \n " ,
2007-10-11 00:34:30 +04:00
share_name ) ) ;
2001-04-09 10:36:38 +04:00
}
2001-04-09 00:01:51 +04:00
}
2007-11-28 01:35:30 +03:00
2008-03-05 03:26:39 +03:00
DEBUG ( 5 , ( " _srvsvc_NetShareSetInfo: %d \n " , __LINE__ ) ) ;
2001-04-09 00:01:51 +04:00
2002-03-05 05:12:00 +03:00
return WERR_OK ;
2001-04-09 00:01:51 +04:00
}
2001-04-06 21:41:47 +04:00
/*******************************************************************
2007-11-28 01:35:30 +03:00
Net share add . Call ' add_share_command " sharename " " pathname "
2006-01-23 17:47:55 +03:00
" comment " " max connections = "
2001-04-06 21:41:47 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
WERROR _srv_net_share_add ( pipes_struct * p , SRV_Q_NET_SHARE_ADD * q_u , SRV_R_NET_SHARE_ADD * r_u )
2001-04-06 21:41:47 +04:00
{
2007-10-11 00:34:30 +04:00
struct current_user user ;
2007-11-28 01:35:30 +03:00
char * command = NULL ;
char * share_name = NULL ;
char * comment = NULL ;
char * pathname = NULL ;
2001-04-07 04:36:38 +04:00
int type ;
2007-10-11 00:34:30 +04:00
int snum ;
int ret ;
char * path ;
2001-04-09 10:36:38 +04:00
SEC_DESC * psd = NULL ;
2005-01-18 22:51:36 +03:00
SE_PRIV se_diskop = SE_DISK_OPERATOR ;
2007-10-19 04:40:25 +04:00
bool is_disk_op ;
2007-10-11 00:34:30 +04:00
int max_connections = 0 ;
2007-11-28 01:35:30 +03:00
TALLOC_CTX * ctx = p - > mem_ctx ;
2001-04-06 21:41:47 +04:00
DEBUG ( 5 , ( " _srv_net_share_add: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
r_u - > parm_error = 0 ;
get_current_user ( & user , p ) ;
2001-04-06 21:41:47 +04:00
2007-10-11 00:34:30 +04:00
is_disk_op = user_has_privileges ( p - > pipe_user . nt_user_token , & se_diskop ) ;
2005-01-18 22:51:36 +03:00
2007-11-28 01:35:30 +03:00
if ( user . ut . uid ! = sec_initial_uid ( ) & & ! is_disk_op )
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2001-04-07 04:36:38 +04:00
2007-10-11 00:34:30 +04:00
if ( ! lp_add_share_cmd ( ) | | ! * lp_add_share_cmd ( ) ) {
DEBUG ( 10 , ( " _srv_net_share_add: No add share command \n " ) ) ;
return WERR_ACCESS_DENIED ;
}
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
switch ( q_u - > info_level ) {
2002-08-17 19:34:15 +04:00
case 0 :
/* No path. Not enough info in a level 0 to do anything. */
return WERR_ACCESS_DENIED ;
2001-04-06 21:41:47 +04:00
case 1 :
2001-04-07 04:36:38 +04:00
/* Not enough info in a level 1 to do anything. */
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2001-04-06 21:41:47 +04:00
case 2 :
2007-11-28 01:35:30 +03:00
share_name = unistr2_to_ascii_talloc ( ctx ,
& q_u - > info . share . info2 . info_2_str . uni_netname ) ;
comment = unistr2_to_ascii_talloc ( ctx ,
& q_u - > info . share . info2 . info_2_str . uni_remark ) ;
pathname = unistr2_to_ascii_talloc ( ctx ,
& q_u - > info . share . info2 . info_2_str . uni_path ) ;
2007-10-11 00:34:30 +04:00
max_connections = ( q_u - > info . share . info2 . info_2 . max_uses = = 0xffffffff ) ? 0 : q_u - > info . share . info2 . info_2 . max_uses ;
type = q_u - > info . share . info2 . info_2 . type ;
2001-04-06 21:41:47 +04:00
break ;
2002-08-17 19:34:15 +04:00
case 501 :
/* No path. Not enough info in a level 501 to do anything. */
return WERR_ACCESS_DENIED ;
2001-04-06 21:41:47 +04:00
case 502 :
2007-11-28 01:35:30 +03:00
share_name = unistr2_to_ascii_talloc ( ctx ,
& q_u - > info . share . info502 . info_502_str . uni_netname ) ;
comment = unistr2_to_ascii_talloc ( ctx ,
& q_u - > info . share . info502 . info_502_str . uni_remark ) ;
pathname = unistr2_to_ascii_talloc ( ctx ,
& q_u - > info . share . info502 . info_502_str . uni_path ) ;
2007-10-11 00:34:30 +04:00
type = q_u - > info . share . info502 . info_502 . type ;
psd = q_u - > info . share . info502 . info_502_str . sd ;
2001-04-09 12:00:19 +04:00
map_generic_share_sd_bits ( psd ) ;
2001-04-06 21:41:47 +04:00
break ;
2002-08-17 19:34:15 +04:00
2008-03-04 23:46:09 +03:00
/* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */
2002-08-17 19:34:15 +04:00
case 1004 :
2001-04-06 21:41:47 +04:00
case 1005 :
2002-08-17 19:34:15 +04:00
case 1006 :
case 1007 :
return WERR_ACCESS_DENIED ;
case 1501 :
2001-04-07 04:36:38 +04:00
/* DFS only level. */
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2001-04-06 21:41:47 +04:00
default :
2007-10-11 00:34:30 +04:00
DEBUG ( 5 , ( " _srv_net_share_add: unsupported switch value %d \n " , q_u - > info_level ) ) ;
2002-03-05 05:12:00 +03:00
return WERR_UNKNOWN_LEVEL ;
2001-04-06 21:41:47 +04:00
}
2005-12-11 08:06:35 +03:00
/* check for invalid share names */
2007-11-28 01:35:30 +03:00
if ( ! share_name | | ! validate_net_name ( share_name ,
INVALID_SHARENAME_CHARS ,
strlen ( share_name ) ) ) {
DEBUG ( 5 , ( " _srv_net_name_validate: Bad sharename \" %s \" \n " ,
share_name ? share_name : " " ) ) ;
2005-12-11 08:06:35 +03:00
return WERR_INVALID_NAME ;
}
2007-11-28 01:35:30 +03:00
if ( strequal ( share_name , " IPC$ " ) | | strequal ( share_name , " global " )
| | ( lp_enable_asu_support ( ) & &
strequal ( share_name , " ADMIN$ " ) ) ) {
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2005-05-23 20:25:31 +04:00
}
2001-04-10 23:43:14 +04:00
2007-10-11 00:34:30 +04:00
snum = find_service ( share_name ) ;
/* Share already exists. */
2007-11-28 01:35:30 +03:00
if ( snum > = 0 ) {
2002-03-05 05:12:00 +03:00
return WERR_ALREADY_EXISTS ;
2007-11-28 01:35:30 +03:00
}
2001-04-07 04:36:38 +04:00
2001-04-07 22:46:47 +04:00
/* We can only add disk shares. */
2007-11-28 01:35:30 +03:00
if ( type ! = STYPE_DISKTREE ) {
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2007-11-28 01:35:30 +03:00
}
2001-04-07 22:46:47 +04:00
/* Check if the pathname is valid. */
2007-11-28 01:35:30 +03:00
if ( ! ( path = valid_share_pathname ( p - > mem_ctx , pathname ) ) ) {
2002-03-05 05:12:00 +03:00
return WERR_OBJECT_PATH_INVALID ;
2007-11-28 01:35:30 +03:00
}
2001-04-07 04:36:38 +04:00
2007-10-11 00:34:30 +04:00
/* Ensure share name, pathname and comment don't contain '"' characters. */
2001-04-09 00:01:51 +04:00
string_replace ( share_name , ' " ' , ' ' ) ;
2005-01-19 21:28:55 +03:00
string_replace ( path , ' " ' , ' ' ) ;
2007-11-28 01:35:30 +03:00
if ( comment ) {
string_replace ( comment , ' " ' , ' ' ) ;
}
command = talloc_asprintf ( ctx ,
" %s \" %s \" \" %s \" \" %s \" \" %s \" %d " ,
lp_add_share_cmd ( ) ,
2007-12-10 22:30:37 +03:00
get_dyn_CONFIGFILE ( ) ,
2007-11-28 01:35:30 +03:00
share_name ,
path ,
comment ? comment : " " ,
2007-10-11 00:34:30 +04:00
max_connections ) ;
2007-11-28 01:35:30 +03:00
if ( ! command ) {
return WERR_NOMEM ;
}
2007-10-11 00:34:30 +04:00
DEBUG ( 10 , ( " _srv_net_share_add: Running [%s] \n " , command ) ) ;
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
/********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
if ( is_disk_op )
become_root ( ) ;
2005-01-18 22:51:36 +03:00
2007-10-11 00:34:30 +04:00
if ( ( ret = smbrun ( command , NULL ) ) = = 0 ) {
/* Tell everyone we updated smb.conf. */
message_send_all ( smbd_messaging_context ( ) ,
MSG_SMB_CONF_UPDATED , NULL , 0 , NULL ) ;
2005-01-20 00:10:56 +03:00
}
2005-01-18 22:51:36 +03:00
2007-10-11 00:34:30 +04:00
if ( is_disk_op )
unbecome_root ( ) ;
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
/********* END SeDiskOperatorPrivilege BLOCK *********/
DEBUG ( 3 , ( " _srv_net_share_add: Running [%s] returned (%d) \n " , command , ret ) ) ;
2007-11-28 01:35:30 +03:00
TALLOC_FREE ( command ) ;
2007-10-11 00:34:30 +04:00
if ( ret ! = 0 )
return WERR_ACCESS_DENIED ;
2001-04-09 10:36:38 +04:00
if ( psd ) {
2006-11-11 21:07:51 +03:00
if ( ! set_share_security ( share_name , psd ) ) {
2007-10-11 00:34:30 +04:00
DEBUG ( 0 , ( " _srv_net_share_add: Failed to add security info to share %s. \n " , share_name ) ) ;
2005-01-19 21:28:55 +03:00
}
2001-04-09 10:36:38 +04:00
}
2001-04-07 22:46:47 +04:00
/*
2001-04-10 05:44:45 +04:00
* We don ' t call reload_services ( ) here , the message will
2001-04-07 22:46:47 +04:00
* cause this to be done before the next packet is read
* from the client . JRA .
*/
2001-04-06 21:41:47 +04:00
DEBUG ( 5 , ( " _srv_net_share_add: %d \n " , __LINE__ ) ) ;
2002-03-05 05:12:00 +03:00
return WERR_OK ;
2001-04-06 21:41:47 +04:00
}
2001-04-06 22:25:17 +04:00
/*******************************************************************
2001-04-07 04:36:38 +04:00
Net share delete . Call " delete share command " with the share name as
a parameter .
2001-04-06 22:25:17 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
WERROR _srv_net_share_del ( pipes_struct * p , SRV_Q_NET_SHARE_DEL * q_u , SRV_R_NET_SHARE_DEL * r_u )
2001-04-06 22:25:17 +04:00
{
2007-10-11 00:34:30 +04:00
struct current_user user ;
2007-11-28 01:35:30 +03:00
char * command = NULL ;
char * share_name = NULL ;
2007-10-11 00:34:30 +04:00
int ret ;
int snum ;
2005-01-18 22:51:36 +03:00
SE_PRIV se_diskop = SE_DISK_OPERATOR ;
2007-10-19 04:40:25 +04:00
bool is_disk_op ;
2007-11-28 01:35:30 +03:00
struct share_params * params ;
TALLOC_CTX * ctx = p - > mem_ctx ;
2001-04-06 22:25:17 +04:00
DEBUG ( 5 , ( " _srv_net_share_del: %d \n " , __LINE__ ) ) ;
2007-11-28 01:35:30 +03:00
share_name = unistr2_to_ascii_talloc ( ctx , & q_u - > uni_share_name ) ;
2007-10-11 00:34:30 +04:00
2007-11-28 01:35:30 +03:00
if ( ! share_name ) {
return WERR_NET_NAME_NOT_FOUND ;
}
if ( strequal ( share_name , " IPC$ " )
2007-10-11 00:34:30 +04:00
| | ( lp_enable_asu_support ( ) & & strequal ( share_name , " ADMIN$ " ) )
| | strequal ( share_name , " global " ) )
2005-05-23 20:25:31 +04:00
{
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2005-05-23 20:25:31 +04:00
}
2001-04-09 22:03:02 +04:00
2007-11-28 01:35:30 +03:00
if ( ! ( params = get_share_params ( p - > mem_ctx , share_name ) ) ) {
return WERR_NO_SUCH_SHARE ;
}
2007-10-11 00:34:30 +04:00
snum = find_service ( share_name ) ;
2001-04-09 22:03:02 +04:00
/* No change to printer shares. */
2007-10-11 00:34:30 +04:00
if ( lp_print_ok ( snum ) )
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2001-04-06 22:25:17 +04:00
2007-10-11 00:34:30 +04:00
get_current_user ( & user , p ) ;
is_disk_op = user_has_privileges ( p - > pipe_user . nt_user_token , & se_diskop ) ;
2007-11-28 01:35:30 +03:00
if ( user . ut . uid ! = sec_initial_uid ( ) & & ! is_disk_op )
2007-10-11 00:34:30 +04:00
return WERR_ACCESS_DENIED ;
2005-01-18 22:51:36 +03:00
2007-10-11 00:34:30 +04:00
if ( ! lp_delete_share_cmd ( ) | | ! * lp_delete_share_cmd ( ) ) {
DEBUG ( 10 , ( " _srv_net_share_del: No delete share command \n " ) ) ;
2002-03-05 05:12:00 +03:00
return WERR_ACCESS_DENIED ;
2007-10-11 00:34:30 +04:00
}
2007-11-28 01:35:30 +03:00
command = talloc_asprintf ( ctx ,
" %s \" %s \" \" %s \" " ,
lp_delete_share_cmd ( ) ,
2007-12-10 22:30:37 +03:00
get_dyn_CONFIGFILE ( ) ,
2007-11-28 01:35:30 +03:00
lp_servicename ( snum ) ) ;
if ( ! command ) {
return WERR_NOMEM ;
}
2007-10-11 00:34:30 +04:00
DEBUG ( 10 , ( " _srv_net_share_del: Running [%s] \n " , command ) ) ;
2001-04-07 04:36:38 +04:00
2007-10-11 00:34:30 +04:00
/********* BEGIN SeDiskOperatorPrivilege BLOCK *********/
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
if ( is_disk_op )
become_root ( ) ;
2006-10-21 21:00:47 +04:00
2007-10-11 00:34:30 +04:00
if ( ( ret = smbrun ( command , NULL ) ) = = 0 ) {
/* Tell everyone we updated smb.conf. */
message_send_all ( smbd_messaging_context ( ) ,
MSG_SMB_CONF_UPDATED , NULL , 0 , NULL ) ;
2006-10-21 21:00:47 +04:00
}
2001-04-07 04:36:38 +04:00
2007-10-11 00:34:30 +04:00
if ( is_disk_op )
unbecome_root ( ) ;
2007-11-28 01:35:30 +03:00
2007-10-11 00:34:30 +04:00
/********* END SeDiskOperatorPrivilege BLOCK *********/
DEBUG ( 3 , ( " _srv_net_share_del: Running [%s] returned (%d) \n " , command , ret ) ) ;
if ( ret ! = 0 )
return WERR_ACCESS_DENIED ;
2005-01-18 22:51:36 +03:00
/* Delete the SD in the database. */
2007-10-07 21:58:48 +04:00
delete_share_security ( lp_servicename ( params - > service ) ) ;
2005-01-18 22:51:36 +03:00
2006-10-21 21:00:47 +04:00
lp_killservice ( params - > service ) ;
2001-04-07 04:36:38 +04:00
2002-03-05 05:12:00 +03:00
return WERR_OK ;
2001-04-06 22:25:17 +04:00
}
2007-10-11 00:34:30 +04:00
WERROR _srv_net_share_del_sticky ( pipes_struct * p , SRV_Q_NET_SHARE_DEL * q_u , SRV_R_NET_SHARE_DEL * r_u )
2002-08-17 19:34:15 +04:00
{
DEBUG ( 5 , ( " _srv_net_share_del_stick: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
return _srv_net_share_del ( p , q_u , r_u ) ;
2002-08-17 19:34:15 +04:00
}
2001-02-27 21:22:39 +03:00
/*******************************************************************
2008-03-05 12:34:45 +03:00
_srvsvc_NetRemoteTOD
2001-02-27 21:22:39 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-03-05 12:34:45 +03:00
WERROR _srvsvc_NetRemoteTOD ( pipes_struct * p ,
struct srvsvc_NetRemoteTOD * r )
2001-02-27 21:22:39 +03:00
{
2008-03-05 12:34:45 +03:00
struct srvsvc_NetRemoteTODInfo * tod ;
2001-02-27 21:22:39 +03:00
struct tm * t ;
time_t unixdate = time ( NULL ) ;
2006-01-23 17:34:26 +03:00
2005-11-28 00:51:46 +03:00
/* We do this call first as if we do it *after* the gmtime call
it overwrites the pointed - to values . JRA */
2006-01-23 17:34:26 +03:00
2005-11-28 00:51:46 +03:00
uint32 zone = get_time_zone ( unixdate ) / 60 ;
2001-02-27 21:22:39 +03:00
2008-03-05 12:34:45 +03:00
DEBUG ( 5 , ( " _srvsvc_NetRemoteTOD: %d \n " , __LINE__ ) ) ;
2006-01-23 17:34:26 +03:00
2008-03-05 12:34:45 +03:00
if ( ! ( tod = TALLOC_ZERO_P ( p - > mem_ctx , struct srvsvc_NetRemoteTODInfo ) ) )
2007-10-11 00:34:30 +04:00
return WERR_NOMEM ;
2008-03-05 12:34:45 +03:00
* r - > out . info = tod ;
2007-10-11 00:34:30 +04:00
2008-03-05 12:34:45 +03:00
DEBUG ( 5 , ( " _srvsvc_NetRemoteTOD: %d \n " , __LINE__ ) ) ;
2007-10-11 00:34:30 +04:00
2001-02-27 21:22:39 +03:00
t = gmtime ( & unixdate ) ;
/* set up the */
2008-03-05 12:34:45 +03:00
init_srvsvc_NetRemoteTODInfo ( tod ,
unixdate ,
0 ,
t - > tm_hour ,
t - > tm_min ,
t - > tm_sec ,
0 ,
zone ,
10000 ,
t - > tm_mday ,
t - > tm_mon + 1 ,
1900 + t - > tm_year ,
t - > tm_wday ) ;
2001-02-27 21:22:39 +03:00
2008-03-05 12:34:45 +03:00
DEBUG ( 5 , ( " _srvsvc_NetRemoteTOD: %d \n " , __LINE__ ) ) ;
return WERR_OK ;
2001-02-27 21:22:39 +03:00
}
2001-05-01 05:01:19 +04:00
2001-06-16 04:32:13 +04:00
/***********************************************************************************
Win9x NT tools get security descriptor .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
WERROR _srv_net_file_query_secdesc ( pipes_struct * p , SRV_Q_NET_FILE_QUERY_SECDESC * q_u ,
SRV_R_NET_FILE_QUERY_SECDESC * r_u )
2001-06-16 04:32:13 +04:00
{
SEC_DESC * psd = NULL ;
size_t sd_size ;
2001-10-31 13:46:25 +03:00
DATA_BLOB null_pw ;
2007-11-28 01:35:30 +03:00
char * filename_in = NULL ;
2007-10-11 00:34:30 +04:00
char * filename = NULL ;
2007-11-28 01:35:30 +03:00
char * qualname = NULL ;
2001-06-16 04:32:13 +04:00
SMB_STRUCT_STAT st ;
2001-09-15 16:55:59 +04:00
NTSTATUS nt_status ;
2007-10-11 00:34:30 +04:00
struct current_user user ;
2001-06-16 04:32:13 +04:00
connection_struct * conn = NULL ;
2007-10-19 04:40:25 +04:00
bool became_user = False ;
2007-11-28 01:35:30 +03:00
TALLOC_CTX * ctx = p - > mem_ctx ;
2001-06-16 04:32:13 +04:00
ZERO_STRUCT ( st ) ;
2007-10-11 00:34:30 +04:00
r_u - > status = WERR_OK ;
2007-11-28 01:35:30 +03:00
qualname = unistr2_to_ascii_talloc ( ctx , & q_u - > uni_qual_name ) ;
if ( ! qualname ) {
r_u - > status = WERR_ACCESS_DENIED ;
goto error_exit ;
}
2001-06-16 04:32:13 +04:00
/* Null password is ok - we are already an authenticated user... */
2007-05-14 16:16:20 +04:00
null_pw = data_blob_null ;
2001-06-16 04:32:13 +04:00
2007-10-11 00:34:30 +04:00
get_current_user ( & user , p ) ;
2001-10-19 00:15:12 +04:00
become_root ( ) ;
2007-10-11 00:34:30 +04:00
conn = make_connection ( qualname , null_pw , " A: " , user . vuid , & nt_status ) ;
2001-10-19 00:15:12 +04:00
unbecome_root ( ) ;
2001-06-16 04:32:13 +04:00
if ( conn = = NULL ) {
2007-10-11 00:34:30 +04:00
DEBUG ( 3 , ( " _srv_net_file_query_secdesc: Unable to connect to %s \n " , qualname ) ) ;
r_u - > status = ntstatus_to_werror ( nt_status ) ;
2001-06-16 04:32:13 +04:00
goto error_exit ;
}
2001-09-19 06:28:15 +04:00
if ( ! become_user ( conn , conn - > vuid ) ) {
2001-09-19 06:53:14 +04:00
DEBUG ( 0 , ( " _srv_net_file_query_secdesc: Can't become connected user! \n " ) ) ;
2007-10-11 00:34:30 +04:00
r_u - > status = WERR_ACCESS_DENIED ;
2001-09-19 06:28:15 +04:00
goto error_exit ;
}
2003-03-19 02:49:03 +03:00
became_user = True ;
2001-09-19 06:28:15 +04:00
2007-11-28 01:35:30 +03:00
filename_in = unistr2_to_ascii_talloc ( ctx , & q_u - > uni_file_name ) ;
if ( ! filename_in ) {
r_u - > status = WERR_ACCESS_DENIED ;
goto error_exit ;
}
2007-10-11 00:34:30 +04:00
nt_status = unix_convert ( ctx , conn , filename_in , False , & filename , NULL , & st ) ;
2007-01-13 02:47:16 +03:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2007-10-11 00:34:30 +04:00
DEBUG ( 3 , ( " _srv_net_file_query_secdesc: bad pathname %s \n " , filename ) ) ;
r_u - > status = WERR_ACCESS_DENIED ;
2004-06-11 21:54:23 +04:00
goto error_exit ;
}
2007-10-11 00:34:30 +04:00
nt_status = check_name ( conn , filename ) ;
2007-01-17 05:09:37 +03:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2007-10-11 00:34:30 +04:00
DEBUG ( 3 , ( " _srv_net_file_query_secdesc: can't access %s \n " , filename ) ) ;
r_u - > status = WERR_ACCESS_DENIED ;
2004-06-11 21:54:23 +04:00
goto error_exit ;
}
2007-12-05 11:53:10 +03:00
nt_status = SMB_VFS_GET_NT_ACL ( conn , filename ,
2007-10-13 23:06:49 +04:00
( OWNER_SECURITY_INFORMATION
| GROUP_SECURITY_INFORMATION
| DACL_SECURITY_INFORMATION ) , & psd ) ;
2001-06-16 04:32:13 +04:00
2007-10-13 23:06:49 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2007-10-11 00:34:30 +04:00
DEBUG ( 3 , ( " _srv_net_file_query_secdesc: Unable to get NT ACL for file %s \n " , filename ) ) ;
2007-10-13 23:06:49 +04:00
r_u - > status = ntstatus_to_werror ( nt_status ) ;
2001-06-16 04:32:13 +04:00
goto error_exit ;
}
2007-12-30 01:00:49 +03:00
sd_size = ndr_size_security_descriptor ( psd , 0 ) ;
2007-10-13 23:06:49 +04:00
2007-10-11 00:34:30 +04:00
r_u - > ptr_response = 1 ;
r_u - > size_response = sd_size ;
r_u - > ptr_secdesc = 1 ;
r_u - > size_secdesc = sd_size ;
r_u - > sec_desc = psd ;
2001-06-16 04:32:13 +04:00
2007-12-21 00:17:16 +03:00
psd - > dacl - > revision = NT4_ACL_REVISION ;
2001-06-16 04:32:13 +04:00
2001-10-19 00:15:12 +04:00
unbecome_user ( ) ;
2007-10-11 00:34:30 +04:00
close_cnum ( conn , user . vuid ) ;
return r_u - > status ;
2001-06-16 04:32:13 +04:00
2002-08-17 19:34:15 +04:00
error_exit :
2001-06-16 04:32:13 +04:00
2001-09-19 06:28:15 +04:00
if ( became_user )
unbecome_user ( ) ;
2007-11-28 01:35:30 +03:00
if ( conn )
2007-10-11 00:34:30 +04:00
close_cnum ( conn , user . vuid ) ;
2001-06-16 04:32:13 +04:00
2007-10-11 00:34:30 +04:00
return r_u - > status ;
2001-06-16 04:32:13 +04:00
}
/***********************************************************************************
Win9x NT tools set security descriptor .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
WERROR _srv_net_file_set_secdesc ( pipes_struct * p , SRV_Q_NET_FILE_SET_SECDESC * q_u ,
SRV_R_NET_FILE_SET_SECDESC * r_u )
2001-06-16 04:32:13 +04:00
{
2007-11-28 01:35:30 +03:00
char * filename_in = NULL ;
2007-10-11 00:34:30 +04:00
char * filename = NULL ;
2007-11-28 01:35:30 +03:00
char * qualname = NULL ;
2002-03-05 05:12:00 +03:00
DATA_BLOB null_pw ;
2001-06-16 04:32:13 +04:00
files_struct * fsp = NULL ;
SMB_STRUCT_STAT st ;
2001-09-15 16:55:59 +04:00
NTSTATUS nt_status ;
2007-10-11 00:34:30 +04:00
struct current_user user ;
2001-06-16 04:32:13 +04:00
connection_struct * conn = NULL ;
2007-10-19 04:40:25 +04:00
bool became_user = False ;
2007-11-28 01:35:30 +03:00
TALLOC_CTX * ctx = p - > mem_ctx ;
2001-06-16 04:32:13 +04:00
ZERO_STRUCT ( st ) ;
2007-10-11 00:34:30 +04:00
r_u - > status = WERR_OK ;
2007-11-28 01:35:30 +03:00
qualname = unistr2_to_ascii_talloc ( ctx , & q_u - > uni_qual_name ) ;
if ( ! qualname ) {
r_u - > status = WERR_ACCESS_DENIED ;
goto error_exit ;
}
2007-10-11 00:34:30 +04:00
2001-06-16 04:32:13 +04:00
/* Null password is ok - we are already an authenticated user... */
2007-05-14 16:16:20 +04:00
null_pw = data_blob_null ;
2001-06-16 04:32:13 +04:00
2007-10-11 00:34:30 +04:00
get_current_user ( & user , p ) ;
2001-10-19 00:15:12 +04:00
become_root ( ) ;
2007-10-11 00:34:30 +04:00
conn = make_connection ( qualname , null_pw , " A: " , user . vuid , & nt_status ) ;
2001-10-19 00:15:12 +04:00
unbecome_root ( ) ;
2001-06-16 04:32:13 +04:00
if ( conn = = NULL ) {
2007-10-11 00:34:30 +04:00
DEBUG ( 3 , ( " _srv_net_file_set_secdesc: Unable to connect to %s \n " , qualname ) ) ;
r_u - > status = ntstatus_to_werror ( nt_status ) ;
2001-06-16 04:32:13 +04:00
goto error_exit ;
}
2001-08-14 03:19:16 +04:00
if ( ! become_user ( conn , conn - > vuid ) ) {
DEBUG ( 0 , ( " _srv_net_file_set_secdesc: Can't become connected user! \n " ) ) ;
2007-10-11 00:34:30 +04:00
r_u - > status = WERR_ACCESS_DENIED ;
2001-08-14 03:19:16 +04:00
goto error_exit ;
}
became_user = True ;
2007-11-28 01:35:30 +03:00
filename_in = unistr2_to_ascii_talloc ( ctx , & q_u - > uni_file_name ) ;
if ( ! filename_in ) {
r_u - > status = WERR_ACCESS_DENIED ;
goto error_exit ;
}
2007-10-11 00:34:30 +04:00
nt_status = unix_convert ( ctx , conn , filename , False , & filename , NULL , & st ) ;
2007-01-13 02:47:16 +03:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2007-10-11 00:34:30 +04:00
DEBUG ( 3 , ( " _srv_net_file_set_secdesc: bad pathname %s \n " , filename ) ) ;
r_u - > status = WERR_ACCESS_DENIED ;
2004-06-11 21:54:23 +04:00
goto error_exit ;
}
2007-10-11 00:34:30 +04:00
nt_status = check_name ( conn , filename ) ;
2007-01-17 05:09:37 +03:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2007-10-11 00:34:30 +04:00
DEBUG ( 3 , ( " _srv_net_file_set_secdesc: can't access %s \n " , filename ) ) ;
r_u - > status = WERR_ACCESS_DENIED ;
2004-06-11 21:54:23 +04:00
goto error_exit ;
}
2007-10-11 00:34:30 +04:00
nt_status = open_file_stat ( conn , NULL , filename , & st , & fsp ) ;
2001-06-16 04:32:13 +04:00
2007-10-11 00:34:30 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2001-06-18 21:52:58 +04:00
/* Perhaps it is a directory */
2006-07-11 22:01:26 +04:00
if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_FILE_IS_A_DIRECTORY ) )
2007-10-11 00:34:30 +04:00
nt_status = open_directory ( conn , NULL , filename , & st ,
2005-07-08 08:51:27 +04:00
FILE_READ_ATTRIBUTES ,
FILE_SHARE_READ | FILE_SHARE_WRITE ,
FILE_OPEN ,
0 ,
2007-02-07 00:05:34 +03:00
FILE_ATTRIBUTE_DIRECTORY ,
2006-07-11 22:01:26 +04:00
NULL , & fsp ) ;
2001-06-19 22:43:17 +04:00
2007-10-11 00:34:30 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 3 , ( " _srv_net_file_set_secdesc: Unable to open file %s \n " , filename ) ) ;
r_u - > status = ntstatus_to_werror ( nt_status ) ;
2001-06-18 21:52:58 +04:00
goto error_exit ;
}
2001-06-16 04:32:13 +04:00
}
2007-10-11 00:34:30 +04:00
nt_status = SMB_VFS_SET_NT_ACL ( fsp , fsp - > fsp_name , q_u - > sec_info , q_u - > sec_desc ) ;
2001-06-16 04:32:13 +04:00
2007-10-11 00:34:30 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 3 , ( " _srv_net_file_set_secdesc: Unable to set NT ACL on file %s \n " , filename ) ) ;
r_u - > status = WERR_ACCESS_DENIED ;
2001-06-16 04:32:13 +04:00
goto error_exit ;
}
2006-02-02 23:44:50 +03:00
close_file ( fsp , NORMAL_CLOSE ) ;
2001-08-14 03:19:16 +04:00
unbecome_user ( ) ;
2007-10-11 00:34:30 +04:00
close_cnum ( conn , user . vuid ) ;
return r_u - > status ;
2001-06-16 04:32:13 +04:00
2002-08-17 19:34:15 +04:00
error_exit :
2001-06-16 04:32:13 +04:00
if ( fsp ) {
2006-02-02 23:44:50 +03:00
close_file ( fsp , NORMAL_CLOSE ) ;
2001-06-16 04:32:13 +04:00
}
2005-07-08 08:51:27 +04:00
if ( became_user ) {
2001-08-14 03:19:16 +04:00
unbecome_user ( ) ;
2005-07-08 08:51:27 +04:00
}
2001-08-14 03:19:16 +04:00
2005-07-08 08:51:27 +04:00
if ( conn ) {
2007-10-11 00:34:30 +04:00
close_cnum ( conn , user . vuid ) ;
2005-07-08 08:51:27 +04:00
}
2001-06-16 04:32:13 +04:00
2007-10-11 00:34:30 +04:00
return r_u - > status ;
2001-06-16 04:32:13 +04:00
}
2001-05-01 05:01:19 +04:00
/***********************************************************************************
It may be that we want to limit users to creating shares on certain areas of the UNIX file area .
We could define areas by mapping Windows style disks to points on the UNIX directory hierarchy .
These disks would the disks listed by this function .
Users could then create shares relative to these disks . Watch out for moving these disks around .
" Nigel Williams " < nigel @ veritas . com > .
2001-05-02 12:14:00 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-05-01 05:01:19 +04:00
2002-07-15 14:35:28 +04:00
static const char * server_disks [ ] = { " C: " } ;
2001-05-01 05:01:19 +04:00
static uint32 get_server_disk_count ( void )
{
return sizeof ( server_disks ) / sizeof ( server_disks [ 0 ] ) ;
}
static uint32 init_server_disk_enum ( uint32 * resume )
{
uint32 server_disk_count = get_server_disk_count ( ) ;
/*resume can be an offset into the list for now*/
2001-06-19 04:44:23 +04:00
if ( * resume & 0x80000000 )
2001-05-01 05:01:19 +04:00
* resume = 0 ;
if ( * resume > server_disk_count )
* resume = server_disk_count ;
return server_disk_count - * resume ;
}
static const char * next_server_disk_enum ( uint32 * resume )
{
const char * disk ;
if ( init_server_disk_enum ( resume ) = = 0 )
return NULL ;
disk = server_disks [ * resume ] ;
( * resume ) + + ;
DEBUG ( 10 , ( " next_server_disk_enum: reporting disk %s. resume handle %d. \n " , disk , * resume ) ) ;
return disk ;
}
2007-10-11 00:34:30 +04:00
WERROR _srv_net_disk_enum ( pipes_struct * p , SRV_Q_NET_DISK_ENUM * q_u , SRV_R_NET_DISK_ENUM * r_u )
2001-05-01 05:01:19 +04:00
{
uint32 i ;
const char * disk_name ;
2007-10-11 00:34:30 +04:00
TALLOC_CTX * ctx = p - > mem_ctx ;
uint32 resume = get_enum_hnd ( & q_u - > enum_hnd ) ;
2001-05-01 05:01:19 +04:00
2007-10-11 00:34:30 +04:00
r_u - > status = WERR_OK ;
2001-05-01 05:01:19 +04:00
2007-10-11 00:34:30 +04:00
r_u - > total_entries = init_server_disk_enum ( & resume ) ;
2001-05-01 05:01:19 +04:00
2008-03-04 23:46:09 +03:00
r_u - > disk_enum_ctr . unknown = 0 ;
2007-10-11 00:34:30 +04:00
if ( ! ( r_u - > disk_enum_ctr . disk_info = TALLOC_ARRAY ( ctx , DISK_INFO , MAX_SERVER_DISK_ENTRIES ) ) ) {
2004-12-07 21:25:53 +03:00
return WERR_NOMEM ;
2002-08-17 19:34:15 +04:00
}
2007-10-11 00:34:30 +04:00
r_u - > disk_enum_ctr . disk_info_ptr = r_u - > disk_enum_ctr . disk_info ? 1 : 0 ;
/*allow one DISK_INFO for null terminator*/
2001-05-01 05:01:19 +04:00
2007-10-11 00:34:30 +04:00
for ( i = 0 ; i < MAX_SERVER_DISK_ENTRIES - 1 & & ( disk_name = next_server_disk_enum ( & resume ) ) ; i + + ) {
2001-05-01 05:01:19 +04:00
2007-10-11 00:34:30 +04:00
r_u - > disk_enum_ctr . entries_read + + ;
2001-05-01 05:01:19 +04:00
/*copy disk name into a unicode string*/
2008-03-04 23:46:09 +03:00
init_unistr3 ( & r_u - > disk_enum_ctr . disk_info [ i ] . disk_name , disk_name ) ;
2001-05-01 05:01:19 +04:00
}
2002-08-17 19:34:15 +04:00
/* add a terminating null string. Is this there if there is more data to come? */
2001-05-01 05:01:19 +04:00
2007-10-11 00:34:30 +04:00
r_u - > disk_enum_ctr . entries_read + + ;
2001-05-01 05:01:19 +04:00
2007-10-11 00:34:30 +04:00
init_unistr3 ( & r_u - > disk_enum_ctr . disk_info [ i ] . disk_name , " " ) ;
2001-05-01 05:01:19 +04:00
2007-10-11 00:34:30 +04:00
init_enum_hnd ( & r_u - > enum_hnd , resume ) ;
return r_u - > status ;
2001-05-01 05:01:19 +04:00
}
2005-12-11 08:06:35 +03:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-11 00:34:30 +04:00
WERROR _srv_net_name_validate ( pipes_struct * p , SRV_Q_NET_NAME_VALIDATE * q_u , SRV_R_NET_NAME_VALIDATE * r_u )
2001-05-01 05:01:19 +04:00
{
2007-10-11 00:34:30 +04:00
fstring sharename ;
2001-05-01 05:01:19 +04:00
2007-10-11 00:34:30 +04:00
switch ( q_u - > type ) {
2001-05-01 05:01:19 +04:00
case 0x9 :
2007-10-11 00:34:30 +04:00
rpcstr_pull ( sharename , q_u - > sharename . buffer , sizeof ( sharename ) , q_u - > sharename . uni_str_len * 2 , 0 ) ;
if ( ! validate_net_name ( sharename , INVALID_SHARENAME_CHARS , sizeof ( sharename ) ) ) {
DEBUG ( 5 , ( " _srv_net_name_validate: Bad sharename \" %s \" \n " , sharename ) ) ;
2005-12-11 08:06:35 +03:00
return WERR_INVALID_NAME ;
}
2001-05-01 05:01:19 +04:00
break ;
2005-12-11 08:06:35 +03:00
2001-05-01 05:01:19 +04:00
default :
2005-10-14 18:51:48 +04:00
return WERR_UNKNOWN_LEVEL ;
2001-05-01 05:01:19 +04:00
}
2005-10-14 18:51:48 +04:00
return WERR_OK ;
2001-05-01 05:01:19 +04:00
}
2006-07-11 22:01:26 +04:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetFileClose ( pipes_struct * p , struct srvsvc_NetFileClose * r )
2006-07-11 22:01:26 +04:00
{
return WERR_ACCESS_DENIED ;
}
2007-10-11 00:34:30 +04:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetCharDevEnum ( pipes_struct * p , struct srvsvc_NetCharDevEnum * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetCharDevGetInfo ( pipes_struct * p , struct srvsvc_NetCharDevGetInfo * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetCharDevControl ( pipes_struct * p , struct srvsvc_NetCharDevControl * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetCharDevQEnum ( pipes_struct * p , struct srvsvc_NetCharDevQEnum * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetCharDevQGetInfo ( pipes_struct * p , struct srvsvc_NetCharDevQGetInfo * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetCharDevQSetInfo ( pipes_struct * p , struct srvsvc_NetCharDevQSetInfo * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetCharDevQPurge ( pipes_struct * p , struct srvsvc_NetCharDevQPurge * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetCharDevQPurgeSelf ( pipes_struct * p , struct srvsvc_NetCharDevQPurgeSelf * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NetConnEnum ( pipes_struct * p , struct srvsvc_NetConnEnum * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
WERROR _srvsvc_NetFileEnum ( pipes_struct * p , struct srvsvc_NetFileEnum * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetFileGetInfo ( pipes_struct * p , struct srvsvc_NetFileGetInfo * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NetSessEnum ( pipes_struct * p , struct srvsvc_NetSessEnum * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
WERROR _srvsvc_NetSessDel ( pipes_struct * p , struct srvsvc_NetSessDel * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
WERROR _srvsvc_NetShareAdd ( pipes_struct * p , struct srvsvc_NetShareAdd * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
WERROR _srvsvc_NetShareDel ( pipes_struct * p , struct srvsvc_NetShareDel * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
WERROR _srvsvc_NetShareDelSticky ( pipes_struct * p , struct srvsvc_NetShareDelSticky * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetShareCheck ( pipes_struct * p , struct srvsvc_NetShareCheck * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NetDiskEnum ( pipes_struct * p , struct srvsvc_NetDiskEnum * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetServerStatisticsGet ( pipes_struct * p , struct srvsvc_NetServerStatisticsGet * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetTransportAdd ( pipes_struct * p , struct srvsvc_NetTransportAdd * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetTransportEnum ( pipes_struct * p , struct srvsvc_NetTransportEnum * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetTransportDel ( pipes_struct * p , struct srvsvc_NetTransportDel * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetSetServiceBits ( pipes_struct * p , struct srvsvc_NetSetServiceBits * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetPathType ( pipes_struct * p , struct srvsvc_NetPathType * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetPathCanonicalize ( pipes_struct * p , struct srvsvc_NetPathCanonicalize * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetPathCompare ( pipes_struct * p , struct srvsvc_NetPathCompare * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NetNameValidate ( pipes_struct * p , struct srvsvc_NetNameValidate * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NETRPRNAMECANONICALIZE ( pipes_struct * p , struct srvsvc_NETRPRNAMECANONICALIZE * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetPRNameCompare ( pipes_struct * p , struct srvsvc_NetPRNameCompare * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetShareDelStart ( pipes_struct * p , struct srvsvc_NetShareDelStart * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetShareDelCommit ( pipes_struct * p , struct srvsvc_NetShareDelCommit * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NetGetFileSecurity ( pipes_struct * p , struct srvsvc_NetGetFileSecurity * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
WERROR _srvsvc_NetSetFileSecurity ( pipes_struct * p , struct srvsvc_NetSetFileSecurity * r )
{
p - > rng_fault_state = True ;
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetServerTransportAddEx ( pipes_struct * p , struct srvsvc_NetServerTransportAddEx * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NetServerSetServiceBitsEx ( pipes_struct * p , struct srvsvc_NetServerSetServiceBitsEx * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NETRDFSGETVERSION ( pipes_struct * p , struct srvsvc_NETRDFSGETVERSION * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NETRDFSCREATELOCALPARTITION ( pipes_struct * p , struct srvsvc_NETRDFSCREATELOCALPARTITION * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NETRDFSDELETELOCALPARTITION ( pipes_struct * p , struct srvsvc_NETRDFSDELETELOCALPARTITION * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE ( pipes_struct * p , struct srvsvc_NETRDFSSETLOCALVOLUMESTATE * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NETRDFSSETSERVERINFO ( pipes_struct * p , struct srvsvc_NETRDFSSETSERVERINFO * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NETRDFSCREATEEXITPOINT ( pipes_struct * p , struct srvsvc_NETRDFSCREATEEXITPOINT * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-01-18 13:18:59 +03:00
WERROR _srvsvc_NETRDFSDELETEEXITPOINT ( pipes_struct * p , struct srvsvc_NETRDFSDELETEEXITPOINT * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NETRDFSMODIFYPREFIX ( pipes_struct * p , struct srvsvc_NETRDFSMODIFYPREFIX * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NETRDFSFIXLOCALVOLUME ( pipes_struct * p , struct srvsvc_NETRDFSFIXLOCALVOLUME * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO ( pipes_struct * p , struct srvsvc_NETRDFSMANAGERREPORTSITEINFO * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00
WERROR _srvsvc_NETRSERVERTRANSPORTDELEX ( pipes_struct * p , struct srvsvc_NETRSERVERTRANSPORTDELEX * r )
2006-09-22 03:57:32 +04:00
{
2006-10-10 12:39:11 +04:00
p - > rng_fault_state = True ;
2006-09-22 03:57:32 +04:00
return WERR_NOT_SUPPORTED ;
}
2007-10-11 00:34:30 +04:00