You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2005/01/17 08:56:13 UTC
cvs commit: jakarta-tomcat-connectors/jni/native/src proc.c
mturk 2005/01/16 23:56:13
Modified: jni/java/org/apache/tomcat/jni Procattr.java
jni/native/src proc.c
Log:
Added user_set and group_set that are new to APR 1.1.0 for
setting uid/gid of newly created processes.
Revision Changes Path
1.3 +19 -1 jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Procattr.java
Index: Procattr.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Procattr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Procattr.java 14 Jan 2005 14:42:37 -0000 1.2
+++ Procattr.java 17 Jan 2005 07:56:13 -0000 1.3
@@ -150,4 +150,22 @@
*/
public static native void errfnSet(long attr, long pool, Object o);
+ /**
+ * Set the username used for running process
+ * @param attr The procattr we care about.
+ * @param username The username used
+ * @param password User password if needed. Password is needed on WIN32
+ * or any other platform having
+ * APR_PROCATTR_USER_SET_REQUIRES_PASSWORD set.
+ */
+ public static native int userSet(long attr, String username, String password);
+
+ /**
+ * Set the group used for running process
+ * @param attr The procattr we care about.
+ * @param groupname The group name used
+ */
+ public static native int groupSet(long attr, String groupname);
+
+
}
1.2 +57 -0 jakarta-tomcat-connectors/jni/native/src/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/proc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- proc.c 14 Jan 2005 13:47:58 -0000 1.1
+++ proc.c 17 Jan 2005 07:56:13 -0000 1.2
@@ -16,6 +16,7 @@
#include "apr.h"
#include "apr_pools.h"
#include "apr_thread_proc.h"
+#include "apr_version.h"
#include "tcn.h"
@@ -375,3 +376,59 @@
}
+TCN_IMPLEMENT_CALL(jint, Procattr, userSet)(TCN_STDARGS,
+ jlong attr,
+ jstring username,
+ jstring password)
+{
+
+#if ((APR_MAJOR_VERSION >= 1) && (APR_MINOR_VERSION >= 1))
+ apr_status_t rv;
+ apr_procattr_t *a = J2P(attr, apr_procattr_t *);
+ TCN_ALLOC_CSTRING(username);
+#if APR_PROCATTR_USER_SET_REQUIRES_PASSWORD
+ TCN_ALLOC_CSTRING(password);
+#else
+ const char *cpassword = NULL;
+#endif
+ UNREFERENCED(o);
+
+ rv = apr_procattr_user_set(a, J2S(username), J2S(password));
+ TCN_FREE_CSTRING(username);
+#if APR_PROCATTR_USER_SET_REQUIRES_PASSWORD
+ TCN_FREE_CSTRING(password);
+#endif
+ return (jint) rv;
+#else
+ UNREFERENCED_STDARGS;
+ UNREFERENCED(attr);
+ UNREFERENCED(username);
+ UNREFERENCED(password);
+
+ return APR_ENOTIMPL;
+#endif
+}
+
+TCN_IMPLEMENT_CALL(jint, Procattr, groupSet)(TCN_STDARGS,
+ jlong attr,
+ jstring group)
+{
+
+#if ((APR_MAJOR_VERSION >= 1) && (APR_MINOR_VERSION >= 1))
+ apr_status_t rv;
+ apr_procattr_t *a = J2P(attr, apr_procattr_t *);
+ TCN_ALLOC_CSTRING(group);
+
+ UNREFERENCED(o);
+
+ rv = apr_procattr_group_set(a, J2S(group));
+ TCN_FREE_CSTRING(group);
+ return (jint) rv;
+#else
+ UNREFERENCED_STDARGS;
+ UNREFERENCED(attr);
+ UNREFERENCED(group);
+
+ return APR_ENOTIMPL;
+#endif
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org