2 Unix SMB/CIFS implementation.
3 Grops and Users Management System initializations.
4 Copyright (C) Simo Sorce 2002
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DBGC_CLASS DBGC_GUMS*/
30 #define PRIV_CREATE_TOKEN 1
31 #define PRIV_ASSIGNPRIMARYTOKEN 2
32 #define PRIV_LOCK_MEMORY 3
33 #define PRIV_INCREASE_QUOTA 4
34 #define PRIV_MACHINE_ACCOUNT 5
36 #define PRIV_SECURITY 7
37 #define PRIV_TAKE_OWNERSHIP 8
38 #define PRIV_LOAD_DRIVER 9
39 #define PRIV_SYSTEM_PROFILE 10
40 #define PRIV_SYSTEMTIME 11
41 #define PRIV_PROF_SINGLE_PROCESS 12
42 #define PRIV_INC_BASE_PRIORITY 13
43 #define PRIV_CREATE_PAGEFILE 14
44 #define PRIV_CREATE_PERMANENT 15
45 #define PRIV_BACKUP 16
46 #define PRIV_RESTORE 17
47 #define PRIV_SHUTDOWN 18
50 #define PRIV_SYSTEM_ENVIRONMENT 21
51 #define PRIV_CHANGE_NOTIFY 22
52 #define PRIV_REMOTE_SHUTDOWN 23
53 #define PRIV_UNDOCK 24
54 #define PRIV_SYNC_AGENT 25
55 #define PRIV_ENABLE_DELEGATION 26
59 GUMS_FUNCTIONS *gums_storage;
60 static void *dl_handle;
62 static PRIVS gums_privs[] = {
63 {PRIV_NONE, "no_privs", "No privilege"}, /* this one MUST be first */
64 {PRIV_CREATE_TOKEN, "SeCreateToken", "Create Token"},
65 {PRIV_ASSIGNPRIMARYTOKEN, "SeAssignPrimaryToken", "Assign Primary Token"},
66 {PRIV_LOCK_MEMORY, "SeLockMemory", "Lock Memory"},
67 {PRIV_INCREASE_QUOTA, "SeIncreaseQuotaPrivilege", "Increase Quota Privilege"},
68 {PRIV_MACHINE_ACCOUNT, "SeMachineAccount", "Machine Account"},
69 {PRIV_TCB, "SeTCB", "TCB"},
70 {PRIV_SECURITY, "SeSecurityPrivilege", "Security Privilege"},
71 {PRIV_TAKE_OWNERSHIP, "SeTakeOwnershipPrivilege", "Take Ownership Privilege"},
72 {PRIV_LOAD_DRIVER, "SeLocalDriverPrivilege", "Local Driver Privilege"},
73 {PRIV_SYSTEM_PROFILE, "SeSystemProfilePrivilege", "System Profile Privilege"},
74 {PRIV_SYSTEMTIME, "SeSystemtimePrivilege", "System Time"},
75 {PRIV_PROF_SINGLE_PROCESS, "SeProfileSingleProcessPrivilege", "Profile Single Process Privilege"},
76 {PRIV_INC_BASE_PRIORITY, "SeIncreaseBasePriorityPrivilege", "Increase Base Priority Privilege"},
77 {PRIV_CREATE_PAGEFILE, "SeCreatePagefilePrivilege", "Create Pagefile Privilege"},
78 {PRIV_CREATE_PERMANENT, "SeCreatePermanent", "Create Permanent"},
79 {PRIV_BACKUP, "SeBackupPrivilege", "Backup Privilege"},
80 {PRIV_RESTORE, "SeRestorePrivilege", "Restore Privilege"},
81 {PRIV_SHUTDOWN, "SeShutdownPrivilege", "Shutdown Privilege"},
82 {PRIV_DEBUG, "SeDebugPrivilege", "Debug Privilege"},
83 {PRIV_AUDIT, "SeAudit", "Audit"},
84 {PRIV_SYSTEM_ENVIRONMENT, "SeSystemEnvironmentPrivilege", "System Environment Privilege"},
85 {PRIV_CHANGE_NOTIFY, "SeChangeNotify", "Change Notify"},
86 {PRIV_REMOTE_SHUTDOWN, "SeRemoteShutdownPrivilege", "Remote Shutdown Privilege"},
87 {PRIV_UNDOCK, "SeUndock", "Undock"},
88 {PRIV_SYNC_AGENT, "SeSynchronizationAgent", "Synchronization Agent"},
89 {PRIV_ENABLE_DELEGATION, "SeEnableDelegation", "Enable Delegation"},
90 {PRIV_ALL, "SaAllPrivs", "All Privileges"}
93 NTSTATUS gums_init(const char *module_name)
95 int (*module_version)(int);
96 NTSTATUS (*module_init)();
97 /* gums_module_init module_init;*/
98 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
100 DEBUG(5, ("Opening gums module %s\n", module_name));
101 dl_handle = sys_dlopen(module_name, RTLD_NOW);
103 DEBUG(0, ("ERROR: Failed to load gums module %s, error: %s\n", module_name, sys_dlerror()));
104 return NT_STATUS_UNSUCCESSFUL;
107 module_version = sys_dlsym(dl_handle, "gumm_version");
108 if (!module_version) {
109 DEBUG(0, ("ERROR: Failed to find gums module version!\n"));
113 if (module_version(GMV_MAJOR) != GUMS_VERSION_MAJOR) {
114 DEBUG(0, ("ERROR: Module's major version does not match gums version!\n"));
118 if (module_version(GMV_MINOR) != GUMS_VERSION_MINOR) {
119 DEBUG(1, ("WARNING: Module's minor version does not match gums version!\n"));
122 module_init = sys_dlsym(dl_handle, "gumm_init");
124 DEBUG(0, ("ERROR: Failed to find gums module's init function!\n"));
128 DEBUG(5, ("Initializing module %s\n", module_name));
130 ret = module_init(&gums_storage);
134 ret = NT_STATUS_UNSUCCESSFUL;
135 sys_dlclose(dl_handle);
141 NTSTATUS gums_unload(void)
144 NTSTATUS (*module_finalize)();
147 return NT_STATUS_UNSUCCESSFUL;
149 module_finalize = sys_dlsym(dl_handle, "gumm_finalize");
150 if (!module_finalize) {
151 DEBUG(0, ("ERROR: Failed to find gums module's init function!\n"));
152 return NT_STATUS_UNSUCCESSFUL;
155 DEBUG(5, ("Finalizing module"));
157 ret = module_finalize();
158 sys_dlclose(dl_handle);