Author: rfm
Date: Fri Jul 25 14:47:18 2014
New Revision: 38016

URL: http://svn.gna.org/viewcvs/gnustep?rev=38016&view=rev
Log:
Add 'gdomap -j path' option to specify the chroot jail path.

Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Tools/gdomap.8
    libs/base/trunk/Tools/gdomap.c

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=38016&r1=38015&r2=38016&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Fri Jul 25 14:47:18 2014
@@ -1,3 +1,10 @@
+2014-07-25  Richard Frith-Macdonald <[email protected]>
+
+       * Source/Tools/gdomap.c: Unless running on windows, allow new -j
+       command-line argument to specify the path in which the process should
+       be jailed (chroot).  The default remains to jail the process in /tmp
+       since there doesn't seem to be a general, portable alternative.
+
 2014-07-25  Richard Frith-Macdonald <[email protected]>
 
        * Source/GSSocketStream.m: Fix handling TLS handshake in the case

Modified: libs/base/trunk/Tools/gdomap.8
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tools/gdomap.8?rev=38016&r1=38015&r2=38016&view=diff
==============================================================================
--- libs/base/trunk/Tools/gdomap.8      (original)
+++ libs/base/trunk/Tools/gdomap.8      Fri Jul 25 14:47:18 2014
@@ -35,6 +35,8 @@
 .RB [ -f ]
 .RB [-i 
 .IR seconds ]
+.RB [-j 
+.IR path ]
 .RB [ -p ]
 
 .SH DESCRIPTION
@@ -137,6 +139,8 @@
 avoid fork() to make debugging easy
 .IP "\fB-i \fIseconds"
 re-probe at this interval (roughly), min 60
+.IP "\fB-j \fIpath"
+place the process in a chroot jail at this path rather than in /tmp
 .IP "\fB-p"
 disable probing for other servers
 .PP

Modified: libs/base/trunk/Tools/gdomap.c
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tools/gdomap.c?rev=38016&r1=38015&r2=38016&view=diff
==============================================================================
--- libs/base/trunk/Tools/gdomap.c      (original)
+++ libs/base/trunk/Tools/gdomap.c      Fri Jul 25 14:47:18 2014
@@ -4372,6 +4372,10 @@
   printf("-d           extra debug logging (normally via syslog).\n");
   printf("-f           avoid fork() to make debugging easy\n");
   printf("-i seconds   re-probe at this interval (roughly), min 60\n");
+#if    !defined(__MINGW__)
+  printf("-j path              specify a jail directory the process is to\n");
+  printf("             run in (if omitted, /tmp is used).\n");
+#endif
   printf("-p           disable probing for other servers\n");
   printf("\n");
   printf("Kill with SIGUSR1 to obtain a dump of all known peers\n");
@@ -4474,7 +4478,12 @@
 main(int argc, char** argv)
 {
   extern char  *optarg;
+#if    defined(__MINGW__)
   char *options = "-CHI:L:M:NP:R:T:U:a:bc:dfi:p";
+#else
+  char *options = "-CHI:L:M:NP:R:T:U:a:bc:dfi:j:p";
+  const char    *jail = 0;
+#endif
   int          c;
   int          ptype = GDO_TCP_GDO;
   int          port = 0;
@@ -4793,6 +4802,12 @@
              }
            break;
 
+#if    !defined(__MINGW__)
+         case 'j':
+           jail = optarg;
+            break;
+#endif
+
          case 'p':
            noprobe++;
            break;
@@ -5021,21 +5036,25 @@
 
 #if    !defined(__svr4__)
   /*
-   * As another level of paranoia - restrict this process to /tmp
+   * As another level of paranoia - jail this process to a directory
    */
 #ifndef __MINGW__
-  if (chdir("/tmp") < 0)
-    {
-      snprintf(ebuf, sizeof(ebuf), "Unable to change directory to /tmp");
+  if (0 == jail)
+    {
+      jail = "/tmp";    /* Not great, but better than nothing */
+    }
+  if (chdir(jail) < 0)
+    {
+      snprintf(ebuf, sizeof(ebuf), "Unable to change directory to %s", jail);
       gdomap_log(LOG_CRIT);
       exit(EXIT_FAILURE);
     }
 
   if (geteuid() == 0)
     {
-      if (chroot("/tmp") < 0)
-       {
-         snprintf(ebuf, sizeof(ebuf), "Unable to change root to /tmp");
+      if (chroot(jail) < 0)
+       {
+         snprintf(ebuf, sizeof(ebuf), "Unable to change root to %s", jail);
          gdomap_log(LOG_CRIT);
          exit(EXIT_FAILURE);
        }


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to