const char *ssl_cmd_SSLMutex(cmd_parms *cmd,
void *dcfg,
- const char *arg)
+ const char *arg_)
{
const char *err;
SSLModConfigRec *mc = myModConfig(cmd->server);
-
+ /* Split arg_ into meth and file */
+ char *meth = apr_pstrdup(cmd->server->process->pool, arg_);
+ char *file = strchr(meth, ':');
+ if (file) {
+ *(file++) = '\0';
+ if (!*file) {
+ file = NULL;
+ }
+ }
+
if ((err = ap_check_cmd_context(cmd, GLOBAL_ONLY))) {
return err;
}
if (ssl_config_global_isfixed(mc)) {
return NULL;
}
-
- if (strcEQ(arg, "none") || strcEQ(arg, "no")) {
+ if (!strcasecmp(meth, "none") || !strcasecmp(meth, "no")) {
mc->nMutexMode = SSL_MUTEXMODE_NONE;
+ return NULL;
}
+
+ /* APR determines temporary filename unless overridden below,
+ * we presume file indicates an szMutexFile is a file path
+ * unless the method sets szMutexFile=file and NULLs file
+ */
+ mc->nMutexMode = SSL_MUTEXMODE_USED;
+ mc->szMutexFile = NULL;
+
/* NOTE: previously, 'yes' implied 'sem' */
- else if (strcEQ(arg, "default") || strcEQ(arg, "yes")) {
- mc->nMutexMode = SSL_MUTEXMODE_USED;
+ if (!strcasecmp(meth, "default") || !strcasecmp(meth, "yes")) {
mc->nMutexMech = APR_LOCK_DEFAULT;
- mc->szMutexFile = NULL; /* APR determines temporary filename */
}
#if APR_HAS_FLOCK_SERIALIZE
- else if (strlen(arg) > 6 && strcEQn(arg, "flock:", 6)) {
- const char *file = ap_server_root_relative(cmd->pool, arg+6);
- if (!file) {
- return apr_pstrcat(cmd->pool, "Invalid SSLMutex flock: path ",
- arg+6, NULL);
- }
- mc->nMutexMode = SSL_MUTEXMODE_USED;
+ else if (!strcasecmp(meth, "flock") && file) {
mc->nMutexMech = APR_LOCK_FLOCK;
- mc->szMutexFile = apr_psprintf(mc->pPool, "%s.%lu",
- file, (unsigned long)getpid());
}
#endif
#if APR_HAS_FCNTL_SERIALIZE
- else if (strlen(arg) > 6 && strcEQn(arg, "fcntl:", 6)) {
- const char *file = ap_server_root_relative(cmd->pool, arg+6);
- if (!file) {
- return apr_pstrcat(cmd->pool, "Invalid SSLMutex fcntl: path ",
- arg+6, NULL);
- }
- mc->nMutexMode = SSL_MUTEXMODE_USED;
+ else if (!strcasecmp(meth, "fcntl") && file) {
mc->nMutexMech = APR_LOCK_FCNTL;
- mc->szMutexFile = apr_psprintf(mc->pPool, "%s.%lu",
- file, (unsigned long)getpid());
}
#endif
#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
- else if (strcEQ(arg, "sysvsem")) {
- mc->nMutexMode = SSL_MUTEXMODE_USED;
+ else if (!strcasecmp(meth, "sysvsem") && file) {
mc->nMutexMech = APR_LOCK_SYSVSEM;
- mc->szMutexFile = NULL; /* APR determines temporary filename */
}
#endif
#if APR_HAS_POSIXSEM_SERIALIZE
- else if (strcEQ(arg, "posixsem")) {
- mc->nMutexMode = SSL_MUTEXMODE_USED;
+ else if (!strcasecmp(meth, "posixsem")) {
mc->nMutexMech = APR_LOCK_POSIXSEM;
- mc->szMutexFile = NULL; /* APR determines temporary filename */
+ mc->szMutexFile = file;
+ file = NULL;
}
#endif
#if APR_HAS_PROC_PTHREAD_SERIALIZE
- else if (strcEQ(arg, "pthread")) {
- mc->nMutexMode = SSL_MUTEXMODE_USED;
+ else if (!strcasecmp(meth, "pthread")) {
mc->nMutexMech = APR_LOCK_PROC_PTHREAD;
- mc->szMutexFile = NULL; /* APR determines temporary filename */
}
#endif
-#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE
- else if (strlen(arg) > 5 && strcEQn(arg, "file:", 5)) {
- const char *file = ap_server_root_relative(cmd->pool, arg+5);
- if (!file) {
- return apr_pstrcat(cmd->pool, "Invalid SSLMutex file: path ",
- arg+5, NULL);
- }
- mc->nMutexMode = SSL_MUTEXMODE_USED;
#if APR_HAS_FLOCK_SERIALIZE
+ else if (!strcasecmp(meth, "file") && file) {
mc->nMutexMech = APR_LOCK_FLOCK;
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
+ }
+#elif APR_HAS_FCNTL_SERIALIZE
+ else if (!strcasecmp(meth, "file") && file) {
mc->nMutexMech = APR_LOCK_FCNTL;
-#endif
- mc->szMutexFile =
- apr_psprintf(mc->pPool, "%s.%lu",
- file, (unsigned long)getpid());
}
#endif
-#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE
- else if (strcEQ(arg, "sem")) {
- mc->nMutexMode = SSL_MUTEXMODE_USED;
#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
+ else if (!strcasecmp(meth, "sem")) {
mc->nMutexMech = APR_LOCK_SYSVSEM;
-#endif
-#if APR_HAS_POSIXSEM_SERIALIZE
+ }
+#elif APR_HAS_POSIXSEM_SERIALIZE
+ else if (!strcasecmp(meth, "sem")) {
mc->nMutexMech = APR_LOCK_POSIXSEM;
-#endif
- mc->szMutexFile = NULL; /* APR determines temporary filename */
+ /* Posix/SysV semaphores aren't file based, use the literal name
+ * if provided and fall back on APR's default if not.
+ */
+ mc->szMutexFile = file;
+ file = NULL;
}
#endif
else {
- return apr_pstrcat(cmd->pool, "Invalid SSLMutex argument ",
- arg, " (", ssl_valid_ssl_mutex_string, ")", NULL);
+ return apr_pstrcat(cmd->pool, "Invalid SSLMutex argument ", arg_,
+ " (", ssl_valid_ssl_mutex_string, ")", NULL);
+ }
+
+ /* Unless the method above assumed responsibility for setting up
+ * mc->szMutexFile and NULLing out file, presume it is a file we
+ * are looking to use
+ */
+ if (file) {
+ mc->szMutexFile = ap_server_root_relative(cmd->pool, file);
+ if (!mc->szMutexFile) {
+ return apr_pstrcat(cmd->pool, "Invalid SSLMutex ", meth,
+ ": filepath ", file, NULL);
+ }
}
return NULL;