Skip to content

Fix BZ 69902 - set file permissions in the ZIP distribution - #1091

Merged
markt-asf merged 1 commit into
apache:mainfrom
liotur:bz-69902-zip-permissions
Oct 19, 2026
Merged

markt-asf merged 1 commit into
apache:mainfrom
liotur:bz-69902-zip-permissions

Conversation

@liotur

@liotur liotur commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

https://bz.apache.org/bugzilla/show_bug.cgi?id=69902

package-tgz sets an explicit dirmode and filemode on each of its tarfilesets.
package-zip sets none, so entries are stored with Ant's defaults, 0644 for files and
0755 for directories, and bin/*.sh is not executable once the archive is extracted on a
Unix platform. dist-static already marks the scripts executable on disk, but a
zipfileset with no filemode stores its own default rather than the mode on disk, so
the bit is dropped at packaging time. The reporter ran into this installing Tomcat
through sdkman (sdkman/sdkman-cli#974).

On the line endings in comment #1: they are already right for the scripts. dist-static
sets bin/*.sh to LF, and *.sh is not in the text.files patternset that the
fixcrlf pass at the top of package-zip uses, so the scripts stay LF while the text
files stay CRLF. This change does not touch that; only the stored modes change.

The new filesets mirror the ones in package-tgz: conf 0700 with 0600 contents, then
bin, lib, logs, temp, webapps, work and the top-level text files 0750/0640,
then bin/*.sh 0750 in a fileset of its own after the rest. The
<exclude name="bin/*.sh"/> is needed because <zip> defaults to duplicate="add":
without it each script is stored twice, first at 0640 and then at 0750. package-tgz
carries the same exclude for the same reason.

Two things left as they are. The top-level apache-tomcat-<version>/ entry keeps Ant's
default 0755, because it comes from the <zipfileset file="..." fullpath="..."/> line
rather than from the filesets; the .tar.gz has no such entry, so extracting it creates
that directory from the umask, which is also 0755 with the usual 022. package-winzip is
unchanged, as the Windows artifact. The deployer, embedded and source archives set no
modes in either format, so package-zip was the only target where the ZIP and the
tar.gz disagreed.

Testing, since comment #1 asked for it. I ran the old and the new package-zip filesets
and the package-tgz ones with Ant 1.10.15 over a stand-in ${tomcat.dist} tree rather
than a full ant release. The new ZIP stores the same permissions as the .tar.gz for
every entry the two have in common:

                                              before    after   tar.gz
apache-tomcat-<version>/bin/                    0755     0750     0750
apache-tomcat-<version>/bin/catalina.bat        0644     0640     0640
apache-tomcat-<version>/bin/catalina.sh         0644     0750     0750
apache-tomcat-<version>/conf/                   0755     0700     0700
apache-tomcat-<version>/conf/server.xml         0644     0600     0600
apache-tomcat-<version>/LICENSE                 0644     0640     0640

Extracted with unzip under umask 022, bin/catalina.sh is 0644 before the change and
running it fails with "permission denied"; after the change it is 0750 and runs. The
entries were already written with create_system 3 (UNIX) before the change, so this
changes the mode values rather than whether modes are stored at all, and no entry gets
the DOS read-only attribute.

package-tgz sets explicit dirmode and filemode values on its tarfilesets
but package-zip does not, so entries are stored with Ant's defaults,
0644 for files and 0755 for directories, and the scripts in bin are not
executable once the archive is extracted on a Unix platform. dist-static
already marks them executable on disk; the mode is dropped at packaging
time.

Use the same modes as package-tgz: conf 0700 with 0600 contents, bin,
lib, logs, temp, webapps and work 0750 with 0640 contents, the same for
the top level text files, and the scripts in bin 0750. The bin/*.sh
exclude keeps the scripts from being stored twice.
@markt-asf

Copy link
Copy Markdown
Contributor

Tx. looks good to me.

@markt-asf
markt-asf merged commit 0ab6097 into apache:main Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants