Skip to content

Commit

Permalink
Set correct ownership if qb_ipcs_connection_auth_set() has been used (#…
Browse files Browse the repository at this point in the history
…382)

When qb_ipcs_connection_auth_set() has been used, the ownership of the
temp directory initially set by handle_new_connection() must be updated
as well.
  • Loading branch information
diabonas authored Feb 12, 2020
1 parent c5cb0db commit dd22a18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ALL_LINT_FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(DEB_INCLUDES) \
# ipc_setup.c: (in function qb_ipcc_us_setup_connect)
# ipc_setup.c:479:2: Return value (type int32_t) ignored: qb_ipc_us_ready(...
# ipc_setup.c:494:2: Return value (type int32_t) ignored: qb_ipc_auth_cred...
SPLINT_SUMMARY_EXP = " 2 code warnings"
SPLINT_SUMMARY_EXP = " 3 code warnings"

run_splint.sh: $(top_srcdir)/configure.ac
@echo '$(SPLINT) $(ALL_LINT_FLAGS) \' > $@-t
Expand Down
10 changes: 10 additions & 0 deletions lib/ipc_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ qb_ipcs_shm_connect(struct qb_ipcs_service *s,
struct qb_ipc_connection_response *r)
{
int32_t res;
char dirname[PATH_MAX];
char *slash;

qb_util_log(LOG_DEBUG, "connecting to client [%d]", c->pid);

Expand All @@ -293,6 +295,14 @@ qb_ipcs_shm_connect(struct qb_ipcs_service *s,
snprintf(r->event, NAME_MAX, "%s-event-%s",
c->description, s->name);

/* Set correct ownership if qb_ipcs_connection_auth_set() has been used */
strlcpy(dirname, c->description, sizeof(dirname));
slash = strrchr(dirname, '/');
if (slash) {
*slash = '\0';
(void)chown(dirname, c->auth.uid, c->auth.gid);
}

res = qb_ipcs_shm_rb_open(c, &c->request,
r->request);
if (res != 0) {
Expand Down

0 comments on commit dd22a18

Please sign in to comment.