diff options
author | Dennis Kaarsemaker <dennis@kaarsemaker.net> | 2016-02-22 21:04:10 +0100 |
---|---|---|
committer | Dennis Kaarsemaker <dennis@kaarsemaker.net> | 2016-03-23 07:44:13 +0100 |
commit | 3ac6d9fe93279d74d36a6bf2b6e2ba182ed3bf34 (patch) | |
tree | 681d3c36caa3f2680ca5b810c09f3d1f54a868cd /storage_xml.c | |
parent | d701547347b15bd76f19fcf667cbf8e5c1219cbb (diff) |
Support for locked-down accounts
In certain situations, e.g. when working with pregenerated
configurations, it is useful to be able lock down accounts so they
cannot be deleted and authentication information (user, password,
server) cannot be changed.
We mark such sensitive settings with ACC_SET_LOCKABLE and will refuse to
change them if the account is locked by setting the ACC_FLAG_LOCKED
flag.
This flag is stored in the xml files as account attribute locked="true".
Diffstat (limited to 'storage_xml.c')
-rw-r--r-- | storage_xml.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/storage_xml.c b/storage_xml.c index 4237e10e..107983cf 100644 --- a/storage_xml.c +++ b/storage_xml.c @@ -85,7 +85,7 @@ static void handle_settings(struct xt_node *node, set_t **head) static xt_status handle_account(struct xt_node *node, gpointer data) { struct xml_parsedata *xd = data; - char *protocol, *handle, *server, *password = NULL, *autoconnect, *tag; + char *protocol, *handle, *server, *password = NULL, *autoconnect, *tag, *locked; char *pass_b64 = NULL; unsigned char *pass_cr = NULL; int pass_len, local = 0; @@ -98,6 +98,7 @@ static xt_status handle_account(struct xt_node *node, gpointer data) server = xt_find_attr(node, "server"); autoconnect = xt_find_attr(node, "autoconnect"); tag = xt_find_attr(node, "tag"); + locked = xt_find_attr(node, "locked"); protocol = xt_find_attr(node, "protocol"); if (protocol) { @@ -126,6 +127,9 @@ static xt_status handle_account(struct xt_node *node, gpointer data) if (local) { acc->flags |= ACC_FLAG_LOCAL; } + if (locked && !g_strcasecmp(locked, "true")) { + acc->flags |= ACC_FLAG_LOCKED; + } } else { g_free(pass_cr); g_free(password); @@ -319,6 +323,9 @@ struct xt_node *xml_generate(irc_t *irc) if (acc->server && acc->server[0]) { xt_add_attr(cur, "server", acc->server); } + if (acc->flags & ACC_FLAG_LOCKED) { + xt_add_attr(cur, "locked", "true"); + } g_free(pass_b64); |