Commit e3f1e9c3 authored by Leigh Stoller's avatar Leigh Stoller

Add eventkey function to return event shared key.

parent 4e738d9e
......@@ -139,6 +139,7 @@ typedef struct {
char swapper[TBDB_FLEN_UID];
char syncserver[TBDB_FLEN_VNAME]; /* The vname */
char keyhash[TBDB_FLEN_PRIVKEY];
char eventkey[TBDB_FLEN_PRIVKEY];
char sfshostid[TBDB_FLEN_SFSHOSTID];
char testdb[256];
} tmcdreq_t;
......@@ -200,6 +201,7 @@ COMMAND_PROTOTYPE(doslothdparams);
COMMAND_PROTOTYPE(doprogagents);
COMMAND_PROTOTYPE(dosyncserver);
COMMAND_PROTOTYPE(dokeyhash);
COMMAND_PROTOTYPE(doeventkey);
COMMAND_PROTOTYPE(dofullconfig);
/*
......@@ -261,6 +263,7 @@ struct command {
{ "programs", FULLCONFIG_ALL, doprogagents},
{ "syncserver", FULLCONFIG_ALL, dosyncserver},
{ "keyhash", FULLCONFIG_ALL, dokeyhash},
{ "eventkey", FULLCONFIG_ALL, doeventkey},
{ "fullconfig", FULLCONFIG_NONE, dofullconfig},
};
static int numcommands = sizeof(command_array)/sizeof(struct command);
......@@ -3652,7 +3655,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" np.role,e.expt_head_uid,e.expt_swap_uid, "
" e.sync_server,pt.class,pt.type, "
" pt.isremotenode,vt.issubnode,e.keyhash, "
" nv.sfshostid "
" nv.sfshostid,e.eventkey "
"from nodes as nv "
"left join interfaces as i on "
" i.node_id=nv.phys_nodeid "
......@@ -3668,7 +3671,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
"left join node_types as vt on "
" vt.type=nv.type "
"where nv.node_id='%s' and i.IP='%s'",
20, reqp->vnodeid, inet_ntoa(ipaddr));
21, reqp->vnodeid, inet_ntoa(ipaddr));
}
else {
res = mydb_query("select t.class,t.type,n.node_id,n.jailflag,"
......@@ -3677,7 +3680,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" e.expt_head_uid,e.expt_swap_uid, "
" e.sync_server,t.class,t.type, "
" t.isremotenode,t.issubnode,e.keyhash, "
" n.sfshostid "
" n.sfshostid,e.eventkey "
"from interfaces as i "
"left join nodes as n on n.node_id=i.node_id "
"left join reserved as r on "
......@@ -3687,7 +3690,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
"left join node_types as t on "
" t.type=n.type and i.iface=t.control_iface "
"where i.IP='%s'",
20, inet_ntoa(ipaddr));
21, inet_ntoa(ipaddr));
}
if (!res) {
......@@ -3751,6 +3754,9 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
/* keyhash for the experiment */
if (row[18])
strcpy(reqp->keyhash, row[18]);
/* event key for the experiment */
if (row[20])
strcpy(reqp->eventkey, row[20]);
}
if (row[9])
reqp->update_accounts = atoi(row[9]);
......@@ -4966,6 +4972,32 @@ COMMAND_PROTOTYPE(dokeyhash)
return 0;
}
/*
* Return eventkey info
*/
COMMAND_PROTOTYPE(doeventkey)
{
char buf[MYBUFSIZE];
/*
* Now check reserved table
*/
if (!reqp->allocated) {
error("EVENTKEY: %s: Node is free\n", reqp->nodeid);
return 1;
}
if (!strlen(reqp->eventkey))
return 0;
sprintf(buf, "EVENTKEY KEY='%s'\n", reqp->eventkey);
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("%s", buf);
return 0;
}
/*
* Return entire config.
*/
......
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