Author: mturk Date: Sat Oct 29 15:52:33 2011 New Revision: 1194909 URL: http://svn.apache.org/viewvc?rev=1194909&view=rev Log: DAEMON-221 Add -umask parameter
Modified: commons/proper/daemon/trunk/RELEASE-NOTES.txt commons/proper/daemon/trunk/src/native/unix/CHANGES.txt commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml commons/proper/daemon/trunk/src/native/unix/native/arguments.c commons/proper/daemon/trunk/src/native/unix/native/arguments.h commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c Modified: commons/proper/daemon/trunk/RELEASE-NOTES.txt URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/RELEASE-NOTES.txt?rev=1194909&r1=1194908&r2=1194909&view=diff ============================================================================== --- commons/proper/daemon/trunk/RELEASE-NOTES.txt (original) +++ commons/proper/daemon/trunk/RELEASE-NOTES.txt Sat Oct 29 15:52:33 2011 @@ -31,6 +31,8 @@ Commons DAEMON 1.0.3 requires a minimum NEW FEATURES: +* DAEMON-221: Add -umask to jsvc so that users don't have to + recompile the jsvc if different umask is desired (1.0.8) * DAEMON-209: Add --LibraryPath to procrun for setting the LoadLibrary search paths (1.0.6) * DAEMON-208: Add -server and -client -jvm <name> synonyms (1.0.6) Modified: commons/proper/daemon/trunk/src/native/unix/CHANGES.txt URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/CHANGES.txt?rev=1194909&r1=1194908&r2=1194909&view=diff ============================================================================== --- commons/proper/daemon/trunk/src/native/unix/CHANGES.txt (original) +++ commons/proper/daemon/trunk/src/native/unix/CHANGES.txt Sat Oct 29 15:52:33 2011 @@ -1,6 +1,11 @@ APACHE COMMONS DAEMON (UNIX) CHANGELOG: Last modified at [$Date$] +Changes with 1.0.8 + * Better detection of JDK (DAEMON-220) + * Use CPPFLAGS in makefile (DAEMON-223) + * Add -umask parameter (DAEMON-221) + Changes with 1.0.7 Modified: commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml?rev=1194909&r1=1194908&r2=1194909&view=diff ============================================================================== --- commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml (original) +++ commons/proper/daemon/trunk/src/native/unix/man/jsvc.1.xml Sat Oct 29 15:52:33 2011 @@ -47,6 +47,7 @@ <arg choice='opt'>-check</arg> <arg choice='opt'>-user <replaceable>user</replaceable></arg> <arg choice='opt'>-wait <replaceable>waittime</replaceable></arg> + <arg choice='opt'>-umask <replaceable>mask</replaceable></arg> <arg choice='opt'>-stop</arg> <arg choice='opt'>-verbose<replaceable>:class|gc|jni</replaceable></arg> <arg choice='opt'>-outfile <replaceable>/full/path/to/file</replaceable></arg> @@ -146,6 +147,13 @@ </listitem> </varlistentry> <varlistentry> + <term><option>-umask</option> mask</term> + <listitem> + <para>sets the file mode creation mask + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>-user</option> user</term> <listitem> <para>user used to run the daemon (defaults to current user)</para> Modified: commons/proper/daemon/trunk/src/native/unix/native/arguments.c URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/arguments.c?rev=1194909&r1=1194908&r2=1194909&view=diff ============================================================================== --- commons/proper/daemon/trunk/src/native/unix/native/arguments.c (original) +++ commons/proper/daemon/trunk/src/native/unix/native/arguments.c Sat Oct 29 15:52:33 2011 @@ -171,6 +171,11 @@ static arg_data *parse(int argc, char *a args->errfile = "/dev/null"; /* Swallow by default */ args->redirectstdin = true; /* Redirect stdin to /dev/null by default */ args->procname = "jsvc.exec"; +#ifndef JSVC_UMASK + args->umask = 0077; +#else + args->umask = JSVC_UMASK; +#endif if (!(args->args = (char **)malloc(argc * sizeof(char *)))) return NULL; @@ -262,6 +267,18 @@ static arg_data *parse(int argc, char *a return NULL; } } + else if (!strcmp(argv[x], "-umask")) { + temp = optional(argc, argv, x++); + if (temp == NULL) { + log_error("Invalid umask specified"); + return NULL; + } + args->umask = atoi(temp); + if (args->umask < 02) { + log_error("Invalid umask specified (min=02)"); + return NULL; + } + } else if (!strcmp(argv[x], "-stop")) { args->stop = true; } Modified: commons/proper/daemon/trunk/src/native/unix/native/arguments.h URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/arguments.h?rev=1194909&r1=1194908&r2=1194909&view=diff ============================================================================== --- commons/proper/daemon/trunk/src/native/unix/native/arguments.h (original) +++ commons/proper/daemon/trunk/src/native/unix/native/arguments.h Sat Oct 29 15:52:33 2011 @@ -73,6 +73,8 @@ typedef struct { char *procname; /** Whether to redirect stdin to /dev/null or not. Defaults to true **/ bool redirectstdin; + /** What umask to use **/ + int umask; } arg_data; /** Modified: commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c?rev=1194909&r1=1194908&r2=1194909&view=diff ============================================================================== --- commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c (original) +++ commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c Sat Oct 29 15:52:33 2011 @@ -45,9 +45,6 @@ #define F_ULOCK 0 /* Unlock a previously locked region */ #define F_LOCK 1 /* Lock a region for exclusive use */ #endif -#ifndef JSVC_UMASK -#define JSVC_UMASK 0077 -#endif extern char **environ; static mode_t envmask; /* mask to create the files */ @@ -1092,13 +1089,13 @@ int main(int argc, char *argv[]) /* * umask() uses inverse logic; bits are CLEAR for allowed access. */ - if ((~JSVC_UMASK) & 0022) { + if (~args->umask & 0022) { log_error("NOTICE: jsvc umask of %03o allows " - "write permission to group and/or other", JSVC_UMASK); + "write permission to group and/or other", args->umask); } - envmask = umask(JSVC_UMASK); + envmask = umask(args->umask); set_output(args->outfile, args->errfile, args->redirectstdin, args->procname); - log_debug("Switching umask back to %03o from %03o", envmask, JSVC_UMASK); + log_debug("Switching umask back to %03o from %03o", envmask, args->umask); res = run_controller(args, data, uid, gid); if (logger_pid != 0) { kill(logger_pid, SIGTERM);