projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: setuid/setgid daemons should not get sensitive env. var./args
[lttng-tools.git]
/
src
/
common
/
utils.c
diff --git
a/src/common/utils.c
b/src/common/utils.c
index e7dccb7b7490cb1c1392461304e70ea7cbf5d390..9a53330004931408df017fb4b2ebbd87ad31a61e 100644
(file)
--- a/
src/common/utils.c
+++ b/
src/common/utils.c
@@
-35,6
+35,7
@@
#include <common/common.h>
#include <common/runas.h>
#include <common/common.h>
#include <common/runas.h>
+#include <common/compat/getenv.h>
#include "utils.h"
#include "defaults.h"
#include "utils.h"
#include "defaults.h"
@@
-477,10
+478,14
@@
int utils_create_pid_file(pid_t pid, const char *filepath)
ret = fprintf(fp, "%d\n", pid);
if (ret < 0) {
PERROR("fprintf pid file");
ret = fprintf(fp, "%d\n", pid);
if (ret < 0) {
PERROR("fprintf pid file");
+ goto error;
}
}
- fclose(fp);
+ if (fclose(fp)) {
+ PERROR("fclose");
+ }
DBG("Pid %d written in file %s", pid, filepath);
DBG("Pid %d written in file %s", pid, filepath);
+ ret = 0;
error:
return ret;
}
error:
return ret;
}
@@
-512,7
+517,7
@@
int utils_create_lock_file(const char *filepath)
*/
ret = flock(fd, LOCK_EX | LOCK_NB);
if (ret) {
*/
ret = flock(fd, LOCK_EX | LOCK_NB);
if (ret) {
-
WARN
("Could not get lock file %s, another instance is running.",
+
ERR
("Could not get lock file %s, another instance is running.",
filepath);
if (close(fd)) {
PERROR("close lock file");
filepath);
if (close(fd)) {
PERROR("close lock file");
@@
-881,11
+886,11
@@
char *utils_get_home_dir(void)
char *val = NULL;
struct passwd *pwd;
char *val = NULL;
struct passwd *pwd;
- val = getenv(DEFAULT_LTTNG_HOME_ENV_VAR);
+ val =
lttng_secure_
getenv(DEFAULT_LTTNG_HOME_ENV_VAR);
if (val != NULL) {
goto end;
}
if (val != NULL) {
goto end;
}
- val = getenv(DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR);
+ val =
lttng_secure_
getenv(DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR);
if (val != NULL) {
goto end;
}
if (val != NULL) {
goto end;
}
@@
-950,7
+955,7
@@
end:
LTTNG_HIDDEN
char *utils_get_kmod_probes_list(void)
{
LTTNG_HIDDEN
char *utils_get_kmod_probes_list(void)
{
- return getenv(DEFAULT_LTTNG_KMOD_PROBES);
+ return
lttng_secure_
getenv(DEFAULT_LTTNG_KMOD_PROBES);
}
/*
}
/*
@@
-960,7
+965,7
@@
char *utils_get_kmod_probes_list(void)
LTTNG_HIDDEN
char *utils_get_extra_kmod_probes_list(void)
{
LTTNG_HIDDEN
char *utils_get_extra_kmod_probes_list(void)
{
- return getenv(DEFAULT_LTTNG_EXTRA_KMOD_PROBES);
+ return
lttng_secure_
getenv(DEFAULT_LTTNG_EXTRA_KMOD_PROBES);
}
/*
}
/*
This page took
0.027648 seconds
and
4
git commands to generate.