Hi list, my work is reaching a point I want to start receiving comments before I put more effort into it. As said on some sources, I was not satisfied with how the new sam interface was coming out, and wanted to explorer a slightly different path. But I have little time and can work mostly on the weekend which is already pretty busy. This mean I have not put as many comments as I would have liked to put. If you do not understand why I choose to do something one way and not another feel free to ask, contribution is really welcome.
Something on the patch: The most important thing is gums.h here it is the interface I had in mind mostly. gums.c is just here to be filled. Helper.c instead is a bunch of work i've done while researching how bits are in a real PDC, so I commit it to not risk loosing that work, it does include a bunch of slightly modified routines (to include talloc contexts mostly) made by jean francois that are yet in group/mapping.c, these functions should on a later date be moved to a more appropriate file like lib/util_seaccess.c or into a specifica file like lib/util_secdesc.c (I vote for this one :) Remember it is still work in progress, it is not ready even for a 0.1 version for my standards :-) Enjoy, Simo. -- Simo Sorce - [EMAIL PROTECTED] Xsec s.r.l. via Durando 10 Ed. G - 20158 - Milano tel. +39 02 2399 7130 - fax: +39 02 700 442 399
diff -uPr cvs.samba.org/samba/source/gums/gums.c source/gums/gums.c
--- cvs.samba.org/samba/source/gums/gums.c Thu Jan 1 01:00:00 1970
+++ source/gums/gums.c Thu Oct 3 16:47:03 2002
@@ -0,0 +1,86 @@
+/*
+ Unix SMB/CIFS implementation.
+ Grops and Users Management System initializations.
+ Copyright (C) Simo Sorce 2002
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_GUMS
+
+#define GMV_MAJOR 0
+#define GMV_MINOR 1
+
+static GUMS_FUNCTIONS *gums_functions;
+static void *dl_handle;
+
+PRIVS privs[] = {
+ {SE_PRIV_NONE, "no_privs", "No privilege" }, /* this one MUST be first */
+ {SE_PRIV_ADD_MACHINES, "SeMachineAccountPrivilege", "Add workstations to the domain" },
+ {SE_PRIV_SEC_PRIV, "SeSecurityPrivilege", "Manage the audit logs" },
+ {SE_PRIV_TAKE_OWNER, "SeTakeOwnershipPrivilege", "Take ownership of file" },
+ {SE_PRIV_ADD_USERS, "SaAddUsers", "Add users to the domain - Samba" },
+ {SE_PRIV_PRINT_OPERATOR, "SaPrintOp", "Add or remove printers - Samba" },
+ {SE_PRIV_ALL, "SaAllPrivs", "all privileges" }
+};
+
+NTSTATUS gums_init(const char *module_name)
+{
+ int (*module_version)(int);
+ NTSTATUS (*module_init)();
+ gums_module_init module_init;
+ NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+
+ DEBUG(5, ("Opening gums module %s\n", module_name));
+ dl_handle = sys_dlopen(module_name, RTLD_NOW);
+ if (!dl_handle) {
+ DEBUG(0, ("ERROR: Failed to load gums module %s, error: %s\n", module_name, sys_dlerror()));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ module_version = sys_dlsym(dl_handle, "gums_version");
+ if (!module_version) {
+ DEBUG(0, ("ERROR: Failed to find gums module version!\n"));
+ goto error;
+ }
+
+ if (module_version(GMV_MAJOR) != GUMS_VERSION_MAJOR) {
+ DEBUG(0, ("ERROR: Module's major version does not match gums version!\n"));
+ goto error;
+ }
+
+ if (module_version(GMV_MINOR) != GUMS_VERSION_MINOR) {
+ DEBUG(1, ("WARNING: Module's minor version does not match gums version!\n"));
+ }
+
+ module_init = sys_dlsym(dl_handle, "gums_init");
+ if (!module_init) {
+ DEBUG(0, ("ERROR: Failed to find gums module's init function!\n"));
+ goto error;
+ }
+
+ DEBUG(5, ("Initializing module %s\n", module_name));
+
+ ret = module_init(&gums_functions);
+
+error:
+}
+
+NTSTATUS gums_unload(void) {
+
+}
diff -uPr cvs.samba.org/samba/source/gums/helper.c source/gums/helper.c
--- cvs.samba.org/samba/source/gums/helper.c Thu Jan 1 01:00:00 1970
+++ source/gums/helper.c Mon Oct 7 00:36:08 2002
@@ -0,0 +1,560 @@
+/*
+ Unix SMB/CIFS implementation.
+ GUMS backends helper functions
+ Copyright (C) Simo Sorce 2002
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#define ALLOC_CHECK(str, ptr, err, label) do { if ((ptr) == NULL) { DEBUG(0, ("%s: out of memory!\n", str)); err = NT_STATUS_NO_MEMORY; goto label; } } while(0)
+#define NTSTATUS_CHECK(str1, str2, err, label) do { if (NT_STATUS_IS_ERR(err)) { DEBUG(0, ("%s: %s failed!\n", str1, str2)); } } while(0)
+
+/****************************************************************************
+ Check if a user is a mapped group.
+
+ This function will check if the group SID is mapped onto a
+ system managed gid or onto a winbind manged sid.
+ In the first case it will be threated like a mapped group
+ and the backend should take the member list with a getgrgid
+ and ignore any user that have been possibly set into the group
+ object.
+
+ In the second case, the group is a fully SAM managed group
+ served back to the system through winbind. In this case the
+ members of a Local group are "unrolled" to cope with the fact
+ that unix cannot contain groups inside groups.
+ The backend MUST never call any getgr* / getpw* function or
+ loops with winbind may happen.
+ ****************************************************************************/
+NTSTATUS is_mapped_group(BOOL *mapped, const DOM_SID *sid)
+{
+ NTSTATUS result;
+ gid_t id;
+
+ /* look if mapping exist, do not make idmap alloc an uid if SID is not found */
+ result = idmap_get_gid_from_sid(&id, sid, False);
+ if (NT_STATUS_IS_OK(result)) {
+ *mapped = gid_is_in_winbind_range(id);
+ } else {
+ *mapped = False;
+ }
+
+ return result;
+}
+
+/****************************************************************************
+ check user privilege
+ ****************************************************************************/
+NTSTATUS se_priv_access_check(NT_USER_TOKEN *token, uint32 privilege)
+{
+ /* no token, no privilege */
+ if (token==NULL)
+ return NT_STATUS_UNSUCCESSFUL;
+
+ if ((token->privilege & privilege)==privilege)
+ return NT_STATUS_OK;
+
+ return NT_STATUS_UNSUCCESSFUL;
+}
+
+/****************************************************************************
+ initialise a privilege list
+ ****************************************************************************/
+void init_privilege(PRIVILEGE_SET *priv_set)
+{
+ priv_set->count=0;
+ priv_set->control=0;
+ priv_set->set=NULL;
+}
+
+/****************************************************************************
+ add a privilege to a privilege array
+ ****************************************************************************/
+NTSTATUS add_privilege(PRIVILEGE_SET *priv_set, TALLOC_CTX *ctx, LUID_ATTR set)
+{
+ LUID_ATTR *new_set;
+
+ /* check if the privilege is not already in the list */
+ if (check_priv_in_privilege(priv_set, set))
+ return NT_STATUS_UNSUCCESSFUL;
+
+ /* we can allocate memory to add the new privilege */
+
+ new_set=(LUID_ATTR *)talloc_realloc(ctx, priv_set->set, (priv_set->count+1)*(sizeof(LUID_ATTR)));
+ if (new_set==NULL) {
+ DEBUG(0,("add_privilege: could not Realloc memory to add a new privilege\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ new_set[priv_set->count].luid.high=set.luid.high;
+ new_set[priv_set->count].luid.low=set.luid.low;
+ new_set[priv_set->count].attr=set.attr;
+
+ priv_set->count++;
+ priv_set->set=new_set;
+
+ return NT_STATUS_OK;
+}
+
+/****************************************************************************
+ add all the privileges to a privilege array
+ ****************************************************************************/
+NTSTATUS add_all_privilege(PRIVILEGE_SET *priv_set)
+{
+ NTSTATUS result = NT_STATUS_OK;
+ LUID_ATTR set;
+
+ set.attr=0;
+ set.luid.high=0;
+
+ set.luid.low=SE_PRIV_ADD_USERS;
+ result = add_privilege(priv_set, set);
+ NTSTATUS_CHECK("add_all_privilege", "add_privilege", result, done);
+
+ set.luid.low=SE_PRIV_ADD_MACHINES;
+ result = add_privilege(priv_set, set);
+ NTSTATUS_CHECK("add_all_privilege", "add_privilege", result, done);
+
+ set.luid.low=SE_PRIV_PRINT_OPERATOR;
+ result = add_privilege(priv_set, set);
+ NTSTATUS_CHECK("add_all_privilege", "add_privilege", result, done);
+
+done:
+ return result;
+}
+
+/****************************************************************************
+ check if the privilege list is empty
+ ****************************************************************************/
+BOOL check_empty_privilege(PRIVILEGE_SET *priv_set)
+{
+ return (priv_set->count == 0);
+}
+
+/****************************************************************************
+ check if the privilege is in the privilege list
+ ****************************************************************************/
+BOOL check_priv_in_privilege(PRIVILEGE_SET *priv_set, LUID_ATTR set)
+{
+ int i;
+
+ /* if the list is empty, obviously we can't have it */
+ if (check_empty_privilege(priv_set))
+ return False;
+
+ for (i=0; i<priv_set->count; i++) {
+ LUID_ATTR *cur_set;
+
+ cur_set=&priv_set->set[i];
+ /* check only the low and high part. Checking the attr field has no meaning */
+ if( (cur_set->luid.low==set.luid.low) && (cur_set->luid.high==set.luid.high) )
+ return True;
+ }
+
+ return False;
+}
+
+/****************************************************************************
+ remove a privilege from a privilege array
+ ****************************************************************************/
+NTSTATUS remove_privilege(PRIVILEGE_SET *priv_set, TALLOC_CTX *ctx, LUID_ATTR set)
+{
+ LUID_ATTR *new_set;
+ LUID_ATTR *old_set;
+ int i,j;
+
+ /* check if the privilege is in the list */
+ if (!check_priv_in_privilege(priv_set, set))
+ return NT_STATUS_UNSUCCESSFUL;
+
+ /* special case if it's the only privilege in the list */
+ if (priv_set->count==1) {
+ init_privilege(priv_set);
+ return NT_STATUS_OK;
+ }
+
+ /*
+ * the privilege is there, create a new list,
+ * and copy the other privileges
+ */
+
+ old_set=priv_set->set;
+
+ new_set=(LUID_ATTR *)talloc(ctx, (priv_set->count - 1) * (sizeof(LUID_ATTR)));
+ if (new_set==NULL) {
+ DEBUG(0,("remove_privilege: could not malloc memory for new privilege list\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0, j=0; i<priv_set->count; i++) {
+ if ((old_set[i].luid.low == set.luid.low) &&
+ (old_set[i].luid.high == set.luid.high)) {
+ continue;
+ }
+
+ new_set[j].luid.low = old_set[i].luid.low;
+ new_set[j].luid.high = old_set[i].luid.high;
+ new_set[j].attr = old_set[i].attr;
+
+ j++;
+ }
+
+ if (j != priv_set->count - 1) {
+ DEBUG(0,("remove_privilege: mismatch ! difference is not -1\n"));
+ DEBUGADD(0,("old count:%d, new count:%d\n", priv_set->count, j));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ /* ok everything is fine */
+
+ priv_set->count--;
+ priv_set->set=new_set;
+
+ safe_free(old_set);
+
+ return True;
+}
+
+#define ALIAS_DEFAULT_SACL_SA_RIGHTS 0x01050013
+#define ALIAS_DEFAULT_DACL_SA_RIGHTS \
+ (READ_CONTROL_ACCESS | \
+ SA_RIGHT_ALIAS_LOOKUP_INFO | \
+ SA_RIGHT_ALIAS_GET_MEMBERS) /* 0x0002000c */
+
+#define ALIAS_DEFAULT_SACL_SEC_ACE_FLAG (SEC_ACE_FLAG_FAILED_ACCESS | SEC_ACE_FLAG_SUCCESSFUL_ACCESS) /* 0xc0 */
+
+NTSTATUS create_builtin_alias_default_sec_desc(SEC_DESC **sec_desc, TALLOC_CTX *ctx)
+{
+ DOM_SID *world = &global_sid_World;
+ DOM_SID *admins = &global_sid_Builtin_Administrators;
+ SEC_ACCESS sa;
+ SEC_ACE sacl_ace;
+ SEC_ACE dacl_aces[2];
+ SEC_ACL *sacl = NULL;
+ SEC_ACL *dacl = NULL
+ SEC_DESC *psd = NULL;
+ size_t psize;
+
+ init_sec_access(&sa, ALIAS_DEFAULT_SACL_SA_RIGHTS);
+ init_sec_ace(&sacl_ace, world, SEC_ACE_TYPE_SYSTEM_AUDIT, sa, ALIAS_DEFAULT_SACL_SEC_ACE_FLAG);
+
+ sacl = make_sec_acl(ctx, NT4_ACL_REVISION, 1, &sacl_ace))
+ if (!sacl) {
+ DEBUG(0, ("build_init_sec_desc: Failed to make SEC_ACL.\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ init_sec_access(&sa, ALIAS_DEFAULT_DACL_SA_RIGHTS);
+ init_sec_ace(&(dacl_aces[0]), world, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0);
+ init_sec_access(&sa, SA_RIGHT_ALIAS_ALL_ACCESS);
+ init_sec_ace(&(dacl_aces[1]), admins, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0);
+
+ dacl = make_sec_acl(ctx, NT4_ACL_REVISION, 2, dacl_aces))
+ if (!sacl) {
+ DEBUG(0, ("build_init_sec_desc: Failed to make SEC_ACL.\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ psd = make_sec_desc(ctx, SEC_DESC_REVISION, admins, admins, sacl, dacl, &psize);
+ if (!psd) {
+ DEBUG(0,("get_share_security: Failed to make SEC_DESC.\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ return psd;
+}
+
+NTSTATUS sec_desc_add_ace_to_dacl(SEC_DESC *sec_desc, TALLOC_CTX *ctx, DOM_SID *sid, uint32 mask)
+{
+ NTSTATUS result;
+ SEC_ACE *new_aces;
+ unsigned num_aces;
+
+ num_aces = sec_desc->dacl->num_aces + 1;
+ result = sec_ace_add_sid(ctx, &new_aces, sec_desc->dacl, num_aces, sid, mask);
+ if (NT_STATUS_IS_OK(result)) {
+ sec_desc->dacl->ace = new_aces;
+ sec_desc->dacl->num_aces = num_aces;
+ sec_desc->dacl->size = SEC_ACL_HEADER_SIZE;
+ for (i = 0; i < num_aces; i++) {
+ sec_desc->dacl->size += ace_list[i].size;
+ }
+ }
+ return result;
+}
+
+NTSTATUS gums_init_builtin_groups(void)
+{
+ NTSTATUS result;
+ GUMS_OBJECT g_obj;
+ GUMS_GROUP *g_grp;
+ SEC_DESC *sec_desc;
+ LUID_ATTR lattr;
+
+ /* Build Builtin the Wellknown Builtin Local Groups */
+ g_obj.type = LOCAL_GROUP;
+ g_obj.mem_ctx = talloc_init_named("gums_init_backend");
+ if (g_obj.mem_ctx == NULL) {
+ DEBUG(0, ("gums_init_backend: Out of Memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* Administrators */
+
+ /* alloc group structure */
+ g_obj.data = talloc(g_obj.mem_ctx, sizeof(GUMS_GROUP));
+ ALLOC_CHECK("gums_init_backend", g_obj.data, result, done);
+
+ /* make admins sid */
+ g_grp = (GUMS_GROUP)g_obj.data;
+ g_grp->sid = (DOM_SID)talloc(g_obj.mem_ctx, sizeof(DOM_SID));
+ ALLOC_CHECK("gums_init_backend", g_grp->sid, result, done);
+ sid_copy(g_grp->sid, &global_sid_Builtin_Administrators);
+
+ /* make security descriptor */
+ result = create_builtin_alias_default_sec_desc(&(g_grp->sec_desc), g_obj.mem_ctx, g_grp->sid);
+ NTSTATUS_CHECK("gums_init_backend", "create_builtin_alias_default_sec_desc", result, done);
+
+ /* make privilege set */
+ /* From BDC join trace:
+ SeSecurityPrivilege
+ SeBackupPrivilege
+ SeRestorePrivilege
+ SeSystemtimePrivilege
+ SeShutdownPrivilege
+ SeRemoteShutdownPrivilege
+ SeTakeOwnershipPrivilege
+ SeDebugPrivilege
+ SeSystemEnvironmentPrivilege
+ SeSystemProfilePrivilege
+ SeProfileSingleProcessPrivilege
+ SeIncreaseBasePriorityPrivilege
+ SeLocalDriverPrivilege
+ SeCreatePagefilePrivilege
+ SeIncreaseQuotaPrivilege
+ */
+ g_grp->priv_set = talloc(g_obj.mem_ctx, sizeof(PRIVILEGE_SET));
+ ALLOC_CHECK("gums_init_backend", g_grp->priv_set, result, done);
+ init_privilege(&(g_grp->priv_set));
+ result = add_all_privilege(&(g_grp->priv_set));
+ NTSTATUS_CHECK("gums_init_backend", "add_all_privilege", result, done);
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Administrators");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+ g_grp->description = talloc_strdup(g_obj.mem_ctx, "Members can fully administer the computer/domain");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* numebr of group members */
+ g_grp->num_members = 0;
+ g_grp->members = NULL;
+
+ /* store Administrators group */
+ result = gums_storage->set_object(&g_obj);
+
+ /* Power Users */
+
+ sid_copy(g_grp->sid, &global_sid_Builtin_Power_Users);
+
+ /* make privilege set */
+ /* SE_PRIV_??? */
+/* > */ init_privilege(&(g_grp->priv_set));
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Power Users");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+/* > */ g_grp->description = talloc_strdup(g_obj.mem_ctx, "???");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* store Power Users group */
+ result = gums_storage->set_object(&g_obj);
+
+ /* Account Operators */
+
+ sid_copy(g_grp->sid, &global_sid_Builtin_Account_Operators);
+
+ /* make privilege set */
+ /* From BDC join trace:
+ SeShutdownPrivilege
+ */
+ init_privilege(&(g_grp->priv_set));
+ lattr.attr=0;
+ lattr.luid.high=0;
+ lattr.luid.low=SE_ADD_USERS;
+ result = add_privilege(&(g_grp->priv_set), lattr);
+ NTSTATUS_CHECK("gums_init_backend", "add_privilege", result, done);
+ lattr.luid.low=SE_ADD_MACHINES;
+ add_privilege(&(g_grp->priv_set), lattr);
+ NTSTATUS_CHECK("gums_init_backend", "add_privilege", result, done);
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Account Operators");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+ g_grp->description = talloc_strdup(g_obj.mem_ctx, "Members can administer domain user and group accounts");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* store Account Operators group */
+ result = gums_storage->set_object(&g_obj);
+
+ /* Server Operators */
+
+ sid_copy(g_grp->sid, &global_sid_Builtin_Server_Operators);
+
+ /* make privilege set */
+ /* From BDC join trace:
+ SeBackupPrivilege
+ SeRestorePrivilege
+ SeSystemtimePrivilege
+ SeShutdownPrivilege
+ SeRemoteShutdownPrivilege
+ */
+ init_privilege(&(g_grp->priv_set));
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Server Operators");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+ g_grp->description = talloc_strdup(g_obj.mem_ctx, "Members can administer domain servers");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* store Server Operators group */
+ result = gums_storage->set_object(&g_obj);
+
+ /* Print Operators */
+
+ sid_copy(g_grp->sid, &global_sid_Builtin_Print_Operators);
+
+ /* make privilege set */
+ /* From BDC join trace:
+ SeShutdownPrivilege
+ */
+
+ init_privilege(&(g_grp->priv_set));
+ /* set printer operator privilege to priv_print_op */
+ lattr.attr=0;
+ lattr.luid.high=0;
+ lattr.luid.low=SE_PRIV_PRINT_OPERATOR;
+ result = add_privilege(&(g_grp->priv_set), lattr);
+ NTSTATUS_CHECK("gums_init_backend", "add_privilege", result, done);
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Print Operators");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+ g_grp->description = talloc_strdup(g_obj.mem_ctx, "Members can administer domain printers");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* store Print Operators group */
+ result = gums_storage->set_object(&g_obj);
+
+ /* Backup Operators */
+
+ sid_copy(g_grp->sid, &global_sid_Builtin_Backup_Operators);
+
+ /* make privilege set */
+ /* From BDC join trace:
+ SeBackupPrivilege
+ SeRestorePrivilege
+ SeShutdownPrivilege
+ */
+ init_privilege(&(g_grp->priv_set));
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Backup Operators");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+ g_grp->description = talloc_strdup(g_obj.mem_ctx, "Members can bypass file security to backup files");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* store Backup Operators group */
+ result = gums_storage->set_object(&g_obj);
+
+ /* Replicator */
+
+ sid_copy(g_grp->sid, &global_sid_Builtin_Replicator);
+
+ /* make privilege set */
+ /* From BDC join trace:
+ SeBackupPrivilege
+ SeRestorePrivilege
+ SeShutdownPrivilege
+ */
+ init_privilege(&(g_grp->priv_set));
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Replicator");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+ g_grp->description = talloc_strdup(g_obj.mem_ctx, "Supports file replication in a domain");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* store Replicator group */
+ result = gums_storage->set_object(&g_obj);
+
+ /* Users */
+
+ sid_copy(g_grp->sid, &global_sid_Builtin_Users);
+
+ /* add ACE to sec dsec dacl */
+ sec_desc_add_ace_to_dacl(g_grp->sec_desc, g_obj.mem_ctx, &global_sid_Builtin_Account_Operators, ALIAS_DEFAULT_DACL_SA_RIGHTS)
+ sec_desc_add_ace_to_dacl(g_grp->sec_desc, g_obj.mem_ctx, &global_sid_Builtin_Power_Users, ALIAS_DEFAULT_DACL_SA_RIGHTS)
+
+ /* make privilege set with zero privileges */
+ init_privilege(&(g_grp->priv_set));
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Users");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+ g_grp->description = talloc_strdup(g_obj.mem_ctx, "Ordinary users");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* store Users group */
+ result = gums_storage->set_object(&g_obj);
+
+ /* Guests */
+
+ sid_copy(g_grp->sid, &global_sid_Builtin_Guests);
+
+ /* make privilege set with zero privileges */
+ init_privilege(&(g_grp->priv_set));
+
+ /* set name */
+ g_grp->group = talloc_strdup(g_obj.mem_ctx, "Guests");
+ ALLOC_CHECK("gums_init_backend", g_grp->group, result, done);
+
+ /* set description */
+ g_grp->description = talloc_strdup(g_obj.mem_ctx, "Users granted guest access to the computer/domain");
+ ALLOC_CHECK("gums_init_backend", g_grp->description, result, done);
+
+ /* store Guests group */
+ result = gums_storage->set_object(&g_obj);
+
+done:
+ talloc_destroy(g_obj.mem_ctx);
+ return result;
+}
+
diff -uPr cvs.samba.org/samba/source/include/gums.h source/include/gums.h
--- cvs.samba.org/samba/source/include/gums.h Thu Jan 1 01:00:00 1970
+++ source/include/gums.h Sun Oct 6 17:58:06 2002
@@ -0,0 +1,200 @@
+/*
+ Unix SMB/CIFS implementation.
+ GUMS structures
+ Copyright (C) Simo Sorce 2002
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _GUMS_H
+#define _GUMS_H
+
+#define GUMS_VERSION_MAJOR 0
+#define GUMS_VERSION_MINOR 1
+
+#define NORMAL_USER 0x001
+#define WORKSTATION_TRUST 0x002
+#define SERVER_TRUST 0x004
+#define DOMAIN_TRUST 0x008
+#define LOCAL_GROUP 0x010
+#define GLOBAL_GROUP 0x020
+
+#define SE_PRIV_NONE 0x0000
+#define SE_PRIV_ADD_MACHINES 0x0006
+#define SE_PRIV_SEC_PRIV 0x0008
+#define SE_PRIV_TAKE_OWNER 0x0009
+#define SE_PRIV_ADD_USERS 0xff01
+#define SE_PRIV_PRINT_OPERATOR 0xff03
+#define SE_PRIV_ALL 0xffff
+
+#define PR_NONE 0x0000
+#define PR_LOG_ON_LOCALLY 0x0001
+#define PR_ACCESS_FROM_NETWORK 0x0002
+#define PR_LOG_ON_BATCH_JOB 0x0004
+#define PR_LOG_ON_SERVICE 0x0010
+
+typedef struct _PRIVS {
+ uint32 se_priv;
+ char *priv;
+ char *description;
+} PRIVS;
+
+typedef struct gums_object
+{
+ TALLOC_CTX *mem_ctx;
+
+ uint32 type;
+ void *data;
+
+} GUMS_OBJECT;
+
+typedef struct gums_user
+{
+ DOM_SID *user_sid; /* Primary User SID */
+ DOM_SID *group_sid; /* Primary Group SID */
+
+ SEC_DESC *sec_desc; /* Security Descriptor */
+ PRIVILEGE_SET *priv_set; /* Privileges list */
+
+ NTTIME logon_time; /* logon time */
+ NTTIME logoff_time; /* logoff time */
+ NTTIME kickoff_time; /* kickoff time */
+ NTTIME pass_last_set_time; /* password last set time */
+ NTTIME pass_can_change_time; /* password can change time */
+ NTTIME pass_must_change_time; /* password must change time */
+
+ char *user; /* Windows username string */
+ char *full_name; /* user's full name string */
+ char *description; /* description */
+ char *home_dir; /* home directory string */
+ char *dir_drive; /* home directory drive string */
+ char *logon_script; /* logon script string */
+ char *profile_path; /* profile path string */
+ char *workstations; /* login from workstations string */
+ char *unknown_str; /* don't know what this is, yet. */
+ char *munged_dial; /* munged path name and dial-back tel number */
+
+ DATA_BLOB lm_pw; /* .data is Null if no password */
+ DATA_BLOB nt_pw; /* .data is Null if no password */
+
+ uint32 unknown_3; /* 0x00ff ffff */
+
+ uint16 logon_divs; /* 168 - number of hours in a week */
+ uint32 hours_len; /* normally 21 bytes */
+ uint8 hours[MAX_HOURS_LEN];
+
+ uint32 unknown_5; /* 0x0002 0000 */
+ uint32 unknown_6; /* 0x0000 04ec */
+
+} GUMS_USER;
+
+typedef struct gums_group
+{
+ DOM_SID *sid;
+
+ SEC_DESC *sec_desc; /* Security Descriptor */
+ PRIVILEGE_SET *priv_set; /* Privileges list */
+
+ char *group;
+ char *description;
+
+ uint32 num_members;
+ DOM_SID **members;
+
+} GUMS_GROUP;
+
+typedef struct gums_data_set
+{
+ int type; /* GUMS_SET_xxx */
+ void *data;
+} GUMS_DATA_SET;
+
+typedef struct gums_functions
+{
+ /* Generic object functions */
+
+ NTSTATUS (*get_domain_sid) (DOM_SID **sid);
+ NTSTATUS (*set_domain_sid) (const DOM_SID *sid);
+
+ NTSTATUS (*get_sequence_number) (void);
+
+ NTSTATUS (*new_object) (DOM_SID **sid, const char *name, const int obj_type);
+ NTSTATUS (*delete_object) (const DOM_SID *sid);
+
+ NTSTATUS (*get_object_from_sid) (GUMS_OBJECT **object, const DOM_SID *sid, const int obj_type);
+ NTSTATUS (*get_sid_from_name) (GUMS_OBJECT **object, const char *name);
+ /* This function is used to get the list of all objects changed since b_time, it is
+ used to support PDC<->BDC synchronization */
+ NTSTATUS (*get_updated_objects) (GUMS_OBJECT **object, const NTTIME base_time);
+
+ NTSTATUS (*enumerate_objects) (DOM_SID **sids, const DOM_SID *sid, const int obj_type);
+
+ /* This function MUST be used ONLY by PDC<->BDC replication code or recovery tools.
+ Never use this function to update an object in the database, use set_object_values() */
+ NTSTATUS (*set_object) (const GUMS_OBJECT *object);
+
+ /* set object values function */
+ NTSTATUS (*set_object_values) (GUMS_DATA_SET *data[], const DOM_SID *sid);
+
+ /* Group related functions */
+ NTSTATUS (*add_member_to_group) (const DOM_SID *group, const DOM_SID *member);
+ NTSTATUS (*delete_member_from_group) (const DOM_SID *group, const DOM_SID *member);
+ NTSTATUS (*enumerate_members) (DOM_SID **members, const DOM_SID *sid, const int type);
+
+ NTSTATUS (*get_user_groups) (DOM_SID **groups, const DOM_SID *sid);
+
+ NTSTATUS (*lock_sid) (const DOM_SID *sid);
+ NTSTATUS (*unlock_sid) (const DOM_SID *sid);
+
+} GUMS_FUNCTIONS;
+
+/* define value types */
+
+#define GUMS_SET_PRIMARY_GROUP 1
+#define GUMS_SET_SEC_DESC 2
+#define GUMS_SET_PRIVILEGE_SET 3
+#define GUMS_SET_MUST_CHANGE_PASS 4
+#define GUMS_SET_CANNOT_CHANGE_PASS 5
+#define GUMS_SET_PASS_NEVER_EXPIRE 6
+#define GUMS_SET_ACCOUNT_DISABLED 7
+#define GUMS_SET_ACCOUNT_LOCKOUT 8
+#define GUMS_SET_LOGON_TIME 9
+#define GUMS_SET_LOGOFF_TIME 10
+#define GUMS_SET_KICKOFF_TIME 11
+#define GUMS_SET_PASS_LAST_SET_TIME 12
+#define GUMS_SET_PASS_CAN_CHANGE_TIME 13
+#define GUMS_SET_PASS_MUST_CHANGE_TIME 14
+#define GUMS_SET_NAME 15
+#define GUMS_SET_FULL_NAME 16
+#define GUMS_SET_DESCRIPTION 17
+#define GUMS_SET_HOME_DIRECTORY 18
+#define GUMS_SET_DRIVE 19
+#define GUMS_SET_LOGON_SCRIPT 20
+#define GUMS_SET_PROFILE_PATH 21
+#define GUMS_SET_WORKSTATIONS 22
+#define GUMS_SET_UNKNOWN_STRING 23
+#define GUMS_SET_MUNGED_DIAL 24
+#define GUMS_SET_LM_PASSWORD 25
+#define GUMS_SET_NT_PASSWORD 26
+#define GUMS_SET_PLAINTEXT_PASSWORD 27
+#define GUMS_SET_UNKNOWN_3 28
+#define GUMS_SET_LOGON_DIVS 29
+#define GUMS_SET_HOURS_LEN 30
+#define GUMS_SET_HOURS 31
+#define GUMS_SET_UNKNOWN_5 32
+#define GUMS_SET_UNKNOWN_6 33
+
+
+#endif /* _GUMS_H */
signature.asc
Description: This is a digitally signed message part
