1
0
forked from bip/bip

Re-open main logfile to allow rotate.

Trivial fix.
This commit is contained in:
Arnaud Cornet 2007-09-03 12:01:13 +02:00
parent a5f8902232
commit 995b3f071a
2 changed files with 22 additions and 12 deletions

View File

@ -178,16 +178,6 @@ static pid_t daemonize(void)
_exit(0);
}
if (conf_log_system) {
snprintf(buf, 4095, "%s/bip.log", conf_log_root);
FILE *f = fopen(buf, "a");
if (!f)
fatal("Can't open %s: %s", buf, strerror(errno));
conf_global_log_file = f;
} else {
conf_global_log_file = stderr;
}
close(0);
close(1);
close(2);
@ -861,6 +851,21 @@ void ircize(bip_t *bip)
}
#endif
static void log_file_setup(void)
{
if (conf_log_system) {
if (conf_global_log_file && conf_global_log_file != stderr)
fclose(conf_log_system);
snprintf(buf, 4095, "%s/bip.log", conf_log_root);
FILE *f = fopen(buf, "a");
if (!f)
fatal("Can't open %s: %s", buf, strerror(errno));
conf_global_log_file = f;
} else {
conf_global_log_file = stderr;
}
}
int main(int argc, char **argv)
{
FILE *conf = NULL;
@ -942,6 +947,8 @@ int main(int argc, char **argv)
check_dir(conf_log_root, 1);
fd = do_pid_stuff();
pid_t pid = 0;
log_file_setup();
if (conf_daemonize)
pid = daemonize();
else
@ -967,6 +974,9 @@ int main(int argc, char **argv)
fatal("%s config file not found", confpath);
fireup(&bip, conf);
fclose(conf);
/* re-open to allow logfile rotate */
log_file_setup();
}
return 1;
}

View File

@ -216,7 +216,7 @@ static void irc_server_connected(struct link_server *server)
LINK(server)->s_state = IRCS_CONNECTED;
LINK(server)->s_conn_attempt = 0;
mylog(LOG_INFO, "Connected user %s to %s", LINK(server)->username,
mylog(LOG_INFO, "Connected user %s to %s", LINK(server)->user->name,
LINK(server)->name);
irc_server_join(server);
@ -694,7 +694,7 @@ static int irc_cli_startup(bip_t *bip, struct link_client *ic,
for (list_it_init(&bip->link_list, &it); list_it_item(&it);
list_it_next(&it)) {
struct link *l = list_it_item(&it);
if (strcmp(user, l->username) == 0 &&
if (strcmp(user, l->user->name) == 0 &&
strcmp(connname, l->name) == 0) {
if (chash_cmp(pass, l->user->password,
l->user->seed) == 0) {