protected function finalizeLinux($data)
{
/* Non-Windows samba printing */
$device = "//" . $this->hostname . "/" . $this->printerName;
if ($this->userName !== null) {
$user = ($this->workgroup != null ? $this->workgroup . "\\" : "") . $this->userName;
if ($this->userPassword == null) {
// No password
$command = sprintf("smbclient %s -U %s -c %s -N", escapeshellarg($device), escapeshellarg($user), escapeshellarg("print -"));
$redactedCommand = $command;
} else {
// With password
$command = sprintf("smbclient %s %s -U %s -c %s", escapeshellarg($device), escapeshellarg($this->userPassword), escapeshellarg($user), escapeshellarg("print -"));
$redactedCommand = sprintf("smbclient %s %s -U %s -c %s", escapeshellarg($device), escapeshellarg("*****"), escapeshellarg($user), escapeshellarg("print -"));
}
} else {
// No authentication information at all
$command = sprintf("smbclient %s -c %s -N", escapeshellarg($device), escapeshellarg("print -"));
$redactedCommand = $command;
}
$retval = $this->runCommand($command, $outputStr, $errorStr, $data);
if ($retval != 0) {
throw new Exception("Failed to print. Command \"{$redactedCommand}\" " . "failed with exit code {$retval}: " . trim($errorStr) . trim($outputStr));
}
}