From 86dba5441c686d037c493e5b498e27249aa6bd9d Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Thu, 12 Feb 2026 14:54:23 +0100 Subject: lib: Fix SSM PUP creation on OS X OS X doesn't support chmod on shm files after creation. Since we already set the mode at creation, that call was redundant. Fixed the getpeereid() function was not accessible because of the guards. Fixed some differences between macOS and Linux with gid_t vs int usage. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/ssm/pool.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/lib/ssm/pool.c') diff --git a/src/lib/ssm/pool.c b/src/lib/ssm/pool.c index a388742d..5537d723 100644 --- a/src/lib/ssm/pool.c +++ b/src/lib/ssm/pool.c @@ -476,7 +476,6 @@ static ssize_t alloc_from_sc_b(struct ssm_pool * pool, /* Generate pool filename: uid=0 for GSPP, uid>0 for PUP */ static char * pool_filename(uid_t uid) { - char * str; char base[64]; if (IS_GSPP(uid)) @@ -484,9 +483,7 @@ static char * pool_filename(uid_t uid) else snprintf(base, sizeof(base), SSM_PUP_NAME_FMT, (int) uid); - str = strdup(base); - - return str; + return strdup(base); } void ssm_pool_close(struct ssm_pool * pool) @@ -527,7 +524,6 @@ void ssm_pool_destroy(struct ssm_pool * pool) } #define MM_FLAGS (PROT_READ | PROT_WRITE) - static struct ssm_pool * __pool_create(const char * name, int flags, uid_t uid, @@ -554,9 +550,7 @@ static struct ssm_pool * __pool_create(const char * name, if (flags & O_CREAT) { if (ftruncate(fd, (off_t) file_size) < 0) goto fail_truncate; - if (uid != geteuid()) - (void) fchown(fd, uid, gid); - if (fchmod(fd, mode) < 0) + if (uid != geteuid() && fchown(fd, uid, gid) < 0) goto fail_truncate; } -- cgit v1.2.3