From 16e8ea906dfab7d86b1a0eaf7569fd9c2bbcc369 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Sun, 2 Mar 2014 19:52:07 +0100 Subject: [PATCH 1/3] Implementing permissions as described in #174 --- .../sbt/packager/GenericPackageSettings.scala | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/packager/GenericPackageSettings.scala b/src/main/scala/com/typesafe/sbt/packager/GenericPackageSettings.scala index 43550859f..d05657ccd 100644 --- a/src/main/scala/com/typesafe/sbt/packager/GenericPackageSettings.scala +++ b/src/main/scala/com/typesafe/sbt/packager/GenericPackageSettings.scala @@ -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 } }, @@ -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, From 892e9fbb2024a54bf8e4969fb4f9464ce8db74d8 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Sun, 2 Mar 2014 20:14:28 +0100 Subject: [PATCH 2/3] Fixing tests --- src/sbt-test/debian/daemon-user-deb/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sbt-test/debian/daemon-user-deb/build.sbt b/src/sbt-test/debian/daemon-user-deb/build.sbt index 09a8697dc..9ba640782 100644 --- a/src/sbt-test/debian/daemon-user-deb/build.sbt +++ b/src/sbt-test/debian/daemon-user-deb/build.sbt @@ -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) From 37c2054c263b31fc359d5b29a789a3fd7f88ca47 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Sun, 2 Mar 2014 20:27:41 +0100 Subject: [PATCH 3/3] Finally fixing build --- src/sbt-test/debian/daemon-user-deb/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sbt-test/debian/daemon-user-deb/build.sbt b/src/sbt-test/debian/daemon-user-deb/build.sbt index 9ba640782..67811963f 100644 --- a/src/sbt-test/debian/daemon-user-deb/build.sbt +++ b/src/sbt-test/debian/daemon-user-deb/build.sbt @@ -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 /var/run/debian-test", "postinst misses chown daemonuser /var/run/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)