| 1 | /*:VRX         _FindHtpasswd | 
|---|
| 2 | */ | 
|---|
| 3 | _FindHtpasswd: | 
|---|
| 4 | IF options.!debug == 1 THEN say '_FindHtpasswd() started' | 
|---|
| 5 | /* htpasswd.exe - required for SWAT but not really part of Samba */ | 
|---|
| 6 | samba.!htpasswdexe = "" | 
|---|
| 7 | if samba.!htpasswdexe = "" then do /* INI entry */ | 
|---|
| 8 | call charout , "  Do we have an INI entry for Apache? " | 
|---|
| 9 | apachepath = VRGetIni( "Apache", "Path", samba.!bin'\sscc.ini' ) | 
|---|
| 10 | say apachepath | 
|---|
| 11 | samba.!htpasswdexe = apachepath'\htpasswd.exe' | 
|---|
| 12 | if \VRFileExists(samba.!htpasswdexe) then do /* It is invalid! */ | 
|---|
| 13 | samba.!htpasswdexe = "" | 
|---|
| 14 | ok = VRDelIni( "Apache", "Path", samba.!bin'\sscc.ini' ) | 
|---|
| 15 | end | 
|---|
| 16 | end | 
|---|
| 17 | if samba.!htpasswdexe = "" then do /* in current directory? */ | 
|---|
| 18 | call charout , "  Is htpasswd.exe in current directory? " | 
|---|
| 19 | ok = SysFileTree('.\htpasswd.exe', exist.,'FO') | 
|---|
| 20 | say exist.0' (1 = Yes, 0 = No)' | 
|---|
| 21 | if exist.0 = 1 then samba.!htpasswdexe = exist.1 | 
|---|
| 22 | end | 
|---|
| 23 | if samba.!htpasswdexe = "" then do /* in parent directory? */ | 
|---|
| 24 | call charout , "  Is htpasswd.exe in parent directory? " | 
|---|
| 25 | ok = SysFileTree('..\htpasswd.exe', exist.,'FO') | 
|---|
| 26 | say exist.0' (1 = Yes, 0 = No)' | 
|---|
| 27 | if exist.0 = 1 then samba.!htpasswdexe = exist.1 | 
|---|
| 28 | end | 
|---|
| 29 | if samba.!htpasswdexe = "" then do /* in ..\BIN directory? */ | 
|---|
| 30 | call charout , "  Is htpasswd.exe in ..\BIN directory? " | 
|---|
| 31 | ok = SysFileTree('..\bin\htpasswd.exe', exist.,'FO') | 
|---|
| 32 | say exist.0' (1 = Yes, 0 = No)' | 
|---|
| 33 | if exist.0 = 1 then samba.!htpasswdexe = exist.1 | 
|---|
| 34 | end | 
|---|
| 35 | if samba.!htpasswdexe = "" then do /* in \apache2\bin */ | 
|---|
| 36 | call charout , "  Is htpasswd.exe in "SysBootDrive()"\apache2\bin path? " | 
|---|
| 37 | ok = SysFileTree(SysBootDrive()'\apache2\bin\htpasswd.exe', exist.,'FO') | 
|---|
| 38 | say exist.0' (1 = Yes, 0 = No)' | 
|---|
| 39 | if exist.0 = 1 then samba.!htpasswdexe = exist.1 | 
|---|
| 40 | end | 
|---|
| 41 | if samba.!htpasswdexe = "" then do /* in ..\..\apache2\bin */ | 
|---|
| 42 | call charout , "  Is htpasswd.exe in ..\..\apache2\bin path? " | 
|---|
| 43 | ok = SysFileTree('..\..\apache2\bin\htpasswd.exe', exist.,'FO') | 
|---|
| 44 | say exist.0' (1 = Yes, 0 = No)' | 
|---|
| 45 | if exist.0 = 1 then samba.!htpasswdexe = exist.1 | 
|---|
| 46 | end | 
|---|
| 47 |  | 
|---|
| 48 | if samba.!htpasswdexe = "" then do /* in PATH ? */ | 
|---|
| 49 | call charout , "  Is htpasswd.exe in PATH? " | 
|---|
| 50 | samba.!htpasswdexe = SysSearchPath("PATH","htpasswd.exe") | 
|---|
| 51 | if samba.!htpasswdexe = "" then say "No."; else say "Yes." | 
|---|
| 52 | end | 
|---|
| 53 |  | 
|---|
| 54 | if samba.!htpasswdexe = "" then do | 
|---|
| 55 | swatauth = 0 | 
|---|
| 56 | swatusers = "" | 
|---|
| 57 | end | 
|---|
| 58 | else do | 
|---|
| 59 | swatauth = 1 | 
|---|
| 60 | swatusers = ETC'\samba\private\swatusers' | 
|---|
| 61 | end | 
|---|
| 62 | IF options.!debug == 1 THEN say '_FindHtpasswd() done' | 
|---|
| 63 | return | 
|---|