#include "system/passwd.h"
#include "lib/util/server_id.h"
#include "ntdomain.h"
-#include "../librpc/gen_ndr/srv_srvsvc.h"
+#include "librpc/gen_ndr/ndr_srvsvc.h"
+#include "librpc/gen_ndr/ndr_srvsvc_scompat.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
#include "../librpc/gen_ndr/open_files.h"
#include "dbwrap/dbwrap.h"
#include "session.h"
#include "../lib/util/util_pw.h"
+#include "locking/share_mode_lock.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "auth.h"
#include "messages.h"
#include "serverid.h"
-#include "lib/conn_tdb.h"
+#include "lib/global_contexts.h"
+#include "source3/lib/substitute.h"
extern const struct generic_mapping file_generic_mapping;
TALLOC_CTX *ctx;
const char *username;
struct srvsvc_NetFileCtr3 *ctr3;
+ struct file_id *fids;
};
struct sess_file_info {
/*******************************************************************
********************************************************************/
-static int enum_file_fn(const struct share_mode_entry *e,
- const char *sharepath,
- const char *fname,
- const char *sname,
+static int enum_file_fn(struct file_id id,
+ const struct share_mode_data *d,
+ const struct share_mode_entry *e,
void *private_data)
{
struct file_enum_count *fenum =
(struct file_enum_count *)private_data;
-
+ struct srvsvc_NetFileCtr3 *ctr3 = fenum->ctr3;
struct srvsvc_NetFileInfo3 *f;
- int i = fenum->ctr3->count;
- files_struct fsp;
- struct byte_range_lock *brl;
- int num_locks = 0;
+ struct file_id *fids = NULL;
char *fullpath = NULL;
uint32_t permissions;
const char *username;
return 0;
}
- f = talloc_realloc(fenum->ctx, fenum->ctr3->array,
- struct srvsvc_NetFileInfo3, i+1);
+ f = talloc_realloc(
+ fenum->ctx,
+ ctr3->array,
+ struct srvsvc_NetFileInfo3,
+ ctr3->count+1);
if ( !f ) {
- DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
+ DBG_ERR("realloc failed for %"PRIu32" items\n", ctr3->count+1);
return 0;
}
- fenum->ctr3->array = f;
-
- /* need to count the number of locks on a file */
+ ctr3->array = f;
- ZERO_STRUCT( fsp );
- fsp.file_id = e->id;
-
- if ( (brl = brl_get_locks(talloc_tos(), &fsp)) != NULL ) {
- num_locks = brl_num_locks(brl);
- TALLOC_FREE(brl);
+ fids = talloc_realloc(
+ fenum->ctx, fenum->fids, struct file_id, ctr3->count+1);
+ if (fids == NULL) {
+ DBG_ERR("realloc failed for %"PRIu32" items\n", ctr3->count+1);
+ return 0;
}
+ fids[ctr3->count] = id;
+ fenum->fids = fids;
- if ( strcmp( fname, "." ) == 0 ) {
- fullpath = talloc_asprintf(fenum->ctx, "C:%s", sharepath );
+ if ( strcmp(d->base_name, "." ) == 0 ) {
+ fullpath = talloc_asprintf(
+ fenum->ctx,
+ "C:%s",
+ d->servicepath);
} else {
- fullpath = talloc_asprintf(fenum->ctx, "C:%s/%s%s",
- sharepath, fname,
- sname ? sname : "");
+ fullpath = talloc_asprintf(
+ fenum->ctx,
+ "C:%s/%s%s",
+ d->servicepath,
+ d->base_name,
+ (d->stream_name != NULL) ? d->stream_name : "");
}
if (!fullpath) {
return 0;
/* now fill in the srvsvc_NetFileInfo3 struct */
- fenum->ctr3->array[i].fid =
- (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id);
- fenum->ctr3->array[i].permissions = permissions;
- fenum->ctr3->array[i].num_locks = num_locks;
- fenum->ctr3->array[i].path = fullpath;
- fenum->ctr3->array[i].user = username;
+ ctr3->array[ctr3->count] = (struct srvsvc_NetFileInfo3) {
+ .fid = (((uint32_t)(procid_to_pid(&e->pid))<<16) |
+ e->share_file_id),
+ .permissions = permissions,
+ .path = fullpath,
+ .user = username,
+ };
- fenum->ctr3->count++;
+ ctr3->count++;
return 0;
}
struct srvsvc_NetFileCtr3 **ctr3,
uint32_t resume)
{
- struct file_enum_count f_enum_cnt;
-
- f_enum_cnt.ctx = ctx;
- f_enum_cnt.username = username;
- f_enum_cnt.ctr3 = *ctr3;
+ struct file_enum_count f_enum_cnt = {
+ .ctx = ctx, .username = username, .ctr3 = *ctr3,
+ };
+ uint32_t i;
- share_entry_forall( enum_file_fn, (void *)&f_enum_cnt );
+ share_entry_forall(enum_file_fn, (void *)&f_enum_cnt );
*ctr3 = f_enum_cnt.ctr3;
+ /* need to count the number of locks on a file */
+
+ for (i=0; i<(*ctr3)->count; i++) {
+ struct files_struct fsp = { .file_id = f_enum_cnt.fids[i], };
+ struct byte_range_lock *brl = NULL;
+
+ brl = brl_get_locks(ctx, &fsp);
+ if (brl == NULL) {
+ continue;
+ }
+
+ (*ctr3)->array[i].num_locks = brl_num_locks(brl);
+
+ TALLOC_FREE(brl);
+ }
+
return WERR_OK;
}
static void init_srv_share_info_0(struct pipes_struct *p,
struct srvsvc_NetShareInfo0 *r, int snum)
{
- r->name = lp_servicename(talloc_tos(), snum);
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+
+ r->name = lp_servicename(talloc_tos(), lp_sub, snum);
}
/*******************************************************************
struct srvsvc_NetShareInfo1 *r,
int snum)
{
- char *net_name = lp_servicename(talloc_tos(), snum);
- char *remark = lp_comment(p->mem_ctx, snum);
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+ char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
+ char *remark = lp_comment(p->mem_ctx, lp_sub, snum);
if (remark) {
- remark = talloc_sub_advanced(
- p->mem_ctx, lp_servicename(talloc_tos(), snum),
- get_current_username(), lp_path(talloc_tos(), snum),
+ remark = talloc_sub_full(
+ p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
+ get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
}
struct srvsvc_NetShareInfo2 *r,
int snum)
{
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
char *remark = NULL;
char *path = NULL;
int max_connections = lp_max_connections(snum);
uint32_t max_uses = max_connections!=0 ? max_connections : (uint32_t)-1;
- char *net_name = lp_servicename(talloc_tos(), snum);
+ char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
- remark = lp_comment(p->mem_ctx, snum);
+ remark = lp_comment(p->mem_ctx, lp_sub, snum);
if (remark) {
- remark = talloc_sub_advanced(
- p->mem_ctx, lp_servicename(talloc_tos(), snum),
- get_current_username(), lp_path(talloc_tos(), snum),
+ remark = talloc_sub_full(
+ p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
+ get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
}
path = talloc_asprintf(p->mem_ctx,
- "C:%s", lp_path(talloc_tos(), snum));
+ "C:%s", lp_path(talloc_tos(), lp_sub, snum));
if (path) {
/*
static void init_srv_share_info_501(struct pipes_struct *p,
struct srvsvc_NetShareInfo501 *r, int snum)
{
- const char *net_name = lp_servicename(talloc_tos(), snum);
- char *remark = lp_comment(p->mem_ctx, snum);
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+ const char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
+ char *remark = lp_comment(p->mem_ctx, lp_sub, snum);
if (remark) {
- remark = talloc_sub_advanced(
- p->mem_ctx, lp_servicename(talloc_tos(), snum),
- get_current_username(), lp_path(talloc_tos(), snum),
+ remark = talloc_sub_full(
+ p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
+ get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
}
static void init_srv_share_info_502(struct pipes_struct *p,
struct srvsvc_NetShareInfo502 *r, int snum)
{
- const char *net_name = lp_servicename(talloc_tos(), snum);
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+ const char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
char *path = NULL;
struct security_descriptor *sd = NULL;
struct sec_desc_buf *sd_buf = NULL;
size_t sd_size = 0;
TALLOC_CTX *ctx = p->mem_ctx;
- char *remark = lp_comment(ctx, snum);
+ char *remark = lp_comment(ctx, lp_sub, snum);
if (remark) {
- remark = talloc_sub_advanced(
- p->mem_ctx, lp_servicename(talloc_tos(), snum),
- get_current_username(), lp_path(talloc_tos(), snum),
+ remark = talloc_sub_full(
+ p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
+ get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
}
- path = talloc_asprintf(ctx, "C:%s", lp_path(talloc_tos(), snum));
+ path = talloc_asprintf(ctx, "C:%s", lp_path(talloc_tos(), lp_sub, snum));
if (path) {
/*
* Change / to \\ so that win2k will see it as a valid path. This was added to
string_replace(path, '/', '\\');
}
- sd = get_share_security(ctx, lp_servicename(talloc_tos(), snum), &sd_size);
+ sd = get_share_security(ctx, lp_servicename(talloc_tos(), lp_sub, snum), &sd_size);
sd_buf = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
struct srvsvc_NetShareInfo1004 *r,
int snum)
{
- char *remark = lp_comment(p->mem_ctx, snum);
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+ char *remark = lp_comment(p->mem_ctx, lp_sub, snum);
if (remark) {
- remark = talloc_sub_advanced(
- p->mem_ctx, lp_servicename(talloc_tos(), snum),
- get_current_username(), lp_path(talloc_tos(), snum),
+ remark = talloc_sub_full(
+ p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
+ get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
}
struct sec_desc_buf **r,
int snum)
{
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
struct security_descriptor *sd;
struct sec_desc_buf *sd_buf = NULL;
size_t sd_size;
TALLOC_CTX *ctx = p->mem_ctx;
- sd = get_share_security(ctx, lp_servicename(talloc_tos(), snum), &sd_size);
+ sd = get_share_security(ctx, lp_servicename(talloc_tos(), lp_sub, snum), &sd_size);
if (sd) {
sd_buf = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
}
static bool is_hidden_share(int snum)
{
- const char *net_name = lp_servicename(talloc_tos(), snum);
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+ const char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
return (net_name[strlen(net_name) - 1] == '$') ? True : False;
}
static bool is_enumeration_allowed(struct pipes_struct *p,
int snum)
{
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+
if (!lp_access_based_share_enum(snum)) {
return true;
}
}
return share_access_check(p->session_info->security_token,
- lp_servicename(talloc_tos(), snum),
+ lp_servicename(talloc_tos(), lp_sub, snum),
FILE_READ_DATA, NULL);
}
uint32_t *total_entries,
bool all_shares)
{
- int num_entries = 0;
- int alloc_entries = 0;
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
+ uint32_t num_entries = 0;
+ uint32_t alloc_entries = 0;
int num_services = 0;
int snum;
TALLOC_CTX *ctx = p->mem_ctx;
- int i = 0;
- int valid_share_count = 0;
+ uint32_t i = 0;
+ uint32_t valid_share_count = 0;
bool *allowed = 0;
union srvsvc_NetShareCtr ctr;
uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
/* Ensure all the usershares are loaded. */
become_root();
- delete_and_reload_printers(server_event_context(), p->msg_ctx);
+ delete_and_reload_printers();
load_usershare_shares(NULL, connections_snum_used);
load_registry_shares();
num_services = lp_numservices();
is_enumeration_allowed(p, snum) &&
(all_shares || !is_hidden_share(snum)) ) {
DEBUG(10, ("counting service %s\n",
- lp_servicename(talloc_tos(), snum) ? lp_servicename(talloc_tos(), snum) : "(null)"));
+ lp_servicename(talloc_tos(), lp_sub, snum) ? lp_servicename(talloc_tos(), lp_sub, snum) : "(null)"));
allowed[snum] = true;
num_entries++;
} else {
DEBUG(10, ("NOT counting service %s\n",
- lp_servicename(talloc_tos(), snum) ? lp_servicename(talloc_tos(), snum) : "(null)"));
+ lp_servicename(talloc_tos(), lp_sub, snum) ? lp_servicename(talloc_tos(), lp_sub, snum) : "(null)"));
}
}
* find out the session on which this file is open and bump up its count
**********************************************************************/
-static int count_sess_files_fn(const struct share_mode_entry *e,
- const char *sharepath,
- const char *fname,
- const char *sname,
+static int count_sess_files_fn(struct file_id fid,
+ const struct share_mode_data *d,
+ const struct share_mode_entry *e,
void *data)
{
struct sess_file_info *info = data;
*/
struct sessionid *sess = &info->session_list[rh + i];
if ((e->uid == sess->uid) &&
- serverid_equal(&e->pid, &sess->pid)) {
+ server_id_equal(&e->pid, &sess->pid)) {
info->ctr->array[i].num_open++;
return 0;
find the share connection on which this open exists.
********************************************************************/
-static int share_file_fn(const struct share_mode_entry *e,
- const char *sharepath,
- const char *fname,
- const char *sname,
+static int share_file_fn(struct file_id fid,
+ const struct share_mode_data *d,
+ const struct share_mode_entry *e,
void *data)
{
struct share_file_stat *sfs = data;
uint32_t i;
uint32_t offset = sfs->total_entries - sfs->resp_entries;
- if (strequal(sharepath, sfs->in_sharepath)) {
+ if (strequal(d->servicepath, sfs->in_sharepath)) {
for (i=0; i < sfs->resp_entries; i++) {
- if (serverid_equal(&e->pid, &sfs->svrid_arr[offset + i])) {
+ if (server_id_equal(
+ &e->pid, &sfs->svrid_arr[offset + i])) {
sfs->netconn_arr[i].num_open ++;
return 0;
}
uint32_t *resume_handle_p,
uint32_t *total_entries)
{
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
uint32_t num_entries = 0;
int snum = 0;
uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
*/
count_share_opens(ctr1->array, svrid_arr,
- lp_path(talloc_tos(), snum),
+ lp_path(talloc_tos(), lp_sub, snum),
num_entries, *total_entries);
}
WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
struct srvsvc_NetSrvGetInfo *r)
{
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
WERROR status = WERR_OK;
DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__));
info102->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
info102->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info102->server_type = lp_default_server_announce();
- info102->comment = string_truncate(lp_server_string(talloc_tos()),
+ info102->comment = string_truncate(lp_server_string(talloc_tos(), lp_sub),
MAX_SERVER_STRING_LENGTH);
info102->users = 0xffffffff;
info102->disc = 0xf;
info101->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
info101->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info101->server_type = lp_default_server_announce();
- info101->comment = string_truncate(lp_server_string(talloc_tos()),
+ info101->comment = string_truncate(lp_server_string(talloc_tos(), lp_sub),
MAX_SERVER_STRING_LENGTH);
r->out.info->info101 = info101;
WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p,
struct srvsvc_NetShareSetInfo *r)
{
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
char *command = NULL;
char *share_name = NULL;
char *comment = NULL;
switch (r->in.level) {
case 1:
- pathname = lp_path(ctx, snum);
+ pathname = lp_path(ctx, lp_sub, snum);
comment = talloc_strdup(ctx, info->info1->comment);
type = info->info1->type;
psd = NULL;
map_generic_share_sd_bits(psd);
break;
case 1004:
- pathname = lp_path(ctx, snum);
+ pathname = lp_path(ctx, lp_sub, snum);
comment = talloc_strdup(ctx, info->info1004->comment);
type = STYPE_DISKTREE;
break;
csc_policy_changed = true;
}
- pathname = lp_path(ctx, snum);
- comment = lp_comment(ctx, snum);
+ pathname = lp_path(ctx, lp_sub, snum);
+ comment = lp_comment(ctx, lp_sub, snum);
type = STYPE_DISKTREE;
break;
case 1006:
case 1007:
return WERR_ACCESS_DENIED;
case 1501:
- pathname = lp_path(ctx, snum);
- comment = lp_comment(ctx, snum);
+ pathname = lp_path(ctx, lp_sub, snum);
+ comment = lp_comment(ctx, lp_sub, snum);
psd = info->info1501->sd;
map_generic_share_sd_bits(psd);
type = STYPE_DISKTREE;
string_replace(comment, '"', ' ');
DEBUG(10,("_srvsvc_NetShareSetInfo: change share command = %s\n",
- lp_change_share_command(talloc_tos()) ? lp_change_share_command(talloc_tos()) : "NULL" ));
+ lp_change_share_command(talloc_tos(), lp_sub) ? lp_change_share_command(talloc_tos(), lp_sub) : "NULL" ));
/* Only call modify function if something changed. */
- if (strcmp(path, lp_path(talloc_tos(), snum)) || strcmp(comment, lp_comment(talloc_tos(), snum))
+ if (strcmp(path, lp_path(talloc_tos(), lp_sub, snum))
+ || strcmp(comment, lp_comment(talloc_tos(), lp_sub, snum))
|| (lp_max_connections(snum) != max_connections)
|| csc_policy_changed) {
- if (!lp_change_share_command(talloc_tos()) || !*lp_change_share_command(talloc_tos())) {
+ if (!lp_change_share_command(talloc_tos(), lp_sub) || !*lp_change_share_command(talloc_tos(), lp_sub)) {
DEBUG(10,("_srvsvc_NetShareSetInfo: No change share command\n"));
return WERR_ACCESS_DENIED;
}
command = talloc_asprintf(p->mem_ctx,
"%s \"%s\" \"%s\" \"%s\" \"%s\" %d \"%s\"",
- lp_change_share_command(talloc_tos()),
+ lp_change_share_command(talloc_tos(), lp_sub),
get_dyn_CONFIGFILE(),
share_name,
path,
ret = smbrun(command, NULL, NULL);
if (ret == 0) {
+ reload_services(NULL, NULL, false);
+
/* Tell everyone we updated smb.conf. */
messaging_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED,
NULL, 0);
if (psd) {
struct security_descriptor *old_sd;
size_t sd_size;
+ NTSTATUS status;
- old_sd = get_share_security(p->mem_ctx, lp_servicename(talloc_tos(), snum), &sd_size);
+ old_sd = get_share_security(p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum), &sd_size);
if (old_sd && !security_descriptor_equal(old_sd, psd)) {
- if (!set_share_security(share_name, psd))
+ status = set_share_security(share_name, psd);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("_srvsvc_NetShareSetInfo: Failed to change security info in share %s.\n",
share_name ));
+ }
}
}
int max_connections = 0;
SMB_STRUCT_STAT st;
TALLOC_CTX *ctx = p->mem_ctx;
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__));
if (p->session_info->unix_token->uid != sec_initial_uid() && !is_disk_op )
return WERR_ACCESS_DENIED;
- if (!lp_add_share_command(talloc_tos()) || !*lp_add_share_command(talloc_tos())) {
+ if (!lp_add_share_command(talloc_tos(), lp_sub) || !*lp_add_share_command(talloc_tos(), lp_sub)) {
DBG_WARNING("_srvsvc_NetShareAdd: No \"add share command\" parameter set in smb.conf.\n");
return WERR_ACCESS_DENIED;
}
command = talloc_asprintf(ctx,
"%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
- lp_add_share_command(talloc_tos()),
+ lp_add_share_command(talloc_tos(), lp_sub),
get_dyn_CONFIGFILE(),
share_name_in,
path,
return WERR_ACCESS_DENIED;
if (psd) {
+ NTSTATUS status;
/* Note we use share_name here, not share_name_in as
we need a canonicalized name for setting security. */
- if (!set_share_security(share_name, psd)) {
+ status = set_share_security(share_name, psd);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("_srvsvc_NetShareAdd: Failed to add security info to share %s.\n",
share_name ));
}
int snum;
bool is_disk_op;
TALLOC_CTX *ctx = p->mem_ctx;
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
DEBUG(5,("_srvsvc_NetShareDel: %d\n", __LINE__));
if (p->session_info->unix_token->uid != sec_initial_uid() && !is_disk_op )
return WERR_ACCESS_DENIED;
- if (!lp_delete_share_command(talloc_tos()) || !*lp_delete_share_command(talloc_tos())) {
+ if (!lp_delete_share_command(talloc_tos(), lp_sub) || !*lp_delete_share_command(talloc_tos(), lp_sub)) {
DBG_WARNING("_srvsvc_NetShareDel: No \"delete share command\" parameter set in smb.conf.\n");
return WERR_ACCESS_DENIED;
}
command = talloc_asprintf(ctx,
"%s \"%s\" \"%s\"",
- lp_delete_share_command(talloc_tos()),
+ lp_delete_share_command(talloc_tos(), lp_sub),
get_dyn_CONFIGFILE(),
share_name);
if (!command) {
WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
struct srvsvc_NetGetFileSecurity *r)
{
+ TALLOC_CTX *frame = talloc_stackframe();
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
struct smb_filename *smb_fname = NULL;
size_t sd_size;
char *servicename = NULL;
SMB_STRUCT_STAT st;
NTSTATUS nt_status;
WERROR werr;
+ struct conn_struct_tos *c = NULL;
connection_struct *conn = NULL;
struct sec_desc_buf *sd_buf = NULL;
files_struct *fsp = NULL;
int snum;
- struct smb_filename *oldcwd_fname = NULL;
uint32_t ucf_flags = 0;
ZERO_STRUCT(st);
werr = WERR_NERR_NETNAMENOTFOUND;
goto error_exit;
}
- snum = find_service(talloc_tos(), r->in.share, &servicename);
+ snum = find_service(frame, r->in.share, &servicename);
if (!servicename) {
werr = WERR_NOT_ENOUGH_MEMORY;
goto error_exit;
goto error_exit;
}
- nt_status = create_conn_struct_cwd(talloc_tos(),
- server_event_context(),
- server_messaging_context(),
- &conn,
- snum, lp_path(talloc_tos(), snum),
- p->session_info, &oldcwd_fname);
+ nt_status = create_conn_struct_tos_cwd(global_messaging_context(),
+ snum,
+ lp_path(frame, lp_sub, snum),
+ p->session_info,
+ &c);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(10, ("create_conn_struct failed: %s\n",
nt_errstr(nt_status)));
werr = ntstatus_to_werror(nt_status);
goto error_exit;
}
+ conn = c->conn;
- nt_status = filename_convert(talloc_tos(),
+ nt_status = filename_convert(frame,
conn,
r->in.file,
ucf_flags,
- NULL,
+ 0,
&smb_fname);
if (!NT_STATUS_IS_OK(nt_status)) {
werr = ntstatus_to_werror(nt_status);
nt_status = SMB_VFS_CREATE_FILE(
conn, /* conn */
NULL, /* req */
- 0, /* root_dir_fid */
smb_fname, /* fname */
FILE_READ_ATTRIBUTES, /* access_mask */
FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
goto error_exit;
}
- nt_status = SMB_VFS_FGET_NT_ACL(fsp,
+ nt_status = SMB_VFS_FGET_NT_ACL(metadata_fsp(fsp),
(SECINFO_OWNER
|SECINFO_GROUP
|SECINFO_DACL), sd_buf, &sd_buf->sd);
close_file(NULL, fsp, NORMAL_CLOSE);
}
- if (oldcwd_fname) {
- vfs_ChDir(conn, oldcwd_fname);
- TALLOC_FREE(oldcwd_fname);
- }
-
- if (conn) {
- SMB_VFS_DISCONNECT(conn);
- conn_free(conn);
- }
-
- TALLOC_FREE(smb_fname);
-
+ TALLOC_FREE(frame);
return werr;
}
WERROR _srvsvc_NetSetFileSecurity(struct pipes_struct *p,
struct srvsvc_NetSetFileSecurity *r)
{
+ TALLOC_CTX *frame = talloc_stackframe();
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
struct smb_filename *smb_fname = NULL;
char *servicename = NULL;
files_struct *fsp = NULL;
SMB_STRUCT_STAT st;
NTSTATUS nt_status;
WERROR werr;
+ struct conn_struct_tos *c = NULL;
connection_struct *conn = NULL;
int snum;
- struct smb_filename *oldcwd_fname = NULL;
struct security_descriptor *psd = NULL;
uint32_t security_info_sent = 0;
uint32_t ucf_flags = 0;
goto error_exit;
}
- snum = find_service(talloc_tos(), r->in.share, &servicename);
+ snum = find_service(frame, r->in.share, &servicename);
if (!servicename) {
werr = WERR_NOT_ENOUGH_MEMORY;
goto error_exit;
goto error_exit;
}
- nt_status = create_conn_struct_cwd(talloc_tos(),
- server_event_context(),
- server_messaging_context(),
- &conn,
- snum, lp_path(talloc_tos(), snum),
- p->session_info, &oldcwd_fname);
+ nt_status = create_conn_struct_tos_cwd(global_messaging_context(),
+ snum,
+ lp_path(frame, lp_sub, snum),
+ p->session_info,
+ &c);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(10, ("create_conn_struct failed: %s\n",
nt_errstr(nt_status)));
werr = ntstatus_to_werror(nt_status);
goto error_exit;
}
+ conn = c->conn;
- nt_status = filename_convert(talloc_tos(),
+ nt_status = filename_convert(frame,
conn,
r->in.file,
ucf_flags,
- NULL,
+ 0,
&smb_fname);
if (!NT_STATUS_IS_OK(nt_status)) {
werr = ntstatus_to_werror(nt_status);
nt_status = SMB_VFS_CREATE_FILE(
conn, /* conn */
NULL, /* req */
- 0, /* root_dir_fid */
smb_fname, /* fname */
FILE_WRITE_ATTRIBUTES, /* access_mask */
FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
close_file(NULL, fsp, NORMAL_CLOSE);
}
- if (oldcwd_fname) {
- vfs_ChDir(conn, oldcwd_fname);
- TALLOC_FREE(oldcwd_fname);
- }
-
- if (conn) {
- SMB_VFS_DISCONNECT(conn);
- conn_free(conn);
- }
-
- TALLOC_FREE(smb_fname);
-
+ TALLOC_FREE(frame);
return werr;
}
struct messaging_context *msg_ctx;
};
-static int enum_file_close_fn(const struct share_mode_entry *e,
- const char *sharepath,
- const char *fname,
- const char *sname,
+static int enum_file_close_fn(struct file_id id,
+ const struct share_mode_data *d,
+ const struct share_mode_entry *e,
void *private_data)
{
char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
}
/* Ok - send the close message. */
- DEBUG(10,("enum_file_close_fn: request to close file %s, %s\n",
- sharepath,
- share_mode_str(talloc_tos(), 0, e) ));
+ DBG_DEBUG("request to close file %s, %s\n", d->servicepath,
+ share_mode_str(talloc_tos(), 0, &id, e));
- share_mode_entry_to_message(msg, e);
+ share_mode_entry_to_message(msg, &id, e);
state->r->out.result = ntstatus_to_werror(
messaging_send_buf(state->msg_ctx,
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
+
+/* include the generated boilerplate */
+#include "librpc/gen_ndr/ndr_srvsvc_scompat.c"