commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1412037 - in /commons/proper/daemon/branches/1.0.x/src/native/unix/native: arguments.c arguments.h home.c jsvc-unix.c
Date Wed, 21 Nov 2012 10:01:23 GMT
Author: mturk
Date: Wed Nov 21 10:01:22 2012
New Revision: 1412037

URL: http://svn.apache.org/viewvc?rev=1412037&view=rev
Log:
DAEMON-264: Add -cwd parameter which defaults to root

Modified:
    commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.c
    commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.h
    commons/proper/daemon/branches/1.0.x/src/native/unix/native/home.c
    commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c

Modified: commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.c?rev=1412037&r1=1412036&r2=1412037&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.c (original)
+++ commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.c Wed Nov 21 10:01:22
2012
@@ -167,6 +167,7 @@ static arg_data *parse(int argc, char *a
     args->onum    = 0;            /* Zero arguments, but let's have some room */
     args->clas    = NULL;         /* No class predefined */
     args->anum    = 0;            /* Zero class specific arguments but make room*/
+    args->cwd     = "/";           /* Use root as default */
     args->outfile = "/dev/null";   /* Swallow by default */
     args->errfile = "/dev/null";   /* Swallow by default */
     args->redirectstdin = true;    /* Redirect stdin to /dev/null by default */
@@ -237,6 +238,13 @@ static arg_data *parse(int argc, char *a
                 return NULL;
             }
         }
+        else if (!strcmp(argv[x], "-cwd")) {
+            args->cwd = optional(argc, argv, x++);
+            if (args->cwd == NULL) {
+                log_error("Invalid working directory specified");
+                return NULL;
+            }
+        }
         else if (!strcmp(argv[x], "-version")) {
             args->vers = true;
             args->dtch = false;

Modified: commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.h
URL: http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.h?rev=1412037&r1=1412036&r2=1412037&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.h (original)
+++ commons/proper/daemon/branches/1.0.x/src/native/unix/native/arguments.h Wed Nov 21 10:01:22
2012
@@ -35,6 +35,8 @@ typedef struct {
     char *name;
     /** The JDK or JRE installation path (JAVA_HOME). */
     char *home;
+    /** Working directory (defaults to /). */
+    char *cwd;
     /** Options used to invoke the JVM. */
     char **opts;
     /** Number of JVM options. */

Modified: commons/proper/daemon/branches/1.0.x/src/native/unix/native/home.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/unix/native/home.c?rev=1412037&r1=1412036&r2=1412037&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/native/unix/native/home.c (original)
+++ commons/proper/daemon/branches/1.0.x/src/native/unix/native/home.c Wed Nov 21 10:01:22
2012
@@ -212,9 +212,13 @@ static home_data *find(char *path)
     home_data *data = NULL;
     int x = 0;
 
-    if (path == NULL) {
+    if (path == NULL || *path == '\0' || *path == '/') {
         log_debug("Home not specified on command line, using environment");
         path = getenv("JAVA_HOME");
+        if (path == NULL || *path == '\0' || *path == '/') {
+            /* guard against empty JAVA_HOME */
+            path = NULL;
+        }
     }
 
     if (path == NULL) {

Modified: commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c?rev=1412037&r1=1412036&r2=1412037&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c (original)
+++ commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c Wed Nov 21 10:01:22
2012
@@ -1223,6 +1223,10 @@ int main(int argc, char *argv[])
 #endif
     }
 
+    if (chdir(args->cwd)) {
+        log_error("ERROR: jsvc was unable to "
+                  "change directory to: %s", args->cwd);
+    }
     /*
      * umask() uses inverse logic; bits are CLEAR for allowed access.
      */



Mime
View raw message