1
0
forked from bip/bip

Bail on invalid confs.

This commit is contained in:
Arnaud Cornet 2008-01-01 13:55:47 +01:00
parent 3eab14cfb9
commit f7d07bc5fa

View File

@ -487,8 +487,10 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
} }
break; break;
case LEX_NICK: case LEX_NICK:
if (!is_valid_nick(t->pdata)) if (!is_valid_nick(t->pdata)) {
conf_die(bip, "Invalid nickname %s.", t->pdata); conf_die(bip, "Invalid nickname %s.", t->pdata);
return 0;
}
MOVE_STRING(l->connect_nick, t->pdata); MOVE_STRING(l->connect_nick, t->pdata);
break; break;
case LEX_USER: case LEX_USER:
@ -571,23 +573,31 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
free(t); free(t);
} }
/* checks that can only be here, or must */ /* checks that can only be here, or must */
if (!l->network) if (!l->network) {
conf_die(bip, "Missing network in connection block"); conf_die(bip, "Missing network in connection block");
return 0;
}
if (!l->connect_nick) { if (!l->connect_nick) {
if (!user->default_nick) if (!user->default_nick) {
conf_die(bip, "No nick set and no default nick."); conf_die(bip, "No nick set and no default nick.");
return 0;
}
l->connect_nick = strdup(user->default_nick); l->connect_nick = strdup(user->default_nick);
} }
if (!l->username) { if (!l->username) {
if (!user->default_username) if (!user->default_username) {
conf_die(bip, "No username set and no default " conf_die(bip, "No username set and no default "
"username."); "username.");
return 0;
}
l->username = strdup(user->default_username); l->username = strdup(user->default_username);
} }
if (!l->realname) { if (!l->realname) {
if (!user->default_realname) if (!user->default_realname) {
conf_die(bip, "No realname set and no default " conf_die(bip, "No realname set and no default "
"realname."); "realname.");
return 0;
}
l->realname = strdup(user->default_realname); l->realname = strdup(user->default_realname);
} }
@ -779,11 +789,13 @@ static int validate_config(bip_t *bip)
#ifdef HAVE_LIBSSL #ifdef HAVE_LIBSSL
if (link->network->ssl && if (link->network->ssl &&
!link->ssl_check_mode) !link->ssl_check_mode) {
conf_die(bip, "user %s, " conf_die(bip, "user %s, "
"connection %s: you should " "connection %s: you should "
"define a ssl_check_mode.", "define a ssl_check_mode.",
user->name, link->name); user->name, link->name);
return 0;
}
#endif #endif
r = 0; r = 0;
@ -791,12 +803,14 @@ static int validate_config(bip_t *bip)
for (hash_it_init(&link->chan_infos, &cit); for (hash_it_init(&link->chan_infos, &cit);
(ci = hash_it_item(&cit)); (ci = hash_it_item(&cit));
hash_it_next(&cit)) { hash_it_next(&cit)) {
if (!ci->name) if (!ci->name) {
conf_die(bip, "user %s, " conf_die(bip, "user %s, "
"connection " "connection "
"%s: channel must have" "%s: channel must have"
"a name.", user->name, "a name.", user->name,
link->name); link->name);
return 0;
}
} }
} }
} }
@ -807,6 +821,7 @@ static int validate_config(bip_t *bip)
"lines to a non-nul value for each user with" "lines to a non-nul value for each user with"
"backlog = true. Faulty user is %s", "backlog = true. Faulty user is %s",
user->name); user->name);
return 0;
} }
} }