Changeset View
Changeset View
Standalone View
Standalone View
scripts/ssh/ssh-exec.php
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | throw new Exception( | ||||
pht( | pht( | ||||
'The %s and %s flags are mutually exclusive. You can not '. | 'The %s and %s flags are mutually exclusive. You can not '. | ||||
'authenticate as both a user ("%s") and a device ("%s"). '. | 'authenticate as both a user ("%s") and a device ("%s"). '. | ||||
'Specify one or the other, but not both.', | 'Specify one or the other, but not both.', | ||||
'--phabricator-ssh-user', | '--phabricator-ssh-user', | ||||
'--phabricator-ssh-device', | '--phabricator-ssh-device', | ||||
$user_name, | $user_name, | ||||
$device_name)); | $device_name)); | ||||
} else if (strlen($user_name)) { | } else if (phutil_nonempty_string($user_name)) { | ||||
$user = id(new PhabricatorPeopleQuery()) | $user = id(new PhabricatorPeopleQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withUsernames(array($user_name)) | ->withUsernames(array($user_name)) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$user) { | if (!$user) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Invalid username ("%s"). There is no user with this username.', | 'Invalid username ("%s"). There is no user with this username.', | ||||
$user_name)); | $user_name)); | ||||
} | } | ||||
id(new PhabricatorAuthSessionEngine()) | id(new PhabricatorAuthSessionEngine()) | ||||
->willServeRequestForUser($user); | ->willServeRequestForUser($user); | ||||
} else if (strlen($device_name)) { | } else if (phutil_nonempty_string($device_name)) { | ||||
if (!$remote_address) { | if (!$remote_address) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Unable to identify remote address from the %s environment '. | 'Unable to identify remote address from the %s environment '. | ||||
'variable. Device authentication is accepted only from trusted '. | 'variable. Device authentication is accepted only from trusted '. | ||||
'sources.', | 'sources.', | ||||
'SSH_CLIENT')); | 'SSH_CLIENT')); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0