From a560ca93e99a47fa97b70d64619dd1a728b4bb90 Mon Sep 17 00:00:00 2001 From: "claire.sloan@aquaq.co.uk" Date: Wed, 8 Feb 2017 17:43:30 +0000 Subject: [PATCH 1/5] added passwords dictionary for connecting to non torq processes --- code/handlers/trackservers.q | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/code/handlers/trackservers.q b/code/handlers/trackservers.q index 9d3917077..8eba6eeb3 100644 --- a/code/handlers/trackservers.q +++ b/code/handlers/trackservers.q @@ -27,6 +27,8 @@ USERPASS:` // the username and password used to make connections STARTUP:@[value;`STARTUP;0b] // whether to automatically make connections on startup DISCOVERY:@[value;`DISCOVERY;enlist`] // list of discovery services to connect to (if not using process.csv) SOCKETTYPE:@[value;`SOCKETTYPE;enlist[`]!enlist `] // dict of proctype!sockettype. sockettype options : `tcp`tcps`unix. e.g. `rdb`tickerplant!`tcp`unix +PASSWORDS:@[value;`PASSWORDS;enlist[`]!enlist `] // dict of host:port!user:pass e.g. `:host:1234!`:user:pass + // If required, change this method to something more secure! // Otherwise just load the usernames and passwords from the passwords directory @@ -47,9 +49,11 @@ loadpassword[] // open a connection opencon:{ if[DEBUG;.lg.o[`conn;"attempting to open handle to ",string x]]; - // If the supplied connection string doesn't contain a user:password, - // and USERPASS is not null, append it - connection:hsym $[(2 >= sum ":"=string x) and not null USERPASS; `$(string x),":",string USERPASS;x]; + + // If the supplied connection string doesnt contain a user:pass and the last PASSWORDS id not null, lookup PASSWORDS dict and append on corresponding user:pass + // else if the supplied connection string doesn't contain a user:pass and USERPASS is not null, append it + + connection:$[(2>=sum ":"=string x) and not null last PASSWORDS;`$(string x),string PASSWORDS[x];$[(2 >= sum ":"=string x) and not null USERPASS;`$(string x),":",string USERPASS;x]]; h:@[{(hopen x;"")};(connection;.servers.HOPENTIMEOUT);{(0Ni;x)}]; From 68408d20c248cb10ab248c3464337742f86d85f5 Mon Sep 17 00:00:00 2001 From: claire-sloan Date: Thu, 9 Feb 2017 15:41:00 +0000 Subject: [PATCH 2/5] Update trackservers.q Added username:password dict for non torq process --- code/handlers/trackservers.q | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/code/handlers/trackservers.q b/code/handlers/trackservers.q index 8eba6eeb3..3264fa0d1 100644 --- a/code/handlers/trackservers.q +++ b/code/handlers/trackservers.q @@ -50,10 +50,9 @@ loadpassword[] opencon:{ if[DEBUG;.lg.o[`conn;"attempting to open handle to ",string x]]; - // If the supplied connection string doesnt contain a user:pass and the last PASSWORDS id not null, lookup PASSWORDS dict and append on corresponding user:pass - // else if the supplied connection string doesn't contain a user:pass and USERPASS is not null, append it - - connection:$[(2>=sum ":"=string x) and not null last PASSWORDS;`$(string x),string PASSWORDS[x];$[(2 >= sum ":"=string x) and not null USERPASS;`$(string x),":",string USERPASS;x]]; + // If the supplied connection string has 2 or more colons append on user:pass from passwords dictionary + // else return connection string passed in + connection:$[2 >= sum ":"=string x; `$(string x),string USERPASS^PASSWORDS[x];x]; h:@[{(hopen x;"")};(connection;.servers.HOPENTIMEOUT);{(0Ni;x)}]; From f6fb6504c53288bffc17b1283494ef0a92b99a1e Mon Sep 17 00:00:00 2001 From: claire-sloan Date: Thu, 9 Feb 2017 15:42:32 +0000 Subject: [PATCH 3/5] Update default.q Added default passwords dictionary --- config/settings/default.q | 1 + 1 file changed, 1 insertion(+) diff --git a/config/settings/default.q b/config/settings/default.q index a58be24f4..0d513f6ec 100644 --- a/config/settings/default.q +++ b/config/settings/default.q @@ -72,6 +72,7 @@ LOADPASSWORD:1b // load the external username:password from ${KDBCONFI STARTUP:0b // whether to automatically make connections on startup DISCOVERY:enlist` // list of discovery services to connect to (if not using process.csv) SOCKETTYPE:enlist[`]!enlist ` // dict of proctype -> sockettype e.g. `hdb`rdb`tp!`tcps`tcp`unix +PASSWORDS:enlist[`]!enlist ` // dict of host:port!user:pass // functions to ignore when called async - bypass all permission checking and logging \d .zpsignore From b4585abe20b184f4e630027718fdc0b83493258e Mon Sep 17 00:00:00 2001 From: claire-sloan Date: Wed, 15 Feb 2017 09:55:40 +0000 Subject: [PATCH 4/5] Update conn.md Added few sentences on non-torq processes. --- docs/conn.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/conn.md b/docs/conn.md index be761ac66..06b864b34 100755 --- a/docs/conn.md +++ b/docs/conn.md @@ -82,6 +82,12 @@ overridden by one for the process type, which is itself overridden by one for the process name. For greater security, the .servers.loadpassword function should be modified. +Some non-torq processes require a username and password to allow connection. +These will be stored in a passwords dictionary. +Passing the host and port of a process into this dictionary will return the full connection string +if it is present within the dictionary. +If however it is not present in the dictionary then the default username and password will be returned. + Retrieving and Using Handles ---------------------------- From da5096fa0ffe9e5740706983ee2f72494bd559f1 Mon Sep 17 00:00:00 2001 From: claire-sloan Date: Wed, 15 Feb 2017 11:39:04 +0000 Subject: [PATCH 5/5] Update trackservers.q Added hsym and ":" when trying to open a connection --- code/handlers/trackservers.q | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/handlers/trackservers.q b/code/handlers/trackservers.q index 3264fa0d1..09428bb6e 100644 --- a/code/handlers/trackservers.q +++ b/code/handlers/trackservers.q @@ -27,7 +27,7 @@ USERPASS:` // the username and password used to make connections STARTUP:@[value;`STARTUP;0b] // whether to automatically make connections on startup DISCOVERY:@[value;`DISCOVERY;enlist`] // list of discovery services to connect to (if not using process.csv) SOCKETTYPE:@[value;`SOCKETTYPE;enlist[`]!enlist `] // dict of proctype!sockettype. sockettype options : `tcp`tcps`unix. e.g. `rdb`tickerplant!`tcp`unix -PASSWORDS:@[value;`PASSWORDS;enlist[`]!enlist `] // dict of host:port!user:pass e.g. `:host:1234!`:user:pass +PASSWORDS:@[value;`PASSWORDS;enlist[`]!enlist `] // dict of host:port!user:pass e.g. `:host:1234!`user:pass // If required, change this method to something more secure! @@ -52,7 +52,7 @@ opencon:{ // If the supplied connection string has 2 or more colons append on user:pass from passwords dictionary // else return connection string passed in - connection:$[2 >= sum ":"=string x; `$(string x),string USERPASS^PASSWORDS[x];x]; + connection:hsym $[2 >= sum ":"=string x; `$(string x),":",string USERPASS^PASSWORDS[x];x]; h:@[{(hopen x;"")};(connection;.servers.HOPENTIMEOUT);{(0Ni;x)}];