/* Perform basic Samba Client init stuff */ /*:VRX */ _CltInit: IF options.!debug == 1 THEN say time()' _CltInit() started' IF options.!debug == 1 THEN say ' Checking Samba Client setup...' /* debuglevel when executing Samba binaries */ debuglevel = ' --debuglevel=0' /* Error status and file variables */ ErrorState = 0 /* _ErrorBinaryNotFound() changes this variable */ DataErrorState = 0 /* _ErrorDataFileNotFound() changes this variable */ /* Evaluate environment */ ETC = value('ETC',,'OS2ENVIRONMENT') IF options.!debug == 1 THEN say ' ETC = "'ETC'"' UnixRoot = value("UNIXROOT",,'OS2ENVIRONMENT') if UnixRoot = "" then do UnixRoot = left(ETC,length(ETC)-4) say ' WARNING! Setting missing UNIXROOT variable to "'UnixRoot'".' ok = value("UNIXROOT",UnixRoot,'OS2ENVIRONMENT') end IF options.!debug == 1 THEN say ' UnixRoot = "'UnixRoot'"' unixetc = UnixRoot'\etc' IF options.!debug == 1 THEN say ' Unixetc = "'unixetc'"' /* Find all executables */ /* Get the path to this file */ samba.!tools = VRParseFilename(VRGet("Application", "Program"),'DP') if samba.!tools = '' then do parse source . . script samba.!tools = VRParseFilename(script,'DP') end IF options.!debug == 1 THEN say ' Samba tools = "'samba.!tools'"' say ' Changing into tools "'directory(samba.!tools)'"' /* smbclient.exe */ samba.!smbclientexe = "" if samba.!smbclientexe = "" then do /* wellknown locations */ WellKnown = sysBootdrive()"\ecs\system\samba;"sysBootdrive()"\samba" Programs = value("PROGRAMS",,'OS2ENVIRONMENT') if Programs <> "" then WellKnown = Wellknown';'Programs'\samba' Tools = value("TOOLS",,'OS2ENVIRONMENT') if Programs <> "" then WellKnown = Wellknown';'Tools'\samba' say Wellknown call charout , " Are binaries in wellknown locations? " ok = VRFindFile("smbclient.exe",WellKnown) if ok <> "" then say "Yes."; else say "No." if ok <> "" then samba.!smbclientexe = ok drop Wellknown end if samba.!smbclientexe = "" then do /* in current directory? */ call charout , " Are binaries in current directory? " ok = SysFileTree('.\smbclient.exe', exist.,'FO') if exist.0 = 1 then say "Yes."; else say "No." if exist.0 = 1 then samba.!smbclientexe = exist.1 end if samba.!smbclientexe = "" then do /* RPM/YUM/FHS tree */ call charout , " Are binaries in RPM/YUM/FHS tree? " ok = SysFileTree(UnixRoot'\usr\bin\smbclient.exe', exist.,'FO') if exist.0 = 1 then say "Yes."; else say "No." if exist.0 = 1 then samba.!smbclientexe = exist.1 end if samba.!smbclientexe = "" then do /* in parent directory? */ call charout , " Are binaries in parent directory? " ok = SysFileTree('..\smbclient.exe', exist.,'FO') if exist.0 = 1 then say "Yes."; else say "No." if exist.0 = 1 then samba.!smbclientexe = exist.1 end if samba.!smbclientexe = "" then do /* in ..\BIN directory? */ call charout , " Are binaries in ..\BIN directory? " ok = SysFileTree('..\bin\smbclient.exe', exist.,'FO') if exist.0 = 1 then say "Yes."; else say "No." if exist.0 = 1 then samba.!smbclientexe = exist.1 end if samba.!smbclientexe = "" then do /* in SMB_EXE ? */ call charout , " Are binaries in SMB_EXE path? " samba.!smbclientexe = SysSearchPath("SMB_EXE","smbclient.EXE") if samba.!smbclientexe = "" then say "No."; else say "Yes." end if samba.!smbclientexe = "" then do /* in PATH ? */ call charout , " Are binaries in PATH? " samba.!smbclientexe = SysSearchPath("PATH","smbclient.EXE") if samba.!smbclientexe = "" then say "No."; else say "Yes." end if samba.!smbclientexe = "" then call _ErrorBinaryNotFound " could not find smbclient.exe!" samba.!bin = VRParseFileName(samba.!smbclientexe,'DP') IF options.!debug == 1 THEN say ' Samba binaries = "'samba.!bin'"' /* net.exe */ samba.!netexe = samba.!bin'\net.exe' if \VRFileExists(samba.!netexe) then call _ErrorBinaryNotFound " could not find net.exe!" IF options.!debug == 1 THEN say ' net.exe = "'samba.!netexe'"' /* testparm.exe */ samba.!testparmexe = samba.!bin'\testparm.exe' if \VRFileExists(samba.!testparmexe) then call _ErrorBinaryNotFound " could not find testparm.exe!" IF options.!debug == 1 THEN say ' testparm.exe = "'samba.!testparmexe'"' /* smbtree.exe */ samba.!smbtreeexe = samba.!bin'\smbtree.exe' if \VRFileExists(samba.!smbtreeexe) then call _ErrorBinaryNotFound " could not find smbtree.exe!" IF options.!debug == 1 THEN say ' smbtree.exe = "'samba.!smbtreeexe'"' /* nmblookup.exe */ samba.!nmblookupexe = samba.!bin'\nmblookup.exe' if \VRFileExists(samba.!nmblookupexe) then call _ErrorBinaryNotFound " could not find nmblookup.exe!" IF options.!debug == 1 THEN say ' nmblookup.exe = "'samba.!nmblookupexe'"' /* smbspool.exe */ samba.!smbspoolexe = samba.!bin'\smbspool.exe' if \VRFileExists(samba.!smbspoolexe) then call _ErrorBinaryNotFound " could not find smbspool.exe!" IF options.!debug == 1 THEN say ' smbspool.exe = "'samba.!smbspoolexe'"' /* rpcclient.exe */ samba.!rpcclientexe = samba.!bin'\rpcclient.exe' if \VRFileExists(samba.!rpcclientexe) then call _ErrorBinaryNotFound " could not find rpcclient.exe!" IF options.!debug == 1 THEN say ' rpcclient.exe = "'samba.!rpcclientexe'"' /* smb.conf */ samba.!smbconf = ETC'\samba\smb.conf' if \VRFileExists(samba.!smbconf) then call _ErrorDataFileNotFound samba.!smbconf' is not present.' IF options.!debug == 1 THEN say ' Samba smb.conf = "'samba.!smbconf'"' /* complete shadow copy of smb.conf in temporary directory - should always be created on the fly */ /* before reading from it */ samba.!shadowsmbconf = TempDir||'smb.conf' /* lmhosts */ samba.!lmhosts = ETC'\samba\lmhosts' if \VRFileExists(samba.!lmhosts) then call _ErrorDataFileNotFound samba.!lmhosts' is not present.' IF options.!debug == 1 THEN say ' Samba lmhosts = "'samba.!lmhosts'"' /* FIXME: Needs to be changed for Samba 3.3+ */ /* upcase table files - several utilities need these */ if (\VRFileExists(samba.!bin'\lib\upcase.dat')) |, (\VRFileExists(samba.!bin'\lib\lowcase.dat')) |, (\VRFileExists(samba.!bin'\lib\valid.dat')) then call _ErrorDataFileNotFound 'upcase table files not present.' /* the password files - we'll create them if they don't exist */ samba.!masterpasswd = unixetc'\master.passwd' if \VRFileExists(samba.!masterpasswd) then call _ErrorDataFileNotFound 'Could not find "'samba.!masterpasswd'"!' IF options.!debug == 1 then say ' master.passwd = "'samba.!masterpasswd'"' samba.!pwddb = unixetc'\pwd.db' if \VRFileExists(samba.!pwddb) then call _ErrorDataFileNotFound 'Could not find "'samba.!pwddb'"!' IF options.!debug == 1 then say ' pwd.db = "'samba.!pwddb'"' samba.!spwddb = unixetc'\spwd.db' if \VRFileExists(samba.!spwddb) then call _ErrorDataFileNotFound 'Could not find "'samba.!spwddb'"!' IF options.!debug == 1 then say ' spwd.db = "'samba.!spwddb'"' samba.!group = unixetc'\group' if \VRFileExists(samba.!group) then call _ErrorDataFileNotFound 'Could not find "'samba.!group'"!' IF options.!debug == 1 then say ' group = "'samba.!group'"' samba.!printcap = unixetc'\printcap' if \VRFileExists(samba.!printcap) then call _ErrorDataFileNotFound 'Could not find "'samba.!printcap'"!' IF options.!debug == 1 then say ' printcap = "'samba.!printcap'"' /* Create these directories to make sure they do exist */ ok = SysMkDir(unixetc) ok = SysMkDir(etc'\samba') ok = SysMkDir(etc'\samba\pid') ok = SysMkDir(etc'\samba\lock') /* This EA makes the testparm warning about browsing go away. */ /* Note: The EA is NOT marked critical as it should be, neverthelesse this fix works */ ok = SysPutEA(etc||'\samba\lock',"MODE", "FEFF0400ED410000"x) /* Messages from Samba will go here */ samba.!error = SysTempFileName(TempDir'smb_err.???') IF options.!debug == 1 THEN say ' samba.!error = "'samba.!error'"' samba.!msg = SysTempFileName(TempDir'smb_msg.???') IF options.!debug == 1 THEN say ' samba.!msg = "'samba.!msg'"' /* Use of this file is deprecated */ ErrorFile = Tempdir'smbutil.error' IF options.!debug == 1 then do if ErrorState then say " One or more basic Samba Client setup errors detected!" else say " No basic Samba Client setup errors detected!" end IF options.!debug == 1 THEN say time()' _CltInit() done, Errorstate = 'Errorstate return /*:VRX */ _SambaFinish: /* Do some basic housekeeping when leaving */ ok = SysFileTree(TempDir'smb_???.???', garbage., 'FO') do I = 1 to garbage.0 ok = stream(garbage.I,'c','close') ok = SysFileDelete(garbage.I) end return /*:VRX */ _ErrorBinaryNotFound: /* Set error status variable and show a short message - incomplete! */ msg = arg(1) say "ERROR: "msg id = VRMessage( VRWindow(), msg, "Samba Client Installation", "E" ) ErrorState = (1|ErrorState) return /*:VRX */ _ErrorDataFileNotFound: /* Set error status variable and show a short message - incomplete! */ msg = arg(1) say "ERROR: "msg DataErrorState = (1|DataErrorState) return /*:VRX */ _SambaExtendSearchPath: IF options.!debug == 1 THEN say time()' _SambaExtendSearchPath() started' /* Add binary and tools path to the PATH variable */ old_path = value('PATH',, 'OS2ENVIRONMENT') if pos(translate(samba.!bin';'),translate(old_path)) = 0 then do if samba.!bin = samba.!tools then new_path = samba.!bin';' else new_path = samba.!bin';'samba.!tools';' ok = value('PATH', new_path || old_path, 'OS2ENVIRONMENT') drop new_path end drop old_path /* Add binary and tools path to the BEGINLIBPATH variable */ old_beginlibpath = SysQueryExtLibPath("B") if pos(translate(samba.!bin';'),translate(old_beginlibpath)) = 0 then do if samba.!bin = samba.!tools then new_beginlibpath = samba.!bin';'old_beginlibpath else new_beginlibpath = samba.!bin';'samba.!tools';'old_beginlibpath ok = SysSetExtLibPath( new_beginlibpath, "B") drop new_beginlibpath end drop old_beginlibpath /* Set LIBPATHSTRICT (this is an option - disabled by default) */ /* ok = value('LIBPATHSTRICT','T', 'OS2ENVIRONMENT') */ IF options.!debug == 1 THEN say time()' _SambaExtendSearchPath() done' return