summaryrefslogtreecommitdiffstats
path: root/server/db/sysdb.h
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-01-12 15:59:53 -0500
committerSimo Sorce <idra@samba.org>2009-01-12 16:01:39 -0500
commitc22c50c2fb9bc962fd11a2c9924481485faae093 (patch)
tree2c272d1c24029234e4932d37b25aaf4dc4b60808 /server/db/sysdb.h
parent17e83b5b0f39f71bbe98c1971bfdf337ab83d00c (diff)
downloadsssd-c22c50c2fb9bc962fd11a2c9924481485faae093.tar.gz
sssd-c22c50c2fb9bc962fd11a2c9924481485faae093.tar.xz
sssd-c22c50c2fb9bc962fd11a2c9924481485faae093.zip
Regroup database rleated functions under db and
rename everything with the sysdb suffix.
Diffstat (limited to 'server/db/sysdb.h')
-rw-r--r--server/db/sysdb.h148
1 files changed, 148 insertions, 0 deletions
diff --git a/server/db/sysdb.h b/server/db/sysdb.h
new file mode 100644
index 000000000..5b7875961
--- /dev/null
+++ b/server/db/sysdb.h
@@ -0,0 +1,148 @@
+/*
+ SSSD
+
+ System Databse Header
+
+ Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
+
+ 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/>.
+*/
+
+#ifndef __SYS_DB_H__
+#define __SYS_DB_H__
+
+#include "ldb.h"
+#include "ldb_errors.h"
+
+#define SYSDB_CONF_SECTION "config/sysdb"
+#define SYSDB_FILE "sssd.ldb"
+
+#define SYSDB_BASE "cn=sysdb"
+#define SYSDB_TMPL_USER_BASE "cn=users,cn=%s,"SYSDB_BASE
+#define SYSDB_TMPL_GROUP_BASE "cn=groups,cn=%s,"SYSDB_BASE
+
+#define SYSDB_PWNAM_FILTER "(&(objectclass=user)(uid=%s))"
+#define SYSDB_PWUID_FILTER "(&(objectclass=user)(uidNumber=%lu))"
+#define SYSDB_PWENT_FILTER "(objectclass=user)"
+
+#define SYSDB_GRNAM_FILTER "(&(objectclass=group)(cn=%s))"
+#define SYSDB_GRNA2_FILTER "(&(objectclass=user)(memberof=%s))"
+#define SYSDB_GRGID_FILTER "(&(objectclass=group)(gidNumber=%lu))"
+#define SYSDB_GRENT_FILTER "(objectclass=group)"
+
+#define SYSDB_INITGR_FILTER "(&(objectclass=group)(gidNumber=*))"
+
+#define SYSDB_PW_NAME "uid"
+#define SYSDB_PW_PWD "userPassword"
+#define SYSDB_PW_UIDNUM "uidNumber"
+#define SYSDB_PW_GIDNUM "gidNumber"
+#define SYSDB_PW_FULLNAME "fullName"
+#define SYSDB_PW_HOMEDIR "homeDirectory"
+#define SYSDB_PW_SHELL "loginShell"
+
+#define SYSDB_GR_NAME "cn"
+#define SYSDB_GR_GIDNUM "gidNumber"
+#define SYSDB_GR_MEMBER "member"
+
+#define SYSDB_LAST_UPDATE "lastUpdate"
+
+#define SYSDB_PW_ATTRS {SYSDB_PW_NAME, SYSDB_PW_UIDNUM, \
+ SYSDB_PW_GIDNUM, SYSDB_PW_FULLNAME, \
+ SYSDB_PW_HOMEDIR, SYSDB_PW_SHELL, \
+ SYSDB_LAST_UPDATE, \
+ NULL}
+#define SYSDB_GRNAM_ATTRS {SYSDB_GR_NAME, SYSDB_GR_GIDNUM, \
+ SYSDB_LAST_UPDATE, \
+ NULL}
+#define SYSDB_GRPW_ATTRS {SYSDB_PW_NAME, SYSDB_LAST_UPDATE, \
+ NULL}
+
+#define SYSDB_INITGR_ATTR "memberof"
+#define SYSDB_INITGR_ATTRS {SYSDB_GR_GIDNUM, SYSDB_LAST_UPDATE, \
+ NULL}
+
+struct sysdb_ctx {
+ struct ldb_context *ldb;
+ const char *ldb_file;
+};
+
+struct confdb_ctx;
+
+typedef void (*sysdb_callback_t)(void *, int, struct ldb_result *);
+
+int sysdb_init(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct confdb_ctx *cdb,
+ struct sysdb_ctx **nlctx);
+
+int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct sysdb_ctx *ctx,
+ const char *domain,
+ const char *name,
+ sysdb_callback_t fn, void *ptr);
+
+int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct sysdb_ctx *ctx,
+ const char *domain,
+ uint64_t uid,
+ sysdb_callback_t fn, void *ptr);
+
+int sysdb_enumpwent(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct sysdb_ctx *ctx,
+ sysdb_callback_t fn, void *ptr);
+
+int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct sysdb_ctx *ctx,
+ const char *domain,
+ const char *name,
+ sysdb_callback_t fn, void *ptr);
+
+int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct sysdb_ctx *ctx,
+ const char *domain,
+ uint64_t gid,
+ sysdb_callback_t fn, void *ptr);
+
+int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct sysdb_ctx *ctx,
+ sysdb_callback_t fn, void *ptr);
+
+int sysdb_initgroups(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct sysdb_ctx *ctx,
+ const char *domain,
+ const char *name,
+ sysdb_callback_t fn, void *ptr);
+
+int sysdb_store_account_posix(TALLOC_CTX *memctx,
+ struct sysdb_ctx *sysdb,
+ const char *domain,
+ char *name, char *pwd,
+ uint64_t uid, uint64_t gid,
+ char *gecos, char *homedir, char *shell);
+
+int sysdb_remove_account_posix(TALLOC_CTX *memctx,
+ struct sysdb_ctx *sysdb,
+ const char *domain, const char *name);
+
+int sysdb_remove_account_posix_by_uid(TALLOC_CTX *memctx,
+ struct sysdb_ctx *sysdb,
+ const char *domain, uid_t uid);
+#endif /* __SYS_DB_H__ */