Skip to content

Commit 4444e36

Browse files
authored
Merge pull request #3476 from citrus-it/perms
Normalise file permissions when generating manifests
2 parents 5b46d1d + c5cb6be commit 4444e36

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

build/dma/local.mog

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
# source. A copy of the CDDL is also available via the Internet at
99
# http://www.illumos.org/license/CDDL.
1010
#
11-
# Copyright 2017 OmniOS Community Edition (OmniOSce) Association.
11+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
1212

1313
user username=dma uid=26 group=mail gcos-field="DragonFly Mail Agent" \
1414
home-dir=/ password=NP
1515

1616
<transform dir path=var/mail$ -> drop>
1717
<transform file path=etc/dma/ -> set preserve renamenew>
1818
<transform file dir path=etc/dma -> set group mail>
19+
<transform file path=etc/dma/auth.conf -> set mode 0640>
1920
<transform file path=usr/lib/smtp/dma -> set group mail>
2021
<transform file path=usr/lib/smtp/dma/dma -> set mode 2755>
2122
<transform file path=usr/lib/smtp/dma/dma-mbox-create -> set mode 4754>

build/sudo/local.mog

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
# http://www.illumos.org/license/CDDL.
1010
#
1111
# Copyright 2011-2012 OmniTI Computer Consulting, Inc. All rights reserved.
12-
# Copyright 2023 OmniOS Community Edition (OmniOSce) Association.
12+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
1313
#
1414

1515
<transform path=var/db -> drop>
1616

1717
<transform file dir path=etc/sudoers -> set group root>
1818
<transform file path=etc/sudoers$ -> set preserve renamenew>
1919
<transform file path=etc/sudo.conf -> set preserve renamenew>
20+
<transform file path=etc/sudoers -> set mode 0440>
21+
<transform dir path=etc/sudoers.d -> set mode 0750>
2022

2123
<transform file path=usr/bin/sudo$ -> set mode 4511>
2224
<transform file path=usr/bin/sudoreplay$ -> set mode 0511>

lib/functions.sh

+20-2
Original file line numberDiff line numberDiff line change
@@ -1733,8 +1733,26 @@ generate_manifest() {
17331733
GENERATE_ARGS+="--target $f "
17341734
done
17351735
fi
1736-
logcmd -p $PKGSEND generate $GENERATE_ARGS $DESTDIR > $outf \
1737-
|| logerr "------ Failed to generate manifest"
1736+
# `pkgsend generate` will produce a manifest based on the files it
1737+
# finds under $DESTDIR. It will set the ownership and group in generated
1738+
# lines to root:bin, but will copy the mode attribute from the file it
1739+
# finds. The modes of files in this directory do generally accurately
1740+
# reflect executability, but other bits may be set depending on how the
1741+
# temporary directory is set up. For example, in a shared build workspace
1742+
# there could be extended ACLs to maintain writeability by the owning
1743+
# group, or the sticky group attribute may be set on directories.
1744+
# Rather than implicitly trusting the mode that is found, we normalise it
1745+
# to something more generic.
1746+
logcmd -p $PKGSEND generate $GENERATE_ARGS $DESTDIR | sed -E '
1747+
# Strip off any special attributes such as setuid or sticky group
1748+
s/\<mode=0[[:digit:]]+([[:digit:]]{3})\>/mode=0\1/
1749+
# Reduce group/other permissions
1750+
s/\<mode=0([75])[[:digit:]]{2}\>/mode=0\155/
1751+
s/\<mode=0([64])[[:digit:]]{2}\>/mode=0\144/
1752+
# Convert unexpected modes to something reasonable
1753+
s/\<mode=02[[:digit:]]{2}\>/mode=0644/
1754+
s/\<mode=0[13][[:digit:]]{2}\>/mode=0755/
1755+
' > $outf || logerr "------ Failed to generate manifest"
17381756
}
17391757

17401758
convert_version() {

0 commit comments

Comments
 (0)