Skip to content

Commit

Permalink
Merge pull request #178 from sbt/wip/linux-server-permissions
Browse files Browse the repository at this point in the history
Implementing permissions as described in #174
  • Loading branch information
jsuereth committed Mar 3, 2014
2 parents cc4719d + 37c2054 commit 41f5273
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ trait GenericPackageSettings
defaultLinuxConfigLocation := "/etc",

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

mapGenericMappingsToLinux(mappings filterNot isWindowsFile, user, group) { name =>
mapGenericMappingsToLinux(mappings filterNot isWindowsFile, Users.Root, Users.Root) { name =>
installLocation + "/" + pkg + "/" + name
}
},
Expand All @@ -92,17 +92,17 @@ trait GenericPackageSettings
},
// Map configuration files
linuxPackageSymlinks <++= (normalizedName in Universal, mappings in Universal, defaultLinuxInstallLocation, defaultLinuxConfigLocation)
map { (pkg, mappings, installLocation, configLocation) =>
val needsConfLink =
mappings exists {
case (file, name) =>
(name startsWith "conf/") && !file.isDirectory
}
if (needsConfLink) Seq(LinuxSymlink(
link = configLocation + "/" + pkg,
destination = installLocation + "/" + pkg + "/conf"))
else Seq.empty
})
map { (pkg, mappings, installLocation, configLocation) =>
val needsConfLink =
mappings exists {
case (file, name) =>
(name startsWith "conf/") && !file.isDirectory
}
if (needsConfLink) Seq(LinuxSymlink(
link = configLocation + "/" + pkg,
destination = installLocation + "/" + pkg + "/conf"))
else Seq.empty
})

def mapGenericFilesToWindows: Seq[Setting[_]] = Seq(
mappings in Windows <<= mappings in Universal,
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/debian/daemon-user-deb/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TaskKey[Unit]("check-control-files") <<= (target, streams) map { (target, out) =
assert(postinst contains "addgroup --system daemongroup", "postinst misses addgroup for daemongroup: " + postinst)
assert(postinst contains "useradd --system --no-create-home --gid daemongroup --shell /bin/false daemonuser", "postinst misses useradd for daemonuser: " + postinst)
assert(postinst contains "chown daemonuser:daemongroup /var/log/debian-test", "postinst misses chown daemonuser /var/log/debian-test: " + postinst)
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)
assert(postinst contains "chown daemonuser:daemongroup /var/run/debian-test", "postinst misses chown daemonuser /var/run/debian-test: " + postinst)
assert(!(postinst contains "addgroup --system daemonuser"), "postinst has addgroup for daemonuser: " + postinst)
assert(!(postinst contains "useradd --system --no-create-home --gid daemonuser --shell /bin/false daemonuser"), "postinst has useradd for daemongroup: " + postinst)
assert(postrm contains "deluser --quiet --system daemonuser > /dev/null || true", "postrm misses purging daemonuser user: " + postrm)
Expand Down

0 comments on commit 41f5273

Please sign in to comment.