summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in3
-rw-r--r--source3/include/smb.h69
-rw-r--r--source3/librpc/idl/wscript_build2
-rw-r--r--source3/librpc/wscript_build5
-rw-r--r--source3/libsmb/smb_share_modes.c30
-rw-r--r--source3/locking/locking.c414
-rw-r--r--source3/rpc_server/srvsvc/srv_srvsvc_nt.c1
-rw-r--r--source3/smbd/close.c1
-rw-r--r--source3/smbd/open.c1
-rw-r--r--source3/smbd/oplock.c1
-rw-r--r--source3/smbd/reply.c1
-rw-r--r--source3/smbd/trans2.c1
-rw-r--r--source3/utils/status.c1
-rw-r--r--source3/web/statuspage.c1
-rwxr-xr-xsource3/wscript_build1
15 files changed, 112 insertions, 420 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 7ff08c6313..62504fd941 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -793,7 +793,8 @@ RPC_SERVER_OBJ = $(RPC_LSARPC_OBJ) $(RPC_WINREG_OBJ) $(RPC_INITSHUTDOWN_OBJ) \
RPC_CLIENT_SCHANNEL_OBJ = rpc_client/cli_pipe_schannel.o
-LOCKING_OBJ = locking/locking.o locking/brlock.o locking/posix.o
+LOCKING_OBJ = locking/locking.o locking/brlock.o locking/posix.o \
+ librpc/gen_ndr/ndr_open_files.o
PRIVILEGES_BASIC_OBJ = ../libcli/security/privileges.o
diff --git a/source3/include/smb.h b/source3/include/smb.h
index b46f49881e..d3a27e9f73 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -545,25 +545,6 @@ struct pending_message_list {
#include "librpc/gen_ndr/server_id.h"
-/* struct returned by get_share_modes */
-struct share_mode_entry {
- struct server_id pid;
- uint64_t op_mid; /* For compatibility with SMB2 opens. */
- uint16 op_type;
- uint32 access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */
- uint32 share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */
- uint32 private_options; /* NT Create options, but we only look at
- * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
- * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB for
- * smbstatus and swat */
- struct timeval time;
- struct file_id id;
- unsigned long share_file_id;
- uint32 uid; /* uid of file opener. */
- uint16 flags; /* See SHARE_MODE_XX above. */
- uint32_t name_hash; /* Jenkins hash of full pathname. */
-};
-
/* oplock break message definition - linearization of share_mode_entry.
Offset Data length.
@@ -605,56 +586,6 @@ Offset Data length.
#define OP_BREAK_MSG_VNN_OFFSET 72
#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 76
-struct delete_token {
- uint32_t name_hash;
- struct security_unix_token *delete_token;
-};
-
-struct share_mode_lock {
- const char *servicepath; /* canonicalized. */
- const char *base_name;
- const char *stream_name;
- struct file_id id;
- int num_share_modes;
- struct share_mode_entry *share_modes;
- int num_delete_tokens;
- struct delete_token *delete_tokens;
- struct timespec old_write_time;
- struct timespec changed_write_time;
- bool fresh;
- bool modified;
- struct db_record *record;
-};
-
-/*
- * Internal structure of locking.tdb share mode db.
- * Used by locking.c and libsmbsharemodes.c
- */
-
-struct locking_data {
- union {
- struct {
- int num_share_mode_entries;
- struct timespec old_write_time;
- struct timespec changed_write_time;
- uint32 num_delete_token_entries;
- } s;
- struct share_mode_entry dummy; /* Needed for alignment. */
- } u;
- /* The following four entries are implicit
-
- (1) struct share_mode_entry modes[num_share_mode_entries];
-
- (2) A num_delete_token_entries of structs {
- uint32_t len_delete_token;
- char unix_token[len_delete_token] (divisible by 4).
- };
-
- (3) char share_name[];
- (4) char file_name[];
- */
-};
-
#define NT_HASH_LEN 16
#define LM_HASH_LEN 16
diff --git a/source3/librpc/idl/wscript_build b/source3/librpc/idl/wscript_build
index 3e07542320..949eecd7dd 100644
--- a/source3/librpc/idl/wscript_build
+++ b/source3/librpc/idl/wscript_build
@@ -5,7 +5,7 @@ import os
topinclude=os.path.join(bld.srcnode.abspath(), 'librpc/idl')
bld.SAMBA_PIDL_LIST('PIDL',
- '''messaging.idl libnetapi.idl
+ '''messaging.idl libnetapi.idl open_files.idl
perfcount.idl secrets.idl libnet_join.idl''',
options='--includedir=%s --header --ndr-parser' % topinclude,
output_dir='../gen_ndr')
diff --git a/source3/librpc/wscript_build b/source3/librpc/wscript_build
index a4af551e7f..8aa016135b 100644
--- a/source3/librpc/wscript_build
+++ b/source3/librpc/wscript_build
@@ -15,6 +15,11 @@ bld.SAMBA3_SUBSYSTEM('NDR_MESSAGING',
public_deps='ndr NDR_SERVER_ID'
)
+bld.SAMBA3_SUBSYSTEM('NDR_OPEN_FILES',
+ source='gen_ndr/ndr_open_files.c',
+ public_deps='ndr NDR_SERVER_ID NDR_FILE_ID NDR_SECURITY'
+ )
+
bld.SAMBA3_SUBSYSTEM('NDR_SECRETS',
source='gen_ndr/ndr_secrets.c',
public_deps='ndr'
diff --git a/source3/libsmb/smb_share_modes.c b/source3/libsmb/smb_share_modes.c
index 42640e0cea..f6f8bf9a1b 100644
--- a/source3/libsmb/smb_share_modes.c
+++ b/source3/libsmb/smb_share_modes.c
@@ -29,6 +29,7 @@
#include "system/filesys.h"
#include "smb_share_modes.h"
#include "tdb_compat.h"
+#include "librpc/gen_ndr/open_files.h"
#include <ccan/hash/hash.h>
/* Database context handle. */
@@ -41,6 +42,35 @@ struct smbdb_ctx {
#undef malloc
#endif
+/*
+ * Internal structure of locking.tdb share mode db.
+ * Used by locking.c and libsmbsharemodes.c
+ */
+
+struct locking_data {
+ union {
+ struct {
+ int num_share_mode_entries;
+ struct timespec old_write_time;
+ struct timespec changed_write_time;
+ uint32 num_delete_token_entries;
+ } s;
+ struct share_mode_entry dummy; /* Needed for alignment. */
+ } u;
+ /* The following four entries are implicit
+
+ (1) struct share_mode_entry modes[num_share_mode_entries];
+
+ (2) A num_delete_token_entries of structs {
+ uint32_t len_delete_token;
+ char unix_token[len_delete_token] (divisible by 4).
+ };
+
+ (3) char share_name[];
+ (4) char file_name[];
+ */
+};
+
int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx, uint64_t dev,
uint64_t ino, uint64_t extid,
const struct smb_share_mode_entry *new_entry,
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 611b2d2990..caa2b5aef6 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -45,6 +45,7 @@
#include "serverid.h"
#include "messages.h"
#include "util_tdb.h"
+#include "../librpc/gen_ndr/ndr_open_files.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_LOCKING
@@ -510,221 +511,35 @@ char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e)
}
/*******************************************************************
- Print out a share mode table.
-********************************************************************/
-
-static void print_share_mode_table(struct locking_data *data)
-{
- int num_share_modes = data->u.s.num_share_mode_entries;
- struct share_mode_entry *shares =
- (struct share_mode_entry *)(data + 1);
- int i;
-
- for (i = 0; i < num_share_modes; i++) {
- struct share_mode_entry entry;
- char *str;
-
- /*
- * We need to memcpy the entry here due to alignment
- * restrictions that are not met when directly accessing
- * shares[i]
- */
-
- memcpy(&entry, &shares[i], sizeof(struct share_mode_entry));
- str = share_mode_str(talloc_tos(), i, &entry);
-
- DEBUG(10,("print_share_mode_table: %s\n", str ? str : ""));
- TALLOC_FREE(str);
- }
-}
-
-static int parse_delete_tokens_list(struct share_mode_lock *lck,
- struct locking_data *pdata,
- const TDB_DATA dbuf)
-{
- uint8_t *p = dbuf.dptr + sizeof(struct locking_data) +
- (lck->num_share_modes *
- sizeof(struct share_mode_entry));
- uint8_t *end_ptr = dbuf.dptr + (dbuf.dsize - 2);
- int delete_tokens_size = 0;
- int i;
-
- lck->num_delete_tokens = 0;
- lck->delete_tokens = NULL;
-
- for (i = 0; i < pdata->u.s.num_delete_token_entries; i++) {
- uint32_t token_len;
- struct delete_token *pdt;
-
- if (end_ptr - p < (sizeof(uint32_t) + sizeof(uint32_t) +
- sizeof(uid_t) + sizeof(gid_t))) {
- DEBUG(0,("parse_delete_tokens_list: "
- "corrupt token list (%u)",
- (unsigned int)(end_ptr - p)));
- smb_panic("corrupt token list");
- return -1;
- }
-
- memcpy(&token_len, p, sizeof(token_len));
- delete_tokens_size += token_len;
-
- if (p + token_len > end_ptr || token_len < sizeof(token_len) +
- sizeof(pdt->name_hash) +
- sizeof(uid_t) +
- sizeof(gid_t)) {
- DEBUG(0,("parse_delete_tokens_list: "
- "invalid token length (%u)\n",
- (unsigned int)token_len ));
- smb_panic("invalid token length");
- return -1;
- }
-
- p += sizeof(token_len);
-
- lck->delete_tokens = talloc_realloc(
- lck, lck->delete_tokens, struct delete_token,
- lck->num_delete_tokens+1);
-
- if (lck->delete_tokens == NULL) {
- DEBUG(0, ("parse_delete_tokens_list: talloc failed"));
- return -1;
- }
- pdt = &lck->delete_tokens[lck->num_delete_tokens];
-
- /* Copy out the name_hash. */
- memcpy(&pdt->name_hash, p, sizeof(pdt->name_hash));
- p += sizeof(pdt->name_hash);
-
- pdt->delete_token = talloc_zero(
- lck->delete_tokens, struct security_unix_token);
- if (pdt->delete_token == NULL) {
- DEBUG(0,("parse_delete_tokens_list: talloc failed"));
- return -1;
- }
-
- /* Copy out the uid and gid. */
- memcpy(&pdt->delete_token->uid, p, sizeof(uid_t));
- p += sizeof(uid_t);
- memcpy(&pdt->delete_token->gid, p, sizeof(gid_t));
- p += sizeof(gid_t);
-
- token_len -= (sizeof(token_len) + sizeof(pdt->name_hash) +
- sizeof(uid_t) + sizeof(gid_t));
-
- /* Any supplementary groups ? */
- if (token_len) {
- int j;
-
- if (token_len % sizeof(gid_t) != 0) {
- DEBUG(0,("parse_delete_tokens_list: "
- "corrupt group list (%u)",
- (unsigned int)(token_len % sizeof(gid_t)) ));
- smb_panic("corrupt group list");
- return -1;
- }
-
- pdt->delete_token->ngroups = token_len / sizeof(gid_t);
- pdt->delete_token->groups = talloc_array(
- pdt->delete_token, gid_t,
- pdt->delete_token->ngroups);
- if (pdt->delete_token->groups == NULL) {
- DEBUG(0,("parse_delete_tokens_list: talloc failed"));
- return -1;
- }
-
- for (j = 0; j < pdt->delete_token->ngroups; j++) {
- memcpy(&pdt->delete_token->groups[j], p,
- sizeof(gid_t));
- p += sizeof(gid_t);
- }
- }
- lck->num_delete_tokens += 1;
- }
-
- return delete_tokens_size;
-}
-
-/*******************************************************************
Get all share mode entries for a dev/inode pair.
********************************************************************/
static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
{
- struct locking_data data;
- int delete_tokens_size;
int i;
struct server_id *pids;
bool *pid_exists;
+ enum ndr_err_code ndr_err;
+ DATA_BLOB blob;
- if (dbuf.dsize < sizeof(struct locking_data)) {
- smb_panic("parse_share_modes: buffer too short");
- }
-
- memcpy(&data, dbuf.dptr, sizeof(data));
-
- lck->old_write_time = data.u.s.old_write_time;
- lck->changed_write_time = data.u.s.changed_write_time;
- lck->num_share_modes = data.u.s.num_share_mode_entries;
+ blob.data = dbuf.dptr;
+ blob.length = dbuf.dsize;
- DEBUG(10, ("parse_share_modes: owrt: %s, "
- "cwrt: %s, ntok: %u, num_share_modes: %d\n",
- timestring(talloc_tos(),
- convert_timespec_to_time_t(lck->old_write_time)),
- timestring(talloc_tos(),
- convert_timespec_to_time_t(
- lck->changed_write_time)),
- (unsigned int)data.u.s.num_delete_token_entries,
- lck->num_share_modes));
-
- if ((lck->num_share_modes < 0) || (lck->num_share_modes > 1000000)) {
- DEBUG(0, ("invalid number of share modes: %d\n",
- lck->num_share_modes));
- smb_panic("parse_share_modes: invalid number of share modes");
+ ndr_err = ndr_pull_struct_blob(
+ &blob, lck, lck,
+ (ndr_pull_flags_fn_t)ndr_pull_share_mode_lock);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(1, ("ndr_pull_share_mode_lock failed\n"));
+ return false;
}
- lck->share_modes = NULL;
-
- if (lck->num_share_modes != 0) {
-
- if (dbuf.dsize < (sizeof(struct locking_data) +
- (lck->num_share_modes *
- sizeof(struct share_mode_entry)))) {
- smb_panic("parse_share_modes: buffer too short");
- }
-
- lck->share_modes = (struct share_mode_entry *)
- talloc_memdup(lck,
- dbuf.dptr+sizeof(struct locking_data),
- lck->num_share_modes *
- sizeof(struct share_mode_entry));
-
- if (lck->share_modes == NULL) {
- smb_panic("parse_share_modes: talloc failed");
- }
- }
+ lck->modified = false;
- /* Get any delete tokens. */
- delete_tokens_size = parse_delete_tokens_list(lck, &data, dbuf);
- if (delete_tokens_size < 0) {
- smb_panic("parse_share_modes: parse_delete_tokens_list failed");
+ if (DEBUGLEVEL >= 10) {
+ DEBUG(10, ("parse_share_modes:\n"));
+ NDR_PRINT_DEBUG(share_mode_lock, lck);
}
- /* Save off the associated service path and filename. */
- lck->servicepath = (const char *)dbuf.dptr + sizeof(struct locking_data) +
- (lck->num_share_modes * sizeof(struct share_mode_entry)) +
- delete_tokens_size;
-
- lck->base_name = (const char *)dbuf.dptr + sizeof(struct locking_data) +
- (lck->num_share_modes * sizeof(struct share_mode_entry)) +
- delete_tokens_size +
- strlen(lck->servicepath) + 1;
-
- lck->stream_name = (const char *)dbuf.dptr + sizeof(struct locking_data) +
- (lck->num_share_modes * sizeof(struct share_mode_entry)) +
- delete_tokens_size +
- strlen(lck->servicepath) + 1 +
- strlen(lck->base_name) + 1;
-
/*
* Ensure that each entry has a real process attached.
*/
@@ -749,19 +564,10 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
for (i = 0; i < lck->num_share_modes; i++) {
struct share_mode_entry *entry_p = &lck->share_modes[i];
- char *str = NULL;
- if (DEBUGLEVEL >= 10) {
- str = share_mode_str(talloc_tos(), i, entry_p);
- }
- DEBUG(10,("parse_share_modes: %s\n",
- str ? str : ""));
if (!pid_exists[i]) {
- DEBUG(10,("parse_share_modes: deleted %s\n",
- str ? str : ""));
entry_p->op_type = UNUSED_SHARE_MODE_ENTRY;
lck->modified = True;
}
- TALLOC_FREE(str);
}
TALLOC_FREE(pid_exists);
TALLOC_FREE(pids);
@@ -769,125 +575,35 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
return True;
}
-static TDB_DATA unparse_share_modes(const struct share_mode_lock *lck)
+static TDB_DATA unparse_share_modes(struct share_mode_lock *lck)
{
- TDB_DATA result;
- int num_valid = 0;
- int i;
- struct locking_data *data;
- ssize_t offset;
- ssize_t sp_len, bn_len, sn_len;
- uint32_t delete_tokens_size = 0;
+ DATA_BLOB blob;
+ enum ndr_err_code ndr_err;
+ uint32_t i;
- result.dptr = NULL;
- result.dsize = 0;
+ if (DEBUGLEVEL >= 10) {
+ DEBUG(10, ("unparse_share_modes:\n"));
+ NDR_PRINT_DEBUG(share_mode_lock, lck);
+ }
for (i=0; i<lck->num_share_modes; i++) {
if (!is_unused_share_mode_entry(&lck->share_modes[i])) {
- num_valid += 1;
+ break;
}
}
-
- if (num_valid == 0) {
- return result;
- }
-
- sp_len = strlen(lck->servicepath);
- bn_len = strlen(lck->base_name);
- sn_len = lck->stream_name != NULL ? strlen(lck->stream_name) : 0;
-
- for (i=0; i<lck->num_delete_tokens; i++) {
- struct delete_token *pdt = &lck->delete_tokens[i];
- delete_tokens_size +=
- (sizeof(uint32_t) +
- sizeof(uint32_t) +
- sizeof(uid_t) +
- sizeof(gid_t) +
- pdt->delete_token->ngroups*sizeof(gid_t));
- }
-
- result.dsize = sizeof(*data) +
- lck->num_share_modes * sizeof(struct share_mode_entry) +
- delete_tokens_size +
- sp_len + 1 +
- bn_len + 1 +
- sn_len + 1;
- result.dptr = talloc_array(lck, uint8, result.dsize);
-
- if (result.dptr == NULL) {
- smb_panic("talloc failed");
- }
-
- data = (struct locking_data *)result.dptr;
- ZERO_STRUCTP(data);
- data->u.s.num_share_mode_entries = lck->num_share_modes;
- data->u.s.old_write_time = lck->old_write_time;
- data->u.s.changed_write_time = lck->changed_write_time;
- data->u.s.num_delete_token_entries = lck->num_delete_tokens;
-
- DEBUG(10,("unparse_share_modes: owrt: %s cwrt: %s, ntok: %u, "
- "num: %d\n",
- timestring(talloc_tos(),
- convert_timespec_to_time_t(lck->old_write_time)),
- timestring(talloc_tos(),
- convert_timespec_to_time_t(
- lck->changed_write_time)),
- (unsigned int)data->u.s.num_delete_token_entries,
- data->u.s.num_share_mode_entries));
-
- memcpy(result.dptr + sizeof(*data), lck->share_modes,
- sizeof(struct share_mode_entry)*lck->num_share_modes);
- offset = sizeof(*data) +
- sizeof(struct share_mode_entry)*lck->num_share_modes;
-
- /* Store any delete on close tokens. */
-
- for (i=0; i<lck->num_delete_tokens; i++) {
- struct delete_token *pdtl = &lck->delete_tokens[i];
- struct security_unix_token *pdt = pdtl->delete_token;
- uint32_t token_size = sizeof(uint32_t) +
- sizeof(uint32_t) +
- sizeof(uid_t) +
- sizeof(gid_t) +
- (pdt->ngroups * sizeof(gid_t));
- uint8_t *p = result.dptr + offset;
-
- memcpy(p, &token_size, sizeof(uint32_t));
- p += sizeof(uint32_t);
-
- memcpy(p, &pdtl->name_hash, sizeof(uint32_t));
- p += sizeof(uint32_t);
-
- memcpy(p, &pdt->uid, sizeof(uid_t));
- p += sizeof(uid_t);
-
- memcpy(p, &pdt->gid, sizeof(gid_t));
- p += sizeof(gid_t);
-
- for (i = 0; i < pdt->ngroups; i++) {
- memcpy(p, &pdt->groups[i], sizeof(gid_t));
- p += sizeof(gid_t);
- }
- offset += token_size;
+ if (i == lck->num_share_modes) {
+ DEBUG(10, ("No used share mode found\n"));
+ return make_tdb_data(NULL, 0);
}
- strlcpy((char *)result.dptr + offset,
- lck->servicepath ? lck->servicepath : "",
- result.dsize - offset);
- offset += sp_len + 1;
- strlcpy((char *)result.dptr + offset,
- lck->base_name ? lck->base_name : "",
- result.dsize - offset);
- offset += bn_len + 1;
- strlcpy((char *)result.dptr + offset,
- lck->stream_name ? lck->stream_name : "",
- result.dsize - offset);
-
- if (DEBUGLEVEL >= 10) {
- print_share_mode_table(data);
+ ndr_err = ndr_push_struct_blob(
+ &blob, lck, lck,
+ (ndr_push_flags_fn_t)ndr_push_share_mode_lock);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ smb_panic("ndr_push_share_mode_lock failed");
}
- return result;
+ return make_tdb_data(blob.data, blob.length);
}
static int share_mode_lock_destructor(struct share_mode_lock *lck)
@@ -949,6 +665,8 @@ static bool fill_share_mode_lock(struct share_mode_lock *lck,
TDB_DATA share_mode_data,
const struct timespec *old_write_time)
{
+ bool fresh;
+
/* Ensure we set every field here as the destructor must be
valid even if parse_share_modes fails. */
@@ -962,12 +680,10 @@ static bool fill_share_mode_lock(struct share_mode_lock *lck,
lck->delete_tokens = NULL;
ZERO_STRUCT(lck->old_write_time);
ZERO_STRUCT(lck->changed_write_time);
- lck->fresh = False;
- lck->modified = False;
- lck->fresh = (share_mode_data.dptr == NULL);
+ fresh = (share_mode_data.dptr == NULL);
- if (lck->fresh) {
+ if (fresh) {
bool has_stream;
if (smb_fname == NULL || servicepath == NULL
|| old_write_time == NULL) {
@@ -986,12 +702,14 @@ static bool fill_share_mode_lock(struct share_mode_lock *lck,
return False;
}
lck->old_write_time = *old_write_time;
+ lck->modified = false;
} else {
if (!parse_share_modes(share_mode_data, lck)) {
DEBUG(0, ("Could not parse share modes\n"));
return False;
}
}
+ lck->fresh = fresh;
return True;
}
@@ -1004,6 +722,7 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
{
struct share_mode_lock *lck;
struct file_id tmp;
+ struct db_record *rec;
TDB_DATA key = locking_key(&id, &tmp);
TDB_DATA value;
@@ -1012,13 +731,14 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
return NULL;
}
- if (!(lck->record = dbwrap_fetch_locked(lock_db, lck, key))) {
+ rec = dbwrap_fetch_locked(lock_db, lck, key);
+ if (rec == NULL) {
DEBUG(3, ("Could not lock share entry\n"));
TALLOC_FREE(lck);
return NULL;
}
- value = dbwrap_record_get_value(lck->record);
+ value = dbwrap_record_get_value(rec);
if (!fill_share_mode_lock(lck, id, servicepath, smb_fname,
value, old_write_time)) {
@@ -1027,6 +747,7 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
return NULL;
}
+ lck->record = rec;
talloc_set_destructor(lck, share_mode_lock_destructor);
return lck;
@@ -1743,15 +1464,12 @@ struct forall_state {
static int traverse_fn(struct db_record *rec, void *_state)
{
struct forall_state *state = (struct forall_state *)_state;
- struct locking_data *data;
- struct share_mode_entry *shares;
- const char *sharepath;
- const char *fname;
- const char *del_tokens;
- uint32_t total_del_token_size = 0;
- int i;
+ uint32_t i;
TDB_DATA key;
TDB_DATA value;
+ DATA_BLOB blob;
+ enum ndr_err_code ndr_err;
+ struct share_mode_lock *lck;
key = dbwrap_record_get_key(rec);
value = dbwrap_record_get_value(rec);
@@ -1760,30 +1478,28 @@ static int traverse_fn(struct db_record *rec, void *_state)
if (key.dsize != sizeof(struct file_id))
return 0;
- data = (struct locking_data *)value.dptr;
- shares = (struct share_mode_entry *)(value.dptr + sizeof(*data));
- del_tokens = (const char *)value.dptr + sizeof(*data) +
- data->u.s.num_share_mode_entries*sizeof(*shares);
-
- for (i = 0; i < data->u.s.num_delete_token_entries; i++) {
- uint32_t del_token_size;
- memcpy(&del_token_size, del_tokens, sizeof(uint32_t));
- total_del_token_size += del_token_size;
- del_tokens += del_token_size;
+ lck = talloc(talloc_tos(), struct share_mode_lock);
+ if (lck == NULL) {
+ return 0;
}
- sharepath = (const char *)value.dptr + sizeof(*data) +
- data->u.s.num_share_mode_entries*sizeof(*shares) +
- total_del_token_size;
- fname = (const char *)value.dptr + sizeof(*data) +
- data->u.s.num_share_mode_entries*sizeof(*shares) +
- total_del_token_size +
- strlen(sharepath) + 1;
+ blob.data = value.dptr;
+ blob.length = value.dsize;
- for (i=0;i<data->u.s.num_share_mode_entries;i++) {
- state->fn(&shares[i], sharepath, fname,
+ ndr_err = ndr_pull_struct_blob(
+ &blob, lck, lck,
+ (ndr_pull_flags_fn_t)ndr_pull_share_mode_lock);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(1, ("ndr_pull_share_mode_lock failed\n"));
+ return 0;
+ }
+ for (i=0; i<lck->num_share_modes; i++) {
+ state->fn(&lck->share_modes[i],
+ lck->servicepath, lck->base_name,
state->private_data);
}
+ TALLOC_FREE(lck);
+
return 0;
}
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index 5db268c1e6..fca616e66b 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -29,6 +29,7 @@
#include "../librpc/gen_ndr/srv_srvsvc.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"
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 837e360769..b259045ddf 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -28,6 +28,7 @@
#include "transfer_file.h"
#include "auth.h"
#include "messages.h"
+#include "../librpc/gen_ndr/open_files.h"
/****************************************************************************
Run a file if it is a magic script.
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 5cda44c930..fceebcb6dd 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -27,6 +27,7 @@
#include "fake_file.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
+#include "../librpc/gen_ndr/open_files.h"
#include "auth.h"
#include "messages.h"
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index bba2e356f5..1bf957d810 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -24,6 +24,7 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "messages.h"
+#include "../librpc/gen_ndr/open_files.h"
/****************************************************************************
Get the number of current exclusive oplocks.
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 7dd3260f0b..a06e7b8339 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -32,6 +32,7 @@
#include "fake_file.h"
#include "rpc_client/rpc_client.h"
#include "../librpc/gen_ndr/ndr_spoolss_c.h"
+#include "../librpc/gen_ndr/open_files.h"
#include "rpc_client/cli_spoolss.h"
#include "rpc_client/init_spoolss.h"
#include "rpc_server/rpc_ncacn_np.h"
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 024979c200..0126419393 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -31,6 +31,7 @@
#include "../libcli/auth/libcli_auth.h"
#include "../librpc/gen_ndr/xattr.h"
#include "../librpc/gen_ndr/ndr_security.h"
+#include "../librpc/gen_ndr/open_files.h"
#include "libcli/security/security.h"
#include "trans2.h"
#include "auth.h"
diff --git a/source3/utils/status.c b/source3/utils/status.c
index f341cb8636..8bae5bc1ae 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -39,6 +39,7 @@
#include "session.h"
#include "locking/proto.h"
#include "messages.h"
+#include "librpc/gen_ndr/open_files.h"
#define SMB_MAXPIDS 2048
static uid_t Ucrit_uid = 0; /* added by OH */
diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c
index 5314f33432..49fb32e4fd 100644
--- a/source3/web/statuspage.c
+++ b/source3/web/statuspage.c
@@ -21,6 +21,7 @@
#include "web/swat_proto.h"
#include "libcli/security/security.h"
#include "locking/proto.h"
+#include "librpc/gen_ndr/open_files.h"
#define _(x) lang_msg_rotate(talloc_tos(),x)
diff --git a/source3/wscript_build b/source3/wscript_build
index 43d121a8dd..a3b5704065 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -890,6 +890,7 @@ bld.SAMBA3_LIBRARY('smbd_base',
vfs vfs_default vfs_posixacl auth rpc LOCKING LIBAFS LIBAFS_SETTOKEN PROFILE
PRINTING PRINTBACKEND NDR_XATTR NDR_NOTIFY REGFIO
smbconf REG_FULL FNAME_UTIL
+ NDR_OPEN_FILES
LIBCLI_SAMR libcli_lsa3 libcli_netlogon3 cli_spoolss
RPC_NDR_SRVSVC npa_tstream INIT_SAMR
cli_smb_common RPC_SERVER smbd_conn param_service