misc: Add standard CrOS testing ssh keys.
Some tests do need to access DUT (especially when doing station-based
testing via SSH Link) with CrOS testing SSH keys. Currently we have a
copy of the keys in setup/ folder but that is not available on station
or DUT. Few projects then try to add keys in board/ folder, which is not
necessary.
This change adds a 'sshkeys' folder into misc/ so every toolkit
installation will have it.
BUG=none
TEST=make test
Change-Id: I248040a3706a2e1100357f6a107079f516c35546
Reviewed-on: https://chromium-review.googlesource.com/364430
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/py/toolkit/installer.py b/py/toolkit/installer.py
index bafb74d..ca3eacb 100755
--- a/py/toolkit/installer.py
+++ b/py/toolkit/installer.py
@@ -14,6 +14,7 @@
import argparse
from contextlib import contextmanager
+import glob
import os
import shutil
import sys
@@ -312,6 +313,15 @@
Spawn(['chown', '-R', myuser, src],
sudo=True, log=True, check_call=True)
+ print '*** Ensure SSH keys file permission...'
+ sshkeys_dir = os.path.join(self._usr_local_dest, 'factory/misc/sshkeys')
+ sshkeys = glob.glob(os.path.join(sshkeys_dir, '*'))
+ ssh_public_keys = glob.glob(os.path.join(sshkeys_dir, '*.pub'))
+ ssh_private_keys = list(set(sshkeys) - set(ssh_public_keys))
+ if ssh_private_keys:
+ Spawn(['chmod', '600'] + ssh_private_keys, log=True, check_call=True,
+ sudo=self._sudo)
+
print '*** Installing symlinks...'
install_symlinks.InstallSymlinks(
'../factory/bin',