summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2014-04-09 20:50:03 +0000
committerflorian <florian@openbsd.org>2014-04-09 20:50:03 +0000
commitdabfd751a1d41554683310abce100d9593f4b103 (patch)
tree2ed3140aab0fb132eb0029a477b4150cfdf69cba
parentdisplay correct imsg when profiling is on and if the type was changed (diff)
downloadwireguard-openbsd-dabfd751a1d41554683310abce100d9593f4b103.tar.xz
wireguard-openbsd-dabfd751a1d41554683310abce100d9593f4b103.zip
Revert 1.93, it breaks permission checks.
"go for it" deraadt@
-rw-r--r--usr.bin/mg/file.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index de8be3dc085..f67596b40f6 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.94 2014/04/03 20:17:12 lum Exp $ */
+/* $OpenBSD: file.c,v 1.95 2014/04/09 20:50:03 florian Exp $ */
/* This file is in the public domain. */
@@ -225,20 +225,22 @@ readin(char *fname)
*/
if (fisdir(fname) == TRUE) {
ro = TRUE;
- } else if ((access(fname, W_OK) == -1) && (errno != ENOENT)) {
- ro = TRUE;
- } else if (errno == ENOENT) {
- (void)xdirname(dp, fname, sizeof(dp));
- (void)strlcat(dp, "/", sizeof(dp));
-
- /* Missing directory; keep buffer read-write, like emacs */
- if (stat(dp, &statbuf) == -1 && errno == ENOENT) {
- if (eyorn("Missing directory, create") == TRUE)
- (void)do_makedir(dp);
- } else if (access(dp, W_OK) == -1 && errno == EACCES) {
- ewprintf("File not found and directory"
- " write-protected");
+ } else if ((access(fname, W_OK) == -1)) {
+ if (errno != ENOENT) {
ro = TRUE;
+ } else if (errno == ENOENT) {
+ (void)xdirname(dp, fname, sizeof(dp));
+ (void)strlcat(dp, "/", sizeof(dp));
+
+ /* Missing directory; keep buffer rw, like emacs */
+ if (stat(dp, &statbuf) == -1 && errno == ENOENT) {
+ if (eyorn("Missing directory, create") == TRUE)
+ (void)do_makedir(dp);
+ } else if (access(dp, W_OK) == -1 && errno == EACCES) {
+ ewprintf("File not found and directory"
+ " write-protected");
+ ro = TRUE;
+ }
}
}
if (ro == TRUE)