On Fri, 2015-06-05 at 11:18 +0530, Samuel Thibault wrote:
> Hello,
> 
> It seems there is still a corner case which doesn't work: the pycorrfit
> package fails to build with:
> 
> chmod -R 644 
> debian/pycorrfit/usr/share/doc/pycorrfit/examples/external_model_functions/
> chmod: cannot access 
> 'debian/pycorrfit/usr/share/doc/pycorrfit/examples/external_model_functions/ExampleFunc_CS_2D+2D+S+T.txt':
>  Permission denied
> 
> etc.  Could you have a look?

Done so now. Attached are two versions of a patch to fakeroot.c. In
netfs_get_dirents(): call netfs_attempt_chmod() before dir_readdir() to
make sure that directories are accessible (executable) before changing
the underlying files. The resulting directory (and file) access
permissions are the same as with fakeroot-tcp and Linux.
The first patch adds S_IXUSR to real_mode, the other adds O_EXEC to
nn->openmodes. Your choice (if OK, of course, maybe I've missed
something.)

Thanks!

Index: hurd-0.6.git20150523/trans/fakeroot.c
===================================================================
--- hurd-0.6.git20150523.orig/trans/fakeroot.c
+++ hurd-0.6.git20150523/trans/fakeroot.c
@@ -796,8 +796,19 @@ netfs_get_dirents (struct iouser *cred,
 		   mach_msg_type_number_t *datacnt,
 		   vm_size_t bufsize, int *amt)
 {
-  return dir_readdir (netfs_node_netnode (dir)->file, data, datacnt,
+  struct netnode *nn = netfs_node_netnode (dir);
+  mode_t real_mode = dir->nn_stat.st_mode;
+  error_t err = 0;
+
+  if ((real_mode & S_IFDIR) && ((real_mode & S_IXUSR) == 0))
+    {
+      err = netfs_attempt_chmod (cred, dir, real_mode | S_IXUSR);
+      if (err)
+	return err;
+    }
+  err = dir_readdir (nn->file, data, datacnt,
 		      entry, nentries, bufsize, amt);
+  return err;
 }
 
 error_t
Index: hurd-0.6.git20150523/trans/fakeroot.c
===================================================================
--- hurd-0.6.git20150523.orig/trans/fakeroot.c
+++ hurd-0.6.git20150523/trans/fakeroot.c
@@ -796,8 +796,20 @@ netfs_get_dirents (struct iouser *cred,
 		   mach_msg_type_number_t *datacnt,
 		   vm_size_t bufsize, int *amt)
 {
-  return dir_readdir (netfs_node_netnode (dir)->file, data, datacnt,
+  struct netnode *nn = netfs_node_netnode (dir);
+  mode_t real_mode = dir->nn_stat.st_mode;
+  error_t err = 0;
+
+  if ((real_mode & S_IFDIR) && ((real_mode & S_IXUSR) == 0))
+    {
+      nn->openmodes |= O_EXEC;
+      err = netfs_attempt_chmod (cred, dir, real_mode);
+      if (err)
+	return err;
+    }
+  err = dir_readdir (nn->file, data, datacnt,
 		      entry, nentries, bufsize, amt);
+  return err;
 }
 
 error_t

Reply via email to