Skip to content

Commit

Permalink
Force stable file modes for built packages (#30823)
Browse files Browse the repository at this point in the history
If you have an unusual umask (e.g., 0002) and clone the GitHub
repository then files that we stick into our packages like the
README.textile and the license will have a file mode of 0664 on disk yet
we expect them to be 0644. Additionally, the same thing happens with
compiled artifacts like JARs. We try to set a default file mode yet it
does not seem to take everywhere. This commit adds explicit file modes
in some places that we were relying on the defaults to ensure that the
built artifacts have a consistent file mode regardless of the underlying
build host.
  • Loading branch information
jasontedor authored and hub-cap committed Jun 25, 2018
1 parent 85e9906 commit 3f95415
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
if (it.relativePath.segments[-2] == 'bin') {
// bin files, wherever they are within modules (eg platform specific) should be executable
it.mode = 0755
} else {
it.mode = 0644
}
}
if (oss) {
Expand Down
10 changes: 10 additions & 0 deletions distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Closure commonPackageConfig(String type, boolean oss) {
}
from(rootProject.projectDir) {
include 'README.textile'
fileMode 0644
}
into('modules') {
with copySpec {
Expand All @@ -135,6 +136,11 @@ Closure commonPackageConfig(String type, boolean oss) {
for (int i = segments.length - 2; i > 0 && segments[i] != 'modules'; --i) {
directory('/' + segments[0..i].join('/'), 0755)
}
if (segments[-2] == 'bin') {
fcp.mode = 0755
} else {
fcp.mode = 0644
}
}
}
}
Expand All @@ -153,6 +159,7 @@ Closure commonPackageConfig(String type, boolean oss) {
include oss ? 'APACHE-LICENSE-2.0.txt' : 'ELASTIC-LICENSE.txt'
rename { 'LICENSE.txt' }
}
fileMode 0644
}
}

Expand Down Expand Up @@ -181,14 +188,17 @@ Closure commonPackageConfig(String type, boolean oss) {
configurationFile '/usr/lib/systemd/system/elasticsearch.service'
into('/usr/lib/tmpfiles.d') {
from "${packagingFiles}/systemd/elasticsearch.conf"
fileMode 0644
}
into('/usr/lib/systemd/system') {
fileType CONFIG | NOREPLACE
from "${packagingFiles}/systemd/elasticsearch.service"
fileMode 0644
}
into('/usr/lib/sysctl.d') {
fileType CONFIG | NOREPLACE
from "${packagingFiles}/systemd/sysctl/elasticsearch.conf"
fileMode 0644
}

// ========= sysV init =========
Expand Down

0 comments on commit 3f95415

Please sign in to comment.