aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Kaarsemaker <dennis@kaarsemaker.net>2016-02-22 21:25:39 +0100
committerDennis Kaarsemaker <dennis@kaarsemaker.net>2016-03-23 07:44:13 +0100
commit446a23ea39184c5fe43cd40706bb683b89534e2e (patch)
treec2a3933f4f962071174225c3bb86b3884927fd15
parente41ba05c0a9002b30e9e2475f56fd207e856a9f8 (diff)
Add a setting to disable 'account add'
In a locked down bitlbee instance it is useful to disable the 'account add' command.
-rw-r--r--bitlbee.conf7
-rw-r--r--conf.c7
-rw-r--r--conf.h1
-rw-r--r--root_commands.c5
4 files changed, 20 insertions, 0 deletions
diff --git a/bitlbee.conf b/bitlbee.conf
index 51b5777a..a79a4483 100644
--- a/bitlbee.conf
+++ b/bitlbee.conf
@@ -69,6 +69,13 @@
## or
# OperPassword = md5:I0mnZbn1t4R731zzRdDN2/pK7lRX
+## AllowAccountAdd
+##
+## Whether to allow registered and identified users to add new accounts using
+## 'account add'
+##
+# AllowAccountAdd 1
+
## HostName
##
## Normally, BitlBee gets a hostname using getsockname(). If you have a nicer
diff --git a/conf.c b/conf.c
index b249a11b..6da77d59 100644
--- a/conf.c
+++ b/conf.c
@@ -56,6 +56,7 @@ conf_t *conf_load(int argc, char *argv[])
conf->authmode = AUTHMODE_OPEN;
conf->auth_pass = NULL;
conf->oper_pass = NULL;
+ conf->allow_account_add = 1;
conf->configdir = g_strdup(CONFIG);
conf->plugindir = g_strdup(PLUGINDIR);
conf->pidfile = g_strdup(PIDFILE);
@@ -245,6 +246,12 @@ static int conf_loadini(conf_t *conf, char *file)
} else if (g_strcasecmp(ini->key, "operpassword") == 0) {
g_free(conf->oper_pass);
conf->oper_pass = g_strdup(ini->value);
+ } else if (g_strcasecmp(ini->key, "allowaccountadd") == 0) {
+ if (!is_bool(ini->value)) {
+ fprintf(stderr, "Invalid %s value: %s\n", ini->key, ini->value);
+ return 0;
+ }
+ conf->allow_account_add = bool2int(ini->value);
} else if (g_strcasecmp(ini->key, "hostname") == 0) {
g_free(conf->hostname);
conf->hostname = g_strdup(ini->value);
diff --git a/conf.h b/conf.h
index 1ee311bd..12b4d369 100644
--- a/conf.h
+++ b/conf.h
@@ -38,6 +38,7 @@ typedef struct conf {
authmode_t authmode;
char *auth_pass;
char *oper_pass;
+ int allow_account_add;
char *hostname;
char *configdir;
char *plugindir;
diff --git a/root_commands.c b/root_commands.c
index 80873c79..0f024345 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -416,6 +416,11 @@ static void cmd_account(irc_t *irc, char **cmd)
MIN_ARGS(3);
+ if (!global.conf->allow_account_add) {
+ irc_rootmsg(irc, "This server does not allow adding new accounts");
+ return;
+ }
+
if (cmd[4] == NULL) {
for (a = irc->b->accounts; a; a = a->next) {
if (strcmp(a->pass, PASSWORD_PENDING) == 0) {