summaryrefslogtreecommitdiffstats
path: root/server/tools/tools_util.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-04-23 22:07:05 +0200
committerSimo Sorce <ssorce@redhat.com>2009-04-28 11:57:15 -0400
commitc1a1b0464b5fad4daa9868b846182ad391f716a2 (patch)
treeb739f02ccea1b92d16a774d8f6270388fc1094d5 /server/tools/tools_util.c
parent6207b76613168e6aa386b7b71b492b66b14fff57 (diff)
downloadsssd-c1a1b0464b5fad4daa9868b846182ad391f716a2.tar.gz
sssd-c1a1b0464b5fad4daa9868b846182ad391f716a2.tar.xz
sssd-c1a1b0464b5fad4daa9868b846182ad391f716a2.zip
Invoke shadow-utils in sss_ tools
Make shadow-utils base path configurable Use default values for params, allow configuring them
Diffstat (limited to 'server/tools/tools_util.c')
-rw-r--r--server/tools/tools_util.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/server/tools/tools_util.c b/server/tools/tools_util.c
index a3669001f..72ab16644 100644
--- a/server/tools/tools_util.c
+++ b/server/tools/tools_util.c
@@ -28,6 +28,94 @@
#include "db/sysdb.h"
#include "tools/tools_util.h"
+/*
+ * Returns:
+ * 0 = yes, local domain proxying to files
+ * -1 = no, other type of domain
+ * > 0 = error code
+ */
+static int is_domain_local_legacy(struct tools_ctx *ctx, struct sss_domain_info *dom)
+{
+ char *libname = NULL;
+ char *conf_path = NULL;
+ int ret = -1;
+
+ /* Is there a better way to find out? Having LEGACYLOCAL as reserved would help */
+ conf_path = talloc_asprintf(ctx, "config/domains/%s", dom->name);
+ if (conf_path == NULL ) {
+ return ENOMEM;
+ }
+
+ ret = confdb_get_string(ctx->confdb, ctx, conf_path,
+ "libName", NULL, &libname);
+ if (ret != EOK) {
+ talloc_free(conf_path);
+ return ret;
+ }
+ if (libname == NULL) {
+ talloc_free(conf_path);
+ return -1;
+ }
+
+ if (strcasecmp(libname, "files") == 0) {
+ talloc_free(conf_path);
+ talloc_free(libname);
+ return EOK;
+ }
+
+ talloc_free(conf_path);
+ talloc_free(libname);
+ return -1;
+}
+
+enum id_domain find_domain_for_id(struct tools_ctx *ctx,
+ uint32_t id,
+ struct sss_domain_info **dom_ret)
+{
+ struct sss_domain_info *dom = NULL;
+
+ if (id) {
+ /* ID specified, find which domain it's in */
+ for (dom = ctx->domains; dom; dom = dom->next) {
+ if (id < dom->id_min || id > dom->id_max) {
+ continue;
+ } else {
+ if (strcasecmp(dom->name, "LOCAL") == 0) {
+ *dom_ret = dom;
+ return ID_IN_LOCAL;
+ } else if (is_domain_local_legacy(ctx, dom) == 0) {
+ *dom_ret = dom;
+ return ID_IN_LEGACY_LOCAL;
+ } else {
+ *dom_ret = dom;
+ return ID_IN_OTHER;
+ }
+ }
+ }
+ if (dom == NULL) {
+ *dom_ret = NULL;
+ return ID_OUTSIDE;
+ }
+ } else {
+ /* No ID specified, find LOCAL */
+ for (dom = ctx->domains; dom; dom = dom->next) {
+ if (strcasecmp(dom->name, "LOCAL") == 0) {
+ *dom_ret = dom;
+ return ID_IN_LOCAL;
+ }
+ }
+ if (dom == NULL) {
+ DEBUG(0, ("Could not get LOCAL domain info\n"));
+ *dom_ret = dom;
+ return ID_ERROR;
+ }
+ }
+
+ /* We should never end up here */
+ *dom_ret = NULL;
+ return ID_ERROR;
+}
+
int setup_db(struct tools_ctx **tools_ctx)
{
TALLOC_CTX *tmp_ctx;