Skip to content

Commit dd22a18

Browse files
authored
Set correct ownership if qb_ipcs_connection_auth_set() has been used (#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.
1 parent c5cb0db commit dd22a18

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ ALL_LINT_FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(DEB_INCLUDES) \
151151
# ipc_setup.c: (in function qb_ipcc_us_setup_connect)
152152
# ipc_setup.c:479:2: Return value (type int32_t) ignored: qb_ipc_us_ready(...
153153
# ipc_setup.c:494:2: Return value (type int32_t) ignored: qb_ipc_auth_cred...
154-
SPLINT_SUMMARY_EXP = " 2 code warnings"
154+
SPLINT_SUMMARY_EXP = " 3 code warnings"
155155

156156
run_splint.sh: $(top_srcdir)/configure.ac
157157
@echo '$(SPLINT) $(ALL_LINT_FLAGS) \' > $@-t

lib/ipc_shm.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ qb_ipcs_shm_connect(struct qb_ipcs_service *s,
283283
struct qb_ipc_connection_response *r)
284284
{
285285
int32_t res;
286+
char dirname[PATH_MAX];
287+
char *slash;
286288

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

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

298+
/* Set correct ownership if qb_ipcs_connection_auth_set() has been used */
299+
strlcpy(dirname, c->description, sizeof(dirname));
300+
slash = strrchr(dirname, '/');
301+
if (slash) {
302+
*slash = '\0';
303+
(void)chown(dirname, c->auth.uid, c->auth.gid);
304+
}
305+
296306
res = qb_ipcs_shm_rb_open(c, &c->request,
297307
r->request);
298308
if (res != 0) {

0 commit comments

Comments
 (0)