[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 11/36] 9pfs: local: post rename operation for ma
From: |
Greg Kurz |
Subject: |
[Qemu-devel] [PATCH RFC 11/36] 9pfs: local: post rename operation for mapped-file security |
Date: |
Mon, 30 Jan 2017 13:11:00 +0100 |
User-agent: |
StGit/0.17.1-20-gc0b1b-dirty |
The rename operation is really the same for the passthrough and mapped
security models. This patch simply moves the mapped-file bits to a
separate function. This will make future modifications easier.
This doesn't fix any bug, it is just preparatory cleanup.
Signed-off-by: Greg Kurz <address@hidden>
---
hw/9pfs/9p-local.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index df453414c902..74953e4dbfe0 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1187,6 +1187,29 @@ static int local_truncate(FsContext *ctx, V9fsPath
*fs_path, off_t size)
return ret;
}
+static int local_post_rename_mapped_file(FsContext *ctx, const char *oldpath,
+ const char *newpath)
+{
+ int err;
+ char *buffer, *buffer1;
+
+ err = local_create_mapped_attr_dir(ctx, newpath);
+ if (err < 0) {
+ return err;
+ }
+ /* rename the .virtfs_metadata files */
+ buffer = local_mapped_attr_path(ctx, oldpath);
+ buffer1 = local_mapped_attr_path(ctx, newpath);
+ err = rename(buffer, buffer1);
+ g_free(buffer);
+ g_free(buffer1);
+ if (err < 0 && errno != ENOENT) {
+ return err;
+ }
+
+ return 0;
+}
+
static int local_rename(FsContext *ctx, const char *oldpath,
const char *newpath)
{
@@ -1202,19 +1225,8 @@ static int local_rename(FsContext *ctx, const char
*oldpath,
}
if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
- char *vbuffer, *vbuffer1;
-
- err = local_create_mapped_attr_dir(ctx, newpath);
+ err = local_post_rename_mapped_file(ctx, oldpath, newpath);
if (err < 0) {
- goto out_err;
- }
- /* rename the .virtfs_metadata files */
- vbuffer = local_mapped_attr_path(ctx, oldpath);
- vbuffer1 = local_mapped_attr_path(ctx, newpath);
- err = rename(vbuffer, vbuffer1);
- g_free(vbuffer);
- g_free(vbuffer1);
- if (err < 0 && errno != ENOENT) {
goto err_out;
}
}
- [Qemu-devel] [PATCH RFC 00/36] 9pfs: local: fix vulnerability to symlink attacks, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 01/36] 9pfs: local: move xattr security ops to 9p-xattr.c, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 02/36] 9pfs: local: split chmod operation per security model, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 03/36] 9pfs: local: split mknod operation per security model, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 04/36] 9pfs: local: split mkdir operation per security model, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 05/36] 9pfs: local: split open2 operation per security model, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 08/36] 9pfs: local: improve error handling in link op, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 09/36] 9pfs: local: post link operation for mapped-file security, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 07/36] 9pfs: local: split mkdir operation per security model, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 10/36] v9fs: local: improve error handling in rename op, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 11/36] 9pfs: local: post rename operation for mapped-file security,
Greg Kurz <=
- [Qemu-devel] [PATCH RFC 12/36] 9pfs: local: pre remove operation for mapped-file security, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 06/36] 9pfs: local: split symlink operation per security model, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 13/36] 9pfs: local: pre unlikat operation for mapped-file security, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 14/36] 9pfs: remove side-effects in local_init(), Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 15/36] 9pfs: remove side-effects in local_open() and local_opendir(), Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 16/36] 9pfs: introduce openat_nofollow() helper, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 17/36] 9pfs: local: keep a file descriptor on the shared folder, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 18/36] 9pfs: local: open/opendir: don't follow symlinks, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 19/36] 9pfs: local: utimensat: don't follow symlinks, Greg Kurz, 2017/01/30
- [Qemu-devel] [PATCH RFC 20/36] 9pfs: local: readlink: don't follow symlinks, Greg Kurz, 2017/01/30