Commit 503418b7 authored by Srikanth Raju's avatar Srikanth Raju Committed by Leigh Stoller

Make the users pubkey be first

Some of these AMIs request only the first ssh key. Which means we never to
load in the entire set. Atleast this will force some bare minimum access.
Maybe its ridiculous to assume the first pubkey is the "important" one
parent 10c58602
......@@ -141,7 +141,15 @@ class Ec2MetaHandler(BaseHTTPRequestHandler):
"join experiments on experiments.pid=group_membership.pid AND experiments.gid=group_membership.gid "
"join reserved on reserved.exptidx=experiments.idx "
"join interfaces on reserved.node_id=interfaces.node_id "
"where interfaces.ip=%s;", (ip,));
"where interfaces.ip=%s and user_pubkeys.uid=experiments.expu_swap_uid "
"UNION "
"select user_pubkeys.uid,user_pubkeys.idx from user_pubkeys "
"join group_membership on group_membership.uid = user_pubkeys.uid "
"join experiments on experiments.pid=group_membership.pid AND experiments.gid=group_membership.gid "
"join reserved on reserved.exptidx=experiments.idx "
"join interfaces on reserved.node_id=interfaces.node_id "
"where interfaces.ip=%s and user_pubkeys.uid!=experiments.expt_swap_uid;"
, (ip,ip,))
list = ""
ctr = 0
......@@ -162,12 +170,20 @@ class Ec2MetaHandler(BaseHTTPRequestHandler):
val = int(args[0])
cursor = self.cnx.cursor()
ip = self.client_address[0]
cursor.execute("select user_pubkeys.pubkey from user_pubkeys "
cursor.execute("((select user_pubkeys.pubkey from user_pubkeys "
"join group_membership on group_membership.uid = user_pubkeys.uid "
"join experiments on experiments.pid=group_membership.pid AND experiments.gid=group_membership.gid "
"join reserved on reserved.exptidx=experiments.idx "
"join interfaces on reserved.node_id=interfaces.node_id "
"where interfaces.ip=%s and user_pubkeys.uid=experiments.expt_swap_uid) "
"UNION "
"(select user_pubkeys.pubkey from user_pubkeys "
"join group_membership on group_membership.uid = user_pubkeys.uid "
"join experiments on experiments.pid=group_membership.pid AND experiments.gid=group_membership.gid "
"join reserved on reserved.exptidx=experiments.idx "
"join interfaces on reserved.node_id=interfaces.node_id "
"where interfaces.ip=%s limit " + str(val) +", 1;", (ip,));
"where interfaces.ip=%s and user_pubkeys.uid!=experiments.expt_swap_uid)) limit " + str(val) + ", 1;",
(ip, ip,))
if cursor.with_rows:
key = cursor.fetchone()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment