commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 19/20: fakeroot: Fix reopening files after a chmod


From: Samuel Thibault
Subject: [hurd] 19/20: fakeroot: Fix reopening files after a chmod
Date: Sat, 23 May 2015 05:09:42 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit ef1312fb2e17d15d695dc29be9c3abc25584ba10
Author: Samuel Thibault <address@hidden>
Date:   Sat May 23 02:18:03 2015 +0530

    fakeroot: Fix reopening files after a chmod
    
    Huge thanks to Svante Signell for having tracked the bug.
    
    * trans/fakeroot.c (netfs_attempt_chmod): Make the file_chmod call
    additionally include the modes from nn->openmodes.
---
 trans/fakeroot.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 51be60c..63303a0 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -544,14 +544,28 @@ real_from_fake_mode (mode_t mode)
 error_t
 netfs_attempt_chmod (struct iouser *cred, struct node *np, mode_t mode)
 {
+  struct netnode *nn;
+  mode_t real_mode;
+
   if ((mode & S_IFMT) == 0)
     mode |= np->nn_stat.st_mode & S_IFMT;
   if ((mode & S_IFMT) != (np->nn_stat.st_mode & S_IFMT))
     return EOPNOTSUPP;
 
+  /* Make sure that `check_openmodes' will still always be able to reopen
+     it.  */
+  real_mode = mode;
+  nn = netfs_node_netnode (np);
+  if (nn->openmodes & O_READ)
+    real_mode |= S_IRUSR;
+  if (nn->openmodes & O_WRITE)
+    real_mode |= S_IWUSR;
+  if (nn->openmodes & O_EXEC)
+    real_mode |= S_IXUSR;
+
   /* We don't bother with error checking since the fake mode change should
      always succeed--worst case a later open will get EACCES.  */
-  (void) file_chmod (netfs_node_netnode (np)->file, mode);
+  (void) file_chmod (nn->file, real_mode);
   set_faked_attribute (np, FAKE_MODE);
   np->nn_stat.st_mode = mode;
   return 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]