From 45c3a605ee7b20d34db4505c13801838576f44fe Mon Sep 17 00:00:00 2001 From: Eric Stern Date: Sat, 30 Nov 2013 18:53:19 -0800 Subject: [PATCH] Correctly handle case where no ssh keys are found Summary: If no ssh keys are in phabricator, bin/ssh-auth errors with undefined `$lines`. This fixes that case and explicitly tells the user no rows were found. Test Plan: Ran bin/ssh-auth before and after change with no ssh keys in the system. Error goes away after change. Reviewers: #blessed_reviewers, epriestley Reviewed By: epriestley CC: epriestley, aran, Korvin Differential Revision: https://secure.phabricator.com/D7675 --- scripts/ssh/ssh-auth.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/ssh/ssh-auth.php b/scripts/ssh/ssh-auth.php index dc7b4d098e..aba2b20f01 100755 --- a/scripts/ssh/ssh-auth.php +++ b/scripts/ssh/ssh-auth.php @@ -15,6 +15,11 @@ $rows = queryfx_all( $user_dao->getTableName(), $ssh_dao->getTableName()); +if (!$rows) { + echo pht("No keys found.")."\n"; + exit(1); +} + $bin = $root.'/bin/ssh-exec'; foreach ($rows as $row) { $user = $row['userName'];