From: Jeremy Allison Date: Wed, 11 Sep 2019 23:42:01 +0000 (-0700) Subject: s3: VFS: vfs_acl_tdb. Implement unlinkat(). X-Git-Tag: talloc-2.3.1~651 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c90d2b4f0d61174a9cd35160ed0ae5d7cb2af6d;p=thirdparty%2Fsamba.git s3: VFS: vfs_acl_tdb. Implement unlinkat(). Note this isn't identical to unlink() as this must cope with (flags & AT_REMOVEDIR), which is identical to rmdir(). It calls either unlink or rmdir depending on the flags parameter. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c index e3945c404ae..451eb4cf23a 100644 --- a/source3/modules/vfs_acl_tdb.c +++ b/source3/modules/vfs_acl_tdb.c @@ -271,6 +271,50 @@ static int unlink_acl_tdb(vfs_handle_struct *handle, return ret; } +/********************************************************************* + On unlinkat we need to delete the tdb record (if using tdb). +*********************************************************************/ + +static int unlinkat_acl_tdb(vfs_handle_struct *handle, + struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + int flags) +{ + struct smb_filename *smb_fname_tmp = NULL; + struct db_context *db = acl_db; + int ret = -1; + + smb_fname_tmp = cp_smb_filename_nostream(talloc_tos(), smb_fname); + if (smb_fname_tmp == NULL) { + errno = ENOMEM; + goto out; + } + + if (smb_fname_tmp->flags & SMB_FILENAME_POSIX_PATH) { + ret = SMB_VFS_LSTAT(handle->conn, smb_fname_tmp); + } else { + ret = SMB_VFS_STAT(handle->conn, smb_fname_tmp); + } + + if (ret == -1) { + goto out; + } + + if (flags & AT_REMOVEDIR) { + ret = rmdir_acl_common(handle, smb_fname_tmp); + } else { + ret = unlink_acl_common(handle, smb_fname_tmp); + } + + if (ret == -1) { + goto out; + } + + acl_tdb_delete(handle, db, &smb_fname_tmp->st); + out: + return ret; +} + /********************************************************************* On rmdir we need to delete the tdb record (if using tdb). *********************************************************************/ @@ -490,6 +534,7 @@ static struct vfs_fn_pointers vfs_acl_tdb_fns = { .disconnect_fn = disconnect_acl_tdb, .rmdir_fn = rmdir_acl_tdb, .unlink_fn = unlink_acl_tdb, + .unlinkat_fn = unlinkat_acl_tdb, .chmod_fn = chmod_acl_module_common, .fchmod_fn = fchmod_acl_module_common, .fget_nt_acl_fn = acl_tdb_fget_nt_acl,