summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/conf_macros.m459
-rw-r--r--server/confdb/confdb.c15
-rw-r--r--server/configure.ac6
-rw-r--r--server/monitor.c11
-rw-r--r--server/nss/nss_ldb.h2
-rw-r--r--server/nss/nsssrv_ldb.c10
-rw-r--r--server/providers/data_provider.c68
-rw-r--r--server/providers/data_provider.h6
-rw-r--r--server/sbus_interfaces.h2
-rw-r--r--server/server.c2
-rw-r--r--server/util/service_helpers.c6
-rw-r--r--server/util/util.h2
12 files changed, 156 insertions, 33 deletions
diff --git a/server/conf_macros.m4 b/server/conf_macros.m4
new file mode 100644
index 00000000..9aac02c5
--- /dev/null
+++ b/server/conf_macros.m4
@@ -0,0 +1,59 @@
+AC_DEFUN(WITH_DB_PATH,
+ [ AC_ARG_WITH([db-path],
+ [AC_HELP_STRING([--with-db-path=PATH],
+ [Path to the SSSD databases [/var/lib/sss/db]]
+ )
+ ]
+ )
+ dbpath="/var/lib/sss/db"
+ if test x"$with_db_path" != x; then
+ dbpath=$with_db_path
+ fi
+ AC_SUBST(dbpath)
+ AC_DEFINE_UNQUOTED(DB_PATH, "$dbpath", [Path to the SSSD databases])
+ ])
+
+AC_DEFUN(WITH_PLUGIN_PATH,
+ [ AC_ARG_WITH([plugin-path],
+ [AC_HELP_STRING([--with-plugin-path=PATH],
+ [Path to the SSSD data provider plugins [/usr/lib/sssd]]
+ )
+ ]
+ )
+ pluginpath="/usr/lib/sssd"
+ if test x"$with_plugin_path" != x; then
+ pluginpath=$with_plugin_path
+ fi
+ AC_SUBST(pluginpath)
+ AC_DEFINE_UNQUOTED(DATA_PROVIDER_PLUGINS_PATH, "$pluginpath", [Path to the SSSD data provider plugins])
+ ])
+
+AC_DEFUN(WITH_PID_PATH,
+ [ AC_ARG_WITH([pid-path],
+ [AC_HELP_STRING([--with-pid-path=PATH],
+ [Where to store pid files for the SSSD [/var/run]]
+ )
+ ]
+ )
+ pidpath="/var/run"
+ if test x"$with_pid_path" != x; then
+ pidpath=$with_pid_path
+ fi
+ AC_SUBST(pidpath)
+ AC_DEFINE_UNQUOTED(PID_PATH, "$pidpath", [Where to store pid files for the SSSD])
+ ])
+
+AC_DEFUN(WITH_PIPE_PATH,
+ [ AC_ARG_WITH([pipe-path],
+ [AC_HELP_STRING([--with-pipe-path=PATH],
+ [Where to store pipe files for the SSSD interconnects [/var/lib/sss/pipes]]
+ )
+ ]
+ )
+ pipepath="/var/lib/sss/pipes"
+ if test x"$with_pipe_path" != x; then
+ pipepath=$with_pipe_path
+ fi
+ AC_SUBST(pipepath)
+ AC_DEFINE_UNQUOTED(PIPE_PATH, "$pipepath", [Where to store pipe files for the SSSD interconnects])
+ ])
diff --git a/server/confdb/confdb.c b/server/confdb/confdb.c
index 3064101a..7d11fae7 100644
--- a/server/confdb/confdb.c
+++ b/server/confdb/confdb.c
@@ -20,13 +20,14 @@
*/
#define _GNU_SOURCE
+#include "config.h"
#include <string.h>
#include <errno.h>
#include "ldb.h"
#include "ldb_errors.h"
#include "util/util.h"
#define CONFDB_VERSION "0.1"
-#define CONFDB_FILE "/var/lib/sss/db/config.ldb"
+#define CONFDB_FILE "config.ldb"
#define CONFDB_DOMAIN_BASEDN "cn=domains,cn=config"
#define CONFDB_DOMAIN_ATTR "cn"
@@ -417,6 +418,7 @@ int confdb_init(TALLOC_CTX *mem_ctx,
struct confdb_ctx **cdb_ctx)
{
struct confdb_ctx *cdb;
+ char *confdb_location;
int ret;
cdb = talloc_zero(mem_ctx, struct confdb_ctx);
@@ -429,12 +431,21 @@ int confdb_init(TALLOC_CTX *mem_ctx,
return EIO;
}
- ret = ldb_connect(cdb->ldb, CONFDB_FILE, 0, NULL);
+ confdb_location = talloc_asprintf(cdb,"%s/%s", DB_PATH,CONFDB_FILE);
+ if (confdb_location == NULL) {
+ talloc_free(cdb);
+ return ENOMEM;
+ }
+ DEBUG(3, ("CONFDB: %s\n",confdb_location));
+
+ ret = ldb_connect(cdb->ldb, confdb_location, 0, NULL);
if (ret != LDB_SUCCESS) {
talloc_free(cdb);
return EIO;
}
+ talloc_free(confdb_location);
+
ret = confdb_test(cdb);
if (ret == ENOENT) {
ret = confdb_init_db(cdb);
diff --git a/server/configure.ac b/server/configure.ac
index 1b01a2ec..0862187d 100644
--- a/server/configure.ac
+++ b/server/configure.ac
@@ -29,6 +29,12 @@ EXTRA_OBJ=""
m4_include(build_macros.m4)
BUILD_WITH_SHARED_BUILD_DIR
+m4_include(conf_macros.m4)
+WITH_DB_PATH
+WITH_PLUGIN_PATH
+WITH_PID_PATH
+WITH_PIPE_PATH
+
m4_include(pkg.m4)
m4_include(libpopt.m4)
m4_include(libtalloc.m4)
diff --git a/server/monitor.c b/server/monitor.c
index 4916e448..5c2ec992 100644
--- a/server/monitor.c
+++ b/server/monitor.c
@@ -114,14 +114,23 @@ static int monitor_dbus_init(struct mt_ctx *ctx)
{
struct sbus_method_ctx *sd_ctx;
char *sbus_address;
+ char *default_monitor_address;
int ret;
+ default_monitor_address = talloc_asprintf(ctx, "unix:path=%s/%s",
+ PIPE_PATH, SSSD_SERVICE_PIPE);
+ if (!default_monitor_address) {
+ return ENOMEM;
+ }
+
ret = confdb_get_string(ctx->cdb, ctx,
"config/services/monitor", "sbusAddress",
- DEFAULT_SBUS_ADDRESS, &sbus_address);
+ default_monitor_address, &sbus_address);
if (ret != EOK) {
+ talloc_free(default_monitor_address);
return ret;
}
+ talloc_free(default_monitor_address);
sd_ctx = talloc_zero(ctx, struct sbus_method_ctx);
if (!sd_ctx) {
diff --git a/server/nss/nss_ldb.h b/server/nss/nss_ldb.h
index b7c2ba7d..3f2d6ea5 100644
--- a/server/nss/nss_ldb.h
+++ b/server/nss/nss_ldb.h
@@ -2,7 +2,7 @@
#define NSS_LDB_CONF_SECTION "config/services/nss"
-#define NSS_DEF_LDB_PATH "/var/lib/sss/db/sssd.ldb"
+#define NSS_DEF_LDB_FILE "sssd.ldb"
#define NSS_DEF_USER_BASE "cn=users,cn=local"
#define NSS_DEF_GROUP_BASE "cn=groups,cn=local"
diff --git a/server/nss/nsssrv_ldb.c b/server/nss/nsssrv_ldb.c
index 6385c5ac..8ad908a4 100644
--- a/server/nss/nsssrv_ldb.c
+++ b/server/nss/nsssrv_ldb.c
@@ -675,6 +675,7 @@ static int nss_ldb_read_conf(TALLOC_CTX *mem_ctx,
{
struct nss_ldb_ctx *ctx;
TALLOC_CTX *tmp_ctx;
+ char *default_ldb_path;
int ret;
tmp_ctx = talloc_new(mem_ctx);
@@ -687,8 +688,15 @@ static int nss_ldb_read_conf(TALLOC_CTX *mem_ctx,
goto done;
}
+ default_ldb_path = talloc_asprintf(tmp_ctx, "%s/%s", DB_PATH, NSS_DEF_LDB_FILE);
+ if (default_ldb_path == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+
nss_ldb_read_var(tmp_ctx, cdb, ctx, "ldbFile",
- NSS_DEF_LDB_PATH, &ctx->ldb_file);
+ default_ldb_path, &ctx->ldb_file);
+ DEBUG(3, ("NSS LDB Cache Path: %s\n", ctx->ldb_file));
nss_ldb_read_var(tmp_ctx, cdb, ctx, "userBase",
NSS_DEF_USER_BASE, &ctx->user_base);
diff --git a/server/providers/data_provider.c b/server/providers/data_provider.c
index cc78c38c..0af17a7a 100644
--- a/server/providers/data_provider.c
+++ b/server/providers/data_provider.c
@@ -108,27 +108,45 @@ static int dp_monitor_init(struct dp_ctx *dpctx)
static int dp_db_init(struct dp_ctx *dpctx)
{
+ TALLOC_CTX *ctx;
char *ldb_file;
+ char *default_db_file;
int ret;
- ret = confdb_get_string(dpctx->cdb, dpctx,
+ ctx = talloc_new(dpctx);
+ if(ctx == NULL) {
+ return ENOMEM;
+ }
+
+ default_db_file = talloc_asprintf(ctx, "%s/%s", DB_PATH, DATA_PROVIDER_DB_FILE);
+ if (default_db_file == NULL) {
+ talloc_free(ctx);
+ return ENOMEM;
+ }
+
+ ret = confdb_get_string(dpctx->cdb, ctx,
DATA_PROVIDER_DB_CONF_SEC, "ldbFile",
- DATA_PROVIDER_DEF_DB_FILE, &ldb_file);
+ default_db_file, &ldb_file);
if (ret != EOK) {
+ talloc_free(ctx);
return ret;
}
- dpctx->ldb = ldb_init(dpctx, dpctx->ev);
+ dpctx->ldb = ldb_init(ctx, dpctx->ev);
if (!dpctx->ldb) {
+ talloc_free(ctx);
return EIO;
}
ret = ldb_connect(dpctx->ldb, ldb_file, 0, NULL);
if (ret != LDB_SUCCESS) {
- talloc_free(dpctx->ldb);
+ talloc_free(ctx);
return EIO;
}
+ talloc_steal(dpctx,dpctx->ldb);
+ talloc_free(ctx);
+
return EOK;
}
@@ -173,44 +191,58 @@ static int dbus_dp_init(struct sbus_conn_ctx *conn_ctx, void *data)
* Set up the monitor service as a D-BUS Server */
static int dp_srv_init(struct dp_ctx *dpctx)
{
+ TALLOC_CTX *tmp_ctx;
struct sbus_method_ctx *sd_ctx;
char *dpbus_address;
+ char *default_dp_address;
int ret;
+ tmp_ctx = talloc_new(dpctx);
+ if (tmp_ctx == NULL) {
+ return ENOMEM;
+ }
+
DEBUG(3, ("Initializing Data Provider D-BUS Server\n"));
+ default_dp_address = talloc_asprintf(tmp_ctx, "unix:path=%s/%s", PIPE_PATH, DATA_PROVIDER_PIPE);
+ if (default_dp_address == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
- ret = confdb_get_string(dpctx->cdb, dpctx,
+ ret = confdb_get_string(dpctx->cdb, tmp_ctx,
"config/services/dataprovider", "dpbusAddress",
- DATA_PROVIDER_ADDRESS, &dpbus_address);
- if (ret != EOK) {
- return ret;
- }
+ default_dp_address, &dpbus_address);
+ if (ret != EOK) goto done;
- sd_ctx = talloc_zero(dpctx, struct sbus_method_ctx);
+ sd_ctx = talloc_zero(tmp_ctx, struct sbus_method_ctx);
if (!sd_ctx) {
- talloc_free(dpbus_address);
- return ENOMEM;
+ ret = ENOMEM;
+ goto done;
}
/* Set up globally-available D-BUS methods */
sd_ctx->interface = talloc_strdup(sd_ctx, DATA_PROVIDER_DBUS_INTERFACE);
if (!sd_ctx->interface) {
- talloc_free(dpbus_address);
- talloc_free(sd_ctx);
- return ENOMEM;
+ ret = ENOMEM;
+ goto done;
}
sd_ctx->path = talloc_strdup(sd_ctx, DATA_PROVIDER_DBUS_PATH);
if (!sd_ctx->path) {
- talloc_free(dpbus_address);
- talloc_free(sd_ctx);
- return ENOMEM;
+ ret = ENOMEM;
+ goto done;
}
sd_ctx->methods = dp_sbus_methods;
sd_ctx->message_handler = sbus_message_handler;
ret = sbus_new_server(dpctx->ev, sd_ctx, dpbus_address,
dbus_dp_init, dpctx);
+ if (ret != EOK) {
+ goto done;
+ }
+ talloc_steal(dpctx, sd_ctx);
+done:
+ talloc_free(tmp_ctx);
return ret;
}
diff --git a/server/providers/data_provider.h b/server/providers/data_provider.h
index be00d51d..7df2ce10 100644
--- a/server/providers/data_provider.h
+++ b/server/providers/data_provider.h
@@ -30,13 +30,11 @@
#define DATA_PROVIDER_VERSION 0x0001
#define DATA_PROVIDER_SERVICE_NAME "dp"
-#define DATA_PROVIDER_ADDRESS "unix:path=/var/lib/sss/pipes/private/dbus-dp"
+#define DATA_PROVIDER_PIPE "sbus-dp"
-#define DATA_PROVIDER_DEF_DB_FILE "/var/lib/sss/db/sssd.ldb"
+#define DATA_PROVIDER_DB_FILE "sssd.ldb"
#define DATA_PROVIDER_DB_CONF_SEC "config/services/nss"
-#define DATA_PROVIDER_PLUGINS_PATH "/usr/lib/sssd"
-
struct dp_mod_ops {
int (*check_online)(void *pvt_data, int *reply);
};
diff --git a/server/sbus_interfaces.h b/server/sbus_interfaces.h
index b0702309..a6a13ad9 100644
--- a/server/sbus_interfaces.h
+++ b/server/sbus_interfaces.h
@@ -38,7 +38,7 @@
#define SERVICE_METHOD_IDENTITY "getIdentity"
#define SERVICE_METHOD_PING "ping"
-#define DEFAULT_SBUS_ADDRESS "unix:path=/var/lib/sss/pipes/private/dbus"
+#define SSSD_SERVICE_PIPE "sbus-monitor"
/* Data Provider */
diff --git a/server/server.c b/server/server.c
index 15dbb8d9..aef1b8d3 100644
--- a/server/server.c
+++ b/server/server.c
@@ -108,8 +108,6 @@ static void server_stdin_handler(struct event_context *event_ctx, struct fd_even
}
}
-#define PID_PATH "/var/run/"
-
/*
main server.
*/
diff --git a/server/util/service_helpers.c b/server/util/service_helpers.c
index 0c16af89..13cca832 100644
--- a/server/util/service_helpers.c
+++ b/server/util/service_helpers.c
@@ -40,6 +40,7 @@ struct service_sbus_ctx *sssd_service_sbus_init(TALLOC_CTX *mem_ctx,
struct sbus_method_ctx *sm_ctx;
TALLOC_CTX *ctx;
char *sbus_address;
+ char *default_monitor_address;
DBusConnection *conn;
int ret;
@@ -49,9 +50,12 @@ struct service_sbus_ctx *sssd_service_sbus_init(TALLOC_CTX *mem_ctx,
ss_ctx = talloc_zero(ctx, struct service_sbus_ctx);
if (ss_ctx == NULL) return NULL;
+ default_monitor_address = talloc_asprintf(ctx, "unix:path=%s/%s", PIPE_PATH,SSSD_SERVICE_PIPE);
+ if (default_monitor_address == NULL) goto error;
+
ret = confdb_get_string(cdb, ctx,
"config/services/monitor", "sbusAddress",
- DEFAULT_SBUS_ADDRESS, &sbus_address);
+ default_monitor_address, &sbus_address);
if (ret != EOK) goto error;
ss_ctx->ev = ev;
diff --git a/server/util/util.h b/server/util/util.h
index 897e3541..6e30cfd2 100644
--- a/server/util/util.h
+++ b/server/util/util.h
@@ -28,8 +28,6 @@ void debug_fn(const char *format, ...);
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
-#define PID_DIR "/var/run/sssd"
-
#define EOK 0
#include "util/dlinklist.h"