From c28d6a90333d6627837866641c3174f86cd19dc7 Mon Sep 17 00:00:00 2001 From: Marc Fiuczynski Date: Sat, 24 Oct 2009 12:21:57 +0000 Subject: [PATCH] Support to add the ssh root pub key to the default administrator. This is for backwards compatibility with 4.3-rc12 and to avoid confusing MyPLC users who have learned to use the root key from /etc/planetlab/ to log in as root to nodes. --- db-config | 2 +- db-config.d/01-init | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/db-config b/db-config index 8333881..1f429e7 100755 --- a/db-config +++ b/db-config @@ -11,7 +11,7 @@ # $HeadURL$ from plc_config import PLCConfiguration -import sys +import sys, os import resource g_url = "" diff --git a/db-config.d/01-init b/db-config.d/01-init index 7fd6bdf..71453a0 100644 --- a/db-config.d/01-init +++ b/db-config.d/01-init @@ -58,3 +58,26 @@ SetPersonPrimarySite(admin['person_id'], site['site_id']) AddRoleToPerson(10, admin['person_id']) AddRoleToPerson(20, admin['person_id']) +# Associate root ssh key with the default administrator +keyfile="/etc/planetlab/root_ssh_key.pub" +person = GetPersons(admin['person_id'])[0] +keys = GetKeys(person['key_ids']) +if os.path.exists(keyfile): + sshkeyfp = file(keyfile,"r") + sshkey = sshkeyfp.read() + sshkeyfp.close() + + found=False + for key in keys: + if key['key_type']=='ssh': + if key['key'] == sshkey: + found=True + else: + # should we delete other keys? + pass + if not found: + key_id = AddPersonKey(admin['person_id'],{'key_type':'ssh','key':sshkey}) +else: + if len(keys)==0: + print "WARNING: default administrator does not have an ssh key" + print "and the default ssh root pub key (%s) file does not exist." -- 2.43.0