chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
92ee644
)
machined: be more thorough when checking whether an image is writable or not
author
Lennart Poettering
<lennart@poettering.net>
Fri, 26 Dec 2014 15:44:15 +0000
(16:44 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Fri, 26 Dec 2014 18:21:58 +0000
(19:21 +0100)
src/machine/image.c
patch
|
blob
|
history
diff --git
a/src/machine/image.c
b/src/machine/image.c
index 9f88b0551f51c1e4328b59e9d2272591c2dbead2..f72a5c39608d538d765d979a053c2bc62c80b7ca 100644
(file)
--- 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;
static int image_make(int dfd, const char *name, const char *path, Image **ret) {
struct stat st;
+ bool writable;
int r;
assert(dfd >= 0);
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;
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)
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,
r = image_new(IMAGE_SUBVOLUME,
name,
path,
- info.read_only,
+ info.read_only
|| !writable
,
info.otime,
0,
ret);
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,
r = image_new(IMAGE_DIRECTORY,
name,
path,
-
fals
e,
+
!writabl
e,
0,
0,
ret);
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,
r = image_new(IMAGE_GPT,
truncated,
path,
- !(st.st_mode & 0222),
+ !(st.st_mode & 0222)
|| !writable
,
crtime,
timespec_load(&st.st_mtim),
ret);
crtime,
timespec_load(&st.st_mtim),
ret);