-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the default owner of packaged files. See #129 #139
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ object JavaServerAppPackaging { | |
def debianSettings: Seq[Setting[_]] = | ||
Seq( | ||
serverLoading := Upstart, | ||
daemonUser := Users.Root, | ||
daemonUser <<= appUser in Linux, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this principle. |
||
// This one is begging for sbt 0.13 syntax... | ||
debianScriptReplacements <<= ( | ||
maintainer in Debian, packageSummary in Debian, serverLoading in Debian, daemonUser in Debian, normalizedName, | ||
|
@@ -55,15 +55,15 @@ object JavaServerAppPackaging { | |
map { (tmpDir, loader, replacements, template) => | ||
makeDebianMaintainerScript(JavaAppStartScript.startScript, Some(template))(tmpDir, loader, replacements) | ||
}, | ||
linuxPackageMappings in Debian <++= (debianMakeStartScript, normalizedName, serverLoading in Debian) | ||
map { (script, name, loader) => | ||
linuxPackageMappings in Debian <++= (debianMakeStartScript, normalizedName, serverLoading in Debian, appUser in Linux) | ||
map { (script, name, loader, owner) => | ||
val (path, permissions) = loader match { | ||
case Upstart => ("/etc/init/" + name + ".conf", "0644") | ||
case SystemV => ("/etc/init.d/" + name, "0755") | ||
} | ||
for { | ||
s <- script.toSeq | ||
} yield LinuxPackageMapping(Seq(s -> path)).withPerms(permissions).withConfig() | ||
} yield LinuxPackageMapping(Seq(s -> path), LinuxFileMetaData(owner, owner, permissions, "true")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these marked as conf files? Do we really want users altering this, or would we rather have them use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. Didnt' realize the bit about lintian. Looks good the way it is then. |
||
}, | ||
|
||
// === etc config mapping === | ||
|
@@ -74,13 +74,13 @@ object JavaServerAppPackaging { | |
}, | ||
debianMakeEtcDefault <<= (normalizedName, target in Universal, serverLoading in Debian, linuxEtcDefaultTemplate in Debian) | ||
map makeEtcDefaultScript, | ||
linuxPackageMappings in Debian <++= (debianMakeEtcDefault, normalizedName) map { (conf, name) => | ||
conf.map(c => LinuxPackageMapping(Seq(c -> ("/etc/default/" + name))).withConfig()).toSeq | ||
linuxPackageMappings in Debian <++= (debianMakeEtcDefault, normalizedName, appUser in Linux) map { (conf, name, owner) => | ||
conf.map(c => LinuxPackageMapping(Seq(c -> ("/etc/default/" + name)), LinuxFileMetaData(owner, owner)).withConfig()).toSeq | ||
}, | ||
// TODO should we specify daemonGroup in configs? | ||
|
||
// === logging directory mapping === | ||
linuxPackageMappings in Debian <+= (normalizedName, defaultLinuxLogsLocation, target in Debian, daemonUser in Debian) map { | ||
linuxPackageMappings in Debian <+= (normalizedName, defaultLinuxLogsLocation, target in Debian, appUser in Linux) map { | ||
(name, logsDir, target, user) => | ||
// create empty var/log directory | ||
val d = target / logsDir | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,9 @@ object Keys extends DebianKeys { | |
def target = sbt.Keys.target | ||
def streams = sbt.Keys.streams | ||
|
||
// file ownership | ||
def appUser = linux.Keys.appUser | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should take the chance and add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, sorting that out now while I'm rearranging which user accounts need creating in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm currently trying to sort things out with the debian policy. The # 5. adjust file and directory permissions
if ! dpkg-statoverride --list $SERVER_HOME >/dev/null
then
chown -R $SERVER_USER:adm $SERVER_HOME
chmod u=rwx,g=rxs,o= $SERVER_HOME
fi There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for appGroup (should be used for %files at rpm build script There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File group name should automatically be used for RPM %files. Did I miss something about the setuid bit? I've used this in the past when you have something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's described here. However I think, even it is considered best-practices, we should not use it. |
||
|
||
//init script parameters | ||
def daemonUser = linux.Keys.daemonUser | ||
def serverLoading = linux.Keys.serverLoading | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ package linux | |
|
||
import Keys._ | ||
import sbt._ | ||
import com.typesafe.sbt.packager.linux.LinuxPlugin.Users | ||
|
||
/** | ||
* Plugin trait containing all the generic values used for | ||
|
@@ -25,7 +26,8 @@ trait LinuxPlugin extends Plugin { | |
} | ||
}, | ||
packageSummary in Linux <<= packageSummary, | ||
packageDescription in Linux <<= packageDescription) | ||
packageDescription in Linux <<= packageDescription, | ||
appUser := Users.Root) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one is gonna be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I had thought that might be a separate pull request due to the number of documentation changes required. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me. |
||
|
||
/** DSL for packaging files into .deb */ | ||
def packageMapping(files: (File, String)*) = LinuxPackageMapping(files) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import NativePackagerKeys._ | ||
import com.typesafe.sbt.packager.archetypes.ServerLoader | ||
|
||
packageArchetype.java_server | ||
|
||
serverLoading in Debian := ServerLoader.Upstart | ||
|
||
appUser in Linux := "daemonUser" | ||
|
||
mainClass in Compile := Some("empty") | ||
|
||
name := "debian-test" | ||
|
||
version := "0.1.0" | ||
|
||
maintainer := "Josh Suereth <[email protected]>" | ||
|
||
packageSummary := "Test debian package" | ||
|
||
packageDescription := """A fun package description of our software, | ||
with multiple lines.""" | ||
|
||
TaskKey[Unit]("check-control-files") <<= (target, streams) map { (target, out) => | ||
val debian = target / "debian-test-0.1.0" / "DEBIAN" | ||
val postinst = IO.read(debian / "postinst") | ||
val postrm = IO.read(debian / "postrm") | ||
assert(postinst contains "addgroup --system daemonUser", "postinst misses addgroup for daemonUser: " + postinst) | ||
assert(postinst contains "useradd --system --no-create-home --gid daemonUser --shell /bin/false daemonUser", "postinst misses useradd for daemonUser: " + postinst) | ||
assert(postinst contains "chown daemonUser:daemonUser /var/log/debian-test", "postinst misses chown daemonUser /var/log/debian-test: " + postinst) | ||
assert(postinst contains "chown daemonUser:daemonUser /usr/share/debian-test/bin/debian-test", "postinst misses chown daemonUser /usr/share/debian-test/bin/debian-test: " + postinst) | ||
assert(postrm contains "deluser --quiet --system daemonUser > /dev/null || true", "postrm misses purging daemonUser user: " + postrm) | ||
assert(postrm contains "delgroup --quiet --system daemonUser > /dev/null || true", "postrm misses purging daemonUser group: " + postrm) | ||
out.log.success("Successfully tested upstart control files") | ||
() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Run the debian packaging. | ||
> debian:package-bin | ||
$ exists target/debian-test-0.1.0.deb | ||
|
||
$ exists target/debian-test-0.1.0/etc | ||
$ exists target/debian-test-0.1.0/etc/init/debian-test.conf | ||
# Check defaults | ||
$ exists target/debian-test-0.1.0/DEBIAN/prerm | ||
$ exists target/debian-test-0.1.0/DEBIAN/postinst | ||
|
||
# Check files for defaults | ||
> check-control-files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be nice to specify group too, and have it default to the user....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1