[269] | 1 | /* Perform basic Samba init stuff */
|
---|
| 2 |
|
---|
| 3 | /*:VRX */
|
---|
| 4 | _SambaInit:
|
---|
| 5 | IF options.!debug == 1 THEN say '_SambaInit() started'
|
---|
| 6 | IF options.!debug == 1 THEN say " Checking Samba setup..."
|
---|
| 7 |
|
---|
| 8 | /* debuglevel when executing Samba binaries */
|
---|
| 9 | debuglevel = ' --debuglevel=0'
|
---|
| 10 |
|
---|
| 11 | /* Error status and file variables */
|
---|
[275] | 12 | ErrorState = 0 /* _ErrorBinaryNotFound() changes this variable */
|
---|
| 13 | DataErrorState = 0 /* _ErrorDataFileNotFound() changes this variable */
|
---|
[269] | 14 |
|
---|
| 15 | /* Evaluate environment */
|
---|
| 16 | ETC = value('ETC',,'OS2ENVIRONMENT')
|
---|
| 17 | IF options.!debug == 1 THEN say ' ETC = "'ETC'"'
|
---|
| 18 |
|
---|
| 19 | UnixRoot = value("UNIXROOT",,'OS2ENVIRONMENT')
|
---|
| 20 | if UnixRoot = "" then do
|
---|
| 21 | UnixRoot = left(ETC,length(ETC)-4)
|
---|
| 22 | say ' WARNING! Setting missing UNIXROOT variable to "'UnixRoot'".'
|
---|
| 23 | ok = value("UNIXROOT",UnixRoot,'OS2ENVIRONMENT')
|
---|
| 24 | end
|
---|
| 25 |
|
---|
| 26 | IF options.!debug == 1 THEN say ' UnixRoot = "'UnixRoot'"'
|
---|
| 27 |
|
---|
| 28 | unixetc = UnixRoot'\etc'
|
---|
| 29 | IF options.!debug == 1 THEN say ' Unixetc = "'unixetc'"'
|
---|
| 30 |
|
---|
[277] | 31 | /* Find all executables */
|
---|
[269] | 32 |
|
---|
[277] | 33 | /* Get the path to this file */
|
---|
[269] | 34 | samba.!tools = VRParseFilename(VRGet("Application", "Program"),'DP')
|
---|
| 35 | if samba.!tools = '' then do
|
---|
| 36 | parse source . . script
|
---|
| 37 | samba.!tools = VRParseFilename(script,'DP')
|
---|
| 38 | end
|
---|
| 39 | IF options.!debug == 1 THEN say ' Samba tools = "'samba.!tools'"'
|
---|
| 40 | say ' Changing into "'directory(samba.!tools)'"'
|
---|
| 41 |
|
---|
| 42 | /* smbd.exe */
|
---|
| 43 | samba.!smbd = ""
|
---|
[451] | 44 | if samba.!smbd = "" then do /* USER\Samba\ServerPath */
|
---|
| 45 | call charout , " Is Samba ServerPath stored in OS2.INI? "
|
---|
| 46 | samba.!bin = strip(VRGetIni( "Samba", "ServerPath2", "USER" ),'T','00'x)
|
---|
| 47 | if samba.!bin <> "" then do
|
---|
| 48 | say 'Yes, found "'samba.!bin'"'
|
---|
| 49 | if VRFileExists(samba.!bin"\smbd.exe") then do
|
---|
| 50 | samba.!smbd = samba.!bin"\smbd.exe"
|
---|
| 51 | say ' Found "'samba.!smbd'".'
|
---|
| 52 | end
|
---|
| 53 | end
|
---|
| 54 | else say 'No, possibly manual installation.'
|
---|
| 55 | end
|
---|
| 56 | if samba.!smbd = "" then do /* wellknown locations */
|
---|
| 57 | WellKnown = SysBootdrive()"\ecs\system\samba;"SysBootdrive()"\samba"
|
---|
| 58 | Programs = value("PROGRAMS",,'OS2ENVIRONMENT')
|
---|
| 59 | if Programs <> "" then WellKnown = Wellknown';'Programs'\samba'
|
---|
| 60 | Tools = value("TOOLS",,'OS2ENVIRONMENT')
|
---|
| 61 | if Tools <> "" then WellKnown = Wellknown';'Tools'\samba'
|
---|
| 62 | call charout , " Are binaries in wellknown locations? "
|
---|
| 63 | ok = VRFindFile("smbd.exe",WellKnown)
|
---|
| 64 | if ok <> "" then say "Yes."; else say "No."
|
---|
| 65 | if ok <> "" then samba.!smbd = ok
|
---|
| 66 | drop Wellknown Tools Programs
|
---|
| 67 | end
|
---|
[269] | 68 | if samba.!smbd = "" then do /* in current directory? */
|
---|
| 69 | call charout , " Are binaries in current directory? "
|
---|
| 70 | ok = SysFileTree('.\smbd.exe', exist.,'FO')
|
---|
[451] | 71 | if exist.0 = 1 then say "Yes."; else say "No."
|
---|
[269] | 72 | if exist.0 = 1 then samba.!smbd = exist.1
|
---|
| 73 | end
|
---|
| 74 | if samba.!smbd = "" then do /* in parent directory? */
|
---|
| 75 | call charout , " Are binaries in parent directory? "
|
---|
| 76 | ok = SysFileTree('..\smbd.exe', exist.,'FO')
|
---|
[451] | 77 | if exist.0 = 1 then say "Yes."; else say "No."
|
---|
[269] | 78 | if exist.0 = 1 then samba.!smbd = exist.1
|
---|
| 79 | end
|
---|
| 80 | if samba.!smbd = "" then do /* in ..\BIN directory? */
|
---|
| 81 | call charout , " Are binaries in ..\BIN directory? "
|
---|
| 82 | ok = SysFileTree('..\bin\smbd.exe', exist.,'FO')
|
---|
[451] | 83 | if exist.0 = 1 then say "Yes."; else say "No."
|
---|
[269] | 84 | if exist.0 = 1 then samba.!smbd = exist.1
|
---|
| 85 | end
|
---|
| 86 | if samba.!smbd = "" then do /* in SMB_EXE ? */
|
---|
| 87 | call charout , " Are binaries in SMB_EXE path? "
|
---|
| 88 | samba.!smbd = SysSearchPath("SMB_EXE","SMBD.EXE")
|
---|
| 89 | if samba.!smbd = "" then say "No."; else say "Yes."
|
---|
| 90 | end
|
---|
| 91 | if samba.!smbd = "" then do /* in PATH ? */
|
---|
| 92 | call charout , " Are binaries in PATH? "
|
---|
| 93 | samba.!smbd = SysSearchPath("PATH","SMBD.EXE")
|
---|
| 94 | if samba.!smbd = "" then say "No."; else say "Yes."
|
---|
| 95 | end
|
---|
| 96 |
|
---|
[408] | 97 | if samba.!smbd = "" then call _ErrorBinaryNotFound 'Could not find smbd.exe!'
|
---|
[269] | 98 |
|
---|
[451] | 99 |
|
---|
[269] | 100 | samba.!bin = VRParseFileName(samba.!smbd,'DP')
|
---|
| 101 | IF options.!debug == 1 THEN say ' Samba binaries = "'samba.!bin'"'
|
---|
[451] | 102 | IF options.!debug == 1 THEN say ' Samba smbd.exe = "'samba.!smbd'"'
|
---|
[269] | 103 |
|
---|
| 104 | /* smb.cmd */
|
---|
| 105 | samba.!smbcmd = samba.!tools'\smb.cmd'
|
---|
| 106 | if \VRFileExists(samba.!smbcmd) then do
|
---|
| 107 | samba.!smbcmd = samba.!bin'\smb.cmd'
|
---|
[408] | 108 | if \VRFileExists(samba.!smbcmd) then call _ErrorBinaryNotFound 'Could not find smb.cmd!'
|
---|
[269] | 109 | end
|
---|
| 110 | IF options.!debug == 1 THEN say ' smb.cmd = "'samba.!smbcmd'"'
|
---|
| 111 |
|
---|
| 112 | /* smbpasswd.exe */
|
---|
| 113 | samba.!smbpasswdexe = samba.!bin'\smbpasswd.exe'
|
---|
[408] | 114 | if \VRFileExists(samba.!smbpasswdexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!smbpasswdexe'"!'
|
---|
[269] | 115 | IF options.!debug == 1 THEN say ' smbpasswd.exe = "'samba.!smbpasswdexe'"'
|
---|
| 116 |
|
---|
| 117 | /* pdbedit.exe */
|
---|
| 118 | samba.!pdbeditexe = samba.!bin'\pdbedit.exe'
|
---|
[408] | 119 | if \VRFileExists(samba.!pdbeditexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!pdbeditexe'"!'
|
---|
[269] | 120 | IF options.!debug == 1 THEN say ' pdbedit.exe = "'samba.!pdbeditexe'"'
|
---|
| 121 |
|
---|
| 122 | /* net.exe */
|
---|
| 123 | samba.!netexe = samba.!bin'\net.exe'
|
---|
[408] | 124 | if \VRFileExists(samba.!netexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!netexe'"!'
|
---|
[269] | 125 | IF options.!debug == 1 THEN say ' net.exe = "'samba.!netexe'"'
|
---|
| 126 |
|
---|
| 127 | /* testparm.exe */
|
---|
| 128 | samba.!testparmexe = samba.!bin'\testparm.exe'
|
---|
[408] | 129 | if \VRFileExists(samba.!testparmexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!testparmexe'"!'
|
---|
[269] | 130 | IF options.!debug == 1 THEN say ' testparm.exe = "'samba.!testparmexe'"'
|
---|
| 131 |
|
---|
| 132 | /* smbtree.exe */
|
---|
| 133 | samba.!smbtreeexe = samba.!bin'\smbtree.exe'
|
---|
[408] | 134 | if \VRFileExists(samba.!smbtreeexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!smbtreeexe'"!'
|
---|
[269] | 135 | IF options.!debug == 1 THEN say ' smbtree.exe = "'samba.!smbtreeexe'"'
|
---|
| 136 |
|
---|
| 137 | /* smbstatus.exe */
|
---|
| 138 | samba.!smbstatusexe = samba.!bin'\smbstatus.exe'
|
---|
[408] | 139 | if \VRFileExists(samba.!smbstatusexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!smbstatusexe'"!'
|
---|
[269] | 140 | IF options.!debug == 1 THEN say ' smbstatus.exe = "'samba.!smbstatusexe'"'
|
---|
| 141 |
|
---|
| 142 | /* smbcontrol.exe */
|
---|
| 143 | samba.!smbcontrolexe = samba.!bin'\smbcontrol.exe'
|
---|
[408] | 144 | if \VRFileExists(samba.!smbcontrolexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!smbcontrolexe'"!'
|
---|
[269] | 145 | IF options.!debug == 1 THEN say ' smbcontrol.exe = "'samba.!smbcontrolexe'"'
|
---|
| 146 |
|
---|
| 147 | /* smbclient.exe */
|
---|
| 148 | samba.!smbclientexe = samba.!bin'\smbclient.exe'
|
---|
[408] | 149 | if \VRFileExists(samba.!smbclientexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!smbclientexe'"!'
|
---|
[269] | 150 | IF options.!debug == 1 THEN say ' smbclient.exe = "'samba.!smbclientexe'"'
|
---|
| 151 |
|
---|
[333] | 152 | /* nmblookup.exe */
|
---|
| 153 | samba.!nmblookupexe = samba.!bin'\nmblookup.exe'
|
---|
[408] | 154 | if \VRFileExists(samba.!nmblookupexe) then call _ErrorBinaryNotFound 'Could not find "'samba.!nmblookupexe'"!'
|
---|
[333] | 155 | IF options.!debug == 1 THEN say ' nmblookup.exe = "'samba.!nmblookupexe'"'
|
---|
| 156 |
|
---|
[269] | 157 | /* pwd_mkdb */
|
---|
| 158 | samba.!pwd_mkdb = SysSearchPath("PATH","pwd_mkdb.exe")
|
---|
| 159 | if samba.!pwd_mkdb = "" then do /* in current directory? */
|
---|
| 160 | ok = SysFileTree('.\pwd_mkdb.exe', exist.,'FO')
|
---|
| 161 | if exist.0 = 1 then samba.!pwd_mkdb = exist.1
|
---|
| 162 | end
|
---|
| 163 | if samba.!pwd_mkdb = "" then do /* in usr/sbin directory? */
|
---|
| 164 | ok = SysFileTree(UnixRoot'\usr\sbin\pwd_mkdb.exe', exist.,'FO')
|
---|
| 165 | if exist.0 = 1 then samba.!pwd_mkdb = exist.1
|
---|
| 166 | end
|
---|
| 167 | if samba.!pwd_mkdb = "" then do /* tools directory? */
|
---|
| 168 | ok = SysFileTree(samba.!tools'\pwd_mkdb.exe', exist.,'FO')
|
---|
| 169 | if exist.0 = 1 then samba.!pwd_mkdb = exist.1
|
---|
| 170 | end
|
---|
| 171 | if samba.!pwd_mkdb = "" then do /* in smbd directory? */
|
---|
| 172 | ok = SysFileTree(samba.!bin'\pwd_mkdb.exe', exist.,'FO')
|
---|
| 173 | if exist.0 = 1 then samba.!pwd_mkdb = exist.1
|
---|
| 174 | end
|
---|
| 175 | if samba.!pwd_mkdb = "" then do /* in SMB_SBIN ? */
|
---|
| 176 | samba.!pwd_mkdb = SysSearchPath("SMB_SBIN","pwd_mkdb.exe")
|
---|
| 177 | end
|
---|
| 178 |
|
---|
[408] | 179 | if samba.!pwd_mkdb = "" then call _ErrorBinaryNotFound 'Could not find "'samba.!pwd_mkdb'"!'
|
---|
[269] | 180 | IF options.!debug == 1 THEN say ' pwd_mkdb.exe = "'samba.!pwd_mkdb'"'
|
---|
| 181 |
|
---|
| 182 | /* logfiles */
|
---|
| 183 | samba.!log = value('SMB_LOGS',,'OS2ENVIRONMENT')
|
---|
| 184 | if samba.!log = "" then do /* new default */
|
---|
[284] | 185 | ok = SysFileTree(etc'\samba\log',exist.,'DO')
|
---|
[269] | 186 | if exist.0 > 0 then samba.!log = etc'\samba\logs'
|
---|
| 187 | end
|
---|
| 188 | if samba.!log = "" then do /* old default */
|
---|
| 189 | ok = SysFileTree(samba.!bin'\logs\log.smbd*',exist.,'FO')
|
---|
| 190 | if exist.0 > 0 then samba.!log = samba.!bin'\logs'
|
---|
| 191 | end
|
---|
| 192 | if samba.!log = "" then do /* LOGFILES */
|
---|
| 193 | samba.!log = value('LOGFILES',,'OS2ENVIRONMENT')
|
---|
| 194 | end
|
---|
| 195 |
|
---|
[408] | 196 | if samba.!log = "" then call _ErrorDataFileNotFound 'Could not find logfiles!'
|
---|
[269] | 197 | IF options.!debug == 1 THEN say ' Samba logfiles = "'samba.!log'"'
|
---|
| 198 |
|
---|
| 199 | /* smb.conf */
|
---|
| 200 | samba.!smbconf = ETC'\samba\smb.conf'
|
---|
[275] | 201 | if \VRFileExists(samba.!smbconf) then call _ErrorDataFileNotFound samba.!smbconf' is not present.'
|
---|
[269] | 202 | IF options.!debug == 1 THEN say ' Samba smb.conf = "'samba.!smbconf'"'
|
---|
| 203 |
|
---|
| 204 | /* find all datafiles - their locations are fixed */
|
---|
[277] | 205 |
|
---|
[269] | 206 | /* the password files - we'll create them if they don't exist */
|
---|
| 207 | samba.!masterpasswd = unixetc'\master.passwd'
|
---|
[408] | 208 | if \VRFileExists(samba.!masterpasswd) then call _ErrorDataFileNotFound 'Could not find "'samba.!masterpasswd'"!'
|
---|
[269] | 209 | IF options.!debug == 1 THEN say ' master.passwd = "'samba.!masterpasswd'"'
|
---|
| 210 |
|
---|
| 211 | samba.!pwddb = unixetc'\pwd.db'
|
---|
[408] | 212 | if \VRFileExists(samba.!pwddb) then call _ErrorDataFileNotFound 'Could not find "'samba.!pwddb'"!'
|
---|
[269] | 213 | IF options.!debug == 1 THEN say ' pwd.db = "'samba.!pwddb'"'
|
---|
| 214 |
|
---|
| 215 | samba.!spwddb = unixetc'\spwd.db'
|
---|
[408] | 216 | if \VRFileExists(samba.!spwddb) then call _ErrorDataFileNotFound 'Could not find "'samba.!spwddb'"!'
|
---|
[269] | 217 | IF options.!debug == 1 THEN say ' spwd.db = "'samba.!spwddb'"'
|
---|
| 218 |
|
---|
| 219 | samba.!group = unixetc'\group'
|
---|
[408] | 220 | if \VRFileExists(samba.!group) then call _ErrorDataFileNotFound 'Could not find "'samba.!group'"!'
|
---|
[269] | 221 | IF options.!debug == 1 THEN say ' group = "'samba.!group'"'
|
---|
| 222 |
|
---|
| 223 | samba.!printcap = unixetc'\printcap'
|
---|
[408] | 224 | if \VRFileExists(samba.!printcap) then call _ErrorDataFileNotFound 'Could not find "'samba.!printcap'"!'
|
---|
[269] | 225 | IF options.!debug == 1 THEN say ' printcap = "'samba.!printcap'"'
|
---|
| 226 |
|
---|
[287] | 227 | /* Create these directories to make sure they do exist */
|
---|
[284] | 228 | ok = SysMkDir(unixetc)
|
---|
[269] | 229 | ok = SysMkDir(etc'\samba')
|
---|
| 230 | ok = SysMkDir(etc'\samba\private')
|
---|
| 231 | ok = SysMkDir(etc'\samba\pid')
|
---|
[284] | 232 | ok = SysMkDir(etc'\samba\log')
|
---|
[269] | 233 | ok = SysMkDir(etc'\samba\lock')
|
---|
| 234 | ok = SysMkDir(etc'\samba\spool')
|
---|
| 235 | ok = SysMkDir(etc'\samba\drivers')
|
---|
| 236 |
|
---|
| 237 | /* use temporary smbpasswd created by pdbedit */
|
---|
| 238 | samba.!smbpasswd = TempDir'smbpasswd'
|
---|
| 239 | IF options.!debug == 1 THEN say ' smbpasswd = "'samba.!smbpasswd'" (will be created by pdbedit on the fly!)'
|
---|
| 240 |
|
---|
| 241 | /* Check if winbindd daemon exists */
|
---|
| 242 | HaveWinbindd = (stream(samba.!bin'\winbindd.exe', 'c', 'query exists') <> "")
|
---|
| 243 |
|
---|
[302] | 244 | /* Do we have a minimum of free temporary space? */
|
---|
| 245 | if _ChkTempFreeSpace < 262144 then call _ErrorDataFileNotFound 'Free space on "'TempDir'" exhausted!'
|
---|
| 246 |
|
---|
[269] | 247 | /* Messages from Samba will go here */
|
---|
| 248 | samba.!error = SysTempFileName(TempDir'smb_err.???')
|
---|
| 249 | samba.!msg = SysTempFileName(TempDir'smb_msg.???')
|
---|
[277] | 250 | /* Use of this file is deprecated */
|
---|
| 251 | ErrorFile = Tempdir'smbutil.error'
|
---|
[269] | 252 |
|
---|
| 253 | IF options.!debug == 1 then do
|
---|
| 254 | if ErrorState then say " One or more basic Samba setup errors detected!"
|
---|
| 255 | else say " No basic Samba setup errors detected!"
|
---|
| 256 | end
|
---|
| 257 | IF options.!debug == 1 THEN say '_SambaInit() done, Errorstate = 'Errorstate
|
---|
| 258 | return
|
---|
| 259 |
|
---|
| 260 | /*:VRX */
|
---|
| 261 | _SambaFinish:
|
---|
| 262 | /* Do some very basic housekeeping when leaving */
|
---|
| 263 | ok = stream(samba.!msg,'c','close')
|
---|
[275] | 264 | ok = stream(samba.!error,'c','close')
|
---|
[269] | 265 | ok = SysFileDelete(samba.!msg)
|
---|
[275] | 266 | ok = SysFileDelete(samba.!error)
|
---|
[269] | 267 | return
|
---|
| 268 |
|
---|
| 269 | /*:VRX */
|
---|
[275] | 270 | _ErrorBinaryNotFound:
|
---|
[269] | 271 | /* Set error status variable and show a short message - incomplete! */
|
---|
| 272 | msg = arg(1)
|
---|
| 273 | say "ERROR: "msg
|
---|
[275] | 274 | id = VRMessage( VRWindow(), msg, "Samba Installation", "E" )
|
---|
[269] | 275 | ErrorState = (1|ErrorState)
|
---|
| 276 | return
|
---|
| 277 |
|
---|
| 278 | /*:VRX */
|
---|
[275] | 279 | _ErrorDataFileNotFound:
|
---|
| 280 | /* Set error status variable and show a short message - incomplete! */
|
---|
| 281 | msg = arg(1)
|
---|
| 282 | say "ERROR: "msg
|
---|
| 283 | DataErrorState = (1|DataErrorState)
|
---|
| 284 | return
|
---|
| 285 |
|
---|
| 286 | /*:VRX */
|
---|
[277] | 287 | _SambaExtendSearchPath:
|
---|
| 288 | IF options.!debug == 1 THEN say '_SambaExtendSearchPath() started'
|
---|
| 289 | /* Add binary and tools path to the PATH variable */
|
---|
| 290 | old_path = value('PATH',, 'OS2ENVIRONMENT')
|
---|
| 291 | if pos(translate(samba.!bin';'),translate(old_path)) = 0 then do
|
---|
| 292 | if samba.!bin = samba.!tools then new_path = samba.!bin';'
|
---|
| 293 | else new_path = samba.!bin';'samba.!tools';'
|
---|
| 294 | ok = value('PATH', new_path || old_path, 'OS2ENVIRONMENT')
|
---|
| 295 | drop new_path
|
---|
| 296 | end
|
---|
| 297 | drop old_path
|
---|
[333] | 298 |
|
---|
| 299 | /* Add binary and tools path to the DPATH variable */
|
---|
| 300 | old_dpath = value('DPATH',, 'OS2ENVIRONMENT')
|
---|
| 301 | if pos(translate(samba.!bin';'),translate(old_dpath)) = 0 then do
|
---|
| 302 | if samba.!bin = samba.!tools then new_dpath = samba.!bin';'
|
---|
| 303 | else new_dpath = samba.!bin';'samba.!tools';'
|
---|
| 304 | ok = value('DPATH', new_dpath || old_dpath, 'OS2ENVIRONMENT')
|
---|
| 305 | drop new_dpath
|
---|
| 306 | end
|
---|
| 307 | drop old_dpath
|
---|
[277] | 308 |
|
---|
| 309 | /* Add binary and tools path to the BEGINLIBPATH variable */
|
---|
| 310 | old_beginlibpath = SysQueryExtLibPath("B")
|
---|
| 311 | if pos(translate(samba.!bin';'),translate(old_beginlibpath)) = 0 then do
|
---|
| 312 | if samba.!bin = samba.!tools then new_beginlibpath = samba.!bin';'old_beginlibpath
|
---|
| 313 | else new_beginlibpath = samba.!bin';'samba.!tools';'old_beginlibpath
|
---|
| 314 | ok = SysSetExtLibPath( new_beginlibpath, "B")
|
---|
| 315 | drop new_beginlibpath
|
---|
| 316 | end
|
---|
| 317 | drop old_beginlibpath
|
---|
[300] | 318 |
|
---|
[333] | 319 |
|
---|
[300] | 320 | /* Set LIBPATHSTRICT (this is an option - disabled by default) */
|
---|
| 321 | /* ok = value('LIBPATHSTRICT','T', 'OS2ENVIRONMENT') */
|
---|
| 322 |
|
---|
[277] | 323 | IF options.!debug == 1 THEN say '_SambaExtendSearchPath() done'
|
---|
| 324 | return
|
---|
| 325 |
|
---|
| 326 | /*:VRX */
|
---|
[451] | 327 | _SambaRunning: procedure expose running. pids. TempDir HaveWinbindd options. samba.
|
---|
[277] | 328 | IF options.!debug == 1 THEN say '_SambaRunning() started'
|
---|
| 329 |
|
---|
[269] | 330 | /* Checks whether any Samba daemon is currently running */
|
---|
| 331 |
|
---|
| 332 | /* Parameters: none or "ALL"
|
---|
| 333 |
|
---|
| 334 | Returns: 1 = at least one Samba daemon is running
|
---|
| 335 | 1 = Parameter "ALL" all Samba daemons are running
|
---|
| 336 | 0 = no Samba daemon is running
|
---|
| 337 | 0 = Parameter "ALL" not all Samba daemons are running
|
---|
| 338 |
|
---|
| 339 | Stems: running. stores which daemon is running
|
---|
| 340 | pids. stores pids of running daemons
|
---|
| 341 | */
|
---|
| 342 | restype = arg(1)
|
---|
| 343 | running. = 0
|
---|
| 344 | pids. = ""
|
---|
| 345 |
|
---|
| 346 | ok = PRProcessList(proc)
|
---|
| 347 |
|
---|
| 348 | do I = 1 to proc.0
|
---|
| 349 | CurProc = VRParseFileName(proc.i.name,'NE')
|
---|
| 350 | if CurProc = "SMBD.EXE" then do
|
---|
| 351 | running.!smbd = 1
|
---|
| 352 | pids.!smbd = pids.!smbd||proc.i.pid||' '
|
---|
| 353 | end
|
---|
| 354 | if CurProc = "NMBD.EXE" then do
|
---|
| 355 | running.!nmbd = 1
|
---|
| 356 | pids.!nmbd = pids.!nmbd||proc.i.pid||' '
|
---|
| 357 | end
|
---|
| 358 | if CurProc = "WINBINDD.EXE" then do
|
---|
| 359 | running.!winb = 1
|
---|
| 360 | pids.!winb = pids.!winb||proc.i.pid||' '
|
---|
| 361 | end
|
---|
| 362 | end
|
---|
| 363 |
|
---|
| 364 | if restype = "ALL" then do
|
---|
| 365 | runres = (running.!smbd & running.!nmbd & (running.!winb | \HaveWinbindd ))
|
---|
| 366 | end
|
---|
| 367 | else do
|
---|
| 368 | runres = (running.!smbd | running.!nmbd |running.!winb)
|
---|
| 369 | end
|
---|
[277] | 370 | IF options.!debug == 1 THEN say '_SambaRunning() done'
|
---|
[269] | 371 | return runres
|
---|
[277] | 372 |
|
---|
| 373 | /*:VRX */
|
---|
| 374 | _PasswordDbRewrite:
|
---|
[926] | 375 | IF options.!debug == 1 then say time()' _PasswordDBRewrite() started'
|
---|
[277] | 376 |
|
---|
| 377 | /* Reset any old rc from pwd_mkdb.exe */
|
---|
| 378 | pwd_mkdbrc = 0
|
---|
| 379 |
|
---|
| 380 | /* delete old .db.tmp files */
|
---|
| 381 | ok = SysFileDelete(UnixETC'\pwd.db.tmp')
|
---|
| 382 | ok = SysFileDelete(UnixETC'\spwd.db.tmp')
|
---|
| 383 |
|
---|
| 384 | /* create backups of old .db files */
|
---|
| 385 | ok = VRCopyFile( UnixETC'\pwd.db', UnixETC'\pwd.db.bak' )
|
---|
| 386 | ok = VRCopyFile( UnixETC'\spwd.db', UnixETC'\spwd.db.bak' )
|
---|
| 387 |
|
---|
| 388 | /* delete old .db files */
|
---|
| 389 | ok = SysFileDelete(UnixETC'\pwd.db')
|
---|
| 390 | ok = SysFileDelete(UnixETC'\spwd.db')
|
---|
| 391 |
|
---|
| 392 | /* Create new password db */
|
---|
| 393 | address cmd samba.!pwd_mkdb' -d 'unixetc' 'samba.!masterpasswd' 2>'samba.!error
|
---|
| 394 | pwd_mkdbrc = rc
|
---|
| 395 | if \VRFileExists(samba.!pwddb) | pwd_mkdbrc <> 0 then do
|
---|
| 396 | call _SambaShowError
|
---|
| 397 | end
|
---|
[926] | 398 | IF options.!debug == 1 then say time()" _PasswordDBRewrite() done ("pwd_mkdbrc")"
|
---|
[287] | 399 | return
|
---|