#define CRITICAL(frmt, args...) g_critical(EXPAND_LOG_MSG(frmt, ##args))
#define ERR(frmt, args...) g_error(EXPAND_LOG_MSG(frmt, ##args))
+#define MAX_STRERROR_LEN 256
+
G_END_DECLS
#endif /* _TLM_LOG_H */
}
}
-const gchar *
+gchar *
tlm_user_get_name (uid_t user_id)
{
struct passwd *pwent;
+ struct passwd buf_pwent;
+ gchar *buf = NULL, *tmp = NULL, *pw_name = NULL;
+ gsize size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size <= sizeof(struct passwd))
+ size = 1024;
- pwent = getpwuid (user_id);
- if (!pwent)
- return NULL;
+ for (; NULL != (tmp = g_realloc(buf, size)); size*=2)
+ {
+ buf = tmp;
+
+ if (ERANGE == getpwuid_r(user_id, &buf_pwent, buf, size, &pwent))
+ continue;
+ break;
+ }
+
+ if (pwent)
+ {
+ pw_name = g_malloc(strlen(pwent->pw_name)+1);
+ if (pw_name)
+ {
+ memset(pw_name, 0, strlen(pwent->pw_name)+1);
+ strncpy(pw_name, pwent->pw_name, strlen(pwent->pw_name));
+ }
+ }
+
+ if (buf)
+ g_free(buf);
- return pwent->pw_name;
+ return pw_name;
}
uid_t
tlm_user_get_uid (const gchar *username)
{
struct passwd *pwent;
+ struct passwd buf_pwent;
+ __uid_t pw_uid = -1;
+ int ret = -1;
+ gchar *buf = NULL, *tmp = NULL;
+ gsize size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size < sizeof(struct passwd))
+ size = 1024;
+
+ for (; NULL != (tmp = g_realloc(buf, size)); size*=2)
+ {
+ buf = tmp;
+
+ ret = getpwnam_r(username, &buf_pwent, buf, size, &pwent);
+ if (0 == ret)
+ pw_uid = pwent->pw_uid;
+ else if (ERANGE == ret)
+ continue;
+ else
+ pw_uid = -1;
+
+ break;
+ }
- pwent = getpwnam (username);
- if (!pwent)
- return -1;
+ if (buf)
+ g_free(buf);
- return pwent->pw_uid;
+ return pw_uid;
}
gid_t
tlm_user_get_gid (const gchar *username)
{
struct passwd *pwent;
+ struct passwd buf_pwent;
+ __gid_t pw_gid = -1;
+ int ret = -1;
+ gchar *buf = NULL, *tmp = NULL;
+ gsize size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size <= sizeof(struct passwd))
+ size = 1024;
+
+ for (; NULL != (tmp = g_realloc(buf, size)); size*=2)
+ {
+ buf = tmp;
+
+ ret = getpwnam_r(username, &buf_pwent, buf, size, &pwent);
+ if (0 == ret)
+ pw_gid = pwent->pw_gid;
+ else if (ERANGE == ret)
+ continue;
+ else
+ pw_gid = -1;
- pwent = getpwnam (username);
- if (!pwent)
- return -1;
+ break;
+ }
- return pwent->pw_gid;
+ if (buf)
+ g_free(buf);
+
+ return pw_gid;
}
-const gchar *
+gchar *
tlm_user_get_home_dir (const gchar *username)
{
struct passwd *pwent;
+ struct passwd buf_pwent;
+ gchar *buf = NULL, *tmp = NULL, *pw_dir = NULL;
+ gsize size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size <= sizeof(struct passwd))
+ size = 1024;
- pwent = getpwnam (username);
- if (!pwent)
- return NULL;
+ for (; NULL != (tmp = g_realloc(buf, size)); size*=2)
+ {
+ buf = tmp;
- return pwent->pw_dir;
+ if (ERANGE == getpwnam_r(username, &buf_pwent, buf, size, &pwent))
+ continue;
+ break;
+ }
+
+ if (pwent)
+ {
+ pw_dir = g_malloc(strlen(pwent->pw_dir)+1);
+ if (pw_dir)
+ {
+ memset(pw_dir, 0, strlen(pwent->pw_dir)+1);
+ strncpy(pw_dir, pwent->pw_dir, strlen(pwent->pw_dir));
+ }
+ }
+
+ if (buf)
+ g_free(buf);
+
+ return pw_dir;
}
-const gchar *
+gchar *
tlm_user_get_shell (const gchar *username)
{
struct passwd *pwent;
+ struct passwd buf_pwent;
+ gchar *buf = NULL, *tmp = NULL, *pw_shell = NULL;
+ gsize size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size <= sizeof(struct passwd))
+ size = 1024;
- pwent = getpwnam (username);
- if (!pwent)
- return NULL;
+ for (; NULL != (tmp = g_realloc(buf, size)); size*=2)
+ {
+ buf = tmp;
- return pwent->pw_shell;
+ if (ERANGE == getpwnam_r(username, &buf_pwent, buf, size, &pwent))
+ continue;
+ break;
+ }
+
+ if (pwent)
+ {
+ pw_shell = g_malloc(strlen(pwent->pw_shell)+1);
+ if (pw_shell)
+ {
+ memset(pw_shell, 0, strlen(pwent->pw_shell)+1);
+ strncpy(pw_shell, pwent->pw_shell, strlen(pwent->pw_shell));
+ }
+ }
+
+ if (buf)
+ g_free(buf);
+
+ return pw_shell;
}
gboolean
size_t sz_hostaddress;
const gchar *tty_name = NULL;
gchar *tty_no_dev_name = NULL, *tty_id = NULL;
+ gchar tty_name_buf[TTY_NAME_MAX+1] = {0,};
DBG ("Log session entry to utmp/wtmp");
hostname = _get_host_name ();
sz_hostaddress = _get_host_address (hostname, &hostaddress);
- tty_name = ttyname (0);
+
+ if (0 == ttyname_r(0, tty_name_buf, TTY_NAME_MAX+1))
+ tty_name = tty_name_buf;
+
if (tty_name) {
tty_no_dev_name = g_strdup (strncmp(tty_name, "/dev/", 5) == 0 ?
tty_name + 5 : tty_name);
DBG("Adding watch for file '%s' in dir '%s'", file_name, dir);
if ((wd = inotify_add_watch (ifd, dir, IN_CREATE)) == -1) {
- WARN ("failed to add inotify watch on %s: %s", dir, strerror (errno));
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
+ WARN ("failed to add inotify watch on %s: %s", dir, strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
res = WATCH_FAILED;
goto remove_and_return;
}
if (!watch_list) return 0;
if ((ifd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC)) < 0) {
- WARN("Failed to start inotify: %s", strerror(errno));
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
+ WARN("Failed to start inotify: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
return 0;
}
void
g_clear_string (gchar **);
-const gchar *
+gchar *
tlm_user_get_name (uid_t user_id);
uid_t
gid_t
tlm_user_get_gid (const gchar *username);
-const gchar *
+gchar *
tlm_user_get_home_dir (const gchar *username);
-const gchar *
+gchar *
tlm_user_get_shell (const gchar *username);
gboolean
if (g_mkdir_with_parents (base_path,
S_IRUSR |S_IWUSR |S_IXUSR |S_IXGRP |S_IXOTH) == -1) {
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
WARN ("Could not create '%s', error: %s", base_path,
- strerror(errno));
+ strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
g_object_unref (server);
server = NULL;
}
_setup_unix_signal_handlers (TlmManager *manager)
{
if (signal (SIGINT, SIG_IGN) == SIG_ERR)
- WARN ("failed ignore SIGINT: %s", strerror(errno));
+ {
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
+ WARN ("failed ignore SIGINT: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
+ }
g_unix_signal_add (SIGTERM, _on_sigterm_cb, (gpointer) manager);
g_unix_signal_add (SIGHUP, _on_sighup_cb, (gpointer) manager);
{
TlmSessionRemote *self = TLM_SESSION_REMOTE(user_data);
TlmSessionRemotePrivate *priv = TLM_SESSION_REMOTE_PRIV(self);
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
switch (priv->last_sig)
{
DBG ("child %u didn't respond to SIGHUP, sending SIGTERM",
priv->cpid);
if (kill (priv->cpid, SIGTERM))
+ {
WARN ("kill(%u, SIGTERM): %s",
priv->cpid,
- strerror(errno));
+ strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
+ }
priv->last_sig = SIGTERM;
return G_SOURCE_CONTINUE;
case SIGTERM:
DBG ("child %u didn't respond to SIGTERM, sending SIGKILL",
priv->cpid);
if (kill (priv->cpid, SIGKILL))
+ {
WARN ("kill(%u, SIGKILL): %s",
priv->cpid,
- strerror(errno));
+ strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
+ }
priv->last_sig = SIGKILL;
return G_SOURCE_CONTINUE;
case SIGKILL:
DBG ("Terminate child session process");
if (kill (priv->cpid, SIGHUP) < 0)
- WARN ("kill(%u, SIGHUP): %s", priv->cpid, strerror(errno));
+ {
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
+ WARN ("kill(%u, SIGHUP): %s", priv->cpid, strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
+ }
priv->last_sig = SIGHUP;
priv->timer_id = g_timeout_add_seconds (
tlm_config_get_uint (priv->config, TLM_CONFIG_GENERAL,
#include <pwd.h>
#include <stdlib.h>
+#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <glib.h>
gboolean delete)
{
struct passwd *pwd_entry = NULL;
- char *command = NULL;
+ struct passwd buf_pwd;
+ gchar *command = NULL;
int res;
+ gchar *buf = NULL, *tmp = NULL;
+ gsize size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size < sizeof(struct passwd))
+ size = 1024;
(void) delete;
/* clear error */
errno = 0;
- pwd_entry = getpwnam (user_name);
+ for (; NULL != (tmp = g_realloc(buf, size)); size*=2)
+ {
+ buf = tmp;
+
+ if (ERANGE == getpwnam_r(user_name, &buf_pwd, buf, size, &pwd_entry))
+ continue;
+ break;
+ }
if (!pwd_entry) {
DBG("Could not get info for user '%s', error : %s",
user_name, strerror(errno));
+
+ if (buf)
+ g_free(buf);
+
return FALSE;
}
if (!pwd_entry->pw_dir) {
DBG("No home folder entry found for user '%s'", user_name);
+
+ if (buf)
+ g_free(buf);
+
return FALSE;
}
g_free (command);
+ if (buf)
+ g_free(buf);
+
return res != -1;
}
_is_valid_user (TlmAccountPlugin *plugin, const gchar *user_name)
{
struct passwd *pwd_entry = NULL;
+ struct passwd pwd_buf;
+ gchar *buf = NULL, *tmp = NULL;
+ gsize size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size < sizeof(struct passwd))
+ size = 1024;
g_return_val_if_fail (plugin, FALSE);
g_return_val_if_fail (TLM_IS_ACCOUNT_PLUGIN_DEFAULT(plugin), FALSE);
/* clear error */
errno = 0;
- pwd_entry = getpwnam (user_name);
+ for (; NULL != (tmp = g_realloc(buf, size)); size*=2)
+ {
+ buf = tmp;
+
+ if (ERANGE == getpwnam_r(user_name, &pwd_buf, buf, size, &pwd_entry))
+ continue;
+ break;
+ }
if (!pwd_entry) {
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
DBG("Could not get info for user '%s', error : %s",
- user_name, strerror(errno));
+ user_name, strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
+ if (buf)
+ g_free(buf);
return FALSE;
}
+ if (buf)
+ g_free(buf);
+
return TRUE;
}
g_weak_ref_init (&__self, self);
if (sigaction(SIGUSR1, &sa, NULL) != 0) {
- WARN ("assert(sigaction()) : %s", strerror(errno));
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
+ WARN ("assert(sigaction()) : %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
}
tlm_log_init("TLM_AUTH_PLUGIN");
GMainContext *ctx = g_main_loop_get_context (main_loop);
if (signal (SIGINT, SIG_IGN) == SIG_ERR)
- WARN ("failed to ignore SIGINT: %s", strerror(errno));
+ {
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
+ WARN ("failed to ignore SIGINT: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
+ }
source = g_unix_signal_source_new (SIGTERM);
g_source_set_callback (source,
{
GMainLoop *main_loop = NULL;
gint in_fd = 0, out_fd = 1;
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
/* Duplicates stdin and stdout descriptors and point the descriptors
* to /dev/null to avoid anyone writing to descriptors
* */
in_fd = dup(0);
if (in_fd == -1) {
- WARN ("Failed to dup stdin : %s(%d)", strerror(errno), errno);
+ WARN ("Failed to dup stdin : %s(%d)", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN), errno);
in_fd = 0;
}
if (!freopen("/dev/null", "r+", stdin)) {
out_fd = dup(1);
if (out_fd == -1) {
- WARN ("Failed to dup stdout : %s(%d)", strerror(errno), errno);
+ WARN ("Failed to dup stdout : %s(%d)", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN), errno);
out_fd = 1;
}
{
int res;
const char *pam_tty = NULL;
- const char *pam_ruser = NULL;
+ char *pam_ruser = NULL;
+ gchar tty_name[TTY_NAME_MAX+1] = {0,};
g_return_val_if_fail (auth_session &&
TLM_IS_AUTH_SESSION(auth_session), FALSE);
pam_tty = getenv ("DISPLAY");
if (!pam_tty)
- pam_tty = ttyname (0);
+ {
+ if (0 == ttyname_r(0, tty_name, TTY_NAME_MAX+1))
+ pam_tty = tty_name;
+ }
if (!pam_tty)
pam_tty = priv->tty_name;
if (pam_tty) {
if (pam_set_item (priv->pam_handle, PAM_RUSER, pam_ruser) != PAM_SUCCESS) {
WARN ("pam_set_item(PAM_RUSER, '%s')", pam_ruser);
}
+ if (pam_ruser)
+ g_free(pam_ruser);
if (pam_set_item (priv->pam_handle, PAM_RHOST, "localhost") !=
PAM_SUCCESS) {
{
int tty_fd = -1;
struct stat tty_stat;
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
DBG ("VTNR is %u", priv->vtnr);
if (priv->vtnr > 0) {
priv->tty_dev = g_strdup_printf ("/dev/tty%u", priv->vtnr);
} else {
- priv->tty_dev = g_strdup (ttyname (0));
+ gchar tty_name[TTY_NAME_MAX+1] = {0,};
+ if (0 == ttyname_r(0, tty_name, TTY_NAME_MAX+1))
+ priv->tty_dev = g_strdup (tty_name);
+ else
+ priv->tty_dev = NULL;
}
DBG ("trying to setup TTY '%s'", priv->tty_dev);
if (!priv->tty_dev) {
goto term_exit;
}
if (access (priv->tty_dev, R_OK|W_OK)) {
- WARN ("TTY not accessible: %s", strerror(errno));
+ WARN ("TTY not accessible: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
goto term_exit;
}
if (lstat (priv->tty_dev, &tty_stat)) {
- WARN ("lstat() failed: %s", strerror(errno));
+ WARN ("lstat() failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
goto term_exit;
}
if (tty_stat.st_nlink > 1 ||
tty_fd = open (priv->tty_dev, O_RDWR | O_NONBLOCK);
if (tty_fd < 0) {
- WARN ("open() failed: %s", strerror(errno));
+ WARN ("open() failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
goto term_exit;
}
if (!isatty (tty_fd)) {
priv->tty_gid = 0;
}
if (ioctl (tty_fd, TCGETS, &priv->tty_state) < 0)
- WARN ("ioctl(TCGETS) failed: %s", strerror(errno));
+ WARN ("ioctl(TCGETS) failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
if (fchown (tty_fd, tlm_user_get_uid (priv->username), -1)) {
WARN ("Changing TTY access rights failed");
}
if (ioctl(tty_fd, KDGKBMODE, &priv->kb_mode) < 0) {
- DBG ("ioctl(KDGKBMODE get) failed: %s", strerror(errno));
+ DBG("ioctl(KDGKBMODE get) failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
} else {
DBG ("ioctl(KDGKBMODE get) val: %d", priv->kb_mode);
}
term_exit:
g_clear_string (&priv->tty_dev);
+
return -1;
}
_setup_terminal (TlmSessionPrivate *priv, int tty_fd)
{
pid_t tty_pgid;
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
if (ioctl (tty_fd, TIOCSCTTY, 1) < 0)
- WARN ("ioctl(TIOCSCTTY) failed: %s", strerror(errno));
+ WARN ("ioctl(TIOCSCTTY) failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
tty_pgid = getpgid (getpid ());
if (ioctl (tty_fd, TIOCSPGRP, &tty_pgid) < 0) {
- WARN ("ioctl(TIOCSPGRP) failed: %s", strerror(errno));
+ WARN ("ioctl(TIOCSPGRP) failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
}
if (ioctl (tty_fd, KDSKBMODE, K_OFF) < 0) {
- DBG ("ioctl(KDSKBMODE set) failed: %s", strerror(errno));
+ DBG ("ioctl(KDSKBMODE set) failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
}
dup2 (tty_fd, 0);
_reset_terminal (TlmSessionPrivate *priv)
{
int tty_fd = -1;
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
if (!priv->tty_dev)
return;
tty_fd = open (priv->tty_dev, O_RDWR | O_NONBLOCK);
if (tty_fd < 0) {
- WARN ("open() failed: %s", strerror(errno));
+ WARN ("open() failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
goto reset_exit;
}
if (priv->kb_mode >= 0 &&
ioctl (tty_fd, KDSKBMODE, priv->kb_mode) < 0) {
- DBG ("ioctl(KDSKBMODE reset) failed: %s", strerror(errno));
+ DBG ("ioctl(KDSKBMODE reset) failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
}
priv->kb_mode = -1;
if (ioctl (tty_fd, TCFLSH, TCIOFLUSH) < 0)
- DBG ("ioctl(TCFLSH) failed: %s", strerror(errno));
+ DBG ("ioctl(TCFLSH) failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
+
if (ioctl (tty_fd, TCSETS, &priv->tty_state) < 0)
- DBG ("ioctl(TCSETSF) failed: %s", strerror(errno));
+ DBG ("ioctl(TCSETSF) failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
if (fchown (tty_fd, priv->tty_uid, priv->tty_gid))
WARN ("Changing TTY access rights failed");
_set_environment (TlmSessionPrivate *priv)
{
gchar **envlist = tlm_auth_session_get_envlist(priv->auth_session);
- const gchar *home_dir = NULL, *shell = NULL;
+ gchar *home_dir = NULL, *shell = NULL;
if (envlist) {
gchar **env = 0;
_setenv_to_session ("USER", priv->username, priv);
_setenv_to_session ("LOGNAME", priv->username, priv);
home_dir = tlm_user_get_home_dir (priv->username);
- if (home_dir) _setenv_to_session ("HOME", home_dir, priv);
+ if (home_dir)
+ {
+ _setenv_to_session ("HOME", home_dir, priv);
+ g_free(home_dir);
+ }
shell = tlm_user_get_shell (priv->username);
- if (shell) _setenv_to_session ("SHELL", shell, priv);
+ if (shell)
+ {
+ _setenv_to_session ("SHELL", shell, priv);
+ g_free(shell);
+ }
if (!tlm_config_has_key (priv->config,
TLM_CONFIG_GENERAL,
gchar **args = NULL;
gchar **args_iter = NULL;
TlmSessionPrivate *priv = session->priv;
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
priv = session->priv;
if (!priv->username)
if (chown (priv->xdg_runtime_dir,
tlm_user_get_uid (priv->username),
tlm_user_get_gid (priv->username)))
- WARN ("chown(\"%s\"): %s", priv->xdg_runtime_dir, strerror(errno));
+ WARN ("chown(\"%s\"): %s", priv->xdg_runtime_dir, strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
if (chmod (priv->xdg_runtime_dir, rtdir_perm))
- WARN ("chmod(\"%s\"): %s", priv->xdg_runtime_dir, strerror(errno));
+ WARN ("chmod(\"%s\"): %s", priv->xdg_runtime_dir, strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
} else {
DBG ("not setting up XDG_RUNTIME_DIR");
}
for (fd = 3; fd < open_max; fd++) {
if (fcntl (fd, F_SETFD, FD_CLOEXEC) < -1) {
WARN ("Failed to close desriptor '%d', error: %s",
- fd, strerror(errno));
+ fd, strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
}
}
DBG ("old pgid=%u", getpgrp ());
if (setsid () == (pid_t) -1)
- WARN ("setsid() failed: %s", strerror (errno));
+ WARN ("setsid() failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
DBG ("new pgid=%u", getpgrp());
if (setup_terminal) {
}
if (initgroups (priv->username, target_gid))
- WARN ("initgroups() failed: %s", strerror(errno));
+ WARN ("initgroups() failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
if (setregid (target_gid, target_gid))
- WARN ("setregid() failed: %s", strerror(errno));
+ WARN ("setregid() failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
if (setreuid (target_uid, target_uid))
- WARN ("setreuid() failed: %s", strerror(errno));
+ WARN ("setreuid() failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
int grouplist_len = NGROUPS_MAX;
gid_t grouplist[NGROUPS_MAX];
if (home) {
DBG ("changing directory to : %s", home);
if (chdir (home) < 0)
- WARN ("Failed to change directroy : %s", strerror (errno));
+ WARN ("Failed to change directroy : %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
} else WARN ("Could not get home directory");
shell = tlm_config_get_string (priv->config,
}
if (signal (SIGINT, SIG_DFL) == SIG_ERR)
- WARN ("failed reset SIGINT: %s", strerror(errno));
+ WARN ("failed reset SIGINT: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
DBG ("executing: ");
args_iter = args;
execvp (args[0], args);
/* we reach here only in case of error */
g_strfreev (args);
- DBG ("execl(): %s", strerror(errno));
+ DBG ("execl(): %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
exit (0);
}
{
TlmSession *session = TLM_SESSION(user_data);
TlmSessionPrivate *priv = TLM_SESSION_PRIV(session);
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
switch (priv->last_sig)
{
if (killpg (getpgid (priv->child_pid), SIGTERM))
WARN ("killpg(%u, SIGTERM): %s",
getpgid (priv->child_pid),
- strerror(errno));
+ strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
priv->last_sig = SIGTERM;
return G_SOURCE_CONTINUE;
case SIGTERM:
if (killpg (getpgid (priv->child_pid), SIGKILL))
WARN ("killpg(%u, SIGKILL): %s",
getpgid (priv->child_pid),
- strerror(errno));
+ strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
priv->last_sig = SIGKILL;
return G_SOURCE_CONTINUE;
case SIGKILL:
}
if (killpg (getpgid (priv->child_pid), SIGHUP) < 0)
+ {
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
WARN ("kill(%u, SIGHUP): %s",
getpgid (priv->child_pid),
- strerror(errno));
+ strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
+ }
priv->last_sig = SIGHUP;
priv->timer_id = g_timeout_add_seconds (
tlm_config_get_uint (priv->config, TLM_CONFIG_GENERAL,
char str[1024];
gchar **argv = NULL;
pid_t child_pid = 0;
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
if (!l || !l->fp) return;
if (!argv)
ERR("Getting argv failure");
if ((child_pid = fork()) < 0) {
- ERR("fork() failed: %s", strerror (errno));
+ ERR("fork() failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
} else if (child_pid == 0) {
/* child process */
INFO("Launching command : %s, pid: %d, ppid: %d\n",
argv[0], getpid (), getppid ());
execvp(argv[0], argv);
- WARN("exec failed: %s", strerror (errno));
+ WARN("exec failed: %s", strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
} else if (control == 'M') {
ChildInfo *info = g_slice_new0 (ChildInfo);
if (!info) {
_tlm_launcher_init (&launcher);
if (!(launcher.fp = fopen(file, "r"))) {
- ERR("Failed to open file '%s':%s", file, strerror(errno));
+ gchar strerr_buf[MAX_STRERROR_LEN] = {0,};
+ ERR("Failed to open file '%s':%s", file, strerror_r(errno, strerr_buf, MAX_STRERROR_LEN));
_tlm_launcher_deinit (&launcher);
return 0;
}