Changeset e41ba05


Ignore:
Timestamp:
2016-03-23T06:44:13Z (9 years ago)
Author:
Dennis Kaarsemaker <dennis@…>
Branches:
master
Children:
446a23e
Parents:
3ac6d9f
git-author:
Dennis Kaarsemaker <dennis@…> (22-02-16 21:26:15)
git-committer:
Dennis Kaarsemaker <dennis@…> (23-03-16 06:44:13)
Message:

Allow individual settings to be locked down

This allows a site admin who pregenerates configs to mark certain
settings as untouchable, ensuring that users cannot mess up their
settings too badly.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • root_commands.c

    r3ac6d9f re41ba05  
    340340                int st;
    341341
     342                if (s && s->flags & SET_LOCKED) {
     343                        irc_rootmsg(irc, "This setting can not be changed");
     344                        return 0;
     345                }
    342346                if (s && checkflags && checkflags(irc, s) == 0) {
    343347                        return 0;
  • set.h

    r3ac6d9f re41ba05  
    4949        SET_PASSWORD = 0x0400, /* Value shows up in settings list as "********". */
    5050        SET_HIDDEN_DEFAULT = 0x0800, /* Hide unless changed from default. */
     51        SET_LOCKED = 0x1000    /* Setting is locked, don't allow changing it */
    5152} set_flags_t;
    5253
  • storage_xml.c

    r3ac6d9f re41ba05  
    6565{
    6666        struct xt_node *c;
     67        struct set *s;
    6768
    6869        for (c = node->children; (c = xt_find_node(c, "setting")); c = c->next) {
    6970                char *name = xt_find_attr(c, "name");
     71                char *locked = xt_find_attr(c, "locked");
    7072
    7173                if (!name) {
     
    8082                }
    8183                set_setstr(head, name, c->text);
     84                if (locked && !g_strcasecmp(locked, "true")) {
     85                        s = set_find(head, name);
     86                        if (s) {
     87                                s->flags |= SET_LOCKED;
     88                        }
     89                }
    8290        }
    8391}
     
    371379                        xt_add_child(cur, xset = xt_new_node("setting", set->value, NULL));
    372380                        xt_add_attr(xset, "name", set->key);
     381                        if (set->flags & SET_LOCKED) {
     382                                xt_add_attr(xset, "locked", "true");
     383                        }
    373384                }
    374385        }
Note: See TracChangeset for help on using the changeset viewer.