commit 180a53cc0c59fcced2f610d4090c714d97f6f260
parent d18cfb26cd21bb30c1855c2d2d4fa729858f39b3
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 1 Jul 2020 18:47:14 +0200
files: warn the root user when all the write bits are missing
Root has carte blanche to both read unreadable files and write
unwritable files -- the file system does not prevent this. So,
alert root when opening a file that is intended to be read-only.
This fulfills https://savannah.gnu.org/bugs/?58685.
Requested-by: Marius Bakke <mbakke@fastmail.com>
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -401,6 +401,10 @@ bool open_buffer(const char *filename, bool new_one)
free(realname);
return FALSE;
}
+#else
+ if (new_one && !(fileinfo.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) &&
+ geteuid() == ROOT_UID)
+ statusline(ALERT, _("%s is meant to be read-only"), realname);
#endif
}