Skip to content

Commit f702541

Browse files
CORE-11535: Fix svlogd rotated log files permissions (#10590) (#10667)
* CORE-11535: Fix svlogd rotated log files permissions (cherry picked from commit 14b4639)
1 parent 0c36ac6 commit f702541

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

node/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
!vendor/github.com/kelseyhightower/confd/etc/calico/confd
88
# - AlmaLinux repository file and our license
99
!almalinux.repo
10+
!patches/svlogd_use_0644_permission_instead_of_0744.patch
1011
!LICENSE
1112
# - Files used in the windows image
1213
!windows-packaging/CalicoWindows/libs

node/Dockerfile.amd64

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,15 @@ RUN rpm -i ${IPSET_SOURCERPM_URL} && \
7373
yum-builddep -y --spec /root/rpmbuild/SPECS/ipset.spec && \
7474
rpmbuild -bb /root/rpmbuild/SPECS/ipset.spec
7575

76+
# Copy the patch that adjusts svlogd log file permissions from 0744 to 0644.
77+
# This file is used in the next step to apply the patch during the build process.
78+
COPY patches/svlogd_use_0644_permission_instead_of_0744.patch /svlogd_use_0644_permission_instead_of_0744.patch
79+
7680
# runit is not available in ubi or AlmaLinux repos so build it.
7781
# get it from the debian repos as the official website doesn't support https
7882
RUN curl -sfL https://ftp.debian.org/debian/pool/main/r/runit/runit_${RUNIT_VER}.orig.tar.gz | tar xz -C /root && \
7983
cd /root/admin/runit-${RUNIT_VER} && \
84+
patch -p1 < /svlogd_use_0644_permission_instead_of_0744.patch && \
8085
package/compile
8186

8287
FROM ${UBI_IMAGE} AS ubi

node/Dockerfile.arm64

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,15 @@ RUN rpm -i ${IPSET_SOURCERPM_URL} && \
7373
yum-builddep -y --spec /root/rpmbuild/SPECS/ipset.spec && \
7474
rpmbuild -bb /root/rpmbuild/SPECS/ipset.spec
7575

76+
# Copy the patch that adjusts svlogd log file permissions from 0744 to 0644.
77+
# This file is used in the next step to apply the patch during the build process.
78+
COPY patches/svlogd_use_0644_permission_instead_of_0744.patch /svlogd_use_0644_permission_instead_of_0744.patch
79+
7680
# runit is not available in ubi or AlmaLinux repos so build it.
7781
# get it from the debian repos as the official website doesn't support https
7882
RUN curl -sfL https://ftp.debian.org/debian/pool/main/r/runit/runit_${RUNIT_VER}.orig.tar.gz | tar xz -C /root && \
7983
cd /root/admin/runit-${RUNIT_VER} && \
84+
patch -p1 < /svlogd_use_0644_permission_instead_of_0744.patch && \
8085
package/compile
8186

8287
FROM ${UBI_IMAGE} AS ubi
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Subject: [PATCH] use_0644_permission_instead_of_0744
2+
---
3+
Index: src/svlogd.c
4+
IDEA additional info:
5+
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
6+
<+>UTF-8
7+
===================================================================
8+
diff --git a/src/svlogd.c b/src/svlogd.c
9+
--- a/src/svlogd.c (revision 142186093dafb75d90ae4aab4a06e2f32bcd74d5)
10+
+++ b/src/svlogd.c (date 1750721596815)
11+
@@ -205,7 +205,7 @@
12+
f[26] ='s'; f[27] =0;
13+
while (rename(ld->fnsave, f) == -1)
14+
pause2("unable to rename processed", ld->name);
15+
- while (chmod(f, 0744) == -1)
16+
+ while (chmod(f, 0644) == -1)
17+
pause2("unable to set mode of processed", ld->name);
18+
ld->fnsave[26] ='u';
19+
if (unlink(ld->fnsave) == -1)
20+
@@ -282,7 +282,7 @@
21+
buffer_flush(&ld->b);
22+
while (fsync(ld->fdcur) == -1)
23+
pause2("unable to fsync current logfile", ld->name);
24+
- while (fchmod(ld->fdcur, 0744) == -1)
25+
+ while (fchmod(ld->fdcur, 0644) == -1)
26+
pause2("unable to set mode of current", ld->name);
27+
close(ld->fdcur);
28+
if (verbose) {
29+
@@ -372,7 +372,7 @@
30+
buffer_flush(&ld->b);
31+
while (fsync(ld->fdcur) == -1)
32+
pause2("unable to fsync current logfile", ld->name);
33+
- while (fchmod(ld->fdcur, 0744) == -1)
34+
+ while (fchmod(ld->fdcur, 0644) == -1)
35+
pause2("unable to set mode of current", ld->name);
36+
close(ld->fdcur);
37+
ld->fdcur =-1;

0 commit comments

Comments
 (0)