Skip to content
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

Allow the upstart job to be executed as a different user #116

Merged
merged 2 commits into from
Dec 31, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ For debian packaging there are a few things generated for you
* A template folder `/var/log/<app-name>`
* A symlink `/installdir/<app-name>/logs` to `/var/log/<app-name` (Installdir is by default `/usr/share`)
* Default `serverLoading` is `Upstart` (you can choose SystemV with `com.typesafe.sbt.packager.archetypes.ServerLoader.SystemV` )
* Default `daemonUser` is _root_ (only relevant for SystemV)
* Default `daemonUser` is _root_
* If you choose different permissions than the default ones for your packages, _add-user_ and _remove-user_ statements will be added to
the `postrm` and `postinst` control files

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ respawn limit ${{retries}} ${{retryTimeout}}
# set the working directory of the job processes
chdir ${{chdir}}

# changes to the user and group before running the job's process
setuid ${{daemon_user}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me (upstart doc). On which system did you test it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only tested with Ubuntu 12.04 LTS (Precise Pangolin)

It doesn't work for Ubuntu 10.04 LTS Lucid as setuid wasn't introduced until version 1.4 of upstart


# Start the process
script
exec ./bin/${{exec}}
end script
end script
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,6 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {

val replacements = Seq("group" -> group, "user" -> user)

val userGroupAdd = Seq(
TemplateWriter.generateScript(DebianPlugin.postinstGroupaddTemplateSource, replacements),
TemplateWriter.generateScript(DebianPlugin.postinstUseraddTemplateSource, replacements)
)

prependAndFixPerms(postinst, userGroupAdd, LinuxFileMetaData())

// remove key, flatten it and then go through each file
pathList.map(_._2).flatten foreach {
case (_, target) =>
Expand All @@ -185,6 +178,13 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
prependAndFixPerms(postinst, chownAdd, LinuxFileMetaData())
}

val userGroupAdd = Seq(
TemplateWriter.generateScript(DebianPlugin.postinstGroupaddTemplateSource, replacements),
TemplateWriter.generateScript(DebianPlugin.postinstUseraddTemplateSource, replacements)
)

prependAndFixPerms(postinst, userGroupAdd, LinuxFileMetaData())

val purgeAdd = Seq(TemplateWriter.generateScript(DebianPlugin.postrmPurgeTemplateSource, replacements))
prependAndFixPerms(postrm, purgeAdd, LinuxFileMetaData())
}
Expand Down