From 9d5fd5db2fb163aed871424308b1bf46b9908ff4 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 14 Jun 2026 18:26:43 +0200 Subject: [PATCH] bin: fix file permission regression in /cfg/startup-config.cfg admin@infix-00-00-00:~$ less /cfg/startup-config.cfg cat: can't open '/cfg/startup-config.cfg': Permission denied /cfg/startup-config.cfg: Permission denied admin@infix-00-00-00:~$ ls -l /cfg/ total 16 -rw------- 1 root wheel 13655 Jun 14 12:59 startup-config.cfg Signed-off-by: Joachim Wiberg --- src/bin/copy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/copy.c b/src/bin/copy.c index bd6a5972..2fcc8584 100644 --- a/src/bin/copy.c +++ b/src/bin/copy.c @@ -138,9 +138,16 @@ static void set_owner(const char *fn, const char *user) if (chown(fn, -1, gid) && errno != EPERM) { const struct group *gr = getgrgid(gid); - warn("setting group owner %s (%d) on %s", + warn("failed setting group owner %s (%d) on %s", gr ? gr->gr_name : "", gid, fn); } + + /* Make sure the group we just set can actually read/write the file. + * umask alone can't: the datastore export goes through a 0600 mkstemp + * temp and cp(1) propagates that mode to the destination. + */ + if (chmod(fn, 0660) && errno != EPERM) + warn("failed setting mode 0660 on %s", fn); } static const char *infix_ds(const char *text, const struct infix_ds **ds)