69267b7a87
OBS-URL: https://build.opensuse.org/request/show/423993 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/lxcfs?expand=0&rev=6
126 lines
2.9 KiB
Diff
126 lines
2.9 KiB
Diff
From f9b24a3e01e49dfa2b98c138f3d4f6f687c8d0b6 Mon Sep 17 00:00:00 2001
|
|
From: Christian Brauner <cbrauner@suse.de>
|
|
Date: Mon, 22 Aug 2016 11:36:02 +0200
|
|
Subject: [PATCH 12/24] lxcfs: better fs behavior on /var/lib/lxcfs
|
|
|
|
return -EPERM for mkdir(), rmdir(), chown(), chmod() on top directory
|
|
/var/lib/lxcfs.
|
|
|
|
Signed-off-by: Christian Brauner <cbrauner@suse.de>
|
|
---
|
|
lxcfs.c | 29 ++++++++++++++++++-----------
|
|
1 file changed, 18 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/lxcfs.c b/lxcfs.c
|
|
index 0c695b7..a013033 100644
|
|
--- a/lxcfs.c
|
|
+++ b/lxcfs.c
|
|
@@ -449,7 +449,7 @@ static int lxcfs_getattr(const char *path, struct stat *sb)
|
|
down_users();
|
|
return ret;
|
|
}
|
|
- return -EINVAL;
|
|
+ return -ENOENT;
|
|
}
|
|
|
|
static int lxcfs_opendir(const char *path, struct fuse_file_info *fi)
|
|
@@ -478,7 +478,7 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, of
|
|
filler(buf, "..", NULL, 0) != 0 ||
|
|
filler(buf, "proc", NULL, 0) != 0 ||
|
|
filler(buf, "cgroup", NULL, 0) != 0)
|
|
- return -EINVAL;
|
|
+ return -ENOMEM;
|
|
return 0;
|
|
}
|
|
if (strncmp(path, "/cgroup", 7) == 0) {
|
|
@@ -493,14 +493,14 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, of
|
|
down_users();
|
|
return ret;
|
|
}
|
|
- return -EINVAL;
|
|
+ return -ENOENT;
|
|
}
|
|
|
|
static int lxcfs_access(const char *path, int mode)
|
|
{
|
|
int ret;
|
|
|
|
- if (strcmp(path, "/") == 0 && access(path, R_OK) == 0)
|
|
+ if (strcmp(path, "/") == 0 && (mode & W_OK) == 0)
|
|
return 0;
|
|
|
|
if (strncmp(path, "/cgroup", 7) == 0) {
|
|
@@ -516,7 +516,7 @@ static int lxcfs_access(const char *path, int mode)
|
|
return ret;
|
|
}
|
|
|
|
- return -EINVAL;
|
|
+ return -EACCES;
|
|
}
|
|
|
|
static int lxcfs_releasedir(const char *path, struct fuse_file_info *fi)
|
|
@@ -551,7 +551,7 @@ static int lxcfs_open(const char *path, struct fuse_file_info *fi)
|
|
return ret;
|
|
}
|
|
|
|
- return -EINVAL;
|
|
+ return -EACCES;
|
|
}
|
|
|
|
static int lxcfs_read(const char *path, char *buf, size_t size, off_t offset,
|
|
@@ -627,7 +627,7 @@ int lxcfs_mkdir(const char *path, mode_t mode)
|
|
return ret;
|
|
}
|
|
|
|
- return -EINVAL;
|
|
+ return -EPERM;
|
|
}
|
|
|
|
int lxcfs_chown(const char *path, uid_t uid, gid_t gid)
|
|
@@ -640,7 +640,10 @@ int lxcfs_chown(const char *path, uid_t uid, gid_t gid)
|
|
return ret;
|
|
}
|
|
|
|
- return -EINVAL;
|
|
+ if (strncmp(path, "/proc", 5) == 0)
|
|
+ return -EPERM;
|
|
+
|
|
+ return -ENOENT;
|
|
}
|
|
|
|
/*
|
|
@@ -652,7 +655,7 @@ int lxcfs_truncate(const char *path, off_t newsize)
|
|
{
|
|
if (strncmp(path, "/cgroup", 7) == 0)
|
|
return 0;
|
|
- return -EINVAL;
|
|
+ return -EPERM;
|
|
}
|
|
|
|
int lxcfs_rmdir(const char *path)
|
|
@@ -664,7 +667,7 @@ int lxcfs_rmdir(const char *path)
|
|
down_users();
|
|
return ret;
|
|
}
|
|
- return -EINVAL;
|
|
+ return -EPERM;
|
|
}
|
|
|
|
int lxcfs_chmod(const char *path, mode_t mode)
|
|
@@ -676,7 +679,11 @@ int lxcfs_chmod(const char *path, mode_t mode)
|
|
down_users();
|
|
return ret;
|
|
}
|
|
- return -EINVAL;
|
|
+
|
|
+ if (strncmp(path, "/proc", 5) == 0)
|
|
+ return -EPERM;
|
|
+
|
|
+ return -ENOENT;
|
|
}
|
|
|
|
const struct fuse_operations lxcfs_ops = {
|
|
--
|
|
2.9.3
|
|
|