Message ID | 1443489278-6435-1-git-send-email-vapier@gentoo.org |
---|---|
State | Accepted, archived |
Headers | show |
On Mon, Sep 28, 2015 at 09:14:38PM -0400, Mike Frysinger wrote: > When running on NFS, opening files with 0444 perms for writing can > sometimes fail. Delay the permission update until the end (which > restores behavior to pre-commit 2873927d15ffb9ee9ed0e2700791a0e5). > > URL: https://bugs.gentoo.org/550986 > Signed-off-by: Mike Frysinger <vapier@gentoo.org> I've already applied my version of the patch which uses fchmod instead of chmod (to avoid static Code Analysis systems from complaining). Cheers, - Ted -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/util/subst.c b/util/subst.c index f36adb4..10ad6b9 100644 --- a/util/subst.c +++ b/util/subst.c @@ -370,7 +370,7 @@ int main(int argc, char **argv) } strcpy(newfn, outfn); strcat(newfn, ".new"); - fd = open(newfn, O_CREAT|O_TRUNC|O_RDWR, 0444); + fd = open(newfn, O_CREAT|O_TRUNC|O_RDWR, 0644); if (fd < 0) { perror(newfn); exit(1); @@ -443,6 +443,11 @@ int main(int argc, char **argv) perror("rename"); exit(1); } + /* set read-only to alert user it is a generated file */ + if (chmod(outfn, 0444)) { + perror("chmod"); + exit(1); + } } } if (old)
When running on NFS, opening files with 0444 perms for writing can sometimes fail. Delay the permission update until the end (which restores behavior to pre-commit 2873927d15ffb9ee9ed0e2700791a0e5). URL: https://bugs.gentoo.org/550986 Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- util/subst.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)