2 Unix SMB/CIFS implementation.
4 provide hooks into smbd C calls from ejs scripts
6 Copyright (C) Jelmer Vernooij 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "scripting/ejs/smbcalls.h"
25 #include "lib/appweb/ejs/ejs.h"
26 #include "lib/samba3/samba3.h"
29 struct samba3_samaccount {
36 pass_must_change_time;
49 uint32_t user_rid, group_rid, hours_len, unknown_6;
50 uint16_t acct_ctrl, logon_divs;
51 uint16_t bad_password_count, logon_count;
52 uint8_t *lm_pw_ptr, *nt_pw_ptr;
53 uint8_t *nt_pw_hist_ptr;
57 struct samba3_groupmapping {
67 uint32_t member_count;
68 struct dom_sid **members;
71 struct samba3_groupdb {
72 uint32_t groupmap_count;
73 struct samba3_groupmapping *groupmappings;
76 struct samba3_alias *aliases;
79 struct samba3_idmap_mapping
81 enum { IDMAP_GROUP, IDMAP_USER } type;
88 /* High water marks */
92 uint32_t mapping_count;
93 struct samba3_idmap_mapping *mappings;
96 struct samba3_winsdb_entry
103 struct ipv4_addr *ips;
108 uint32_t min_password_length;
109 uint32_t password_history;
110 uint32_t user_must_logon_to_change_password;
111 uint32_t maximum_password_age;
112 uint32_t minimum_password_age;
113 uint32_t lockout_duration;
114 uint32_t reset_count_minutes;
115 uint32_t bad_lockout_minutes;
116 uint32_t disconnect_time;
117 uint32_t refuse_machine_password_change;
120 struct samba3_regval {
126 struct samba3_regkey {
129 uint32_t value_count;
130 struct samba3_regval *values;
132 uint32_t subkey_count;
139 struct samba3_regkey *keys;
142 struct samba3_secrets
144 struct cli_credentials *ipc_cred;
146 uint32_t ldappw_count;
153 uint32_t domain_count;
154 struct samba3_domainsecrets
160 time_t last_change_time;
165 int sec_channel_type;
168 uint32_t trusted_domain_count;
169 struct samba3_trusted_dom_pass {
170 uint32_t uni_name_len;
171 const char *uni_name[32]; /* unicode domain name */
172 const char *pass; /* trust relationship's password */
174 struct dom_sid domain_sid; /* remote domain's sid */
177 uint32_t afs_keyfile_count;
179 struct samba3_afs_keyfile {
189 struct samba3_parameter {
194 struct samba3_share_info {
196 struct security_descriptor secdesc;
198 uint32_t parameter_count;
199 struct samba3_parameter *parameters;
204 uint32_t winsdb_count;
205 struct samba3_winsdb_entry *winsdb_entries;
207 uint32_t samaccount_count;
208 struct samba3_samaccount *samaccounts;
210 uint32_t share_count;
211 struct samba3_share_info *shares;
213 struct samba3_secrets secrets;
214 struct samba3_groupdb group;
215 struct samba3_idmapdb idmap;
216 struct samba3_policy policy;
217 struct samba3_regdb registry;
223 initialise samba3 ejs subsystem
225 static int ejs_samba3_read(MprVarHandle eid, int argc, struct MprVar **argv)
227 struct MprVar *mpv = mprInitObject(eid, "samba3", argc, argv);
228 struct samba3 *samba3;
232 ejsSetErrorMsg(eid, "samba3_read invalid arguments");
236 status = samba3_read(mprToString(argv[0]), mprToString(argv[0]), mprMemCtx(), &samba3);
238 if (NT_STATUS_IS_ERR(status)) {
239 ejsSetErrorMsg(eid, "samba3_read: error");
243 mprSetThisPtr(eid, "db", samba3);
250 setup C functions that be called from ejs
252 void smb_setup_ejs_samba3(void)
254 ejsDefineCFunction(-1, "samba3_read", ejs_samba3_read, NULL, MPR_VAR_SCRIPT_HANDLE);