source: trunk/guitools/sscc/sscc.vrx@ 858

Last change on this file since 858 was 771, checked in by Herwig Bauernfeind, 12 years ago

GUI-Tools: SSCC 1.0.x warn if USER and HOSTNAME have the same value (which is nonsense anyway) (Ticket #220)

File size: 111.7 KB
Line 
1/*:VRX Main
2*/
3/* Main
4*/
5Main:
6/* Process the arguments.
7 Get the parent window.
8*/
9 parse source . calledAs .
10 parent = ""
11 argCount = arg()
12 argOff = 0
13 if( calledAs \= "COMMAND" )then do
14 if argCount >= 1 then do
15 parent = arg(1)
16 argCount = argCount - 1
17 argOff = 1
18 end
19 end; else do
20 call VROptions 'ImplicitNames'
21 call VROptions 'NoEchoQuit'
22 end
23 InitArgs.0 = argCount
24 if( argCount > 0 )then do i = 1 to argCount
25 InitArgs.i = arg( i + argOff )
26 end
27 drop calledAs argCount argOff
28
29/* Load the windows
30*/
31 call VRInit
32 parse source . . spec
33 _VREPrimaryWindowPath = ,
34 VRParseFileName( spec, "dpn" ) || ".VRW"
35 _VREPrimaryWindow = ,
36 VRLoad( parent, _VREPrimaryWindowPath )
37 drop parent spec
38 if( _VREPrimaryWindow == "" )then do
39 call VRMessage "", "Cannot load window:" VRError(), ,
40 "Error!"
41 _VREReturnValue = 32000
42 signal _VRELeaveMain
43 end
44
45/* Process events
46*/
47 call Init
48 signal on halt
49 do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
50 _VREEvent = VREvent()
51 interpret _VREEvent
52 end
53_VREHalt:
54 _VREReturnValue = Fini()
55 call VRDestroy _VREPrimaryWindow
56_VRELeaveMain:
57 call VRFini
58exit _VREReturnValue
59
60VRLoadSecondary:
61 __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
62 if __vrlsWait then do
63 call VRFlush
64 end
65 __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
66 if __vrlsHWnd = '' then signal __vrlsDone
67 if __vrlsWait \= 1 then signal __vrlsDone
68 call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
69 __vrlsTmp = __vrlsWindows.0
70 if( DataType(__vrlsTmp) \= 'NUM' ) then do
71 __vrlsTmp = 1
72 end
73 else do
74 __vrlsTmp = __vrlsTmp + 1
75 end
76 __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
77 __vrlsWindows.0 = __vrlsTmp
78 do while( VRIsValidObject( VRWindow() ) = 1 )
79 __vrlsEvent = VREvent()
80 interpret __vrlsEvent
81 end
82 __vrlsTmp = __vrlsWindows.0
83 __vrlsWindows.0 = __vrlsTmp - 1
84 call VRWindow __vrlsWindows.__vrlsTmp
85 __vrlsHWnd = ''
86__vrlsDone:
87return __vrlsHWnd
88
89/*:VRX __VXREXX____APPENDS__
90*/
91__VXREXX____APPENDS__:
92/*
93#append U:\Develop\Samba\guitools-1.0\shared\inittempdir.vrs
94#append U:\Develop\Samba\guitools-1.0\shared\sambainit.vrs
95#append U:\Develop\Samba\guitools-2.0\shared\nlv.vrs
96#append U:\Develop\Samba\guitools-1.0\shared\swat.vrs
97*/
98return
99/*:VRX _ActiveGroup
100*/
101_ActiveGroup:
102 ActiveGroup = translate(arg(1))
103 ActiveGroupObj = VRGet("GB_"ActiveGroup, "Self")
104 ok = VRset(ActiveGroupObj, "Visible", 1)
105return
106
107/*:VRX _bs2fs
108*/
109_bs2fs: procedure
110 string = arg(1)
111return translate(string,'/','\')
112
113/*:VRX _CfgPageSetupSize
114*/
115_CfgPageSetupSize:
116 if arg(1) = "GB_Global"
117 then ok = VRset(arg(1), "Top", 0)
118 else ok = VRset(arg(1), "Top", Fwidth)
119
120 ok = VRset(arg(1), "Left",VRGet("GB_SmbConfTree","Width") + 60)
121
122 if arg(1) = "GB_Global"
123 then ok = VRset(arg(1), "Height",VRGet("GB_SmbConfTree","height")+FWidth)
124 else ok = VRset(arg(1), "Height",VRGet("GB_SmbConfTree","height"))
125
126 ok = VRset(arg(1), "Width", VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
127return
128
129/*:VRX _ChooseDir
130*/
131_ChooseDir:
132 Invoked = VRInfo("Object")
133 InitDir = VRGet("EF_"||substr(VRGet(Invoked, "name"),5),"Value")
134 if pos('\\',InitDir) > 0 then do
135 Msg.Text = NLVGetMessage(63,InitDir)
136 Msg.Type = "E"
137 call _ShowMsg
138 return
139 end
140 VarPos = pos('%', InitDir)
141 if VarPos > 0 then do
142 VarChar = substr(InitDir,VarPos,2)
143 InitDir = left(InitDir,VarPos-1)
144 say VarChar
145 end
146 NewPath = _dirDialog('Choose path for 'VRGet("DT_Shares","Caption"),_fs2bs(InitDir))
147 if NewPath = "" then return
148 if VarPos > 0 then NewPath = NewPath'\'VarChar
149 ok = VRset("EF_"||substr(VRGet(Invoked, "name"),5),"value",NewPath)
150return
151
152/*:VRX _CreateVocObject
153*/
154_CreateVocObject:
155 IF options.!debug == 1 THEN say "_CreateVocObject() started"
156 If VRIsValidObject(VocObjType"_"upVoc ) then Success = 1
157 else do
158 /* Creative descriptive text */
159 Objs = Objs + 1
160 Voc.V = translate(left(Voc.V,1))||substr(Voc.V,2)
161 CreatedObjs.Objs = VRCreate(ActiveGroupObj, "DescriptiveText", "Name", "DT_"upVoc, 'Caption', Voc.V, "Top", ObjYPos+50 , "Left", 120+72, "Visible", 1, "AutoSize", 1)
162 select
163 when pos("\\",Val.V) > 0 then nop
164 when pos(" dir",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
165 when pos("file",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
166 when pos("path",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
167 otherwise nop /* do not beautify */
168 end
169
170 DT_Handle = CreatedObjs.Objs
171 /* The CB or EF */
172 Objs = Objs + 1
173 select
174 when VocObjType = "CB" then do
175 CreatedObjs.Objs = VRCreate(ActiveGroupObj, "Checkbox", "Name", VocObjType"_"upVoc, "Top", ObjYPos+30, "AutoSize", 1)
176 ok = VRSet(VocObjType"_"upVoc, "Click", "call _ShareObject_Changed")
177 end
178 otherwise do
179 CreatedObjs.Objs = VRCreate(ActiveGroupObj, "EntryField", "Name", VocObjType"_"upVoc, "Top", ObjYPos , "Width", 2800, "Height", "253")
180 ok = VRSet(VocObjType"_"upVoc, "Change", "call _ShareObject_Changed")
181 end
182 end
183 Success = (CreatedObjs.OBjs <> "")
184 if Success then do /* SUccess */
185 ok = VRSet(VocObjType"_"upVoc, "Left", max(1500, 120*2+VRGet(DT_handle,"Width")))
186 if VocObjType = "EF" & upCurSection ="GLOBAL" then do
187 OWidth = 2800-max(0,VRGet(VocObjType"_"upVoc, "Left")-1500)
188 if datatype(Val.V) = "NUM" then OWidth = length(Val.V)*90+200
189 else OWidth = length(Val.V)*90+440
190 if Val.V = "" then OWidth = 1500
191 ok = VRSet(VocObjType"_"upVoc, "Width", OWidth)
192 if (pos("_DIRECTORY",upVoc) > 0 | pos("_PATH",upVoc) > 0) & pos("MODE",upVoc) = 0 & pos("MASK",upVoc) = 0 then do
193 Objs = Objs + 1
194 CreatedObjs.Objs = VRCreate(ActiveGroupObj, "ImagePushButton", "Name", "IPB_"upVoc, "Top", ObjYPos+30, "AutoSize", 0 , "PicturePath", "#2;#3", "Left", VRGet(VocObjType"_"upVoc,"Left")+VRGet(VocObjType"_"upVoc,"Width")+72)
195 ok = VRSet("IPB_"upVoc, "Click", "call _ChooseDir")
196 ok = VRSet("IPB_"upVoc,"Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
197 ok = VRSet("IPB_"upVoc,"Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
198 end
199 end
200
201 /* ok = VRSet(VocObjType"_"upVoc, "BackColor", "Red") */
202 ok = VRSet(VocObjType"_"upVoc, "Visible", 1)
203 CreatedObjs.0 = Objs
204 ObjYPos= ObjYPos + ObjDelta
205 end
206 else do
207 say "Failed to Create "||VocObjType"_"upVoc||' in 'ActiveGroupObj
208 end
209 end
210 IF options.!debug == 1 THEN say ' Object: "'VocObjType'_'upVoc'" Value: "'Val.V'" Handle:"'CreatedObjs.Objs'"'
211 IF options.!debug == 1 THEN say "_CreateVocObject() done"
212return Success
213/*:VRX _dirdialog
214*/
215_DirDialog: procedure
216 Title = arg(1)
217 InitDir = arg(2)
218 RC = RxFuncQuery("DRCtrlPickDirectory")
219 if RC = 0 then do /* use DrCtrl if available */
220 MyDir=DRCtrlPickDirectory(InitDir, Title)
221 end
222 else do
223 MyDir = VRFileDialog(VRWindow,Title, 'o', InitDir||'\dummy')
224 if MyDir <> '' then MyDir = strip(filespec('D',MyDir)||Filespec('P',MyDir),'T','\')
225 end
226return MyDir
227/*:VRX _FindIBMLANPath
228*/
229_FindIBMLANPath:
230 say '_FindIBMLANPath() started.'
231 ibmlanini = SysBootDrive()'\IBMLAN\IBMLAN.INI'
232 ibmlaniniexists = VRFileExists(ibmlanini)
233 say ' Does "'ibmlanini'" exist? 'ibmlaniniexists' (1=Yes, 0=No)'
234
235 lsshareini = SysBootDrive()'\IBMLAN\LSSHARE.INI'
236 lsshareiniexists = VRFileExists(lsshareini)
237 say ' Does "'lsshareini'" exist? 'lsshareiniexists' (1=Yes, 0=No)'
238 say '_FindIBMLANPath() done.'
239return
240
241/*:VRX _fs2bs
242*/
243_fs2bs: procedure
244 string = arg(1)
245return translate(string,'\','/')
246
247/*:VRX _GroupCreate
248*/
249_GroupCreate:
250 /* Create kLIBC group file */
251 ok = SysFileDelete(samba.!group)
252 call lineout samba.!group, '# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)
253 call lineout samba.!group, '# syntax:'
254 call lineout samba.!group, '# groupname:password:GID:user[,user,...,]'
255 call lineout samba.!group, 'admin:*:512:root,'
256 call lineout samba.!group, 'users:*:513:'
257 call lineout samba.!group, 'guests:*:514:'
258 call lineout samba.!group, 'machines:*:515:'
259 call lineout samba.!group, 'dc:*:516:'
260 call lineout samba.!group, 'certadmin:*:517:'
261 call lineout samba.!group, 'schemeadmin:*:518:'
262 call lineout samba.!group, 'entadmin:*:519:'
263 call lineout samba.!group, 'poladmin:*:520:'
264 ok = stream(samba.!group,'c','close')
265return
266/*:VRX _GUIInit
267*/
268_GUIInit:
269 if datatype(Top) = 'NUM' then do
270 ok = VRset("Main","Top",Top)
271 ok = VRset("Main","Left",Left)
272 ok = VRset("Main","Width",Width)
273 ok = VRset("Main","Height",Height)
274 end
275 else ok = VRset("Main","Width", 9250)
276
277 settings.!curfcolor = VRGetIni('PM_Default_Colors', 'ActiveTitleText', 'User', 'NoClose')
278 settings.!curbcolor = VRGetIni('PM_Default_Colors', 'ActiveTitleTextBgnd', 'User')
279
280 ok = VRSet("DT_SmbConfTree","BACKCOLOR", settings.!curbcolor )
281 ok = VRSet("DT_SmbConfTree","FORECOLOR", settings.!curfcolor )
282
283 ok = VRSet("EF_Binaries_Version","value",samba.!version)
284 ok = VRSet("EF_Binaries_Path","value",samba.!bin)
285 ok = VRSet("EF_Scripts_Path","value",samba.!tools)
286 ok = VRSet("EF_UnixRoot_Path","value",UnixRoot)
287 ok = VRSet("EF_ETC_Path","value",ETC)
288 ok = VRSet("CN_SmbConf","Caption", smbconf)
289 ok = VRSet("IPB_ChooseDir","Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
290 ok = VRSet("IPB_ChooseDir","Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
291 ok = VRSet("IPB_NewItem","Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
292 ok = VRSet("IPB_NewItem","Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
293
294 ok = VRSet("Menu_File_Import_IBMPeer", "Enabled", lsshareiniexists * ibmlaniniexists )
295
296 ok = VRSet("Menu_Options_MiniIcons","Checked", \advanced.!bigicons)
297 ok = VRset("CN_smbconf","MiniIcons", \advanced.!bigicons)
298
299 if _ChkTempFreeSpace() < 262144 then do
300 Msg.Type = "W"
301 Msg.Text = NLVGetMessage(116, TempDir)
302 call _ShowMsg
303 end
304
305 ok = VRSet("Menu_File_PrintCap","Enabled", \IsCupsPrintcap)
306 if \IsCupsPrintcap then call _PrintCapCreate
307
308 if SmbConfExists then call _SmbConfLoad
309 else ok = VRSet("TM_Installer","Enabled", 1)
310return
311
312/*:VRX _GUIInitNLV
313*/
314_GUIInitNLV:
315 say '_GUIInitNLV started'
316 CALL NLVSetup
317 CALL NLVSetText 'Main', 'Caption', 1
318 Msg.Title = VRGet("Main", "Caption")
319
320 CALL NLVSetText 'PB_Reload', 'Caption', 11
321 CALL NLVSetText 'PB_Reload', 'Hinttext', 111
322 CALL NLVSetText 'PB_Save', 'Caption', 12
323 CALL NLVSetText 'PB_Save', 'Hinttext', 112
324 CALL NLVSetText 'PB_Undo', 'Caption', 9
325 CALL NLVSetText 'PB_Undo', 'Hinttext', 109
326 CALL NLVSetText 'PB_Cancel', 'Caption', 10
327 CALL NLVSetText 'PB_Cancel', 'Hinttext', 110
328 CALL NLVSetText 'PB_Help', 'Caption', 4
329 CALL NLVSetText 'PB_Help', 'Hinttext', 104
330 CALL NLVSetText 'PB_Add_Voc_OK', 'Caption', 2
331 CALL NLVSetText 'PB_Add_Voc_OK', 'Hinttext', 102
332 CALL NLVSetText 'PB_Add_Voc_Cancel','Caption', 3
333 CALL NLVSetText 'PB_Add_Voc_Cancel','Hinttext', 103
334 CALL NLVSetText 'Menu_File', 'Caption', 21
335 CALL NLVSetText 'Menu_Options', 'Caption', 22
336 CALL NLVSetText 'Menu_Help', 'Caption', 23
337
338 CALL NLVSetText 'Menu_File_Import_IBMPeer', 'Caption', 24
339 CALL NLVSetText 'Menu_File_Reset', 'Caption', 25
340 CALL NLVSetText 'Menu_File_Debug', 'Caption', 26
341 CALL NLVSetText 'Menu_File_ImportHosts', 'Caption', 36
342 CALL NLVSetText 'Menu_File_PrintCap', 'Caption', 37
343 CALL NLVSetText 'Menu_File_SmbUpdate', 'Caption', 44
344 CALL NLVSetText 'Menu_File_Exit', 'Caption', 27
345
346 CALL NLVSetText 'Menu_Options_SimpleMode', 'Caption', 28
347 CALL NLVSetText 'Menu_Options_ExportMode', 'Caption', 29
348 CALL NLVSetText 'Menu_Options_MiniIcons', 'Caption', 74
349 CALL NLVSetText 'Menu_Help_smbconf', 'Caption', 30
350 CALL NLVSetText 'Menu_Help_About', 'Caption', 31
351 CALL NLVSetText 'Menu_Action', 'Caption', 32
352 CALL NLVSetText 'Menu_Action_AddHomes', 'Caption', 33
353 CALL NLVSetText 'Menu_Action_AddNetlogon', 'Caption', 34
354 CALL NLVSetText 'Menu_Action_AddProfiles', 'Caption', 35
355 CALL NLVSetText 'Menu_Action_AddProfiles', 'Caption', 35
356 CALL NLVSetText 'Menu_Action_EraseTransient','Caption', 47
357
358 CALL NLVSetText 'Menu_ShareContext_AddPrinter', 'Caption', 40
359 CALL NLVSetText 'Menu_ShareContext_Add', 'Caption', 41
360 CALL NLVSetText 'Menu_ShareContext_RemovePrinter','Caption', 42
361 CALL NLVSetText 'Menu_ShareContext_Remove', 'Caption', 43
362 CALL NLVSetText 'Menu_ShareContext_RenamePrinter','Caption', 48
363 CALL NLVSetText 'Menu_ShareContext_Rename', 'Caption', 49
364
365 CALL NLVSetText 'DT_Help', 'Caption', 80
366 CALL NLVSetText 'DT_Heading', 'Caption', 81
367 CALL NLVSetText 'DT_Binaries_Version', 'Caption', 82
368 CALL NLVSetText 'DT_Binaries_Path', 'Caption', 83
369 CALL NLVSetText 'DT_Scripts_Path', 'Caption', 84
370/* CALL NLVSetText 'DT_SmbConfTree', 'Caption', 73 */
371say NLVGetMessage(73)
372 ok = VRSet("DT_SmbConfTree","Caption", NLVGetMessage(73))
373 Drive = NLVGetMessage(38)
374 say '_GUIInitNLV done'
375return
376
377/*:VRX _INIRead
378*/
379_INIRead:
380 IF options.!debug == 1 THEN say '_INIRead() started'
381 OurINI = strip(VRParseFileName(VRget("Application","Program"),'DP')'\SSCC.INI',,'\')
382 ok = SysFileTree(OurINI, INIFound.,'FO')
383 if INIFound.0 = 1 then OurINI = VRParseFileName(INIFound.1,'DPNE')
384 say 'OurINI ='OurINI
385
386 Top = VRGetIni( "Pos", "Top", OurINI , 'NoClose')
387 Left = VRGetIni( "Pos", "Left", OurINI , 'NoClose')
388 Width = VRGetIni( "Pos", "Width", OurINI , 'NoClose')
389 Height= VRGetIni( "Pos", "Height", OurINI , 'NoClose')
390
391 options.!debug = VRGetIni( "Options", "Debug", OurINI, 'NoClose')
392 if options.!debug = "" then options.!debug = 0
393
394 ok = VRSet("Menu_File_Debug","Checked",options.!Debug)
395 if options.!Debug then ok = VRREdirectStdIO("ON")
396 else ok = VRREdirectStdIO("OFF")
397
398 options.!builddir = VRGetIni( "Options", "BuildDir", OurINI, 'NoClose')
399 if options.!builddir = "" then options.!builddir = ""
400
401 advanced.!bigicons = VRGetIni( "Options", "BigIcons", OurINI)
402 if advanced.!bigicons = "" then advanced.!bigicons = 1
403
404 /* Initialize several variables */
405 indent = '09'x
406 ManageDaemons = 1
407
408 /* these were formerly defined in smb.conf */
409 CreatedObjs.0 = 0
410 ChangeList = ""
411 ValueChanged = 0
412 CurSection = ""
413 CreatedObjs.0 = 0
414 ActiveGroup = "Global"
415
416 InstallMode = 0 /* Normally 0 for configure mode, /Install switch overrides this */
417 UseTDBSam = 0 /* only for installermode */
418 CreatePDC = 0 /* only for installermode */
419
420 FWidth = 32
421
422 IF options.!debug == 1 THEN say '_INIRead() done'
423return
424
425/*:VRX _INIWrite
426*/
427_INIWrite:
428 ok = VRSetIni( "Pos", "Top", VRGet("Main","Top"), OurINI, 'NoClose')
429 ok = VRSetIni( "Pos", "Left", VRGet("Main","Left"), OurINI, 'NoClose')
430 ok = VRSetIni( "Pos", "Width", VRGet("Main","Width"), OurINI, 'NoClose')
431 ok = VRSetIni( "Pos", "Height", VRGet("Main","Height"), OurINI, 'NoClose')
432 ok = VRSetIni( "Options", "BuildDir", options.!builddir, OurINI, 'NoClose')
433 ok = VRSetIni( "Options", "Debug", options.!debug, OurINI, 'NoClose')
434 ok = VRSetIni( "Options", "BigIcons", \VRGet("Menu_Options_MiniIcons","Checked"),OurINI)
435return
436
437/*:VRX _InstallerMode
438*/
439_InstallerMode:
440 ok = VRSet("Main", "Visible", 1)
441 window = VRLoadSecondary( "Installer", "W" )
442 ok = VRSet("Main", "Visible", 1)
443return
444
445/*:VRX _LMHostsImport
446*/
447_LMHostsImport:
448 hosts = ETC'\hosts'
449 lmhosts = ETC'\samba\lmhosts'
450
451 ok = SysFileDelete(lmhosts)
452
453 call lineout lmhosts,'# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
454 call lineout lmhosts,'# Syntax:'
455 call lineout lmhosts,'# IP-address NetBIOS-name'
456
457 do until lines(hosts) = 0
458 hostsline = linein(hosts)
459 parse var hostsline IP FQDN Alias
460 parse var FQDN hostname'.'domain
461 if IP <> '127.0.0.1' then do
462 say left(IP, 25)||hostname
463 call lineout lmhosts, left(IP, 25)||hostname
464 end
465 end
466
467 ok = stream(hosts,'c','close')
468 ok = stream(lmhosts,'c','close')
469 Msg.Text = NLVGetMessage(50, lmhosts)
470 msg.Type = 'I'
471 call _ShowMsg
472return
473
474/*:VRX _LoadOtherFuncs
475*/
476_LoadOtherFuncs:
477 if options.!Debug = 1
478 then ok = VRREdirectStdIO("ON")
479 else ok = VRREdirectStdIO("OFF")
480
481 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
482 call SysLoadFuncs
483
484 call rxfuncadd 'IniLoadFuncs', 'REXXINI', 'IniLoadFuncs'
485 call IniLoadFuncs
486
487 call RxFuncAdd 'PRLoadFuncs', 'PR1UTIL', 'PRLoadFuncs'
488 call PRLoadFuncs
489
490 /* Deal with DRCtrlxxx */
491 RC = RxFuncQuery("DRCtrlPickDirectory")
492 if RC = 1 then do /* DRCtrlXXX not already registered */
493 /* Load DRCtrl functions */
494 ok = RxFuncAdd('DRCtrlLoadFuncs', 'drctl017', 'DRCtrlLoadFuncs')
495 if ok = 0 then CALL DRCtrlLoadFuncs
496 end
497return
498
499/*:VRX _MasterPasswdCreate
500*/
501_MasterPasswdCreate:
502 call lineout samba.!masterpasswd, '# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)
503 call lineout samba.!masterpasswd, '# syntax:'
504 call lineout samba.!masterpasswd, '# username:passwd:UID:GID:login-class:chg pw x sec:deact x sec:GECOS:home:shell'
505 call lineout samba.!masterpasswd, 'root:*:0:513::0:0:root:/nonexistent:/usr/sbin/nologin'
506 call lineout samba.!masterpasswd, 'guest:*:65534:65534::0:0:guest:/nonexistent:/usr/sbin/nologin'
507 ok = stream(samba.!masterpasswd,'c','close')
508return
509
510/*:VRX _MsgYesNo
511*/
512_MsgYesNo:
513 IF options.!debug == 1 THEN say '_MsgYesNo() started'
514 IF options.!debug == 1 THEN say ' Msgbox:"'Msg.Text'"'
515 buttons.0 = 2
516 buttons.1 = NLVGetMessage('6')
517 buttons.2 = NLVGetMessage('7')
518 default = 2
519 buttons.default = buttons.2
520 esc = 2
521 buttons.esc = buttons.2
522 RC = VRMessage( VRWindow(), Msg.Text, Msg.Title,"Q","buttons.",default, esc )
523 IF options.!debug == 1 THEN say ' Answer: 'RC' ( 1 = Yes, 2 = No)'
524 IF options.!debug == 1 THEN say '_MsgYesNo() done'
525return RC
526
527/*:VRX _MyIniEnum
528*/
529_MyIniEnum: procedure expose sections. Voc. Val.
530 CurSection = arg(1)
531 do I = 1 to sections.0
532 say I':'sections.I
533 if sections.I = Cursection then leave
534 end
535 if I <= sections.0 then do
536 say 'sections.'I'.0='sections.I.0
537 Voc.0 = sections.I.0
538 Val.0 = sections.I.0
539 do J = 1 to Voc.0
540 parse var sections.I.J Voc.J'='Val.J
541 Voc.J = strip(Voc.J)
542 Val.J = strip(Val.J)
543 end
544 end
545return
546
547/*:VRX _MyIniEnumSections
548*/
549_MyIniEnumSections: procedure expose sections.
550 say '_MyIniEnumSections() started'
551 smbconf = arg(1)
552 sections. = ""
553 I = 0
554 J = 0
555 do until lines(smbconf) = 0
556 smbconfline = strip(translate(linein(smbconf),' ','09'x))
557 select
558 when left(smbconfline,1) =' ' then nop /* empty line */
559 when left(smbconfline,1) =';' then nop /* Comment */
560 when left(smbconfline,1) ='#' then nop /* Comment */
561 when left(smbconfline,1) ='[' then do /* Section */
562 sections.I.0 = J
563 I = I + 1
564 J = 0
565 parse var smbconfline '['CurSection']'
566 sections.I = CurSection
567 say ' 'CurSection
568 end
569 otherwise do /* Option */
570 parse var smbconfline option'='value
571 J = J + 1
572 sections.I.J = smbconfline
573 option = translate(strip(option),'_!?',' :$')
574 value = strip(value)
575 OptStr = CurSection'.'option'="'Value'"'
576 /* say OptStr */
577 end
578 end
579 end
580 sections.0 = I
581 sections.I.0 = J
582 ok = stream(smbconf,'c','close')
583 say '_MyIniEnumSections() done.'
584return
585
586/*:VRX _NLVSetup
587*/
588_NLVSetup:
589 call NLVSetup
590RETURN
591/*:VRX _ParseCommandLine
592*/
593_ParseCommandLine:
594 IF options.!debug == 1 THEN SAY "_ParseCommandLine() started"
595 CmdLine = VRGet("Application","Commandline")
596 IF options.!debug == 1 THEN SAY ' original commandline ="'CmdLine'"'
597 upCmdLine = translate(CmdLine)
598
599 InstPos = pos('/INSTALL',upCmdLine)
600
601 if InstPos > 0 then do
602 IF options.!debug == 1 THEN SAY " /install switch detected"
603 InstallMode = 1
604 end
605 IF options.!debug == 1 THEN SAY "_ParseCommandLine() done"
606return
607
608/*:VRX _PrintCapCreate
609*/
610_PrintCapCreate:
611 ok = SysFileDelete(samba.!printcap)
612 ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
613 call lineout samba.!printcap, '# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
614 call lineout samba.!printcap, '# syntax:'
615 call lineout samba.!printcap, '# Printerqueue|printername'
616 do I = 1 to printers.0
617 queue = printers.I
618 name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
619 call lineout samba.!printcap, queue'|'name
620 end
621 ok = stream(samba.!printcap,'c','close')
622return
623
624/*:VRX _SambaCheckComponents
625*/
626_SambaCheckComponents:
627 IF options.!debug == 1 THEN say '_SambaCheckComponents() started'
628
629 /* set deprecated variables */
630 smbconf = samba.!smbconf
631 printcap = samba.!printcap
632
633 /* detect presence of several components and act accordingly */
634 SmbConfExists = VRFileExists(samba.!smbconf)
635 IF options.!debug == 1 THEN say ' Does "'smbconf'" exist? 'SmbConfExists' (1=Yes, 0=No)'
636
637 IsCupsPrintcap = 0
638 if VRFileExists(samba.!printcap) then do
639 printcapline = translate(linein(samba.!printcap))
640 if pos("CUPS",printcapline) > 0 then IsCupsPrintcap = 1
641 ok = stream(samba.!printcap,'c','close')
642 end
643 IF options.!debug == 1 THEN say ' Is printcap from CUPS? 'IsCupsPrintcap' (1=Yes, 0=No)'
644
645 if \VRFileExists(samba.!smbcmd) then do
646 Msg.Title = NLVGetMessage('1')
647 Msg.Type = "E"
648 Msg.Text = NLVGetMessage(53, samba.!smbcmd)' - 'NLVGetMessage(55)
649 call _ShowMsg
650 ManageDaemons = 0
651 end
652 IF options.!debug == 1 THEN say ' Is "'samba.!smbcmd'" present, able to manage daemons = 'ManageDaemons' (1=Yes, 0=No)'
653
654 if \VRFileExists(samba.!testparmexe) then do
655 Msg.Title = NLVGetMessage('1')
656 Msg.Text = NLVGetMessage(53,samba.!testparmexe)' - 'NLVGetMessage(54)
657 Msg.Type = "E"
658 call _ShowMsg
659 call Quit
660 end
661 IF options.!debug == 1 THEN say ' Is "'samba.!testparmexe'" present, continuing.'
662
663 if \VRFileExists(samba.!smbpasswdexe) then do
664 Msg.Title = NLVGetMessage('1')
665 Msg.Text = NLVGetMessage(53,samba.!smbpasswdexe)' - 'NLVGetMessage(54)
666 Msg.Type = "E"
667 call _ShowMsg
668 call Quit
669 end
670 IF options.!debug == 1 THEN say ' Is "'samba.!smbpasswdexe'" is present, continuing.'
671
672 if SmbConfExists then do
673 call _SmbConfBackup
674 if InstallMode then do
675 window = VRLoadSecondary( "RemoveConfig", "W" )
676 end
677 end
678
679 if \VRFileExists(swatusers) & swatauth = 1 & InstallMode = 0 then do
680 Msg.Text = NLVGetMessage(115, swatusers)
681 Msg.Type = "W"
682 call _ShowMsg
683 end
684 IF options.!debug == 1 THEN say ' Does "'samba.!smbconf'" still exist? 'SmbConfExists' (1=Yes, 0=No)'
685 IF options.!debug == 1 THEN say ' Running in InstallMode = 'InstallMode' (1=Yes, 0=No)'
686
687 IF options.!debug == 1 THEN say '_SambaCheckComponents() done'
688return
689
690
691/* Msg.Text = NLVGetMessage(56, samba.!smbconf)
692 Msg.Type = "Q"
693 ok = _MsgYesNo()
694 if ok = 1 then do
695 ok = SysFileDelete(samba.!smbconf)
696 SmbConfExists = 0
697 Msg.Text = "Also reinitialize backend?" /* NLVGetMessage(56, samba.!smbconf) */
698 Msg.Type = "Q"
699 ok = _MsgYesNo()
700 if ok = 1 then do
701 ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
702 do I = 1 to xdb.0
703 ok = SysFileDelete(xdb.I)
704 if ok <> 0 then do
705 Msg.Text = "Error "ok" deleting "xdb.I"!"
706 Msg.Type = "W"
707 call _ShowMsg
708 end
709 end
710 end
711 end
712 else InstallMode = 0
713 */
714/*:VRX _SambaGroupMapInst
715*/
716_SambaGroupMapInst:
717 IF options.!debug == 1 THEN SAY "_SambaGroupMapInst() started"
718 /* These group mappings are obligatory */
719 IF options.!debug == 1 THEN SAY " Mapping Required domain groups"
720 address cmd samba.!netexe' groupmap add rid=512 ntgroup="Domain Admins" unixgroup="admin" type=domain comment="Domain Administrators"'
721 address cmd samba.!netexe' groupmap add rid=513 ntgroup="Domain Users" unixgroup="users" type=domain comment="Domain Users"'
722 address cmd samba.!netexe' groupmap add rid=514 ntgroup="Domain Guests" unixgroup="guests" type=domain comment="Domain Guests"'
723
724 /* These group mappings are optional */
725 IF options.!debug == 1 THEN SAY " Mapping Optional domain groups"
726 address cmd samba.!netexe' groupmap add rid=515 ntgroup="Domain Computers" unixgroup="machines" type=domain comment="Domain Computers"'
727 address cmd samba.!netexe' groupmap add rid=516 ntgroup="Domain Controllers" unixgroup="dc" type=domain comment="Domain Controllers"'
728 address cmd samba.!netexe' groupmap add rid=517 ntgroup="Domain Certificate Admins" unixgroup="certadmin" type=domain comment="Domain Certificate Administrators"'
729 address cmd samba.!netexe' groupmap add rid=518 ntgroup="Domain Schema Admins" unixgroup="schemeadmin" type=domain comment="Domain Schema Administrators"'
730 address cmd samba.!netexe' groupmap add rid=519 ntgroup="Domain Enterprise Admins" unixgroup="entadmin" type=domain comment="Domain Enterprise Administrators"'
731 address cmd samba.!netexe' groupmap add rid=520 ntgroup="Domain Policy Admins" unixgroup="poladmin" type=domain comment="Domain Policy Administrators"'
732
733 /* The following ones are unsupported at the moment - use at your own risk */
734 /*
735 IF options.!debug == 1 THEN SAY say " Mapping Builtin groups"
736 address cmd samba.!netexe' groupmap add rid=544 ntgroup="Builtin Admins" unixgroup="ntadmin" type=builtin
737 address cmd samba.!netexe' groupmap add rid=545 ntgroup="Builtin Users" unixgroup="ntusers" type=builtin
738 address cmd samba.!netexe' groupmap add rid=546 ntgroup="Builtin Guests" unixgroup="ntguests" type=builtin
739 address cmd samba.!netexe' groupmap add rid=547 ntgroup="Builtin Power Users" unixgroup="" type=builtin
740 address cmd samba.!netexe' groupmap add rid=548 ntgroup="Builtin Account Operators" unixgroup="" type=builtin
741 address cmd samba.!netexe' groupmap add rid=549 ntgroup="Builtin System Operators" unixgroup="operator" type=builtin
742 address cmd samba.!netexe' groupmap add rid=550 ntgroup="Builtin Print Operators" unixgroup="lp" type=builtin
743 address cmd samba.!netexe' groupmap add rid=551 ntgroup="Builtin Backup Operators" unixgroup="backup" type=builtin
744 address cmd samba.!netexe' groupmap add rid=552 ntgroup="Builtin Replicator" unixgroup="" type=builtin
745 address cmd samba.!netexe' groupmap add rid=553 ntgroup="Builtin RAS Servers" unixgroup="" type=builtin
746 */
747 IF options.!debug == 1 THEN SAY "_SambaGroupMapInst() done"
748return
749
750/*:VRX _SambaGuestCreate
751*/
752_SambaGuestCreate:
753 IF options.!debug == 1 THEN say "_SambaGuestCreate() started"
754 IF options.!debug == 1 THEN say ' 'samba.!smbpasswdexe' -a guest -n'
755 samba.!smbpasswdexe' -a guest -n -D 0 2>'samba.!error' 1>'samba.!message
756
757 if rc = 0 then call _SambaShowMsg
758 else call _SambaShowError
759
760 IF options.!debug == 1 THEN say "_SambaGuestCreate() done"
761return
762
763/*:VRX _SambaRootPWCheck
764*/
765_SambaRootPWCheck:
766 if VRGet("EF_RootPassword","Value") ="" then do
767 Msg.type = "E"
768 Msg.Text = NLVGetMessage(57, "root")
769 call _ShowMsg
770 return 0
771 end
772 if VRGet("EF_RootPassword_repeat","Value") ="" then do
773 Msg.type = "E"
774 Msg.Text = NLVGetMessage(58,"root")
775 call _ShowMsg
776 return 0
777 end
778
779 if VRGet("EF_RootPassword","Value") <> VRGet("EF_RootPassword_repeat","Value") then do
780 Msg.type = "E"
781 Msg.Text = NLVGetMessage(59, "root")
782 call _ShowMsg
783 return 0
784 end
785return 1
786
787/*:VRX _SambaRootPWSet
788*/
789_SambaRootPWSet:
790 IF options.!debug == 1 THEN say "_SambaRootPWSet() started"
791
792 /* Write root password to a temp file */
793 pwdfile = TempDir'newpwd'
794 call lineout pwdfile, VRGet("EF_RootPassword","value")
795 call lineout pwdfile, VRGet("EF_RootPassword","value")
796 ok = stream(pwdfile,"c","close")
797
798 /* Create the root account */
799 IF options.!debug == 1 THEN say ' 'samba.!smbpasswdexe' -a root -s <'pwdfile
800 samba.!smbpasswdexe' -a root -s -D 0 <'pwdfile' 2>'samba.!error' 1>'samba.!message
801
802 if rc = 0 then call _SambaShowMsg
803 else call _SambaShowError
804
805 /* Remove the temp password file */
806 ok = SysFileDelete(pwdfile)
807
808 /* Deal with swat */
809 /* FixMe: We do not need htpasswd.exe anymore as we use rxcrypt.dll */
810 if swatauth then do
811 /* we always remove the old swat */
812 say ' 'samba.!htpasswdexe' -D "'swatusers'" root'
813 address cmd samba.!htpasswdexe' -D "'swatusers'" root' /* ' 2>'samba.!error' 1>'samba.!msg
814 if rc <> 0 then call _SambaShowError; else call _SambaShowMsg */
815
816 if VRFileExists(swatusers) then cFlag = ""; else cFlag="c"
817 say ' 'samba.!htpasswdexe' -b'cFLag' "'swatusers'" root **********'
818 address cmd samba.!htpasswdexe' -b'cFlag' "'swatusers'" root 'VRGet("EF_RootPassword","value") /* ' 2>'samba.!error' 1>'samba.!msg
819 if rc <> 0 then call _SambaShowError
820 else call _SambaShowMsg */
821 end
822 IF options.!debug == 1 THEN say "_SambaRootPWSet() done"
823return
824
825/*:VRX _SambaShowError
826*/
827_SambaShowError: procedure expose samba. settings. options.
828 I = 0
829 do while lines(samba.!error) <> 0
830 I = I + 1
831 smberr.I = linein(samba.!error)
832 say I':err:'smberr.I
833 end
834 ok = stream(Samba.!error,"c","close")
835 ok = SysFileDelete(Samba.!error)
836 smberr.0 = I
837 /* we did not get any error text */
838 if smberr.0 = 0 then return
839 Buttons.1 = "OK"
840 Buttons.0 = 1
841 id = VRMessageStem( VRWindow(), "smberr.", VRGet("Main", "Caption") , "Error", "Buttons.", buttons.1, buttons.1 )
842return
843
844/*:VRX _SambaShowMsg
845*/
846_SambaShowMsg: procedure expose samba. settings. options.
847 I = 0
848 do while lines(samba.!message) <> 0
849 I = I + 1
850 smbmsg.I = linein(samba.!message)
851 say I':msg:'smbmsg.I
852 end
853 ok = stream(Samba.!message,"c","close")
854 ok = SysFileDelete(Samba.!message)
855 smbmsg.0 = I
856 /* we did not get any message */
857 if smbmsg.0 = 0 then return
858 Buttons.1 = "OK"
859 Buttons.0 = 1
860 id = VRMessageStem( VRWindow(), "smbmsg.", VRGet("Main", "Caption") , "I", "Buttons.", buttons.1, buttons.1 )
861return
862/*:VRX _SambaUserCreate
863*/
864_SambaUserCreate:
865 eCSUser = value("USER",,"OS2ENVIRONMENT")
866 HostName = value("HOSTNAME",,"OS2ENVIRONMENT")
867 if translate(eCSUser) = translate(Hostname) then do
868 Msg.Text = NLVGetMessage(118, eCSUser)
869 Msg.Type = "I"
870 call _ShowMsg
871 end
872 if translate(eCSUser) <> "root" & translate(eCSUser) <> "guest" then do
873 Msg.Text = NLVGetMessage(75, eCSUser)
874 Msg.Type = "I"
875 call _ShowMsg
876 end
877return
878
879/*:VRX _SambaVersion
880*/
881_SambaVersion:
882 say "_SambaVersion() started"
883 address cmd samba.!smbd' -V >'samba.!msg
884 samba.!version = linein(samba.!msg)
885 say " Samba "samba.!version
886 ok = stream(samba.!msg,"c","close")
887 say "_SambaVersion() done"
888return
889
890/*:VRX _SaveChanges
891*/
892_SaveChanges:
893 say '_SaveChanges() started for ['CurSection']'
894
895 do I = 1 to words(ChangeList)
896 ChangeObj = word(ChangeList,I)
897 say "Changed object: "ChangeObj
898
899 parse var ChangeObj ChangeObjType '_' ChangeVoc
900
901 ChangeVoc = translate(ChangeVoc, ' ', '_')
902 say "Changed voc: "ChangeVoc
903 VocIdx = VRGet(ChangeObj,'Userdata')
904 if ChangeObjType = "EF" then do
905
906 NewVal = VRGet(ChangeObj, 'Value')
907 parse var sections.CurSIdx.VocIdx OldVoc'='OldVal
908 OldVoc = strip(oldVoc)
909 sections.CurSIdx.VocIdx = OldVoc' = 'NewVal
910
911 if VRGet(ChangeObj, 'Value') <> "" then do
912 select
913 when pos("\\", VRGet(ChangeObj, 'Value')) > 0 then ok = IniSet(ChangeVoc, VRGet(ChangeObj, 'Value'), CurSection, samba.!smbconf)
914 when pos(" dir", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
915 when pos("file", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
916 when pos("path", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
917/* when pos("command",ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf) */
918/* when pos("script", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf) */
919 otherwise ok = IniSet(ChangeVoc, VRGet(ChangeObj, 'Value'), CurSection, samba.!smbconf)
920 end
921 say "INISet ok = "ok
922 end
923 else do
924 ok = IniDel( ChangeVoc, CurSection, samba.!smbconf )
925 say "INIDel ok = "ok
926 if ok = "" then ok = 0
927 end
928 end
929 if ChangeObjType = "CB" then do
930 If VRGet(ChangeObj, 'Set') then BoolVal = "Yes"; else BoolVal = "No"
931
932 parse var sections.CurSIdx.VocIdx OldVoc'='OldVal
933 OldVoc = strip(oldVoc)
934 sections.CurSIdx.VocIdx = OldVoc' = 'BoolVal
935
936 ok = IniSet(ChangeVoc, BoolVal, CurSection, samba.!smbconf)
937 say "INISet ok = "ok" (Bool)"
938 end
939 end
940
941 if ok = 0 then do
942 Msg.Type = "I"
943 Msg.Text = NLVGetMessage(51)
944 end
945 else do
946 Msg.Type = "E"
947 Msg.Text = NLVGetMessage(52)
948 end
949 call _ShowMsg
950
951 call TM_Value_Trigger
952
953 say '_SaveChanges() done'
954return
955/*:VRX _ShareObject_Changed
956*/
957_ShareObject_Changed:
958 say "_ShareObject_Changed() started"
959 ValueChanged = 1
960 if pos(VRGet(VRInfo("OBject"),"Name"), ChangeList) = 0 then Changelist = ChangeList' 'VRGet(VRInfo("OBject"),"Name")
961 ok = VRSet("PB_Save", "Enabled", 1)
962 say " ValueChanged = "ValueChanged
963 say Changelist
964 say "_ShareObject_Changed() done"
965return
966
967/*:VRX _SharesReset
968*/
969_SharesReset:
970 say '_SharesReset started'
971 ok = VRset("EF_path", "Value","")
972 ok = VRFlush( , "EF_path" )
973 ok = VRset("CB_Browseable", "Set", 1)
974 ok = VRFlush( , "CB_Browseable" )
975 ok = VRset("CB_Read_Only", "Set", 0)
976 ok = VRFlush( , "CB_Read_Only")
977 ok = VRset("CB_Guest_OK", "Set", 0)
978 ok = VRFlush( , "CB_Guest_OK" )
979 do I = 1 to CreatedObjs.0
980 ok = VRDestroy(CreatedObjs.I)
981 end
982 say '_SharesReset done'
983return
984
985/*:VRX _ShowMsg
986*/
987_ShowMsg:
988 Buttons.1 = "OK"
989 Buttons.0 = 1
990 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
991return
992
993/*:VRX _Smb35Init
994*/
995_Smb35Init:
996 IF options.!debug == 1 THEN say '_Smb35Init() started'
997 say '1 -> 'samba.!smbpasswdexe' -a dummyuser -n -D 10'
998 address cmd samba.!smbpasswdexe' -a dummyuser -n -D 10'
999 say '2 -> 'samba.!smbpasswdexe' -x dummyuser -D 10'
1000 address cmd samba.!smbpasswdexe' -x dummyuser -D 10'
1001 say '3 -> 'samba.!pdbeditexe' --policies-reset -d=3'
1002 address cmd samba.!pdbeditexe' --policies-reset -d=3'
1003 say 'X -> ----------------------'
1004 IF options.!debug == 1 THEN say '_Smb35Init() done'
1005return
1006
1007/*:VRX _SmbConfBackup
1008*/
1009_SmbConfBackup:
1010 ok = VRCopyFile( SmbConf, SmbConf"-backup" )
1011return
1012
1013/*:VRX _SmbConfCommitChanges
1014*/
1015_SmbConfCommitChanges:
1016 IF options.!debug == 1 THEN say '_SmbConfCommitChanges() started'
1017
1018 src = TempDir'smb.conf'
1019 if stream(src,'c','query size') = 0 then do
1020 ok = VRCopyFile(smbconf,src)
1021 end
1022 trg = smbconf
1023 ok = SysFileDelete(smbconf)
1024 call lineout trg, '# Samba config file created using SSCC ver. 'word(VRGet("Main","Hinttext"),2)
1025 call lineout trg, '# from 'value("USER",,'OS2ENVIRONMENT')'@'value("HOSTNAME",,'OS2ENVIRONMENT')
1026 call lineout trg, '# Date: 'date()' 'time()
1027 lct = 0
1028 do until lines(src) = 0
1029 smbline = linein(src)
1030 if pos("idmap uid",smbline) > 0 then iterate
1031 if pos("idmap gid",smbline) > 0 then iterate
1032 if pos("winbind separator",smbline) > 0 then iterate
1033 if pos("copy ",smbline) > 0 then iterate
1034 call lineout trg, smbline
1035 lct = lct + 1
1036 end
1037 say "Lines saved "lct
1038 ok = stream(trg,'c','close')
1039 ok = stream(src,'c','close')
1040 ok = SysFileDelete(src)
1041 IF options.!debug == 1 THEN say '_SmbConfCommitChanges() done'
1042return
1043
1044/*:VRX _SmbConfCreateDefault
1045*/
1046_SmbConfCreateDefault:
1047 ok = SysFileDelete(smbconf)
1048
1049 /* Create a basic smb.conf */
1050 call _SmbConfDefault_Global
1051 call _SmbConfDefault_Scripts
1052 if CreatePDC then do
1053 call _SmbConfDefault_NetLogon
1054 call _SmbConfDefault_Profiles
1055 end
1056 call _SmbConfDefault_Homes
1057 call _SmbConfDefault_SharePrinters
1058 call _SmbConfDefault_ShareDrives
1059 ok = stream(smbconf,'c','close')
1060return
1061
1062/*:VRX _SmbConfCreateDefault_OldInstall
1063*/
1064_SmbConfCreateDefault_OldInstall:
1065 DriveList = SysDriveMap('C:','Local')
1066 ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
1067 ok = VRSet("EF_NetBIOS_Name","Value", Value("HOSTNAME",,"OS2ENVIRONMENT"))
1068
1069 DrivesOH.0 = 0
1070 do I = 1 to words(DriveList)
1071 CurDrive = word(DriveList,I)
1072 Filesys = SysFilesystemType(Curdrive)
1073 DriveInfo=SysDriveInfo(CurDrive)
1074 parse var DriveInfo DrvLet CurFree CurSize CurLabel
1075 curlabel = strip(Curlabel)
1076 CurFree = word(Driveinfo,2)
1077 CurSize = word(Driveinfo,3)
1078 if Curlabel = "" then Curlabel = '?'
1079
1080 if datatype(CurSize) = 'NUM' then do
1081 CurSize = CurSize/(1024*1024)
1082 CurFree = CurFree/(1024*1024)
1083
1084 CurSize = format(CurSize,,0)'MB'
1085 CurFree = format(CurFree,,0)'MB'
1086 end
1087 else do
1088 CurSize = '?'
1089 CurFree = '?'
1090 end
1091
1092/* DrivesOH.I = VRCreate( "GB_Drives", "CheckBox", "Name", "CB_"left(CurDrive,1), "Top", 120, "Left", 1325+(I-1)*420, "Visible", 1, "Caption", CurDrive, "AutoSize", 1, "set", 1, "Userdata", FileSys, "HintText", CurDrive' ('Curlabel', 'FileSys') size: 'CurSize', free: 'CurFree) */
1093 Shares.!drives.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,,left(CurDrive,1) ,"#4")
1094 if FileSys = '' | FileSys = 'CDFS' then do
1095/* ok = VRSet(DrivesOH.I, "ForeColor", "Red") */
1096 end
1097/* if CurDrive = SysBootDrive() then ok = VRSet(DrivesOH.I, "Set", 0)
1098 if CurDrive = translate(left(samba.!bin,2)) then ok = VRSet(DrivesOH.I, "Set", 0) */
1099 end
1100 DrivesOH.0 = I-1
1101
1102 PrintersOH.0 = 0
1103 Colum = 1325
1104 dx = 0
1105 do I = 1 to printers.0
1106 queue = printers.I
1107 name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
1108/* PrintersOH.I = VRCreate( "GB_printers", "CheckBox", "Name", "CB_"queue, "Top", 120+(I-1-dx)*250, "Left", Colum, "Visible", 1, "Caption", Name, "AutoSize", 1, "set", 1, "UserData", Queue) */
1109 Shares.!printers.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,,queue,"#6")
1110 if I = 6 then do
1111 Colum = 4000
1112 dx = 6
1113 end
1114 end
1115 PrintersOH.0 = I-1
1116return
1117
1118/*:VRX _SmbConfDefault_Global
1119*/
1120_SmbConfDefault_Global:
1121 Migrate = (arg(1) = 1)
1122 if \Migrate then do /* when migrating these 4 lines are there already */
1123 section = '[global]'
1124 call lineout smbconf, section
1125 call lineout smbconf, Indent||'workgroup = 'VRGet("EF_Workgroup_Initial","value")
1126 call lineout smbconf, Indent||'netbios name = 'value('HOSTNAME',,'OS2ENVIRONMENT')
1127 call lineout smbconf, Indent||'server string = %h Samba Server for eCS (OS/2)'
1128 call lineout smbconf, Indent||'comment = Samba Server for eCS (OS/2)'
1129 end
1130
1131 call lineout smbconf, Indent||'dos charset = IBM-850'
1132 call lineout smbconf, Indent||'display charset = IBM-850'
1133 call lineout smbconf, Indent||'unix charset = IBM-850'
1134
1135 CurCP = SysQueryProcessCodePage()
1136 if CurCP <> "850" then do
1137 Msg.Text = NLVGetMessage(117)
1138 Msg.Type = "W"
1139 call _ShowMsg
1140 end
1141 if UseTDBsam = 1 then do
1142 call lineout smbconf, Indent||'passdb backend = tdbsam'
1143 end
1144 call lineout smbconf, Indent||'log level = 2'
1145 call lineout smbconf, Indent||'log file = '||ETC||'\samba\log\log.smbd.%U.%M'
1146 call lineout smbconf, Indent||'null passwords = Yes'
1147 call lineout smbconf, Indent||'guest account = guest'
1148 call lineout smbconf, Indent||'security = user'
1149 call lineout smbconf, Indent||'load printers = No'
1150 call lineout smbconf, Indent||'time server = Yes'
1151 call lineout smbconf, Indent||'lock directory = '||ETC||'\samba\lock'
1152 /* This EA makes the testparm warning about browsing go away.
1153 Note: The EA is NOT marked critical as it should be,
1154 neverthelesse this fix works */
1155 ok = SysPutEA(ETC||'\samba\lock',"MODE", "FEFF0400ED410000"x)
1156 call lineout smbconf, Indent||'ea support = Yes'
1157 call lineout smbconf, Indent||'store dos attributes = Yes'
1158 call lineout smbconf, Indent||'lm announce = Yes'
1159 call lineout smbconf, Indent||'wins support = Yes'
1160 call lineout smbconf, Indent||'wide links = No'
1161 ok = SysFileTree(samba.!printcap,exist.,'FO')
1162 if exist.0 = 1 then do
1163 call lineout smbconf, Indent||'printcap name = 'samba.!printcap
1164 end
1165 samba.!smbusermap = ETC||'\samba\private\smbusermap'
1166 call lineout smbconf, Indent||'username map = 'samba.!smbusermap
1167 if \VRFileExists(samba.!smbusermap) then call _SmbUserMapCreate
1168 if CreatePDC then do
1169 call lineout smbconf, Indent||'local master = Yes'
1170 call lineout smbconf, Indent||'preferred master = Yes'
1171 call lineout smbconf, Indent||'domain master = Yes'
1172 call lineout smbconf, Indent||'os level = 65'
1173 call lineout smbconf, ';'Indent||'domain groups ='
1174 call lineout smbconf, ';'Indent||'domain admin group = '
1175 call lineout smbconf, Indent||'domain admin users = root'
1176 call lineout smbconf, Indent||'domain logons = Yes'
1177 call lineout smbconf, Indent||'logon home = \\%L\Profiles\%U'
1178 call lineout smbconf, Indent||'logon path = \\%L\Profiles\%U'
1179 call lineout smbconf, Indent||'logon drive = z:'
1180 call lineout smbconf, Indent||'logon script = %U.cmd'
1181 end
1182 else do
1183 call lineout smbconf, Indent||'create mask = 0777'
1184 end
1185 ok = stream(smbconf, 'c','close')
1186return
1187/*:VRX _SmbConfDefault_Homes
1188*/
1189_SmbConfDefault_Homes:
1190 /* Create Homes section */
1191 call lineout smbconf, '[HOMES]'
1192 call lineout smbconf, Indent||"comment = Home directory"
1193 smbhome = samba.!bin'\homes'
1194 Home = strip(value('Home',,'OS2ENVIRONMENT'),'T','\')
1195 if Home <> '' then do
1196 User = value('USER',,'OS2ENVIRONMENT')
1197 if User <> '' then do
1198 if translate(User) = translate(Filespec('N',Home)) | translate(Filespec('N',Home)) = "DEFAULT" then smbHome = strip(filespec('D',Home)||filespec('P',Home),'T','\')
1199 end
1200 end
1201 ok = SysMkDir(smbhome)
1202 call lineout smbconf, Indent||"path = "_bs2fs(smbhome)'/%u'
1203 call lineout smbconf, Indent||"read only = No"
1204 call lineout smbconf, Indent||"browseable = No"
1205 call lineout smbconf, Indent
1206 ok = stream(smbconf, 'c','close')
1207return
1208
1209/*:VRX _SmbConfDefault_Netlogon
1210*/
1211_SmbConfDefault_Netlogon:
1212 /* Create Netlogon section */
1213 call lineout smbconf, '[NETLOGON]'
1214 call lineout smbconf, Indent||"comment = Netlogon service"
1215 smbnetlogon = samba.!bin'\netlogon'
1216 ok = SysMkDir(smbnetlogon)
1217 call lineout smbconf, Indent||"path = "_bs2fs(smbnetlogon)
1218 call lineout smbconf, Indent||"read only = Yes"
1219 call lineout smbconf, Indent||"browseable = Yes"
1220 call lineout smbconf, Indent||"share modes = No"
1221 call lineout smbconf, Indent
1222 ok = stream(smbconf, 'c','close')
1223return
1224
1225/*:VRX _SmbConfDefault_Profiles
1226*/
1227_SmbConfDefault_Profiles:
1228 /* Create profiles section */
1229 call lineout smbconf, '[profiles]'
1230 call lineout smbconf, Indent||"comment = profiles"
1231 smbprofiles = samba.!bin'\profiles'
1232 ok = SysMkDir(smbprofiles)
1233 call lineout smbconf, Indent||"path = "_bs2fs(smbprofiles)
1234 call lineout smbconf, Indent||"profile acls = Yes"
1235 call lineout smbconf, Indent||"read only = No"
1236 call lineout smbconf, Indent||"browseable = Yes"
1237 call lineout smbconf, Indent||"create mask = 0777"
1238 call lineout smbconf, Indent||"directory mask = 0777"
1239 call lineout smbconf, Indent
1240 ok = stream(smbconf, 'c','close')
1241return
1242
1243/*:VRX _SmbConfDefault_Scripts
1244*/
1245_SmbConfDefault_Scripts:
1246 smbtools = samba.!bin
1247
1248 /* user scripts */
1249 call lineout smbconf, ';'||Indent||'user scripts'
1250 call lineout smbconf, Indent||'add user script = '||smbtools||'\usermod.cmd -a "%u"'
1251 call lineout smbconf, Indent||'delete user script = '||smbtools||'\usermod.cmd -x "%u"'
1252 call lineout smbconf, Indent||'rename user script = '||smbtools||'\usermod.cmd -r "%uold" "%unew"'
1253 call lineout smbconf, Indent||'add machine script = '||smbtools||'\usermod.cmd -a "%u"'
1254 call lineout smbconf, Indent||'set primary group script = '||smbtools||'\usermod.cmd -p "%u" "%g"'
1255
1256 /* group scripts */
1257 call lineout smbconf, ';'||Indent||'group scripts'
1258 call lineout smbconf, Indent||'add group script = '||smbtools||'\groupmod.cmd -a "%g"'
1259 call lineout smbconf, Indent||'delete group script = '||smbtools||'\groupmod.cmd -x "%g"'
1260 call lineout smbconf, Indent||'add user to group script = '||smbtools||'\groupmod.cmd -j "%g" "%u"'
1261 call lineout smbconf, Indent||'delete user from group script = '||smbtools||'\groupmod.cmd -l "%g" "%u"'
1262
1263 /* share scripts */
1264 call lineout smbconf, ';'||Indent||'share scripts'
1265 call lineout smbconf, Indent||'add share command = '||smbtools||'\addshare.cmd'
1266 call lineout smbconf, Indent||'change share command = '||smbtools||'\changeshare.cmd'
1267 call lineout smbconf, Indent||'delete share command = '||smbtools||'\delshare.cmd'
1268
1269 /* other scripts */
1270 call lineout smbconf, ';'||Indent||'other scripts'
1271 call lineout smbconf, Indent||'enumports command = '||smbtools||'\enumports.cmd'
1272 call lineout smbconf, Indent
1273 call lineout smbconf
1274 ok = stream(smbconf, 'c','close')
1275return
1276
1277/*:VRX _SmbConfDefault_ShareDrives
1278*/
1279_SmbConfDefault_ShareDrives:
1280 DriveList = SysDriveMap('C:','Local')
1281
1282 do I = 1 to words(DriveList)
1283 CurDrive = word(DriveList,I)
1284say CurDrive
1285 Filesys = SysFilesystemType(Curdrive)
1286 DriveInfo=SysDriveInfo(CurDrive)
1287 parse var DriveInfo DrvLet CurFree CurSize CurLabel
1288
1289 if FileSys = '' | FileSys = 'CDFS' then do
1290 read_write = 'read only = Yes'
1291 end
1292 else do
1293 read_write = 'read only = No'
1294 end
1295 if FileSys = '' then FileSys = 'CDFS'
1296
1297 section = '['left(curdrive,1)']'
1298 comment = 'comment = 'Drive' 'CurDrive' ('FileSys')'
1299 path = 'path = 'Curdrive'/'
1300 guest_ok = 'guest ok = Yes'
1301 hide_files = 'hide files = /*. SF/root/'
1302
1303 call lineout smbconf, section
1304 call lineout smbconf, Indent||comment
1305 call lineout smbconf, Indent||path
1306 call lineout smbconf, Indent||read_write
1307 call lineout smbconf, Indent||guest_ok
1308 call lineout smbconf, Indent||hide_files
1309 call lineout smbconf, Indent
1310 end
1311 ok = stream(smbconf, 'c','close')
1312return
1313
1314/* browsable = 'browsable = Yes'
1315 printable = 'printable = No'
1316 public = 'public = Yes'
1317 call lineout smbconf, Indent||browsable
1318 call lineout smbconf, Indent||printable
1319 call lineout smbconf, Indent||public */
1320/*:VRX _SmbConfDefault_SharePrinters
1321*/
1322_SmbConfDefault_SharePrinters:
1323 ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
1324
1325 do I = 1 to printers.0
1326 queue = printers.I
1327 name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
1328
1329/* call lineout samba.!printcap, queue'|'name */
1330
1331 section = '['queue']'
1332 path = 'path = 'ETC'\samba\spool\'queue
1333 ok = SysMkDir(ETC'\samba\spool\'queue)
1334 comment = 'comment = 'name
1335 create_mask = 'create mask = 0700'
1336 guest_ok = 'guest ok = Yes'
1337
1338 printable = 'printable = Yes'
1339 print_command = 'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
1340 printer_name = 'printer name = 'queue
1341
1342 call lineout smbconf, section
1343 call lineout smbconf, Indent||comment
1344 call lineout smbconf, Indent||path
1345 call lineout smbconf, Indent||create_mask
1346 call lineout smbconf, Indent||printable
1347 call lineout smbconf, Indent||print_command
1348 call lineout smbconf, Indent||printer_name
1349 call lineout smbconf, Indent||guest_ok
1350
1351 call lineout smbconf, Indent
1352
1353 end
1354 ok = stream(smbconf, 'c','close')
1355 ok = stream(samba.!printcap,'c','close')
1356return
1357
1358/* browsable = 'browsable = Yes'
1359 call lineout smbconf, Indent||browsable */
1360/*:VRX _SmbConfLoad
1361*/
1362_SmbConfLoad:
1363 IF options.!debug == 1 THEN say '_SmbConfLoad() started'
1364 IF options.!debug == 1 THEN say ' Loading "'samba.!smbconf'" ('stream(samba.!smbconf,'c','query size')' bytes)'
1365
1366/* ok = IniEnumSections(sections., samba.!smbconf) */
1367
1368 section. = ""
1369 sections.0 = 0
1370 call _MyIniEnumSections(samba.!smbconf)
1371
1372 special = 'global printers netlogon print$ homes profiles'
1373 Specialstatus.0 = sections.0
1374 PrintStatus.0 = sections.0
1375 sectionhandles.0 = sections.0
1376 recordhandle.0 = sections.0
1377
1378 do I = 1 to sections.0
1379 IF options.!debug == 1 THEN say ' ['sections.I'] section loaded'
1380 if wordpos(translate(sections.I),translate(special)) > 0 Then SpecialStatus.I = 1
1381 Else SpecialStatus.I = 0
1382 PrintRes = IniGet("Printable", sections.I, samba.!smbconf)
1383 if Translate(PrintRes) = "YES" | Translate(PrintRes) = "TRUE" then PrintStatus.I = 1
1384 else PrintStatus.I = 0
1385
1386 IF options.!debug == 1 THEN say ' ['sections.I'] status (special:'SpecialStatus.I', print:'Printstatus.I')'
1387 if Printstatus.I = 1 & SpecialStatus.I = 0 then do /* printer share */
1388 recordhandle.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,,sections.I,"#65:PMWP.DLL")
1389 ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"ReadOnly", 1)
1390 IF options.!debug == 1 THEN say ' ['sections.I'] added to shared printer tree'
1391 end
1392 if Printstatus.I = 0 & SpecialStatus.I = 0 then do /* directory share */
1393 recordhandle.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,, sections.I,"#64:PMWP.DLL")
1394 ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"ReadOnly", 1)
1395 IF options.!debug == 1 THEN say ' ['sections.I'] added to shared folder tree'
1396 end
1397 if translate(sections.I) = 'PROFILES' then do
1398 recordhandle.I = smbconf.!profiles
1399 ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
1400 end
1401 if translate(sections.I) = 'NETLOGON' then do
1402 recordhandle.I = smbconf.!netlogon
1403 ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
1404 end
1405 if translate(sections.I) = 'HOMES' then do
1406 recordhandle.I = smbconf.!homes
1407 ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
1408 end
1409 if translate(sections.I) = 'GLOBAL' then recordhandle.I = smbconf.!global
1410 end
1411 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!root, "Collapsed", 0 )
1412 IF options.!debug == 1 THEN say '_SmbConfLoad() done'
1413return
1414
1415
1416/* if VRGet("DT_AlreadySmbConf","Visible") then do
1417 smbline = strip(translate(linein(smbconf),' ','09'x))
1418
1419 do while translate(left(smbline,8)) <> "[GLOBAL]"
1420 smbline = strip(translate(linein(smbconf),' ','09'x))
1421 end
1422
1423 do until left(smbline,1) = '['
1424 smbline = strip(translate(linein(smbconf),' ','09'x))
1425 parse var smbline voc '=' val
1426 voc = strip(voc)
1427 val = strip(val)
1428 if translate(voc) = "WORKGROUP" then do
1429 ok = VRset("EF_WorkGroup", "Value", val)
1430 ok = VRSet("EF_WorkGroup", "BackColor", "(255,255,180)")
1431 end
1432 if translate(voc) = "NETBIOS NAME" then do
1433 ok = VRset("EF_NetBIOS_Name", "Value", val)
1434 ok = VRSet("EF_NetBIOS_Name", "BackColor", "(255,255,180)")
1435 end
1436 if translate(voc) = "SERVER STRING" then do
1437 ok = VRset("EF_Server_String", "Value", val)
1438 ok = VRSet("EF_server_string", "BackColor", "(255,255,180)")
1439 end
1440
1441 end
1442 ok = stream(smbconf, 'c','close')
1443 end */
1444
1445/*:VRX _SmbConfMigratePeer
1446*/
1447_SmbConfMigratePeer:
1448 Ok = SysFileDelete(smbconf)
1449 /* Migrate Peer To Samba */
1450
1451 /* IBMLAN.INI part */
1452 ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1453
1454 do while translate(left(ibmlanline,11)) <> "[REQUESTER]"
1455 ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1456 end
1457
1458 call lineout smbconf, '[global]'
1459 do until left(ibmlanline,1) = '['
1460 ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1461 parse var ibmlanline voc '=' val
1462 voc = strip(voc)
1463 val = strip(val)
1464 if translate(voc) = "DOMAIN" then do
1465 call lineout smbconf, Indent||'workgroup = 'val
1466 end
1467 if translate(voc) = "COMPUTERNAME" then do
1468 call lineout smbconf, Indent||'netbios name = 'val
1469 end
1470 end
1471 do while translate(left(ibmlanline,6)) <> '[PEER]'
1472 ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1473 end
1474 do until left(ibmlanline,1) = '[' | lines(ibmlanini) = 0
1475 ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1476 parse var ibmlanline voc '=' val
1477 voc = strip(voc)
1478 val = strip(val)
1479 if translate(voc) = "SRVCOMMENT" then do
1480 call lineout smbconf, Indent||'server string = 'val
1481 call lineout smbconf, Indent||'comment = 'val
1482 end
1483 end
1484 call _SmbConfDefault_Global 1 /* 1 = migration mode */
1485
1486 call _SmbConfDefault_Scripts
1487 if CreatePDC then do
1488 call _SmbConfDefault_NetLogon
1489 call _SmbConfDefault_Profiles
1490 end
1491 call _SmbConfDefault_Homes
1492
1493 /* LSSHARE.INI part */
1494
1495 ok = SysINI(lsshareini,"ALL:","Shares." )
1496 SharePath.0 = shares.0
1497 Comment.0 = shares.0
1498 Type.0 = shares.0
1499
1500 ok = VRMethod( "Application", "ListPrinters", "printer." )
1501
1502 do I = 1 to shares.0
1503 call lineout smbconf, '['Shares.I']'
1504 sharepath.I = SysINI(lsshareini, shares.I, 'Path')
1505 Type.I = c2d(left(SysINI(lsshareini, shares.I, 'Type'),1))
1506 if Type.I = '1' then do /* We migrate a printer */
1507 do J = 1 to printer.0
1508 parse var printer.J PrinterName';'PrinterQueue';'PrinterDriver
1509 if PrinterQueue = Sharepath.I then leave
1510 end
1511 call lineout smbconf, Indent||'path = '_bs2fs(ETC'\samba\spool\'printerqueue)
1512 ok = SysMkDir(ETC'\samba\spool\'printerqueue)
1513 call lineout smbconf, Indent||'comment = 'Printername
1514 call lineout smbconf, Indent||'create mask = 0700'
1515 call lineout smbconf, Indent||'printer name = 'printerqueue
1516 call lineout smbconf, Indent||'printing = os2'
1517 call lineout smbconf, Indent||'printable = Yes'
1518 call lineout smbconf, Indent||'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
1519 call lineout smbconf, Indent||'browseable = Yes'
1520 call lineout smbconf, Indent||'guest ok = Yes'
1521 call lineout smbconf, Indent||'read only = No'
1522 end
1523 else do /* we migrate a folder */
1524 Comment.I = SysINI(lsshareini, shares.I, 'Remark')
1525 call lineout smbconf, Indent||'comment = 'Comment.I
1526 call lineout smbconf, Indent||'path = 'translate(Sharepath.I,'/','\')
1527 call lineout smbconf, Indent||'read only = No'
1528 call lineout smbconf, Indent||'browseable = Yes'
1529 call lineout smbconf, Indent||'hide files = /*. SF/root/'
1530 end
1531 call lineout smbconf, " "
1532 end
1533 ok = stream(smbconf,'c','close')
1534return
1535
1536/*:VRX _SmbConfRestore
1537*/
1538_SmbConfRestore:
1539 ok = VRCopyFile( SmbConf"-backup", SmbConf)
1540return
1541
1542/*:VRX _SmbConfShareRemove
1543*/
1544_SmbConfShareRemove:
1545 Aborted = 0
1546 ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "SelectedHandle." )
1547 if Selectedhandle.0 = 0 then return
1548 Msg.Title = NLVGetMessage(67)
1549 do I = 1 to sections.0
1550 if recordhandle.I = SelectedHandle.1 then do
1551 if recordhandle.I = smbconf.!homes | recordhandle.I = smbconf.!global then do
1552 Msg.Text = NLVGetMessage(61, Sections.I)
1553 Msg.Type = 'E'
1554 call _ShowMsg
1555 Aborted = 1
1556 return
1557 end
1558
1559 Msg.Text = NLVGetMessage(62, Sections.I)
1560 Msg.Type = "Q"
1561 ok = _MsgYesNo()
1562 if ok = 2 then return
1563
1564 NewSmbConf = TempDir'smb.conf'
1565 ok = SysFileDelete(NewSmbConf)
1566 smbline = strip(linein(smbconf))
1567 do while left(translate(smbline),length(sections.I)+2) <> translate('['sections.I']')
1568 call lineout NewSmbConf, smbline
1569 smbline = strip(linein(smbconf))
1570 end
1571 smbline = strip(linein(smbconf))
1572 do while left(translate(smbline),1) <> '[' & lines(smbconf) <> 0
1573 smbline = strip(linein(smbconf))
1574 end
1575 do until lines(smbconf) = 0
1576 call lineout NewSmbConf, smbline
1577 smbline = strip(linein(smbconf))
1578 end
1579 call lineout NewSmbConf, smbline
1580 ok = stream(smbconf, 'c', 'close')
1581 ok = stream(Newsmbconf, 'c', 'close')
1582 ok = VRCopyFile( NewSmbConf, smbconf )
1583 end
1584 end
1585 call _SmbConfTreeReset
1586
1587 if _SambaRunning() then do
1588 Msg.Text = NLVGetMessage(69)
1589 Msg.Type = 'I'
1590 call _ShowMsg
1591 end
1592return
1593
1594/*:VRX _SmbConfShareRename
1595*/
1596_SmbConfShareRename:
1597 Aborted = 0
1598 ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "SelectedHandle." )
1599 if Selectedhandle.0 = 0 then return
1600
1601 do I = 1 to sections.0
1602 if recordhandle.I = SelectedHandle.1 then do
1603 if recordhandle.I = smbconf.!homes | recordhandle.I = smbconf.!global then do
1604 Msg.Text = NLVGetMessage(66, Sections.I)
1605 Msg.Type = 'E'
1606 call _ShowMsg
1607 Aborted = 1
1608 return
1609 end
1610 Buttons.1 = NLVGetMessage(2)
1611 Buttons.2 = NLVGetMessage(3)
1612 Buttons.0 = 2
1613 NewShareName = Sections.I
1614 id = VRPrompt( VRWindow(), NLVGetMessage(66), "NewShareName", NLVGetMessage(68), "Buttons.", buttons.1, buttons.2 )
1615 if ID = 2 | NewShareName = "" then return
1616
1617 NewSmbConf = TempDir'smb.conf'
1618 ok = SysFileDelete(NewSmbConf)
1619 smbline = strip(linein(smbconf))
1620 do while left(translate(smbline),length(sections.I)+2) <> translate('['sections.I']')
1621 call lineout NewSmbConf, smbline
1622 smbline = strip(linein(smbconf))
1623 end
1624 call lineout NewSmbConf, '['NewShareName']'
1625 smbline = strip(linein(smbconf))
1626 do until lines(smbconf) = 0
1627 call lineout NewSmbConf, smbline
1628 smbline = strip(linein(smbconf))
1629 end
1630 call lineout NewSmbConf, smbline
1631 ok = stream(smbconf, 'c', 'close')
1632 ok = stream(Newsmbconf, 'c', 'close')
1633 ok = VRCopyFile( NewSmbConf, smbconf )
1634 end
1635 end
1636 call _SmbConfTreeReset
1637
1638 if _SambaRunning() then do
1639 Msg.Text = NLVGetMessage(69)
1640 Msg.Type = 'I'
1641 call _ShowMsg
1642 end
1643return
1644
1645/*:VRX _SmbConfTreeInit
1646*/
1647_SmbConfTreeInit:
1648 IF options.!debug == 1 THEN say '_SmbConfTreeInit() started.'
1649 call _CfgPageSetupSize "GB_Help"
1650 call _CfgPageSetupSize "GB_Global"
1651 call _CfgPageSetupSize "GB_Shares"
1652 IF options.!debug == 1 THEN say ' Page setup done.'
1653
1654 ok = VRMethod("CN_smbconf", "RemoveRecord", "ALL")
1655 smbconf.!root = VRMethod( "CN_smbconf", "AddRecord",,, "smb.conf","#33:PMWP.DLL")
1656 smbconf.!global = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Global","#33:PMWP.DLL")
1657 smbconf.!homes = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Homes","#33:PMWP.DLL")
1658 smbconf.!netlogon = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Netlogon","#33:PMWP.DLL")
1659 smbconf.!profiles = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Profiles","#33:PMWP.DLL")
1660 smbconf.!printers = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, NLVGetMessage(45),"#93:PMWP.DLL")
1661 smbconf.!dirs = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, NLVGetMessage(46),"#27:PMWP.DLL")
1662 IF options.!debug == 1 THEN say ' smb.conf sections created.'
1663
1664 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!netlogon, "Visible", 0 , "ReadOnly", 1)
1665 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!profiles, "Visible", 0 , "ReadOnly", 1)
1666 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!homes, "Visible", 0 , "ReadOnly", 1)
1667 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!root, "Collapsed",1, "ReadOnly", 1 )
1668 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!global, "ReadOnly", 1)
1669 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "ReadOnly", 1)
1670 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "ReadOnly", 1)
1671
1672 IF options.!debug == 1 THEN say ' visibility set.'
1673 IF options.!debug == 1 THEN say '_SmbConfTreeInit() done.'
1674return
1675
1676/*:VRX _SmbConfTreeReset
1677*/
1678_SmbConfTreeReset:
1679 call _SharesReset
1680 ok = VRMethod( "CN_SmbConf", "RemoveRecord", smbconf.!root )
1681 call _SmbConfTreeInit
1682 call _GUIInit
1683return
1684
1685/*:VRX _SmbUserMapCreate
1686*/
1687_SmbUserMapCreate:
1688 call lineout samba.!smbusermap, '# Created by SSCC version 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
1689 call lineout samba.!smbusermap, '# syntax:'
1690 call lineout samba.!smbusermap, '# Samba username = Windows username'
1691 call lineout samba.!smbusermap, 'root = Administrator'
1692 ok = stream(samba.!smbusermap,'c','close')
1693return
1694
1695/*:VRX About_Close
1696*/
1697About_Close:
1698 call About_Fini
1699return
1700
1701/*:VRX About_Create
1702*/
1703About_Create:
1704 call About_Init
1705 ok = VRSet("About","Caption", NLVGetMessage(31))
1706 ok = VRSet("PB_AboutOK","Caption", NLVGetMessage(2))
1707 SambaTeam.0 = 9
1708 SambaTeam.1 = 'Silvan Scherrer'
1709 SambaTeam.2 = 'Herwig Bauernfeind'
1710 SambaTeam.3 = 'Vitali Pelenyov'
1711 SambaTeam.4 = 'Paul Smedley'
1712 SambaTeam.5 = 'Yuri Dario'
1713 SambaTeam.6 = 'Alex Taylor'
1714 SambaTeam.7 = 'Nikolay Kolosov'
1715 SambaTeam.8 = 'All the Samba people'
1716 SambaTeam.9 = 'All the netlabs people'
1717 ok = VRSet("About","Font", VRGet("GB_Help2","Font"))
1718 ok = VRMethod("LB_SambaTeam","AddStringList", "SambaTeam." )
1719 ok = VRSet("DT_SambaTeam","Caption", NLVGetMessage(72))
1720 ok = VRSet("MLE_Version","Value", NLVGetMessage(1)||'0D0A'x||VRGet("Main", "Hinttext")||'0D0A'x||'0D0A'x||SambaVer)
1721return
1722
1723/*:VRX About_Fini
1724*/
1725About_Fini:
1726 window = VRInfo( "Window" )
1727 call VRDestroy window
1728 drop window
1729return
1730/*:VRX About_Init
1731*/
1732About_Init:
1733 window = VRInfo( "Object" )
1734 if( \VRIsChildOf( window, "Notebook" ) ) then do
1735 call VRMethod window, "CenterWindow"
1736 call VRSet window, "Visible", 1
1737 call VRMethod window, "Activate"
1738 end
1739 drop window
1740return
1741
1742/*:VRX CB_Browseable_Click
1743*/
1744CB_Browseable_Click:
1745 call _ShareObject_Changed
1746return
1747
1748/*:VRX CB_EA_Support_Click
1749*/
1750CB_EA_Support_Click:
1751 call _ShareObject_Changed
1752return
1753
1754/*:VRX CB_Guest_OK_Click
1755*/
1756CB_Guest_OK_Click:
1757 call _ShareObject_Changed
1758return
1759
1760/*:VRX CB_LM_Announce_Click
1761*/
1762CB_LM_Announce_Click:
1763 call _ShareObject_Changed
1764return
1765
1766/*:VRX CB_Null_passwords_Click
1767*/
1768CB_Null_passwords_Click:
1769 call _ShareObject_Changed
1770return
1771
1772/*:VRX CB_Read_Only_Click
1773*/
1774CB_Read_Only_Click:
1775 call _ShareObject_Changed
1776return
1777
1778/*:VRX CB_RemoveSmbConf_Click
1779*/
1780CB_RemoveSmbConf_Click:
1781 ok = VRSet("CB_RemoveBackend", "Enabled", VRGet("CB_RemoveSmbConf","set"))
1782 if VRGet("CB_RemoveBackend", "Enabled") = 0 then ok = VRSet("CB_RemoveBackend", "Set", 0)
1783return
1784
1785/*:VRX CB_Store_DOS_attributes_Click
1786*/
1787CB_Store_DOS_attributes_Click:
1788 call _ShareObject_Changed
1789return
1790
1791/*:VRX CB_Time_Server_Click
1792*/
1793CB_Time_Server_Click:
1794 call _ShareObject_Changed
1795return
1796
1797/*:VRX CB_WINS_Support_Click
1798*/
1799CB_WINS_Support_Click:
1800 call _ShareObject_Changed
1801return
1802
1803/*:VRX CN_smbconf_Click
1804*/
1805CN_smbconf_Click:
1806 IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() started'
1807 IF options.!debug == 1 THEN SAY ' Using 'smbconf' ('stream(smbconf,'c','query size')' bytes)'
1808 if ValueChanged then do
1809 if CurSection <> "" then do
1810 Msg.Title = NLVGetMessage('1')
1811 Msg.Text = NLVGetMessage(60, CurSection)
1812 ok = _MsgYesNo()
1813 if ok = 1 then call _SaveChanges
1814 CurSection = ""
1815 end
1816 end
1817
1818 Ok = VRset("Main", "Painting", 0)
1819 ok = VRset("GB_Help", "Visible", 0)
1820 ok = VRset("GB_Global", "Visible", 0)
1821 ok = VRset("GB_Shares", "Visible", 0)
1822
1823 ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "Prophandle." )
1824 if PropHandle.0 = 0 then do
1825 IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() aborted, no handle'
1826 Ok = VRset("Main", "Painting", 1)
1827 return
1828 end
1829 ParentHandle = VRMethod("CN_smbconf","GetRecordAttr", Prophandle.1,"Parent")
1830
1831 if Prophandle.1 = smbconf.!root then ok = VRset("GB_Help", "Visible", 1)
1832 if Prophandle.1 = smbconf.!global | Parenthandle = smbconf.!global then call _ActiveGroup "Global"
1833 if Prophandle.1 = smbconf.!homes | Parenthandle = smbconf.!homes then call _ActiveGroup "Shares"
1834 if Prophandle.1 = smbconf.!netlogon | Parenthandle = smbconf.!netlogon then call _ActiveGroup "Shares"
1835 if Prophandle.1 = smbconf.!profiles | Parenthandle = smbconf.!profiles then call _ActiveGroup "Shares"
1836 if Prophandle.1 = smbconf.!dirs then call _ActiveGroup "Help"
1837 if Prophandle.1 = smbconf.!printers then call _ActiveGroup "Help"
1838 if Parenthandle = smbconf.!dirs then call _ActiveGroup "Shares"
1839 if Parenthandle = smbconf.!printers then call _ActiveGroup "Shares"
1840
1841 call _SharesReset
1842 Ok = VRset("Main", "Painting", 1)
1843
1844 ok = VRSet("TM_Value", "Enabled", 1)
1845 if Prophandle.1 = smbconf.!root | Prophandle.1 = smbconf.!dirs | Prophandle.1 = smbconf.!printers then do
1846 IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() aborted, got parent handle'
1847 Ok = VRset("Main", "Painting", 1)
1848 return
1849 end
1850 IF options.!debug == 1 THEN SAY ' Got child handle, start populating now'
1851 ObjYPos = 1280+361+72-120
1852 ObjXPos = 1325+72
1853 ObjDelta= 380
1854 CreatedObjs.0 = 0
1855 Objs = 0
1856
1857 Page = 1 /* for global */
1858
1859 do I = 1 to sections.0
1860 if Prophandle.1 <> recordhandle.I then iterate
1861
1862 Ok = VRset("Main", "Painting", 0)
1863 CurSection = sections.I
1864 CurSIdx = I
1865 upCurSection = translate(CurSection)
1866 IF options.!debug == 1 THEN SAY ' Section ['sections.I']'
1867
1868 if upCurSection = 'GLOBAL' then do
1869 ObjYPos = 1605+-120+361+361+361+361+361+361
1870 ObjXPos = 1325
1871 ObjDelta = 320
1872 if Page = 1 then do
1873 if \VRIsValidObject("GB_"ActiveGroup"_1") then do
1874 ActiveGroupObj = VRCreate("GB_Global", "Window", "Name", "GL_GLOBAL_"Page, "Height", 1500, "Width", 1500, "Visible", 0, "Font", "9.WarpSans")
1875 IF options.!debug == 1 THEN say ' Neues Fenster VRCreate = 'ok
1876 ok = VRLoad( "GB_Global", VRWindowPath(), "GL_GLOBAL_"Page )
1877 IF options.!debug == 1 THEN say ' VRLoad = 'ok
1878 ok = VRMethod("GB_Global", "InsertPage", "GL_GLOBAL_"Page, "+"Page)
1879 IF options.!debug == 1 THEN say ' InsertPage = 'ok
1880
1881/* ok = VRset("Main", "Painting", 1)
1882 Msg.Text = NLVGetMessage(114)
1883 Msg.Type = "I"
1884 call _ShowMsg
1885 return */
1886 end
1887 ActiveGroupObj = VRGet("GB_"ActiveGroup"_1", "Self")
1888 end
1889 end
1890 else do
1891 if \VRIsValidObject("GB_"ActiveGroup) then do
1892 ok = VRset("Main", "Painting", 1)
1893 Msg.Text = NLVGetMessage(114)
1894 Msg.Type = "I"
1895 call _ShowMsg
1896 return
1897 end
1898 ActiveGroupObj = "GB_"ActiveGroup
1899 ok = VRSet("DT_"ActiveGroup,"Caption",sections.I)
1900 end
1901 say "CurSection="CurSection
1902 say "smbconf="smbconf
1903
1904 /* ok = IniEnum("Voc", hdl) */ /* Old command: Fill the Voc stem with vocabulary */
1905
1906 call _MyIniEnum(CurSection)
1907
1908 if upCurSection <> 'GLOBAL' then do
1909 ok = VRSet("CB_Read_Only", "set", 1)
1910 end
1911 do V = 1 to Voc.0 /* loop for every vocabulary */
1912 ValueChanged = 0
1913 ChangeList = ""
1914
1915 /* get value for this vocabulary */
1916 Val.V = IniGet(Voc.V, CurSection, samba.!smbconf) /* this is currently done by _MyIniEnum (which is probably not good) */
1917 select
1918 when pos("\\",Val.V) > 0 then nop
1919 when pos(" dir",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
1920 when pos("file",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
1921 when pos("path",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
1922 when pos("username map",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
1923 otherwise nop /* do not beautify */
1924 end
1925
1926 IF options.!debug == 1 THEN say ' Process: "'Voc.V'" = "'Val.V'"'
1927
1928 /* Proper format to ease checking and object creation */
1929 upVal = translate(Val.V)
1930 upVoc = translate(translate(Voc.V,'_',' '))
1931
1932 if upVal = 'YES'| upVal = 'NO'
1933 then VocObjType = 'CB'
1934 else VocObjType = 'EF'
1935
1936 /* Non configurable items */
1937 if upVoc = "PRINTABLE" then iterate
1938 if pos('SCRIPT', upVoc) > 0 then iterate
1939 if pos('COMMAND', upVoc) > 0 then iterate
1940
1941 if upVoc = "COMMENT" then do
1942 CurPage = Page
1943 CurActiveGroupObj = ActiveGroupObj
1944 if Page <> 1 then ActiveGroupObj = VRGet("GB_"ActiveGroup"_1", "Self")
1945 OldObjYPos = ObjYPos
1946 if upCurSection = "GLOBAL" then ObjYPos = 860-120
1947 else ObjYPos = 860+361+72
1948 if _CreateVocObject() then do
1949 ok = VRSet(VocObjType"_"upVoc, 'Value', Val.V)
1950 ok = VRFlush( , VocObjType"_"upVoc )
1951 end
1952 ActiveGroupObj = CurActiveGroupObj
1953 Page = CurPage
1954 ObjYPos = OldObjYPos
1955 end
1956 else do /* Normalfall */
1957 if _CreateVocObject() then do
1958 if upVal = "YES" | upVal = "NO" then do
1959 ok = VRset(VocObjType"_"upVoc,"Set", (upVal="YES"))
1960 ok = VRFlush( , VocObjType"_"upVoc )
1961 end
1962 else do
1963 ok = VRSet(VocObjType"_"upVoc, 'Value', Val.V)
1964 ok = VRFlush( , VocObjType"_"upVoc )
1965 if translate(VocObjType"_"upVoc) = VocObjType"_PRINTER_NAME" then do
1966 ok = VRSet(VocObjType"_"upVoc, 'ReadOnly', 1)
1967 ok = VRSet(VocObjType"_"upVoc, 'BackColor', 'PaleGray')
1968 end
1969 end
1970 end
1971 nop
1972 end
1973 ok = VRSet(VocObjType"_"upVoc, 'Userdata', V)
1974
1975 if upCurSection = 'GLOBAL' then do
1976 if upVoc = "WINBIND_SEPARATOR" then do /* Workaround for Samba Ticket #57 */
1977 ok = VRset("DT_WINBIND_SEPARATOR","Visible","0")
1978 ok = VRset("EF_WINBIND_SEPARATOR","Value","|")
1979 ok = VRFlush( , "EF_WINBIND_SEPARATOR" )
1980 ok = VRset("EF_WINBIND_SEPARATOR","Visible",0)
1981 ObjYPos = ObjYPos - ObjDelta
1982 end
1983
1984 if ObjYPos > VRGet("GB_Global","Height") - 1200 then do
1985 /* Ok = VRset("Main", "Painting", 1) */
1986 Page = Page + 1
1987 if Page = 2 then do
1988 Ok = VRset("Main", "Painting", 1)
1989 ok = VRSet("Main", 'Pointer', 'Wait' )
1990 Ok = VRset("Main", "Painting", 0)
1991 end
1992 if \VRIsValidOBject("GL_GLOBAL_"Page) then do
1993 ActiveGroupObj = VRCreate("GB_Global", "Window", "Name", "GL_GLOBAL_"Page, "Height", 1500, "Width", 1500, "Visible", 0, "Font", "9.WarpSans")
1994 IF options.!debug == 1 THEN say ' Neues Fenster VRCreate = 'ok
1995 ok = VRLoad( "GB_Global", VRWindowPath(), "GL_GLOBAL_"Page )
1996 IF options.!debug == 1 THEN say ' VRLoad = 'ok
1997 ok = VRMethod("GB_Global", "InsertPage", "GL_GLOBAL_"Page, "+"Page)
1998 IF options.!debug == 1 THEN say ' InsertPage = 'ok
1999 end
2000 else do
2001 ActiveGroupObj = VRGet("GL_GLOBAL_"Page, "Self")
2002 end
2003 ObjYPos = 0
2004 IF options.!debug == 1 THEN say " Page ="page
2005 /* Ok = VRset("Main", "Painting", 0) */
2006 end
2007 end
2008 end
2009 end
2010 if upCurSection = "GLOBAL" then do
2011 if VRGet("EF_Netbios_name","Value") = "" then do
2012 ok = VRset("EF_NETBIOS_NAME","Value",Value("HOSTNAME",,"OS2ENVIRONMENT"))
2013 ok = VRFlush( , "EF_NETBIOS_NAME" )
2014 end
2015 if VRGet("EF_WorkGroup","Value") = "" then do
2016 ok = VRset("EF_WorkGroup","Value","WORKGROUP")
2017 ok = VRFlush( , "EF_WorkGroup" )
2018 end
2019 end
2020
2021 Ok = VRset("Main", "Painting", 1)
2022 ok = VRSet("Main", 'Pointer', '<default>' )
2023 IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() done'
2024return
2025/*:VRX CN_smbconf_ContextMenu
2026*/
2027CN_smbconf_ContextMenu:
2028 ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "Prophandle." )
2029 if PropHandle.0 = 0 then return
2030 ParentHandle = VRMethod("CN_smbconf","GetRecordAttr", Prophandle.1,"Parent")
2031 ok = VRset("Menu_ShareContext_AddPrinter", "Visible", 0)
2032 ok = VRset("Menu_ShareContext_RenamePrinter", "Visible", 0)
2033 ok = VRset("Menu_ShareContext_RemovePrinter", "Visible", 0)
2034 ok = VRset("Menu_ShareContext_Add", "Visible", 0)
2035 ok = VRset("Menu_ShareContext_Rename", "Visible", 0)
2036 ok = VRset("Menu_ShareContext_Remove", "Visible", 0)
2037
2038 if Prophandle.1 = smbconf.!root then ok = VRset("GB_Help", "Visible", 1)
2039 if Prophandle.1 = smbconf.!global | Parenthandle = smbconf.!global then return
2040 if Prophandle.1 = smbconf.!homes | Parenthandle = smbconf.!homes then return
2041 if Prophandle.1 = smbconf.!dirs then do
2042 ok = VRset("Menu_ShareContext_Add", "Visible", 1)
2043 end
2044 if Parenthandle = smbconf.!dirs then do
2045 ok = VRset("Menu_ShareContext_Add", "Visible", 1)
2046 ok = VRset("Menu_ShareContext_Rename", "Visible", 1)
2047 ok = VRset("Menu_ShareContext_Remove", "Visible", 1)
2048 end
2049 if Prophandle.1 = smbconf.!printers then do
2050 ok = VRset("Menu_ShareContext_AddPrinter", "Visible", 1)
2051 end
2052 if Parenthandle = smbconf.!printers then do
2053 ok = VRset("Menu_ShareContext_AddPrinter", "Visible", 1)
2054 ok = VRset("Menu_ShareContext_RenamePrinter", "Visible", 1)
2055 ok = VRset("Menu_ShareContext_RemovePrinter", "Visible", 1)
2056 end
2057
2058 ok = VRMethod( "Menu_ShareContext", "Popup", , , "", "" )
2059
2060return
2061
2062/*:VRX EF_display_charset_Change
2063*/
2064EF_display_charset_Change:
2065 call _ShareObject_Changed
2066return
2067
2068/*:VRX EF_dos_charset_Change
2069*/
2070EF_dos_charset_Change:
2071 call _ShareObject_Changed
2072return
2073
2074/*:VRX EF_Log_file_Change
2075*/
2076EF_Log_file_Change:
2077 call _ShareObject_Changed
2078return
2079
2080/*:VRX EF_LOG_LEVEL_Change
2081*/
2082EF_LOG_LEVEL_Change:
2083 call _ShareObject_Changed
2084return
2085
2086/*:VRX EF_NetBIOS_Name_Change
2087*/
2088EF_NetBIOS_Name_Change:
2089 call _ShareObject_Changed
2090return
2091
2092/*:VRX EF_path_Change
2093*/
2094EF_path_Change:
2095 call _ShareObject_Changed
2096return
2097
2098/*:VRX EF_SECURITY_Change
2099*/
2100EF_SECURITY_Change:
2101 call _ShareObject_Changed
2102return
2103
2104/*:VRX EF_Server_String_Change
2105*/
2106EF_Server_String_Change:
2107 call _ShareObject_Changed
2108return
2109
2110/*:VRX EF_Unix_charset_Change
2111*/
2112EF_Unix_charset_Change:
2113 call _ShareObject_Changed
2114return
2115
2116/*:VRX EF_Workgroup_Change
2117*/
2118EF_Workgroup_Change:
2119 call _ShareObject_Changed
2120return
2121
2122/*:VRX Fini
2123*/
2124Fini:
2125 window = VRWindow()
2126 call VRSet window, "Visible", 0
2127 drop window
2128return 0
2129
2130/*:VRX GB_Global_1_Close
2131*/
2132GB_Global_1_Close:
2133 call GB_Global_1_Fini
2134return
2135
2136/*:VRX GB_Global_1_Create
2137*/
2138GB_Global_1_Create:
2139 call GB_Global_1_Init
2140return
2141
2142/*:VRX GB_Global_1_Fini
2143*/
2144GB_Global_1_Fini:
2145 window = VRInfo( "Window" )
2146 call VRDestroy window
2147 drop window
2148return
2149/*:VRX GB_Global_1_Init
2150*/
2151GB_Global_1_Init:
2152 window = VRInfo( "Object" )
2153 if( \VRIsChildOf( window, "Notebook" ) ) then do
2154 call VRMethod window, "CenterWindow"
2155 call VRSet window, "Visible", 1
2156 call VRMethod window, "Activate"
2157 end
2158 drop window
2159return
2160
2161/*:VRX Halt
2162*/
2163Halt:
2164 signal _VREHalt
2165return
2166
2167/*:VRX Init
2168*/
2169Init:
2170 window = VRWindow()
2171 call VRMethod window, "CenterWindow"
2172 call VRSet window, "Visible", 1
2173 call VRMethod window, "Activate"
2174 drop window
2175return
2176
2177/*:VRX Installer_Close
2178*/
2179Installer_Close:
2180 Msg.Text = NLVGetMessage(114)
2181 Msg.Type = "I"
2182 call _ShowMsg
2183 call Installer_Fini
2184return
2185
2186/*:VRX Installer_Create
2187*/
2188Installer_Create:
2189 call Installer_Init
2190 CALL NLVSetText 'Installer', 'Caption', 90
2191 CALL NLVSetText 'DT_RootPasswordDescription', 'Caption', 91
2192 CALL NLVSetText 'DT_RootPassword', 'Caption', 92
2193 CALL NLVSetText 'DT_RootPassword_repeat', 'Caption', 93
2194 CALL NLVSetText 'CB_NoRoot', 'Caption', 94
2195 CALL NLVSetText 'DT_Backend', 'Caption', 95
2196 CALL NLVSetText 'DT_ServerType', 'Caption', 96
2197 CALL NLVSetText 'PB_Install_Default', 'Caption', 97
2198 CALL NLVSetText 'PB_Install_Migration', 'Caption', 98
2199
2200 ok = VRSet("PB_Install_Migration", "Enabled", lsshareiniexists * ibmlaniniexists )
2201 ok = VRSet("TM_Installer","Enabled", 0)
2202 if stream(samba.!group,'c','query exists') = "" | stream(samba.!group,'c','query size') < 120 then do
2203 call _GroupCreate
2204 end
2205 if stream(samba.!masterpasswd,'c','query exists') = "" | stream(samba.!group,'c','query size') < 230 then do
2206 call _MasterPasswdCreate
2207 call _PasswordDBRewrite
2208 ok = VRSet("CB_NoRoot","Enabled", 0)
2209 end
2210 if stream(samba.!pwddb,'c','query exists') = "" | stream(samba.!spwddb,'c','query exists') = "" then do
2211 call _PasswordDBRewrite
2212 ok = VRSet("CB_NoRoot","Enabled", 0)
2213 end
2214 if \VRFileExists(ETC'\samba\private\secrets.tdb') then do
2215 ok = VRSet("CB_NoRoot","Enabled", 0)
2216 end
2217 UseTDBsam = 1
2218 CreatePDC = 0
2219return
2220
2221/*:VRX Installer_Fini
2222*/
2223Installer_Fini:
2224 window = VRInfo( "Window" )
2225 call VRDestroy window
2226 drop window
2227return
2228/*:VRX Installer_Init
2229*/
2230Installer_Init:
2231 window = VRInfo( "Object" )
2232 if( \VRIsChildOf( window, "Notebook" ) ) then do
2233 call VRMethod window, "CenterWindow"
2234 call VRSet window, "Visible", 1
2235 call VRMethod window, "Activate"
2236 end
2237 drop window
2238return
2239
2240/*:VRX IPB_ChooseDir_Click
2241*/
2242IPB_ChooseDir_Click:
2243 InitDir = VRGet("EF_Path","Value")
2244 VarPos = pos('%', InitDir)
2245 if VarPos > 0 then do
2246 VarChar = substr(InitDir,VarPos,2)
2247 InitDir = left(InitDir,VarPos-1)
2248 say VarChar
2249 end
2250 NewPath = _dirDialog('Choose path for 'VRGet("DT_Shares","Caption"),_fs2bs(InitDir))
2251 if NewPath = "" then return
2252 if VarPos > 0 then NewPath = NewPath'\'VarChar
2253 ok = VRset("EF_Path","value",NewPath)
2254return
2255
2256/*:VRX IPB_NewItem_Click
2257*/
2258IPB_NewItem_Click:
2259 smbconfopt = samba.!tools'\smbconf.opt'
2260say smbconfopt
2261 do until lines(smbconfopt) = 0
2262 smbconfline = linein(smbconfopt)
2263say smbconfline
2264 I = I + 1
2265 opt.I = smbconfline
2266 end
2267 opt.0 = I
2268 ok = stream(smbconfopt,'c','close')
2269 ok = VRMethod("DDCB_Add_Voc","Reset")
2270 ok = VRMethod("DDCB_Add_Voc","AddStringList", opt.)
2271 ok = VRSet("DDCB_Add_Voc","Top",ObjYPos-380)
2272 ok = VRSet("EF_Add_Voc","Top",ObjYPos-380)
2273 ok = VRSet("PB_Add_Voc_OK","Top",ObjYPos)
2274 ok = VRSet("PB_Add_Voc_Cancel","Top",ObjYPos)
2275
2276 ok = VRSet("DDCB_ADD_Voc","Visible",1)
2277 ok = VRSet("EF_ADD_Voc","Visible",1)
2278 ok = VRSet("PB_Add_Voc_OK","Visible",1)
2279 ok = VRSet("PB_add_Voc_Cancel","Visible",1)
2280return
2281
2282/*:VRX Main_Close
2283*/
2284Main_Close:
2285 call Quit
2286return
2287
2288/*:VRX Main_Create
2289*/
2290Main_Create:
2291 ok = VRREdirectStdIO("ON")
2292 options.!debug = 1
2293
2294 call _LoadOtherFuncs
2295
2296 call _INIRead
2297
2298 call _ParseCommandLine
2299
2300 call _InitTempDir
2301 call _SambaInit
2302 call _SambaExtendSearchPath
2303 call _GUIInitNLV
2304
2305 call _FindHtpasswd
2306 call Main_Resize
2307 call _SambaCheckComponents
2308 call _SambaVersion
2309 call _FindIBMLANPath
2310 call _SmbConfTreeInit /* creates the records for default sections */
2311
2312 /* Installation mode is triggered by a timer activated in GUIInit, when no smb.conf exists */
2313 call _GUIInit
2314return
2315
2316/*:VRX Main_Resize
2317*/
2318Main_Resize:
2319 IF options.!debug == 1 THEN SAY "Main_Resize() started"
2320 Ok = VRset("Main", "Painting", 0)
2321
2322 /* /* Basic measurements */
2323 main_iwidth = VRGet("Main","InteriorWidth") /* Width of window client-area */
2324 main_iheight = VRGet("Main","InteriorHeight") /* Height of window client-area */
2325
2326 if main_iheight < 5500 then ok = VRSet("Main","Height",6200)
2327 sbar_height = VRGet("GB_STATUSBAR","Height") /* Height of status-bar */
2328 split_left = VRGet("SPLIT_Main","Left") /* Position of the left edge of the split-bar */
2329 marginx2 = margin * 2 /* Common margin around controls */
2330 pbtn_height = 400 /* Height of the panels' internal button areas */
2331
2332 pane_height = main_iheight - sbar_height - (margin * 4) /* Height of a split-bar panel */
2333 lpane_width = split_left - margin /* Width of the left split-bar panel */
2334 rpane_width = main_iwidth - split_left - 60 - margin /* Width of the right split-bar panel */ */
2335
2336 /* ab hier alt */
2337 ok = VRSet("GB_SmbConfTree","Top", FWidth)
2338 ok = VRSet("GB_SmbConfTree","Left", FWidth-24)
2339 ok = VRSet("GB_SmbConfTree","Height", VRGet("Main", "Height") -1350)
2340
2341 ok = VRset("GB_SmbConfTree3","Top", FWidth)
2342 ok = VRset("GB_SmbConfTree3","Left", FWidth)
2343 ok = VRset("GB_SmbConfTree3","Height", 245 )
2344 ok = VRset("GB_SmbConfTree3","Width", VRGet("GB_SmbConfTree","Width") -(FWidth*2))
2345
2346 ok = VRset("DT_SmbConfTree","Top", 8)
2347 ok = VRset("DT_SmbConfTree","Left", 8)
2348 ok = VRset("DT_SmbConfTree","Height", 213)
2349 ok = VRset("DT_SmbConfTree","Width", VRGet("GB_SmbConfTree3","Width") - 24)
2350
2351 ok = VRset("GB_SmbConfTree2","Left", FWidth)
2352 ok = VRset("GB_SmbConfTree2","Top", 245 + FWidth*2)
2353 ok = VRset("GB_SmbConfTree2","Width", VRGet("GB_SmbConfTree","Width")-FWidth*2)
2354 ok = VRset("GB_SmbConfTree2","Height", VRGet("GB_SmbConfTree","Height")-FWidth*3-245)
2355
2356 ok = VRset("CN_SmbConf", "Top", FWidth)
2357 ok = VRset("CN_SmbConf", "Left", FWidth)
2358 ok = VRset("CN_SmbConf", "Width", VRGet("GB_SmbConfTree2","Width") -(FWidth*2))
2359 ok = VRset("CN_SmbConf", "Height", VRGet("GB_SmbConfTree2","Height")-(FWidth*2))
2360
2361 ok = VRset("GB_Help", "Top", FWidth)
2362 ok = VRset("GB_Help", "Left", VRGet("GB_SmbConfTree","Width") + 60)
2363 ok = VRSet("GB_Help", "Height", VRGet("GB_SmbConfTree","Height"))
2364 ok = VRSet("GB_Help", "Width", VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
2365
2366 ok = VRset("GB_Help3","Top", FWidth)
2367 ok = VRset("GB_Help3","Left", FWidth)
2368 ok = VRset("GB_Help3","Height", 245 )
2369 ok = VRset("GB_Help3","Width", VRGet("GB_Help","Width") -(FWidth*2))
2370
2371 ok = VRset("GB_Help2","Left", FWidth)
2372 ok = VRset("GB_Help2","Top", 245 + FWidth*2)
2373 ok = VRset("GB_Help2","Width", VRGet("GB_Help","Width")-FWidth*2)
2374 ok = VRset("GB_Help2","Height", VRGet("GB_Help","Height")-FWidth*3-245)
2375
2376 ok = VRset("DT_Help","Top", 8)
2377 ok = VRset("DT_Help","Left", 8)
2378 ok = VRset("DT_Help","Height", 213)
2379 ok = VRset("DT_Help","Width", VRGet("GB_Help3","Width") - 24)
2380
2381 ok = VRset("GB_Shares", "Top", FWidth)
2382 ok = VRset("GB_Shares", "Left", VRGet("GB_SmbConfTree","Width") + 60)
2383 ok = VRSet("GB_Shares", "Height", VRGet("GB_SmbConfTree","Height"))
2384 ok = VRSet("GB_Shares", "Width", VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
2385
2386 ok = VRset("GB_Shares3","Top", FWidth)
2387 ok = VRset("GB_Shares3","Left", FWidth)
2388 ok = VRset("GB_Shares3","Height", 245 )
2389 ok = VRset("GB_Shares3","Width", VRGet("GB_Shares","Width") -(FWidth*2))
2390
2391 ok = VRset("GB_Shares2","Left", FWidth)
2392 ok = VRset("GB_Shares2","Top", 245 + FWidth*2)
2393 ok = VRset("GB_Shares2","Width", VRGet("GB_Shares","Width")-FWidth*2)
2394 ok = VRset("GB_Shares2","Height", VRGet("GB_Shares","Height")-FWidth*3-245)
2395
2396 ok = VRset("DT_Shares", "Top", 8)
2397 ok = VRset("DT_Shares", "Left", 8)
2398 ok = VRset("DT_Shares", "Height", 213)
2399 ok = VRset("DT_Shares", "Width", VRGet("GB_Shares3","Width") - 24)
2400
2401 ok = VRSet("GB_Global", "Height", VRGet("GB_SmbConfTree","Height"))
2402 ok = VRSet("GB_Global", "Width", VRGet("GB_Shares", "Width"))
2403
2404 MButton.bTop = VRGet("GB_SmbConfTree","height")+FWidth*2
2405 MButton.bLeft = VRGet("GB_Shares","Left")
2406 MButton.bWidth = VRGet("PB_Save","Width")
2407
2408 if MButton.bTop < 1300 & MButton.bLeft < 1300 then do
2409 MButton.bTop = 4842
2410 MButton.bLeft = 3758
2411 MButton.bWidth = 1241
2412 FWidth = 32
2413 end
2414
2415 ok = VRSet("PB_Reload", "Top", MButton.bTop)
2416 ok = VRSet("PB_Reload", "Left", MButton.bLeft)
2417 ok = VRSet("PB_Reload", "Width", MButton.bWidth)
2418
2419 ok = VRSet("PB_Save", "Top", MButton.bTop)
2420 ok = VRSet("PB_Save", "Left", MButton.bLeft+1*FWidth+MButton.bWidth)
2421 ok = VRSet("PB_Reload", "Width", MButton.bWidth)
2422
2423 ok = VRSet("PB_Undo", "Top", MButton.bTop)
2424 ok = VRSet("PB_Undo", "Left", MButton.bLeft+2*FWidth+MButton.bWidth*2)
2425 ok = VRSet("PB_Undo", "Width", MButton.bWidth)
2426
2427 ok = VRSet("PB_Cancel", "Top", MButton.bTop)
2428 ok = VRSet("PB_Cancel", "Left", MButton.bLeft+3*FWidth+MButton.bWidth*3)
2429 ok = VRSet("PB_Cancel", "Width", MButton.bWidth)
2430
2431 /* ok = VRSet("PB_Help", "Top", MButton.bTop)
2432 ok = VRSet("PB_Help", "Left", MButton.bLeft+6*FWidth+MButton.bWidth*3)
2433 ok = VRSet("PB_Help", "Width", MButton.bWidth) */
2434
2435 drop MButton.b
2436
2437 Top = VRGet("Main","Top")
2438 Left = VRGet("Main","Left")
2439 Width = VRGet("Main","Width")
2440 Height = VRGet("Main","Height")
2441
2442 if ActiveGroup = "Global" then do
2443
2444 end
2445 IF options.!debug == 1 THEN SAY " Window size = "VRGet("Main","Width")', 'VRGet("Main","Height")
2446
2447 /* check and empty event queue, trash spurious resize events */
2448 EventString = ''
2449 TrashedResize = 0
2450 do until EventString = 'nop'
2451 EventString = VREvent('N')
2452 say ' Event: "'EventString'" ('TrashedResize')'
2453 if EventString <> 'nop' then do
2454 if EventString = 'CALL Main_Resize' then TrashedResize = TrashedResize + 1
2455 else interpret eventString
2456 end
2457 end
2458 if TrashedResize >= 2 then CALL Main_Resize
2459
2460 IF options.!debug == 1 THEN SAY " Window size = "VRGet("Main","Width")', 'VRGet("Main","Height")
2461 Ok = VRset("Main", "Painting", 1)
2462 IF options.!debug == 1 THEN SAY "Main_Resize() done"
2463return
2464
2465/*:VRX Menu_Action_AddHomes_Click
2466*/
2467Menu_Action_AddHomes_Click:
2468 call _SmbConfDefault_Homes
2469 call _SmbConfTreeInit
2470 call _SmbConfLoad
2471return
2472
2473/*:VRX Menu_Action_AddNetLogon_Click
2474*/
2475Menu_Action_AddNetLogon_Click:
2476 call _SmbConfDefault_Netlogon
2477 call _SmbConfTreeInit
2478 call _SmbConfLoad
2479return
2480
2481/*:VRX Menu_Action_AddProfiles_Click
2482*/
2483Menu_Action_AddProfiles_Click:
2484 call _SmbConfDefault_Profiles
2485 call _SmbConfTreeInit
2486 call _SmbConfLoad
2487return
2488
2489/*:VRX Menu_Action_EraseTransient_Click
2490*/
2491Menu_Action_EraseTransient_Click:
2492 if _SambaRunning() then do
2493 Msg.Text = NLVGetMessage(70)
2494 Msg.Type = "E"
2495 ok = _ShowMsg()
2496 return
2497 end
2498
2499 ok = VRMethod("CN_smbconf","SetRecordAttr", smbconf.!global, "Selected", 1)
2500 call CN_smbconf_Click
2501
2502 if VRIsValidObject( "EF_LOCK_DIRECTORY" ) then do
2503 LockDir = VRGet("EF_Lock_Directory","Value")
2504 Msg.Text = NLVGetMessage(71)
2505 Msg.Type = "Q"
2506 ok = _MsgYesNo()
2507 if ok <> 1 then return
2508
2509 ok = SysFileDelete(LockDir"\gencache.tdb")
2510 ok = SysFileDelete(LockDir"\brlock.tdb")
2511 ok = SysFileDelete(LockDir"\unexpected.tdb")
2512 ok = SysFileDelete(LockDir"\connections.tdb")
2513 ok = SysFileDelete(LockDir"\locking.tdb")
2514 ok = SysFileDelete(LockDir"\messages.tdb")
2515 end
2516return
2517
2518/*:VRX Menu_File_Debug_Click
2519*/
2520Menu_File_Debug_Click:
2521 options.!debug = VRGet("Menu_File_debug","Checked")
2522
2523 /* The following 2 lines are unnecessary for a checkbox ! */
2524 ok = VRSet("Menu_File_debug","Checked",\options.!debug)
2525 options.!debug = \options.!debug
2526
2527 if options.!debug
2528 then ok = VRRedirectStdIO("On")
2529 else ok = VRRedirectStdIO("OFF")
2530
2531return
2532
2533/*:VRX Menu_File_Exit_Click
2534*/
2535Menu_File_Exit_Click:
2536 call Quit
2537return
2538
2539/*:VRX Menu_File_Import_IBMPeer_Click
2540*/
2541Menu_File_Import_IBMPeer_Click:
2542 call _SmbConfMigratePeer
2543 ok = SysFileTree(smbconf,exist.,'FO')
2544 SmbConfExists = exist.0
2545 call _SmbConfTreeReset
2546return
2547
2548/*:VRX Menu_File_ImportHosts_Click
2549*/
2550Menu_File_ImportHosts_Click:
2551 if VRFileExists(ETC'\samba\lmhosts') then do
2552 Msg.Text = NLVGetMessage(56, ETC'\samba\lmhosts')
2553 Msg.Type = 'Q'
2554 if _MsgYesNo() = 1 then do
2555 call _LMHostsImport
2556 end
2557 end
2558 else call _LMHostsImport
2559return
2560
2561/*:VRX Menu_File_PrintCap_Click
2562*/
2563Menu_File_PrintCap_Click:
2564 call _PrintcapCreate
2565 Msg.Text = NLVGetMessage(50, samba.!printcap)
2566 msg.Type = 'I'
2567 call _ShowMsg
2568return
2569
2570/*:VRX Menu_File_reset_Click
2571*/
2572Menu_File_reset_Click:
2573 call _SmbConfCreateDefault
2574 ok = SysFileTree(smbconf,exist.,'FO')
2575 SmbConfExists = exist.0
2576 call _SmbConfTreeReset
2577return
2578
2579/*:VRX Menu_File_SmbUpdate_Click
2580*/
2581Menu_File_SmbUpdate_Click:
2582 BuildFile = VRFileDialog( VRWindow(), NLVGetMessage(64), "Open", options.!builddir"\samba-*zip", , , )
2583 if BuildFile = '' then return
2584 options.!builddir = VRParseFilename(buildfile,'DP')
2585 address CMD samba.!smbcmd' stop'
2586 OldDir = Directory(Strip(samba.!bin,'T','\'))
2587 ok = VRRedirectStdIO('ON')
2588 address cmd 'unzip.exe -oCj 'BuildFile' *.exe *.dll'
2589 say 'unzip RC = 'RC
2590 if RC <> 0 then address cmd 'PAUSE'
2591 IF options.!debug <> 1 THEN ok = VRRedirectStdIO('OFF')
2592 ok = directory(OldDir)
2593 call _SambaVersion
2594 ok = VRSet("EF_Binaries_Version","value",samba.!version)
2595 address CMD samba.!smbcmd' start'
2596return
2597
2598/*:VRX Menu_Help_About_Click
2599*/
2600Menu_Help_About_Click:
2601 say ' 'samba.!smbd' -V --debuglevel=0 2>'samba.!error' 1>'smboutput
2602 address cmd samba.!smbd' -V --debuglevel=0 2>'samba.!error' 1>'smboutput
2603
2604 SambaVer = "Samba "||strip(linein(smboutput))
2605 ok = stream(smboutput,'c','close')
2606
2607 window = VRLoadSecondary( "About", "W" )
2608return
2609
2610/*:VRX Menu_Options_ExportMode_Click
2611*/
2612Menu_Options_ExportMode_Click:
2613 say 'ExpertMode_Click started'
2614 say samba.!testparmexe' -v -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
2615 address cmd samba.!testparmexe' -v -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
2616 say 'VRCopyFile('TempDir'smb.conf, 'smbconf' )'
2617 say " smb.conf GrӇe: "stream(smbconf,'c','QUERY SIZE')
2618 ok = VRCopyFile( TempDir'smb.conf', smbconf )
2619 say " smb.conf GrӇe: "stream(smbconf,'c','QUERY SIZE')
2620 say 'Copy ok ='ok' (1 = success, 0 = failure)'
2621 call _SmbConfTreeReset
2622 call Main_Resize
2623 say 'ExpertMode_Click done'
2624return
2625
2626/*:VRX Menu_Options_MiniIcons_Click
2627*/
2628Menu_Options_MiniIcons_Click:
2629 advanced.!bigicons = \advanced.!bigicons
2630 ok = VRset("CN_SMBCONF", "MiniIcons", \advanced.!bigicons)
2631 ok = VRset("Menu_Options_MiniIcons", "Checked", \advanced.!bigicons)
2632return
2633
2634/*:VRX Menu_Options_SimpleMode_Click
2635*/
2636Menu_Options_SimpleMode_Click:
2637 say 'SimpleMode_Click started'
2638
2639 /* Workaround for testparm bugs */
2640 say 'VRCopyFile('smbconf', 'TempDir'smb.conf )'
2641 ok = VRCopyFile( smbconf, TempDir'smb.conf')
2642 call _SmbConfCommitChanges
2643
2644 say samba.!testparmexe' -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
2645 address cmd samba.!testparmexe' -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
2646 NewSize = stream(TempDir"smb.conf",'c','QUERY SIZE')
2647 say " "TempDir"smb.conf GrӇe: "NewSize
2648 if NewSize = 0 then 'pause'
2649 say " smb.conf GrӇe: "stream(smbconf,'c','QUERY SIZE')
2650 say 'VRCopyFile('TempDir'smb.conf, 'smbconf' )'
2651 ok = VRCopyFile( TempDir'smb.conf' , smbconf )
2652 say " smb.conf GrӇe: "stream(smbconf,'c','QUERY SIZE')
2653 say 'Copy ok ='ok' (1 = success, 0 = failure)'
2654 call _SmbConfTreeReset
2655 do I = Page to 3 by -1
2656 ok = VRMethod( "GB_Global", "DeletePage", I )
2657 ok = VRDestroy("GL_GLOBAL_"I)
2658 end
2659 Page = 2
2660 call Main_resize
2661say 'SimpleMode_Click done'
2662return
2663
2664/*:VRX Menu_ShareContext_Add_Click
2665*/
2666Menu_ShareContext_Add_Click:
2667 NewShareDir = _dirDialog()
2668 if NewShareDir = "" then return
2669 NewShareName = filespec("N",NewShareDir)
2670 Buttons.1 = "OK"
2671 Buttons.2 = "Abort"
2672 Buttons.0 = 2
2673 id = VRPrompt( VRWindow(), "Enter name for new share", "NewShareName", "Add new Samba share", "Buttons.", buttons.1, buttons.2 )
2674 if ID = 2 | NewShareName = "" then return
2675 NewShareHandle = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,, NewShareName,"#4")
2676 call lineout smbconf, '['NewShareName']'
2677 call lineout smbconf, Indent||'path = '_bs2fs(NewShareDir)
2678 call lineout smbconf, Indent||'comment = 'NewShareName' directory'
2679 call lineout smbconf, Indent||'browseable = Yes'
2680 call lineout smbconf, Indent||'read only = Yes'
2681 call lineout smbconf, Indent||'hide files = /*.?SF/'
2682 call lineout smbconf
2683 call _SmbConfTreeReset
2684 Msg.Text = NLVGetMessage(69)
2685 Msg.Type = 'I'
2686 call _ShowMsg
2687 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
2688 ok = VRMethod("CN_smbconf","SetRecordAttr",NewShareHandle, "Selected", 1 )
2689return
2690
2691/*:VRX Menu_ShareContext_AddPrinter_Click
2692*/
2693Menu_ShareContext_AddPrinter_Click:
2694 AbortPrinter = 1
2695 window = VRLoadSecondary( "PrinterSelection", "W" )
2696 if AbortPrinter then return
2697 parse var SharePrinter PrinterName';'PrinterQueue';'PrinterDriver
2698 NewShareHandle = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,, PrinterQueue,"#4")
2699 call lineout smbconf, '['PrinterQueue']'
2700 call lineout smbconf, Indent||'path = '_bs2fs(ETC'\samba\spool\'printerqueue)
2701 ok = SysMkDir(ETC'\samba\spool\'printerqueue)
2702 call lineout smbconf, Indent||'comment = 'Printername
2703 call lineout smbconf, Indent||'create mask = 0700'
2704 call lineout smbconf, Indent||'printer name = 'printerqueue
2705 call lineout smbconf, Indent||'printing = os2'
2706 call lineout smbconf, Indent||'printable = Yes'
2707 call lineout smbconf, Indent||'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
2708 call lineout smbconf, Indent||'browseable = Yes'
2709 call lineout smbconf, Indent||'guest ok = Yes'
2710 call lineout smbconf, Indent||'read only = No'
2711 call lineout smbconf
2712 call _SmbConfTreeReset
2713 Msg.Text = NLVGetMessage(69)
2714 Msg.Type = 'I'
2715 call _ShowMsg
2716 ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
2717 ok = VRMethod("CN_smbconf","SetRecordAttr",NewShareHandle, "Selected", 1 )
2718return
2719
2720/*:VRX Menu_ShareContext_Remove_Click
2721*/
2722Menu_ShareContext_Remove_Click:
2723 call _SmbConfShareRemove
2724 if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
2725return
2726
2727/*:VRX Menu_ShareContext_RemovePrinter_Click
2728*/
2729Menu_ShareContext_RemovePrinter_Click:
2730 call _SmbConfShareRemove
2731 if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
2732return
2733
2734/*:VRX Menu_ShareContext_Rename_Click
2735*/
2736Menu_ShareContext_Rename_Click:
2737 call _SmbConfShareRename
2738 if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
2739return
2740
2741/*:VRX Menu_ShareContext_RenamePrinter_Click
2742*/
2743Menu_ShareContext_RenamePrinter_Click:
2744 call _SmbConfShareRename
2745 if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
2746return
2747
2748/*:VRX PB_1_Click
2749*/
2750PB_1_Click:
2751 ok = VRREdirectStdIO("ON")
2752 Buttons.1 = NLVGetMessage(2)
2753 Buttons.2 = NLVGetMessage(3)
2754 Buttons.0 = 2
2755 command = 'd:\samba\smbpasswd.exe'
2756 id = VRPrompt( VRWindow(), "Console", "command", "Console", "Buttons.", buttons.1, buttons.2 )
2757 if id = 2 then return
2758 say command
2759 address cmd command
2760 /* samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg */
2761 /* if RC <> 0 then call _SambaShowError; else call _SambaShowMsg */
2762return
2763
2764/*:VRX PB_AboutOK_Click
2765*/
2766PB_AboutOK_Click:
2767 call About_Close
2768return
2769
2770/*:VRX PB_Add_Voc_Cancel_Click
2771*/
2772PB_Add_Voc_Cancel_Click:
2773 drop opt.
2774 ok = VRSet("DDCB_Add_Voc","Value","")
2775 ok = VRSet("EF_Add_Voc", "Value","")
2776
2777 ok = VRSet("DDCB_ADD_Voc","Visible",0)
2778 ok = VRSet("EF_ADD_Voc","Visible",0)
2779 ok = VRSet("PB_Add_Voc_OK","Visible",0)
2780 ok = VRSet("PB_add_Voc_Cancel","Visible",0)
2781return
2782
2783/*:VRX PB_Add_Voc_OK_Click
2784*/
2785PB_Add_Voc_OK_Click:
2786 NewVoc = VRGet("DDCB_Add_Voc","Value")
2787 NewValue=VRGet("EF_Add_Voc", "Value")
2788 call IniSet NewVoc, NewValue, CurSection, samba.!smbconf
2789 drop opt.
2790 ok = VRSet("DDCB_Add_Voc","Value","")
2791 ok = VRSet("EF_Add_Voc", "Value","")
2792 ok = VRSet("DDCB_ADD_Voc","Visible",0)
2793 ok = VRSet("EF_ADD_Voc","Visible",0)
2794 ok = VRSet("PB_Add_Voc_OK","Visible",0)
2795 ok = VRSet("PB_add_Voc_Cancel","Visible",0)
2796
2797 call Menu_Options_SimpleMode_Click
2798return
2799
2800/*:VRX PB_Cancel_Click
2801*/
2802PB_Cancel_Click:
2803 IF options.!debug == 1 THEN say 'PB_Cancel_Click() started'
2804 if VRGet("PB_Save","Enabled") then call PB_Save_Click
2805'pause'
2806 call Quit
2807 IF options.!debug == 1 THEN say 'PB_Cancel_Click() done'
2808return
2809
2810/*:VRX PB_Help_Click
2811*/
2812PB_Help_Click:
2813
2814return
2815
2816/*:VRX PB_Install_Default_Click
2817*/
2818PB_Install_Default_Click:
2819 if VRGet("EF_Workgroup_Initial","Value") = "" then return
2820
2821 if \VRGet("CB_NoRoot","Set") then do
2822 if \_SambaRootPWCheck() then return
2823 end
2824
2825 call _SmbConfCreateDefault
2826 /* call _Smb35Init */
2827 ok = SysFileTree(smbconf,exist.,'FO')
2828 SmbConfExists = exist.0
2829 call _SmbConfBackup
2830 call _SmbConfTreeReset
2831
2832 if \VRGet("CB_NoRoot","Set") then do
2833 call _SambaRootPWSet
2834 end
2835 call _SambaGuestCreate
2836
2837 call _SambaUserCreate
2838 ok = VRSet("Main", 'Pointer', 'WAIT' )
2839 call _SambaGroupMapInst
2840 ok = VRSet("Main", 'Pointer', '<default>' )
2841 /* call Menu_File_ImportHosts_Click */
2842
2843 call Installer_Close
2844return
2845
2846/*:VRX PB_Install_Migration_Click
2847*/
2848PB_Install_Migration_Click:
2849 if VRGet("EF_Workgroup_Initial","Value") = "" then return
2850
2851 if \VRGet("CB_NoRoot","Set") then do
2852 if \_SambaRootPWCheck() then return
2853 end
2854
2855
2856 call _SmbConfMigratePeer
2857 ok = SysFileTree(smbconf,exist.,'FO')
2858 SmbConfExists = exist.0
2859 call _SmbConfBackup
2860 call _SmbConfTreeReset
2861 if \VRGet("CB_NoRoot","Set") then do
2862 call _SambaRootPWSet
2863 end
2864 call _SambaGuestCreate
2865
2866 call _SambaUserCreate
2867 ok = VRSet("Main", 'Pointer', 'WAIT' )
2868 call _SambaGroupMapInst
2869 ok = VRSet("Main", 'Pointer', '<default>' )
2870
2871/* call Menu_File_ImportHosts_Click */
2872
2873 call Installer_Close
2874return
2875
2876/*:VRX PB_Printer_Abort_Click
2877*/
2878PB_Printer_Abort_Click:
2879 call PrinterSelection_Close
2880return
2881
2882/*:VRX PB_Printer_OK_Click
2883*/
2884PB_Printer_OK_Click:
2885 SharePrinter = RawPrinter(VRGet("LB_Printers","SelectedString"))
2886 AbortPrinter = 0
2887 say SharePrinter
2888 call PrinterSelection_Close
2889return
2890
2891RawPrinter:
2892 do I = 1 to printer.0 until PurePrinter(printer.I) = arg(1)
2893 end
2894return printer.I
2895/*:VRX PB_Reload_Click
2896*/
2897PB_Reload_Click:
2898 call PB_Save_Click
2899 call beep 960, 1
2900 address CMD samba.!smbcmd' reload'
2901return
2902
2903/*:VRX PB_RemoveContinue_Click
2904*/
2905PB_RemoveContinue_Click:
2906
2907 if VRGet("CB_RemoveSmbConf","set") then do
2908 ok = SysFileDelete(samba.!smbconf)
2909 SmbConfExists = 0
2910 Installmode = 1
2911 end
2912 else Installmode = 0
2913
2914 if VRGet("CB_RemoveBackend","set") then do
2915 ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
2916 do I = 1 to xdb.0
2917 ok = SysFileDelete(xdb.I)
2918 if ok <> 0 then do
2919 Msg.Text = "Error "ok" deleting "xdb.I"!"
2920 Msg.Type = "W"
2921 call _ShowMsg
2922 end
2923 end
2924 end
2925 if VRGet("CB_RemoveLMHosts","set") then do
2926 call _LMHostsImport
2927 end
2928
2929 call RemoveConfig_Close
2930return
2931
2932/*:VRX PB_Save_Click
2933*/
2934PB_Save_Click:
2935 IF options.!debug == 1 THEN say 'PB_Save_Click() started'
2936 if ValueChanged then do
2937 if CurSection <> "" then do
2938 call _SaveChanges
2939 ok = VRSet("PB_Save", "Enabled", 0)
2940 call CN_smbconf_Click
2941 end
2942 end
2943 IF options.!debug == 1 THEN say 'PB_Save_Click() done'
2944return
2945
2946/*:VRX PB_StartStop_Click
2947*/
2948PB_StartStop_Click:
2949 call PB_Save_Click
2950 call beep 960, 1
2951 address CMD samba.!smbcmd' reload'
2952return
2953
2954/*:VRX PB_Undo_Click
2955*/
2956PB_Undo_Click:
2957 call _SmbConfRestore
2958 SmbConfExists = 1
2959 call _SmbConfTreeReset
2960return
2961
2962/*:VRX PrinterSelection_Close
2963*/
2964PrinterSelection_Close:
2965 call PrinterSelection_Fini
2966return
2967
2968/*:VRX PrinterSelection_Create
2969*/
2970PrinterSelection_Create:
2971 call PrinterSelection_Init
2972 ok = VRMethod( "Application", "ListPrinters", "printer." )
2973
2974 CALL NLVSetText 'Printerselection', 'Caption', 40
2975 CALL NLVSetText 'PB_Printer_OK', 'Caption', 2
2976 CALL NLVSetText 'PB_Printer_Abort', 'Caption', 3
2977
2978 do I = 1 to printer.0
2979 ok = VRMethod("LB_Printers","AddString",PurePrinter(printer.I))
2980 if PurePrinter(printer.!default) = PurePrinter(printer.I) then ok = VRSet("LB_Printers","Selected",I)
2981 end
2982return
2983/*:VRX PrinterSelection_Fini
2984*/
2985PrinterSelection_Fini:
2986 window = VRInfo( "Window" )
2987 call VRDestroy window
2988 drop window
2989return
2990/*:VRX PrinterSelection_Init
2991*/
2992PrinterSelection_Init:
2993 window = VRInfo( "Object" )
2994 if( \VRIsChildOf( window, "Notebook" ) ) then do
2995 call VRMethod window, "CenterWindow"
2996 call VRSet window, "Visible", 1
2997 call VRMethod window, "Activate"
2998 end
2999 drop window
3000return
3001
3002/*:VRX PurePrinter
3003*/
3004PurePrinter:
3005return substr(arg(1),1,pos(';',arg(1))-1)
3006
3007/*:VRX Quit
3008*/
3009Quit:
3010 IF options.!debug == 1 THEN say "Quit() start"
3011
3012 if VRGet("Main","WindowState") = "Maximized"|,
3013 VRGet("Main","WindowState") = "Minimized" then ok = VRMethod("Main", "Restore")
3014
3015 if samba.!testparmexe <> "" then do
3016 address cmd samba.!testparmexe' -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
3017 call _SmbConfCommitChanges
3018 end
3019
3020 call _INIWrite
3021 call _SambaFinish
3022 ok = SysFileDelete(TempDir'sscc.testparm')
3023 ok = SysFileDelete(smboutput)
3024
3025 IF options.!debug == 1 THEN say "Quit() done"
3026 /* ok = VRRedirectStdio('OFF') */
3027 window = VRWindow()
3028 call VRSet window, "Shutdown", 1
3029 drop window
3030return
3031
3032/*:VRX RB_PDC_Click
3033*/
3034RB_PDC_Click:
3035 CreatePDC = VRGet("RB_PDC","Set")
3036return
3037
3038/*:VRX RB_smbpasswd_Click
3039*/
3040RB_smbpasswd_Click:
3041 UseTDBsam = 0
3042return
3043
3044/*:VRX RB_Standalone_Click
3045*/
3046RB_Standalone_Click:
3047 CreatePDC = \VRGet("RB_Standalone","Set")
3048return
3049
3050/*:VRX RB_tdbsam_Click
3051*/
3052RB_tdbsam_Click:
3053 UseTDBsam = 1
3054return
3055
3056/*:VRX RemoveConfig_Close
3057*/
3058RemoveConfig_Close:
3059 call RemoveConfig_Fini
3060return
3061
3062/*:VRX RemoveConfig_Create
3063*/
3064RemoveConfig_Create:
3065 call RemoveConfig_Init
3066 CALL NLVSetText 'RemoveConfig', 'Caption', 90
3067 CALL NLVSetText 'PB_RemoveContinue', 'Caption', 14
3068
3069 ok = VRset("CB_RemoveSmbConf","Caption", NLVGetMessage(56, 'smb.conf'))
3070 ok = VRset("CB_RemoveBackend","Caption", NLVGetMessage(56, 'Backend'))
3071 ok = VRset("CB_RemoveLMHosts","Caption", NLVGetMessage(56, 'lmhosts'))
3072
3073 /* Check if ?db backend files exist */
3074 ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
3075 if xdb.0 = 0 then ok = VRset("CB_RemoveBackend","Enabled", 0)
3076
3077 /* Check if LMHOsts exists */
3078 ok = VRset("CB_RemoveLMHosts","Enabled", VRFileExists(ETC'\samba\lmhosts'))
3079return
3080
3081/*:VRX RemoveConfig_Fini
3082*/
3083RemoveConfig_Fini:
3084 window = VRInfo( "Window" )
3085 call VRDestroy window
3086 drop window
3087return
3088/*:VRX RemoveConfig_Init
3089*/
3090RemoveConfig_Init:
3091 window = VRInfo( "Object" )
3092 if( \VRIsChildOf( window, "Notebook" ) ) then do
3093 call VRMethod window, "CenterWindow"
3094 call VRSet window, "Visible", 1
3095 call VRMethod window, "Activate"
3096 end
3097 drop window
3098return
3099
3100/*:VRX TM_Installer_Trigger
3101*/
3102TM_Installer_Trigger:
3103 call _InstallerMode
3104return
3105
3106/*:VRX TM_Value_Trigger
3107*/
3108TM_Value_Trigger:
3109 say "TM_Value_Trigger started"
3110 ValueChanged = 0
3111 ok = VRSet("PB_Save", "Enabled", 0)
3112 ChangeList = ""
3113 ok = VRSet("TM_Value", "Enabled", 0)
3114 say "TM_Value_Trigger done"
3115return
Note: See TracBrowser for help on using the repository browser.