|
@@ 234-268 (lines=35) @@
|
| 231 |
|
return $this->screenIsNotRunning($sessionName); |
| 232 |
|
} |
| 233 |
|
|
| 234 |
|
public function hasFileWithPermissions($filename, $owner, $group, $mode) |
| 235 |
|
{ |
| 236 |
|
// shorthand |
| 237 |
|
$octMode = decoct($mode); |
| 238 |
|
|
| 239 |
|
// what are we doing? |
| 240 |
|
$log = usingLog()->startAction("make sure file '{$filename}' exists on host '{$this->args[0]}' with permissions '{$octMode}' owned by '{$owner}:{$group}'"); |
| 241 |
|
|
| 242 |
|
// make sure we have valid host details |
| 243 |
|
$hostDetails = $this->getHostDetails(); |
| 244 |
|
|
| 245 |
|
// get the file details |
| 246 |
|
$details = fromHost($hostDetails->hostId)->getFileDetails($filename); |
| 247 |
|
|
| 248 |
|
// validate the details |
| 249 |
|
if ($details === null) { |
| 250 |
|
throw Exceptions::newExpectFailedException(__METHOD__, "'{$filename}' exists", "'{$filename}' does not exist"); |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
if ($details->type != 'file') { |
| 254 |
|
throw Exceptions::newExpectFailedException(__METHOD__, "'{$filename}' is a file", "'{$filename}' is type '{$details->type}'"); |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
if ($details->mode != $mode) { |
| 258 |
|
$theirOctMode = decoct($details->mode); |
| 259 |
|
throw Exceptions::newExpectFailedException(__METHOD__, "'{$filename}' has permissions '{$octMode}'", "'{$filename}' has permissions '{$theirOctMode}'"); |
| 260 |
|
} |
| 261 |
|
|
| 262 |
|
if ($details->user != $owner || $details->group != $group) { |
| 263 |
|
throw Exceptions::newExpectFailedException(__METHOD__, "'{$filename}' has ownership '{$owner}:{$group}'", "'{$filename}' has ownership '{$details->user}:{$details->group}'"); |
| 264 |
|
} |
| 265 |
|
|
| 266 |
|
// if we get here, then all is good |
| 267 |
|
$log->endAction(); |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
public function hasFolderWithPermissions($folder, $owner, $group, $mode) |
| 271 |
|
{ |
|
@@ 270-304 (lines=35) @@
|
| 267 |
|
$log->endAction(); |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
public function hasFolderWithPermissions($folder, $owner, $group, $mode) |
| 271 |
|
{ |
| 272 |
|
// shorthand |
| 273 |
|
$octMode = decoct($mode); |
| 274 |
|
|
| 275 |
|
// what are we doing? |
| 276 |
|
$log = usingLog()->startAction("make sure folder '{$folder}' exists on host '{$this->args[0]}' with permissions '{$octMode}' owned by '{$owner}:{$group}'"); |
| 277 |
|
|
| 278 |
|
// make sure we have valid host details |
| 279 |
|
$hostDetails = $this->getHostDetails(); |
| 280 |
|
|
| 281 |
|
// get the file details |
| 282 |
|
$details = fromHost($hostDetails->hostId)->getFileDetails($folder); |
| 283 |
|
|
| 284 |
|
// validate the details |
| 285 |
|
if ($details === null) { |
| 286 |
|
throw Exceptions::newExpectFailedException(__METHOD__, "'{$folder}' exists", "'{$folder}' does not exist"); |
| 287 |
|
} |
| 288 |
|
|
| 289 |
|
if ($details->type != 'dir') { |
| 290 |
|
throw Exceptions::newExpectFailedException(__METHOD__, "'{$folder}' is a file", "'{$folder}' is type '{$details->type}'"); |
| 291 |
|
} |
| 292 |
|
|
| 293 |
|
if ($details->mode != $mode) { |
| 294 |
|
$theirOctMode = decoct($details->mode); |
| 295 |
|
throw Exceptions::newExpectFailedException(__METHOD__, "'{$folder}' has permissions '{$octMode}'", "'{$folder}' has permissions '{$theirOctMode}'"); |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
if ($details->user != $owner || $details->group != $group) { |
| 299 |
|
throw Exceptions::newExpectFailedException(__METHOD__, "'{$folder}' has ownership '{$owner}:{$group}'", "'{$folder}' has ownership '{$details->user}:{$details->group}'"); |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
// if we get here, then all is good |
| 303 |
|
$log->endAction(); |
| 304 |
|
} |
| 305 |
|
} |
| 306 |
|
|