summaryrefslogtreecommitdiff
path: root/src/machine
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-26 16:44:15 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-26 19:21:58 +0100
commit86e339c8846cdf614a41653384c0b4e84b233696 (patch)
tree802a85d1ca3ecc32ff2001d3c455f7d174c1816b /src/machine
parent92ee6447b1deef7c79962a8121fdf8e58acb3a83 (diff)
machined: be more thorough when checking whether an image is writable or not
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/image.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/machine/image.c b/src/machine/image.c
index 9f88b0551f..f72a5c3960 100644
--- a/src/machine/image.c
+++ b/src/machine/image.c
@@ -86,6 +86,7 @@ static int image_new(
static int image_make(int dfd, const char *name, const char *path, Image **ret) {
struct stat st;
+ bool writable;
int r;
assert(dfd >= 0);
@@ -98,6 +99,8 @@ static int image_make(int dfd, const char *name, const char *path, Image **ret)
if (fstatat(dfd, name, &st, 0) < 0)
return -errno;
+ writable = faccessat(dfd, name, W_OK, AT_EACCESS) >= 0;
+
if (S_ISDIR(st.st_mode)) {
if (!ret)
@@ -127,7 +130,7 @@ static int image_make(int dfd, const char *name, const char *path, Image **ret)
r = image_new(IMAGE_SUBVOLUME,
name,
path,
- info.read_only,
+ info.read_only || !writable,
info.otime,
0,
ret);
@@ -143,7 +146,7 @@ static int image_make(int dfd, const char *name, const char *path, Image **ret)
r = image_new(IMAGE_DIRECTORY,
name,
path,
- false,
+ !writable,
0,
0,
ret);
@@ -168,7 +171,7 @@ static int image_make(int dfd, const char *name, const char *path, Image **ret)
r = image_new(IMAGE_GPT,
truncated,
path,
- !(st.st_mode & 0222),
+ !(st.st_mode & 0222) || !writable,
crtime,
timespec_load(&st.st_mtim),
ret);