X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-registry.c;h=3f1390dc3df1e65449700c12fa502215a9e29426;hp=26f306d52d516ac6091e74a1cb26ef73821dbbbd;hb=b4d096a6292e78c601dba161dbb15f48ad89935f;hpb=d7ba13889c8692b14f99238ddf2721ed78df89d2 diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 26f306d52..3f1390dc3 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -43,13 +43,13 @@ static int ht_match_event(struct cds_lfht_node *node, const void *_key) key = _key; /* It has to be a perfect match. */ - if (strncmp(event->name, key->name, sizeof(event->name)) != 0) { + if (strncmp(event->name, key->name, sizeof(event->name))) { goto no_match; } /* It has to be a perfect match. */ if (strncmp(event->signature, key->signature, - strlen(event->signature) != 0)) { + strlen(event->signature))) { goto no_match; } @@ -547,6 +547,7 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, int byte_order, uint32_t major, uint32_t minor, + const char *root_shm_path, const char *shm_path, uid_t euid, gid_t egid) @@ -571,6 +572,11 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, session->long_alignment = long_alignment; session->byte_order = byte_order; session->metadata_fd = -1; + session->uid = euid; + session->gid = egid; + strncpy(session->root_shm_path, root_shm_path, + sizeof(session->root_shm_path)); + session->root_shm_path[sizeof(session->root_shm_path) - 1] = '\0'; if (shm_path[0]) { strncpy(session->shm_path, shm_path, sizeof(session->shm_path)); @@ -593,9 +599,9 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, } if (session->metadata_path[0]) { /* Create metadata file */ - ret = open(session->metadata_path, + ret = run_as_open(session->metadata_path, O_WRONLY | O_CREAT | O_EXCL, - S_IRUSR | S_IWUSR); + S_IRUSR | S_IWUSR, euid, egid); if (ret < 0) { PERROR("Opening metadata file"); goto error; @@ -671,9 +677,17 @@ void ust_registry_session_destroy(struct ust_registry_session *reg) if (ret) { PERROR("close"); } - ret = unlink(reg->metadata_path); + ret = run_as_unlink(reg->metadata_path, + reg->uid, reg->gid); if (ret) { PERROR("unlink"); } } + if (reg->root_shm_path[0]) { + /* + * Try deleting the directory hierarchy. + */ + (void) run_as_recursive_rmdir(reg->root_shm_path, + reg->uid, reg->gid); + } }