Exemplo n.º 1
0
static int unlink_acl_tdb(vfs_handle_struct *handle,
			  const struct smb_filename *smb_fname)
{
	struct smb_filename *smb_fname_tmp = NULL;
	struct db_context *db = acl_db;
	int ret = -1;

	smb_fname_tmp = cp_smb_filename(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;
	}

	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;
}
Exemplo n.º 2
0
static int sys_acl_set_fd_tdb(vfs_handle_struct *handle,
                              files_struct *fsp,
                              SMB_ACL_T theacl)
{
    struct db_context *db;
    NTSTATUS status;
    int ret;

    SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);

    status = vfs_stat_fsp(fsp);
    if (!NT_STATUS_IS_OK(status)) {
        return -1;
    }

    ret = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle,
                                      fsp,
                                      theacl);
    if (ret == -1) {
        return -1;
    }

    acl_tdb_delete(handle, db, &fsp->fsp_name->st);
    return 0;
}
Exemplo n.º 3
0
static int sys_acl_set_file_tdb(vfs_handle_struct *handle,
                              const char *path,
                              SMB_ACL_TYPE_T type,
                              SMB_ACL_T theacl)
{
	SMB_STRUCT_STAT sbuf;
	struct db_context *db = acl_db;
	int ret = -1;

	ret = vfs_stat_smb_basename(handle->conn, path, &sbuf);
	if (ret == -1) {
		return -1;
	}

	ret = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle,
						path,
						type,
						theacl);
	if (ret == -1) {
		return -1;
	}

	acl_tdb_delete(handle, db, &sbuf);
	return 0;
}
Exemplo n.º 4
0
static int sys_acl_set_file_tdb(vfs_handle_struct *handle,
                                const char *path,
                                SMB_ACL_TYPE_T type,
                                SMB_ACL_T theacl)
{
    SMB_STRUCT_STAT sbuf;
    struct db_context *db;
    int ret = -1;

    SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);

    if (lp_posix_pathnames()) {
        ret = vfs_lstat_smb_fname(handle->conn, path, &sbuf);
    } else {
        ret = vfs_stat_smb_fname(handle->conn, path, &sbuf);
    }

    if (ret == -1) {
        return -1;
    }

    ret = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle,
                                        path,
                                        type,
                                        theacl);
    if (ret == -1) {
        return -1;
    }

    acl_tdb_delete(handle, db, &sbuf);
    return 0;
}
Exemplo n.º 5
0
static int rmdir_acl_tdb(vfs_handle_struct *handle, const char *path)
{

    SMB_STRUCT_STAT sbuf;
    struct db_context *db;
    int ret = -1;

    SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);

    if (lp_posix_pathnames()) {
        ret = vfs_lstat_smb_fname(handle->conn, path, &sbuf);
    } else {
        ret = vfs_stat_smb_fname(handle->conn, path, &sbuf);
    }

    if (ret == -1) {
        return -1;
    }

    ret = SMB_VFS_NEXT_RMDIR(handle, path);
    if (ret == -1) {
        return -1;
    }

    acl_tdb_delete(handle, db, &sbuf);
    return 0;
}
Exemplo n.º 6
0
static int sys_acl_set_fd_tdb(vfs_handle_struct *handle,
                            files_struct *fsp,
                            SMB_ACL_T theacl)
{
	SMB_STRUCT_STAT sbuf;
	struct db_context *db;
	int ret;

	SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);

	if (fsp->is_directory || fsp->fh->fd == -1) {
		if (fsp->posix_open) {
			ret = SMB_VFS_LSTAT(fsp->conn,fsp->fsp_name, &sbuf);
		} else {
			ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf);
		}
	} else {
		ret = SMB_VFS_FSTAT(fsp, &sbuf);
	}
	if (ret == -1) {
		return -1;
	}

	ret = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle,
						fsp,
						theacl);
	if (ret == -1) {
		return -1;
	}

	acl_tdb_delete(handle, db, &sbuf);
	return 0;
}
Exemplo n.º 7
0
static int rmdir_acl_tdb(vfs_handle_struct *handle, const char *path)
{

    SMB_STRUCT_STAT sbuf;
    struct db_context *db = acl_db;
    int ret = -1;

    if (lp_posix_pathnames()) {
        ret = vfs_lstat_smb_fname(handle->conn, path, &sbuf);
    } else {
        ret = vfs_stat_smb_fname(handle->conn, path, &sbuf);
    }

    if (ret == -1) {
        return -1;
    }

    ret = rmdir_acl_common(handle, path);
    if (ret == -1) {
        return -1;
    }

    acl_tdb_delete(handle, db, &sbuf);
    return 0;
}
Exemplo n.º 8
0
static int unlink_acl_tdb(vfs_handle_struct *handle,
                          const struct smb_filename *smb_fname)
{
    struct smb_filename *smb_fname_tmp = NULL;
    struct db_context *db = acl_db;
    NTSTATUS status;
    int ret = -1;

    status = copy_smb_filename(talloc_tos(), smb_fname, &smb_fname_tmp);
    if (!NT_STATUS_IS_OK(status)) {
        errno = map_errno_from_nt_status(status);
        goto out;
    }

    if (lp_posix_pathnames()) {
        ret = SMB_VFS_LSTAT(handle->conn, smb_fname_tmp);
    } else {
        ret = SMB_VFS_STAT(handle->conn, smb_fname_tmp);
    }

    if (ret == -1) {
        goto out;
    }

    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;
}
Exemplo n.º 9
0
static int rmdir_acl_tdb(vfs_handle_struct *handle,
		const struct smb_filename *smb_fname)
{

	SMB_STRUCT_STAT sbuf;
	struct db_context *db = acl_db;
	int ret = -1;

	ret = vfs_stat_smb_basename(handle->conn, smb_fname, &sbuf);
	if (ret == -1) {
		return -1;
	}

	ret = rmdir_acl_common(handle, smb_fname);
	if (ret == -1) {
		return -1;
	}

	acl_tdb_delete(handle, db, &sbuf);
	return 0;
}
Exemplo n.º 10
0
static int sys_acl_set_file_tdb(vfs_handle_struct *handle,
                              const char *path,
                              SMB_ACL_TYPE_T type,
                              SMB_ACL_T theacl)
{
	struct db_context *db = acl_db;
	int ret = -1;
	struct smb_filename smb_fname = {
		.base_name = discard_const_p(char, path)
	};

	ret = SMB_VFS_STAT(handle->conn, &smb_fname);
	if (ret == -1) {
		return -1;
	}

	ret = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle,
						path,
						type,
						theacl);
	if (ret == -1) {
		return -1;
	}

	acl_tdb_delete(handle, db, &smb_fname.st);
	return 0;
}

/*********************************************************************
 Remove a Windows ACL - we're setting the underlying POSIX ACL.
*********************************************************************/

static int sys_acl_set_fd_tdb(vfs_handle_struct *handle,
                            files_struct *fsp,
                            SMB_ACL_T theacl)
{
	struct db_context *db = acl_db;
	NTSTATUS status;
	int ret;

	status = vfs_stat_fsp(fsp);
	if (!NT_STATUS_IS_OK(status)) {
		return -1;
	}

	ret = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle,
						fsp,
						theacl);
	if (ret == -1) {
		return -1;
	}

	acl_tdb_delete(handle, db, &fsp->fsp_name->st);
	return 0;
}

static struct vfs_fn_pointers vfs_acl_tdb_fns = {
	.connect_fn = connect_acl_tdb,
	.disconnect_fn = disconnect_acl_tdb,
	.rmdir_fn = rmdir_acl_tdb,
	.unlink_fn = unlink_acl_tdb,
	.chmod_fn = chmod_acl_module_common,
	.fchmod_fn = fchmod_acl_module_common,
	.fget_nt_acl_fn = fget_nt_acl_common,
	.get_nt_acl_fn = get_nt_acl_common,
	.fset_nt_acl_fn = fset_nt_acl_common,
	.chmod_acl_fn = chmod_acl_acl_module_common,
	.fchmod_acl_fn = fchmod_acl_acl_module_common,
	.sys_acl_set_file_fn = sys_acl_set_file_tdb,
	.sys_acl_set_fd_fn = sys_acl_set_fd_tdb
};

static_decl_vfs;
NTSTATUS vfs_acl_tdb_init(void)
{
	return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "acl_tdb",
				&vfs_acl_tdb_fns);
}