From 0d9f4a2886087692642dd3eba68f0b95657232bc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Mar 2009 15:18:18 -0800 Subject: Last part of fix for #6154 - zfs does not honor admin users. Jeremy. --- source3/locking/locking.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 1737eab1c6..e9a5f757e5 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -1295,7 +1295,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close, (Should this be in locking.c.... ?). *************************************************************************/ -static UNIX_USER_TOKEN *copy_unix_token(TALLOC_CTX *ctx, UNIX_USER_TOKEN *tok) +static UNIX_USER_TOKEN *copy_unix_token(TALLOC_CTX *ctx, const UNIX_USER_TOKEN *tok) { UNIX_USER_TOKEN *cpy; @@ -1326,7 +1326,7 @@ static UNIX_USER_TOKEN *copy_unix_token(TALLOC_CTX *ctx, UNIX_USER_TOKEN *tok) Replace the delete on close token. ****************************************************************************/ -void set_delete_on_close_token(struct share_mode_lock *lck, UNIX_USER_TOKEN *tok) +void set_delete_on_close_token(struct share_mode_lock *lck, const UNIX_USER_TOKEN *tok) { TALLOC_FREE(lck->delete_token); /* Also deletes groups... */ @@ -1346,7 +1346,7 @@ void set_delete_on_close_token(struct share_mode_lock *lck, UNIX_USER_TOKEN *tok lck entry. This function is used when the lock is already granted. ****************************************************************************/ -void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, UNIX_USER_TOKEN *tok) +void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, const UNIX_USER_TOKEN *tok) { if (lck->delete_on_close != delete_on_close) { set_delete_on_close_token(lck, tok); @@ -1358,8 +1358,9 @@ void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, } } -bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKEN *tok) +bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const UNIX_USER_TOKEN *tok) { + UNIX_USER_TOKEN *tok_copy = NULL; struct share_mode_lock *lck; DEBUG(10,("set_delete_on_close: %s delete on close flag for " @@ -1373,6 +1374,16 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKE return False; } + if (fsp->conn->admin_user) { + tok_copy = copy_unix_token(lck, tok); + tok_copy->uid = (uid_t)0; + if (tok_copy == NULL) { + TALLOC_FREE(lck); + return false; + } + tok = tok_copy; + } + set_delete_on_close_lck(lck, delete_on_close, tok); if (fsp->is_directory) { -- cgit From 1fcc11ff25f1c3e7586b13b24e5d0eec4ccfaedc Mon Sep 17 00:00:00 2001 From: Dave Richards Date: Fri, 13 Mar 2009 14:15:28 -0700 Subject: s3: Add strict lock/unlock calls to the vfs layer to replace is_locked --- source3/locking/locking.c | 90 +++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 35 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/locking.c b/source3/locking/locking.c index e9a5f757e5..bafb89522a 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -75,69 +75,89 @@ const char *lock_flav_name(enum brl_flavour lock_flav) Called in the read/write codepath. ****************************************************************************/ -bool is_locked(files_struct *fsp, - uint32 smbpid, - uint64_t count, - uint64_t offset, - enum brl_type lock_type) +void init_strict_lock_struct(files_struct *fsp, + uint32 smbpid, + br_off start, + br_off size, + enum brl_type lock_type, + struct lock_struct *plock) +{ + SMB_ASSERT(lock_type == READ_LOCK || lock_type == WRITE_LOCK); + + plock->context.smbpid = smbpid; + plock->context.tid = fsp->conn->cnum; + plock->context.pid = procid_self(); + plock->start = start; + plock->size = size; + plock->fnum = fsp->fnum; + plock->lock_type = lock_type; + plock->lock_flav = lp_posix_cifsu_locktype(fsp); +} + +bool strict_lock_default(files_struct *fsp, struct lock_struct *plock) { int strict_locking = lp_strict_locking(fsp->conn->params); - enum brl_flavour lock_flav = lp_posix_cifsu_locktype(fsp); - bool ret = True; - - if (count == 0) { - return False; + bool ret = False; + + if (plock->size == 0) { + return True; } if (!lp_locking(fsp->conn->params) || !strict_locking) { - return False; + return True; } if (strict_locking == Auto) { - if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK || lock_type == WRITE_LOCK)) { + if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (plock->lock_type == READ_LOCK || plock->lock_type == WRITE_LOCK)) { DEBUG(10,("is_locked: optimisation - exclusive oplock on file %s\n", fsp->fsp_name )); - ret = False; + ret = True; } else if ((fsp->oplock_type == LEVEL_II_OPLOCK) && - (lock_type == READ_LOCK)) { + (plock->lock_type == READ_LOCK)) { DEBUG(10,("is_locked: optimisation - level II oplock on file %s\n", fsp->fsp_name )); - ret = False; + ret = True; } else { struct byte_range_lock *br_lck = brl_get_locks_readonly(talloc_tos(), fsp); if (!br_lck) { - return False; + return True; } - ret = !brl_locktest(br_lck, - smbpid, - procid_self(), - offset, - count, - lock_type, - lock_flav); + ret = brl_locktest(br_lck, + plock->context.smbpid, + plock->context.pid, + plock->start, + plock->size, + plock->lock_type, + plock->lock_flav); TALLOC_FREE(br_lck); } } else { struct byte_range_lock *br_lck = brl_get_locks_readonly(talloc_tos(), fsp); if (!br_lck) { - return False; + return True; } - ret = !brl_locktest(br_lck, - smbpid, - procid_self(), - offset, - count, - lock_type, - lock_flav); + ret = brl_locktest(br_lck, + plock->context.smbpid, + plock->context.pid, + plock->start, + plock->size, + plock->lock_type, + plock->lock_flav); TALLOC_FREE(br_lck); } - DEBUG(10,("is_locked: flavour = %s brl start=%.0f len=%.0f %s for fnum %d file %s\n", - lock_flav_name(lock_flav), - (double)offset, (double)count, ret ? "locked" : "unlocked", - fsp->fnum, fsp->fsp_name )); + DEBUG(10,("strict_lock_default: flavour = %s brl start=%.0f " + "len=%.0f %s for fnum %d file %s\n", + lock_flav_name(plock->lock_flav), + (double)plock->start, (double)plock->size, + ret ? "unlocked" : "locked", + plock->fnum, fsp->fsp_name )); return ret; } +void strict_unlock_default(files_struct *fsp, struct lock_struct *plock) +{ +} + /**************************************************************************** Find out if a lock could be granted - return who is blocking us if we can't. ****************************************************************************/ -- cgit