summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2009-02-25 17:17:48 +0100
committerSumit Bose <sbose@redhat.com>2009-02-25 17:17:48 +0100
commit03bed7eef6a8de74359a05917c54e56a8304c0ba (patch)
tree18ef34e276d046894c49e70f85434830528aaf88
parent28972c0520b7121b986848c0ae7c52bf5a683922 (diff)
downloadsssd-pam.tar.gz
sssd-pam.tar.xz
sssd-pam.zip
started local backendpam
-rw-r--r--server/providers/local_be.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/server/providers/local_be.c b/server/providers/local_be.c
new file mode 100644
index 000000000..830b4758b
--- /dev/null
+++ b/server/providers/local_be.c
@@ -0,0 +1,103 @@
+/*
+ SSSD
+
+ Local Backend Module
+
+ Authors:
+ Sumit Bose <sbose@redhat.com>
+
+ Copyright (C) 2008 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <errno.h>
+#include <ldap.h>
+#include <sys/time.h>
+
+#include <security/pam_modules.h>
+
+#include "util/util.h"
+#include "providers/dp_backend.h"
+#include "db/sysdb.h"
+#include "../sss_client/sss_cli.h"
+
+struct local_ctx {
+ char *preferred_hash;
+ char *auth_helper;
+ char *chauthtok_helper;
+};
+
+struct be_mod_ops local_mod_ops = {
+ .check_online = NULL,
+ .get_account_info = NULL,
+ .pam_handler = local_pam_handler
+};
+
+int sssm_local_init(struct be_ctx *bectx, struct be_mod_ops **ops, void **pvt_data)
+{
+ struct local_ctx *ctx;
+ char *preferred_hash;
+ int ret;
+ struct stat stat_buff;
+
+ ctx = talloc(bectx, struct local_ctx);
+ if (!ctx) {
+ return ENOMEM;
+ }
+
+ ret = confdb_get_string(bectx->cdb, ctx, bectx->conf_path,
+ "preferredHash", "sha512", &preferred_hash);
+ if (ret != EOK) goto done;
+ if (strncasecmp(preferred_hash, "sha512", 6)!=0 &&
+ strncasecmp(preferred_hash, "sha256", 6)!=0 &&
+ strncasecmp(preferred_hash, "md5", 3)!=0) {
+ DEBUG(1, ("unsupported hash type [%s].\n", preferred_hash));
+ ret = EINVAL;
+ goto done;
+ }
+
+ ctx->preferred_hash = preferred_hash;
+
+ ret = confdb_get_string(bectx->cdb, ctx, bectx->conf_path,
+ "authHelper", NULL, &auth_helper);
+ if (ret != EOK) goto done;
+ ret = stat(auth_helper, &stat_buff);
+ if (ret != EOK) {
+ DEBUG(1, ("stat failed on [%s].\n", auth_helper));
+ goto done;
+ }
+
+ ctx->auth_helper = auth_helper;
+
+ ret = confdb_get_string(bectx->cdb, ctx, bectx->conf_path,
+ "chauthtokHelper", NULL, &chauthtok_helper);
+ if (ret != EOK) goto done;
+ ret = stat(chauthtok_helper, &stat_buff);
+ if (ret != EOK) {
+ DEBUG(1, ("stat failed on [%s].\n", chauthtok_helper));
+ goto done;
+ }
+ ctx->chauthtok_helper = chauthtok_helper;
+
+ *ops = &local_mod_ops;
+ *pvt_data = ctx;
+ ret = EOK;
+
+done:
+ if (ret != EOK) {
+ talloc_free(ctx);
+ }
+ return ret;
+}