Skip to content

Commit 41f5273

Browse files
committed
Merge pull request #178 from sbt/wip/linux-server-permissions
Implementing permissions as described in #174
2 parents cc4719d + 37c2054 commit 41f5273

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/main/scala/com/typesafe/sbt/packager/GenericPackageSettings.scala

+16-16
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ trait GenericPackageSettings
6767
defaultLinuxConfigLocation := "/etc",
6868

6969
// First we look at the src/linux files
70-
linuxPackageMappings <++= (sourceDirectory in Linux, daemonUser in Linux, daemonGroup in Linux) map { (dir, user, group) =>
71-
mapGenericMappingsToLinux(MappingsHelper contentOf dir, user, group)(identity)
70+
linuxPackageMappings <++= (sourceDirectory in Linux) map { dir =>
71+
mapGenericMappingsToLinux(MappingsHelper contentOf dir, Users.Root, Users.Root)(identity)
7272
},
7373
// Now we look at the src/universal files.
74-
linuxPackageMappings <++= (normalizedName in Universal, mappings in Universal, defaultLinuxInstallLocation, daemonUser in Linux, daemonGroup in Linux) map {
75-
(pkg, mappings, installLocation, user, group) =>
74+
linuxPackageMappings <++= (normalizedName in Universal, mappings in Universal, defaultLinuxInstallLocation) map {
75+
(pkg, mappings, installLocation) =>
7676
// TODO - More windows filters...
7777
def isWindowsFile(f: (File, String)): Boolean =
7878
f._2 endsWith ".bat"
7979

80-
mapGenericMappingsToLinux(mappings filterNot isWindowsFile, user, group) { name =>
80+
mapGenericMappingsToLinux(mappings filterNot isWindowsFile, Users.Root, Users.Root) { name =>
8181
installLocation + "/" + pkg + "/" + name
8282
}
8383
},
@@ -92,17 +92,17 @@ trait GenericPackageSettings
9292
},
9393
// Map configuration files
9494
linuxPackageSymlinks <++= (normalizedName in Universal, mappings in Universal, defaultLinuxInstallLocation, defaultLinuxConfigLocation)
95-
map { (pkg, mappings, installLocation, configLocation) =>
96-
val needsConfLink =
97-
mappings exists {
98-
case (file, name) =>
99-
(name startsWith "conf/") && !file.isDirectory
100-
}
101-
if (needsConfLink) Seq(LinuxSymlink(
102-
link = configLocation + "/" + pkg,
103-
destination = installLocation + "/" + pkg + "/conf"))
104-
else Seq.empty
105-
})
95+
map { (pkg, mappings, installLocation, configLocation) =>
96+
val needsConfLink =
97+
mappings exists {
98+
case (file, name) =>
99+
(name startsWith "conf/") && !file.isDirectory
100+
}
101+
if (needsConfLink) Seq(LinuxSymlink(
102+
link = configLocation + "/" + pkg,
103+
destination = installLocation + "/" + pkg + "/conf"))
104+
else Seq.empty
105+
})
106106

107107
def mapGenericFilesToWindows: Seq[Setting[_]] = Seq(
108108
mappings in Windows <<= mappings in Universal,

src/sbt-test/debian/daemon-user-deb/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ TaskKey[Unit]("check-control-files") <<= (target, streams) map { (target, out) =
2929
assert(postinst contains "addgroup --system daemongroup", "postinst misses addgroup for daemongroup: " + postinst)
3030
assert(postinst contains "useradd --system --no-create-home --gid daemongroup --shell /bin/false daemonuser", "postinst misses useradd for daemonuser: " + postinst)
3131
assert(postinst contains "chown daemonuser:daemongroup /var/log/debian-test", "postinst misses chown daemonuser /var/log/debian-test: " + postinst)
32-
assert(postinst contains "chown daemonuser:daemongroup /usr/share/debian-test/bin/debian-test", "postinst misses chown daemonuser /usr/share/debian-test/bin/debian-test: " + postinst)
32+
assert(postinst contains "chown daemonuser:daemongroup /var/run/debian-test", "postinst misses chown daemonuser /var/run/debian-test: " + postinst)
3333
assert(!(postinst contains "addgroup --system daemonuser"), "postinst has addgroup for daemonuser: " + postinst)
3434
assert(!(postinst contains "useradd --system --no-create-home --gid daemonuser --shell /bin/false daemonuser"), "postinst has useradd for daemongroup: " + postinst)
3535
assert(postrm contains "deluser --quiet --system daemonuser > /dev/null || true", "postrm misses purging daemonuser user: " + postrm)

0 commit comments

Comments
 (0)