[Rd] R CMD INSTALL and file permission settings

Dirk Eddelbuettel edd at debian.org
Sat Jun 8 18:22:56 CEST 2013


  The directory /usr/local/lib/R/site-library can be used for site-wide
  multi-user installations of R.  

  This is even the default on Debian and Ubuntu (following a suggestion by
  Kurt and Fritz a decade ago over beers -- what could be better).  However,
  R enforces wrong permissions on directories and files there (removing
  group-write) which effectively defeats this purpose, and breaks multiuser
  installation:  if Tom, Dick and Harry are members of group 'r-users', each
  one can install in the directory, but neither can _upgrade_ a package
  installed by one of the others.  

  I would like to correct this.


  For a while now, R CMD INSTALL dispatches installation work to the R
  function tools:::.install_packages() from the file tools/install.R. The
  function does a lot of hardcoded 'chmod' with constant arguments:

  edd at max:~/svn/r-devel/src/library/tools/R$ grep Sys.chmod install.R 
                  if (!WINDOWS) Sys.chmod(file.path(dest, files), "755")
                      Sys.chmod(file.path(instdir, f), "644")
                  Sys.chmod(Sys.glob(file.path(instdir, "data", "*")), "644")
              Sys.chmod(Sys.glob(file.path(instdir, "demo", "*")), "644")
                      Sys.chmod(Sys.glob(file.path(instdir, "exec", "*")), "755")
                  Sys.chmod(i2_files[execs], "755")
  edd at max:~/svn/r-devel/src/library/tools/R$ 

  Moreover, it also calls a C function for cleanup cleanup:

  edd at max:~/svn/r-devel/src/library/tools/R$ grep ".Call(dir" install.R 
          .Call(dirchmod, instdir)
                      .Call(dirchmod, ss)
                              .Call(dirchmod, ss)
              ## tree, since the later .Call(dirchmod) call will
  edd at max:~/svn/r-devel/src/library/tools/R$

  which also uses unconditional 644 / 755

      mode_t mask = S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR, /* 0644 */
          dirmask = mask | S_IXUSR | S_IXGRP | S_IXOTH; /* 0755 */


  Add a new option() [with a to-be-determined name] which, if enabled, turns
  on group-write modes for files and directories, ie "664" and "775".  

  One way would be to set two character vars at the beginning of
  _install_packages and to pass a flag to the dirchmod call as so that
  'S_IWGRP' (the 00020 "write by group" permission) can be set.

  I would be happy to write such a patch (including documentation updates) if
  someone from R Core can signal willigness to look at it.

Thanks,  Dirk

Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com

More information about the R-devel mailing list