projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleanup compiler warnings
[lttng-tools.git]
/
ltt-sessiond
/
main.c
diff --git
a/ltt-sessiond/main.c
b/ltt-sessiond/main.c
index 1e2a0831dc80187b4b581e72ef97a037762a3fa4..567742ebb783bc1a4bfdf9f6ff89ddc8193f1604 100644
(file)
--- a/
ltt-sessiond/main.c
+++ b/
ltt-sessiond/main.c
@@
-1,5
+1,6
@@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@
-114,6
+115,22
@@
static int modprobe_remove_kernel_modules(void);
*/
static struct ltt_session_list *session_list_ptr;
*/
static struct ltt_session_list *session_list_ptr;
+static gid_t allowed_group(void)
+{
+ struct group *grp;
+
+ if (opt_tracing_group) {
+ grp = getgrnam(opt_tracing_group);
+ } else {
+ grp = getgrnam(default_tracing_group);
+ }
+ if (!grp) {
+ return -1;
+ } else {
+ return grp->gr_gid;
+ }
+}
+
/*
* Init quit pipe.
*
/*
* Init quit pipe.
*
@@
-1045,7
+1062,7
@@
static int mount_debugfs(char *path)
int ret;
char *type = "debugfs";
int ret;
char *type = "debugfs";
- ret = mkdir_recursive(path, S_IRWXU | S_IRWXG);
+ ret = mkdir_recursive(path, S_IRWXU | S_IRWXG
, geteuid(), getegid()
);
if (ret < 0) {
goto error;
}
if (ret < 0) {
goto error;
}
@@
-1226,9
+1243,10
@@
static int create_kernel_session(struct ltt_session *session)
goto error;
}
goto error;
}
- ret = mkdir_recursive(session->path, S_IRWXU | S_IRWXG );
+ ret = mkdir_recursive(session->path, S_IRWXU | S_IRWXG,
+ geteuid(), allowed_group());
if (ret < 0) {
if (ret < 0) {
- if (ret != EEXIST) {
+ if (ret !=
-
EEXIST) {
ERR("Trace directory creation error");
goto error;
}
ERR("Trace directory creation error");
goto error;
}
@@
-2423,8
+2441,6
@@
end:
*/
static int check_existing_daemon(void)
{
*/
static int check_existing_daemon(void)
{
- int ret;
-
if (access(client_unix_sock_path, F_OK) < 0 &&
access(apps_unix_sock_path, F_OK) < 0)
return 0;
if (access(client_unix_sock_path, F_OK) < 0 &&
access(apps_unix_sock_path, F_OK) < 0)
return 0;
@@
-2444,14
+2460,10
@@
static int check_existing_daemon(void)
static int set_permissions(void)
{
int ret;
static int set_permissions(void)
{
int ret;
- struct group *grp;
-
- /* Decide which group name to use */
- (opt_tracing_group != NULL) ?
- (grp = getgrnam(opt_tracing_group)) :
- (grp = getgrnam(default_tracing_group));
+ gid_t gid;
- if (grp == NULL) {
+ gid = allowed_group();
+ if (gid < 0) {
if (is_root) {
WARN("No tracing group detected");
ret = 0;
if (is_root) {
WARN("No tracing group detected");
ret = 0;
@@
-2463,21
+2475,21
@@
static int set_permissions(void)
}
/* Set lttng run dir */
}
/* Set lttng run dir */
- ret = chown(LTTNG_RUNDIR, 0, g
rp->gr_g
id);
+ ret = chown(LTTNG_RUNDIR, 0, gid);
if (ret < 0) {
ERR("Unable to set group on " LTTNG_RUNDIR);
perror("chown");
}
/* lttng client socket path */
if (ret < 0) {
ERR("Unable to set group on " LTTNG_RUNDIR);
perror("chown");
}
/* lttng client socket path */
- ret = chown(client_unix_sock_path, 0, g
rp->gr_g
id);
+ ret = chown(client_unix_sock_path, 0, gid);
if (ret < 0) {
ERR("Unable to set group on %s", client_unix_sock_path);
perror("chown");
}
/* kconsumerd error socket path */
if (ret < 0) {
ERR("Unable to set group on %s", client_unix_sock_path);
perror("chown");
}
/* kconsumerd error socket path */
- ret = chown(kconsumerd_err_unix_sock_path, 0, g
rp->gr_g
id);
+ ret = chown(kconsumerd_err_unix_sock_path, 0, gid);
if (ret < 0) {
ERR("Unable to set group on %s", kconsumerd_err_unix_sock_path);
perror("chown");
if (ret < 0) {
ERR("Unable to set group on %s", kconsumerd_err_unix_sock_path);
perror("chown");
This page took
0.024559 seconds
and
4
git commands to generate.