diff --git a/modules/dav/fs/dbm.c b/modules/dav/fs/dbm.c index 4753099409e..31635db6991 100644 --- a/modules/dav/fs/dbm.c +++ b/modules/dav/fs/dbm.c @@ -47,6 +47,10 @@ #include "http_log.h" #include "http_main.h" /* for ap_server_conf */ +#ifndef DEFAULT_PROPDB_DBM_TYPE +#define DEFAULT_PROPDB_DBM_TYPE "default" +#endif + APLOG_USE_MODULE(dav_fs); struct dav_db { @@ -129,8 +133,8 @@ void dav_fs_ensure_state_dir(apr_pool_t * p, const char *dirname) /* dav_dbm_open_direct: Opens a *dbm database specified by path. * ro = boolean read-only flag. */ -dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, int ro, - dav_db **pdb) +dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, + const char *dbmtype, int ro, dav_db **pdb) { #if APR_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7) const apr_dbm_driver_t *driver; @@ -142,10 +146,10 @@ dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, int ro, *pdb = NULL; #if APR_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7) - if ((status = apr_dbm_get_driver(&driver, NULL, &err, p)) != APR_SUCCESS) { + if ((status = apr_dbm_get_driver(&driver, dbmtype, &err, p)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, status, ap_server_conf, APLOGNO(10289) - "mod_dav_fs: The DBM library '%s' could not be loaded: %s", - err->reason, err->msg); + "mod_dav_fs: The DBM library '%s' for '%s' could not be loaded: %s", + err->reason, dbmtype, err->msg); return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 1, status, "Could not load library for database."); } @@ -156,9 +160,9 @@ dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, int ro, return dav_fs_dbm_error(NULL, p, status); } #else - if ((status = apr_dbm_open(&file, pathname, - ro ? APR_DBM_READONLY : APR_DBM_RWCREATE, - APR_OS_DEFAULT, p)) + if ((status = apr_dbm_open_ex(&file, dbmtype, pathname, + ro ? APR_DBM_READONLY : APR_DBM_RWCREATE, + APR_OS_DEFAULT, p)) != APR_SUCCESS && !ro) { /* ### do something with 'status' */ @@ -206,7 +210,7 @@ static dav_error * dav_dbm_open(apr_pool_t * p, const dav_resource *resource, /* ### do we need to deal with the umask? */ - return dav_dbm_open_direct(p, pathname, ro, pdb); + return dav_dbm_open_direct(p, pathname, DEFAULT_PROPDB_DBM_TYPE, ro, pdb); } void dav_dbm_close(dav_db *db) diff --git a/modules/dav/fs/lock.c b/modules/dav/fs/lock.c index 2126b3189d1..c477302ca47 100644 --- a/modules/dav/fs/lock.c +++ b/modules/dav/fs/lock.c @@ -182,6 +182,7 @@ struct dav_lockdb_private request_rec *r; /* for accessing the uuid state */ apr_pool_t *pool; /* a pool to use */ const char *lockdb_path; /* where is the lock database? */ + const char *lockdb_type; /* where is the lock database? */ int opened; /* we opened the database */ dav_db *db; /* if non-NULL, the lock database */ @@ -306,6 +307,7 @@ static dav_error * dav_fs_really_open_lockdb(dav_lockdb *lockdb) err = dav_dbm_open_direct(lockdb->info->pool, lockdb->info->lockdb_path, + lockdb->info->lockdb_type, lockdb->ro, &lockdb->info->db); if (err != NULL) { @@ -342,7 +344,7 @@ static dav_error * dav_fs_open_lockdb(request_rec *r, int ro, int force, comb->priv.r = r; comb->priv.pool = r->pool; - comb->priv.lockdb_path = dav_get_lockdb_path(r); + comb->priv.lockdb_path = dav_get_lockdb_path(r, &comb->priv.lockdb_type); if (comb->priv.lockdb_path == NULL) { return dav_new_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, DAV_ERR_LOCK_NO_DB, 0, diff --git a/modules/dav/fs/mod_dav_fs.c b/modules/dav/fs/mod_dav_fs.c index 6845d90543c..f76d21c8d06 100644 --- a/modules/dav/fs/mod_dav_fs.c +++ b/modules/dav/fs/mod_dav_fs.c @@ -34,7 +34,7 @@ typedef struct { /* per-server configuration */ typedef struct { const char *lockdb_path; - + const char *lockdb_type; } dav_fs_server_conf; extern module AP_MODULE_DECLARE_DATA dav_fs_module; @@ -42,12 +42,19 @@ extern module AP_MODULE_DECLARE_DATA dav_fs_module; #ifndef DEFAULT_DAV_LOCKDB #define DEFAULT_DAV_LOCKDB "davlockdb" #endif +#ifndef DEFAULT_DAV_LOCKDB_TYPE +#define DEFAULT_DAV_LOCKDB_TYPE "default" +#endif -const char *dav_get_lockdb_path(const request_rec *r) + +const char *dav_get_lockdb_path(const request_rec *r, const char **dbmtype) { dav_fs_server_conf *conf; conf = ap_get_module_config(r->server->module_config, &dav_fs_module); + + *dbmtype = conf->lockdb_type; + return conf->lockdb_path; } @@ -119,6 +126,8 @@ static void *dav_fs_merge_server_config(apr_pool_t *p, newconf->lockdb_path = child->lockdb_path ? child->lockdb_path : parent->lockdb_path; + newconf->lockdb_type = + child->lockdb_type ? child->lockdb_type : parent->lockdb_type; return newconf; } @@ -167,6 +176,9 @@ static apr_status_t dav_fs_post_config(apr_pool_t *p, apr_pool_t *plog, if (!conf->lockdb_path) { conf->lockdb_path = ap_state_dir_relative(p, DEFAULT_DAV_LOCKDB); } + if (!conf->lockdb_type) { + conf->lockdb_type = DEFAULT_DAV_LOCKDB_TYPE; + } } return OK; @@ -191,6 +203,19 @@ static const char *dav_fs_cmd_davlockdb(cmd_parms *cmd, void *config, return NULL; } +/* + * Command handler for the DAVLockDBType directive, which is TAKE1 + */ +static const char *dav_fs_cmd_davlockdbtype(cmd_parms *cmd, void *config, + const char *arg1) +{ + dav_fs_server_conf *conf = ap_get_module_config(cmd->server->module_config, + &dav_fs_module); + conf->lockdb_type = arg1; + + return NULL; +} + /* * Command handler for the DAVquota directive, which is TAKE1 */ @@ -215,6 +240,8 @@ static const command_rec dav_fs_cmds[] = /* per server */ AP_INIT_TAKE1("DAVLockDB", dav_fs_cmd_davlockdb, NULL, RSRC_CONF, "specify a lock database"), + AP_INIT_TAKE1("DAVLockDBType", dav_fs_cmd_davlockdbtype, NULL, RSRC_CONF, + "specify a lock database DBM type"), /* per directory */ AP_INIT_TAKE1("DAVquota", dav_fs_cmd_quota, NULL, ACCESS_CONF|RSRC_CONF, diff --git a/modules/dav/fs/repos.h b/modules/dav/fs/repos.h index fa3b138ea3e..849ba5f21f7 100644 --- a/modules/dav/fs/repos.h +++ b/modules/dav/fs/repos.h @@ -66,8 +66,8 @@ dav_error * dav_fs_get_locknull_members(const dav_resource *resource, /* DBM functions used by the repository and locking providers */ extern const dav_hooks_db dav_hooks_db_dbm; -dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, int ro, - dav_db **pdb); +dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, + const char *dbmtype, int ro, dav_db **pdb); void dav_dbm_get_statefiles(apr_pool_t *p, const char *fname, const char **state1, const char **state2); dav_error * dav_dbm_delete(dav_db *db, apr_datum_t key); @@ -77,8 +77,9 @@ void dav_dbm_freedatum(dav_db *db, apr_datum_t data); int dav_dbm_exists(dav_db *db, apr_datum_t key); void dav_dbm_close(dav_db *db); -/* where is the lock database located? */ -const char *dav_get_lockdb_path(const request_rec *r); +/* Returns path to lock database and configured dbm type as + * *dbmtype. */ +const char *dav_get_lockdb_path(const request_rec *r, const char **dbmtype); dav_error *dav_fs_get_quota(const request_rec *r, const char *path, apr_off_t *quota_bytes);