fix: better logging behaviour
This commit is contained in:
parent
3e6d0333b7
commit
398019afe8
36 changed files with 256 additions and 188 deletions
src/helpers
|
@ -20,7 +20,7 @@ helper_connect_tcp_server(char* host, uint16_t port)
|
|||
hints.ai_socktype = SOCK_STREAM; //set socket flag
|
||||
|
||||
if ((status = getaddrinfo(host, port_str, &hints, &res)) != 0) { //getaddrinfo() will evaluate the given address, using the hints-flags and port, and return an IP address and other server infos
|
||||
LOG_ERROR("getaddrinfo: %s\n", gai_strerror(status));
|
||||
LOGGER_ERR("getaddrinfo: %s\n", gai_strerror(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ helper_connect_tcp_server(char* host, uint16_t port)
|
|||
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); //creating Socket
|
||||
|
||||
if ((status = connect(s, res->ai_addr, res->ai_addrlen)) != 0) {
|
||||
LOG_ERROR("connect() failed\n");
|
||||
LOGGER_ERR("connect() failed\n");
|
||||
freeaddrinfo(res);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ get_uid_for_user(char *user)
|
|||
|
||||
if(pwd == NULL)
|
||||
{
|
||||
LOG_FATAL("couldn't find user to drop privileges\n");
|
||||
LOGGER_CRIT("couldn't find user to drop privileges\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ get_gid_for_group(char *group)
|
|||
|
||||
if(grp == NULL)
|
||||
{
|
||||
LOG_FATAL("couldn't find group to drop privileges\n");
|
||||
LOGGER_CRIT("couldn't find group to drop privileges\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -62,16 +62,16 @@ helper_drop_privileges()
|
|||
uid_t uid = get_uid_for_user(global_config.user);
|
||||
gid_t gid = get_gid_for_group(global_config.group);
|
||||
|
||||
LOG_DEBUG("drop privileges to %lu:%lu\n", uid, gid);
|
||||
LOGGER_DEBUG("drop privileges to %lu:%lu\n", uid, gid);
|
||||
|
||||
if (setgid(gid) == -1)
|
||||
{
|
||||
LOG_FATAL("failed to drop group privileges\n");
|
||||
LOGGER_CRIT("failed to drop group privileges\n");
|
||||
exit(1);
|
||||
}
|
||||
if (setuid(uid) == -1)
|
||||
{
|
||||
LOG_FATAL("failed to drop user privileges\n");
|
||||
LOGGER_CRIT("failed to drop user privileges\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,12 +50,12 @@ helper_parse_cli(int argc, const char **argv, config_t *config)
|
|||
config->run_type = RUN_TYPE_START;
|
||||
return;
|
||||
}
|
||||
LOG_FATAL("bad action '%s' given ('start')\n", argv[0]);
|
||||
LOGGER_CRIT("bad action '%s' given ('start')\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_FATAL("no action given ('start')\n");
|
||||
LOGGER_CRIT("no action given ('start')\n");
|
||||
exit(1);
|
||||
}
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue