summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/locking/locking.c41
-rw-r--r--source3/smbd/dir.c2
-rw-r--r--source3/smbd/filename.c18
-rw-r--r--source3/smbd/trans2.c13
4 files changed, 41 insertions, 33 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 8d8c0347a5..5faebef1fe 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -940,37 +940,40 @@ bool rename_share_filename(struct messaging_context *msg_ctx,
return True;
}
-struct timespec get_write_time(struct file_id id)
+void get_file_infos(struct file_id id,
+ bool *delete_on_close,
+ struct timespec *write_time)
{
- struct timespec result;
struct share_mode_lock *lck;
- ZERO_STRUCT(result);
+ if (delete_on_close) {
+ *delete_on_close = false;
+ }
+
+ if (write_time) {
+ ZERO_STRUCTP(write_time);
+ }
if (!(lck = fetch_share_mode_unlocked(talloc_tos(), id, NULL, NULL))) {
- return result;
+ return;
}
- result = lck->changed_write_time;
- if (null_timespec(result)) {
- result = lck->old_write_time;
+ if (delete_on_close) {
+ *delete_on_close = lck->delete_on_close;
}
- TALLOC_FREE(lck);
- return result;
-}
+ if (write_time) {
+ struct timespec wt;
-bool get_delete_on_close_flag(struct file_id id)
-{
- bool result;
- struct share_mode_lock *lck;
-
- if (!(lck = fetch_share_mode_unlocked(talloc_tos(), id, NULL, NULL))) {
- return False;
+ wt = lck->changed_write_time;
+ if (null_timespec(wt)) {
+ wt = lck->old_write_time;
+ }
+
+ *write_time = wt;
}
- result = lck->delete_on_close;
+
TALLOC_FREE(lck);
- return result;
}
bool is_valid_share_mode_entry(const struct share_mode_entry *e)
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 8531d6250d..5fc2e3719e 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -886,7 +886,7 @@ bool get_dir_entry(TALLOC_CTX *ctx,
*date = sbuf.st_mtime;
fileid = vfs_file_id_from_sbuf(conn, &sbuf);
- write_time_ts = get_write_time(fileid);
+ get_file_infos(fileid, NULL, &write_time_ts);
if (!null_timespec(write_time_ts)) {
*date = convert_timespec_to_time_t(write_time_ts);
}
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 10e9583049..4323e843d2 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -611,11 +611,19 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
} /* end else */
#ifdef DEVELOPER
- if (VALID_STAT(st) &&
- get_delete_on_close_flag(vfs_file_id_from_sbuf(conn,
- &st))) {
- result = NT_STATUS_DELETE_PENDING;
- goto fail;
+ /*
+ * This sucks!
+ * We should never provide different behaviors
+ * depending on DEVELOPER!!!
+ */
+ if (VALID_STAT(st)) {
+ bool delete_pending;
+ get_file_infos(vfs_file_id_from_sbuf(conn, &st),
+ &delete_pending, NULL);
+ if (delete_pending) {
+ result = NT_STATUS_DELETE_PENDING;
+ goto fail;
+ }
}
#endif
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 06bb31622f..9e56434d5c 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1398,8 +1398,8 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
adate_ts = get_atimespec(&sbuf);
create_date_ts = get_create_timespec(&sbuf,lp_fake_dir_create_times(SNUM(conn)));
- write_time_ts = get_write_time(
- vfs_file_id_from_sbuf(conn, &sbuf));
+ get_file_infos(vfs_file_id_from_sbuf(conn, &sbuf),
+ NULL, &write_time_ts);
if (!null_timespec(write_time_ts)) {
mdate_ts = write_time_ts;
}
@@ -3870,8 +3870,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
}
fileid = vfs_file_id_from_sbuf(conn, &sbuf);
- delete_pending = get_delete_on_close_flag(fileid);
- write_time_ts = get_write_time(fileid);
+ get_file_infos(fileid, &delete_pending, &write_time_ts);
} else {
/*
* Original code - this is an open file.
@@ -3887,8 +3886,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
}
pos = fsp->fh->position_information;
fileid = vfs_file_id_from_sbuf(conn, &sbuf);
- delete_pending = get_delete_on_close_flag(fileid);
- write_time_ts = get_write_time(fileid);
+ get_file_infos(fileid, &delete_pending, &write_time_ts);
access_mask = fsp->access_mask;
}
@@ -3959,12 +3957,11 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
}
fileid = vfs_file_id_from_sbuf(conn, &sbuf);
- delete_pending = get_delete_on_close_flag(fileid);
+ get_file_infos(fileid, &delete_pending, &write_time_ts);
if (delete_pending) {
reply_nterror(req, NT_STATUS_DELETE_PENDING);
return;
}
- write_time_ts = get_write_time(fileid);
}
if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {