summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/CloudConfig/cc_ssh_import_id.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/cloudinit/CloudConfig/cc_ssh_import_id.py b/cloudinit/CloudConfig/cc_ssh_import_id.py
index bf1314be..9dd2159a 100644
--- a/cloudinit/CloudConfig/cc_ssh_import_id.py
+++ b/cloudinit/CloudConfig/cc_ssh_import_id.py
@@ -20,15 +20,30 @@ import subprocess
import traceback
def handle(name,cfg,cloud,log,args):
+ ids = [ ]
if len(args) != 0:
user = args[0]
- ids = [ ]
if len(args) > 1:
ids = args[1:]
else:
user = util.get_cfg_option_str(cfg,"user","ubuntu")
ids = util.get_cfg_option_list_or_str(cfg,"ssh_import_id",[])
+ try:
+ fp = open("/proc/cmdline")
+ cmdline = fp.read()
+ fp.close()
+ names = [ "ssh_import_id", "ssh_import" ]
+ cmd_ids = [ ]
+ for i in cmdline.strip().split():
+ for n in names:
+ if i.startswith(n + "="):
+ print i
+ cmd_ids=i[len(n)+1:].split(",")
+ ids.extend(cmd_ids)
+ except:
+ log.warn("failed to read /proc/cmdline for import_id")
+
if len(ids) == 0: return
cmd = [ "sudo", "-Hu", user, "ssh-import-id" ] + ids