-
Notifications
You must be signed in to change notification settings - Fork 37
feat(debian): Add example broker binary #224
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
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d23144b
examplebroker: Fix installation path for config file
3v1n0 e8ba375
examplebroker: Rename config and interface files to match actual name
3v1n0 3d18c2c
examplebroker: Add standalone example broker implementation
3v1n0 50a09cd
systemd: Add examplebroker service file
3v1n0 3783a16
examplebroker: Add default dbus service config
3v1n0 b3f64c5
debian: Add authd-example-broker package
3v1n0 e03ab22
debian: Move authd debhelper files to authd package namespace
3v1n0 6165cb3
debian/rules: Disable (and mask) the authd-example-broker service by …
3v1n0 ef849e9
debian: Do not install example-broker systemd service or config file
3v1n0 b90d0b2
examplebroker/ExampleBroker: Rename it in examplebroker/ExampleBroker…
3v1n0 d3d6581
debian/authd-example-broker.examples: Add simple broker installer script
3v1n0 10b16e8
debian: do Use ${env:...} syntax for installing with rename
3v1n0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| examplebroker/ExampleBroker.conf | ||
| debian/authd-example-broker.service | ||
| debian/authd-example-broker.installer.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/dh-exec | ||
|
|
||
| usr/bin/examplebroker-bin => ${env:AUTHD_DAEMONS_PATH}/authd-examplebroker | ||
|
|
||
| examplebroker/com.ubuntu.authd.ExampleBroker.conf /usr/share/dbus-1/system.d | ||
| examplebroker/com.ubuntu.authd.ExampleBroker.service /usr/share/dbus-1/system-services | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -eu | ||
|
|
||
| usage() { | ||
| echo "$0 [install | uninstall | help]" | ||
| } | ||
|
|
||
| if [ -z "$0" ]; then | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$(id -u)" != 0 ]; then | ||
| echo "Need to run as root" | ||
| exit | ||
| fi | ||
|
|
||
| SYSTEMD_SERVICE=authd-example-broker.service | ||
| CONFIG_FILE=ExampleBroker.conf | ||
|
|
||
| if [ "$1" = "install" ]; then | ||
| install -m644 \ | ||
| /usr/share/doc/authd-example-broker/examples/"${CONFIG_FILE}" \ | ||
| -Dt /etc/authd/brokers.d | ||
|
|
||
| install -m644 \ | ||
| /usr/share/doc/authd-example-broker/examples/"${SYSTEMD_SERVICE}" \ | ||
| -Dt /usr/lib/systemd/system | ||
|
|
||
| systemctl daemon-reload | ||
| elif [ "$1" = "uninstall" ]; then | ||
| rm -fv /etc/authd/brokers.d/"${CONFIG_FILE}" | ||
| rmdir -v /etc/authd/brokers.d 2>/dev/null || true | ||
| rm -fv /usr/lib/systemd/system/"${SYSTEMD_SERVICE}" | ||
|
|
||
| systemctl daemon-reload | ||
| elif [ "$1" = "help" ]; then | ||
| usage | ||
| exit 0 | ||
| else | ||
| echo "unknown command '$1'" | ||
| usage | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [Unit] | ||
| Description=Authd Example Broker | ||
| After=authd.service | ||
| Requires=authd.service | ||
|
|
||
| [Service] | ||
| Type=dbus | ||
| BusName=com.ubuntu.authd.ExampleBroker | ||
| ExecStart=@AUTHD_DAEMONS_PATH@/authd-examplebroker | ||
| Restart=on-failure | ||
|
|
||
| # Some daemon restrictions | ||
| ProtectSystem=strict | ||
| ProtectControlGroups=true | ||
| ProtectHome=true | ||
| ProtectKernelModules=true | ||
| PrivateTmp=true | ||
| RestrictAddressFamilies=AF_UNIX AF_LOCAL AF_NETLINK | ||
| MemoryDenyWriteExecute=true | ||
| RestrictRealtime=true |
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [D-BUS Service] | ||
| Name=com.ubuntu.authd.ExampleBroker | ||
| Exec=/bin/false | ||
| User=root | ||
| SystemdService=authd-example-broker.service |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| //go:build with_standalone_examplebroker | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "log" | ||
| "os" | ||
|
|
||
| "github.com/ubuntu/authd/examplebroker" | ||
| ) | ||
|
|
||
| func main() { | ||
| // Create the directory for the broker configuration files. | ||
| cfgPath, err := os.MkdirTemp(os.TempDir(), "standalonebroker.d") | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| defer os.RemoveAll(cfgPath) | ||
|
|
||
| conn, err := examplebroker.StartBus(cfgPath) | ||
| if err != nil { | ||
| log.Fatal("Error starting standalone broker:", err) | ||
| } | ||
| defer conn.Close() | ||
|
|
||
| <-context.Background().Done() | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this is still not what we want. IMHO, the examplebroker should be an executable that, when executed, exports the broker on
dbusand cleans it up when the program finishes running. This way, we don't need to worry about having to install/uninstall it. Its purpose is to testauthd, not the broker behaviour, so we don't need anything directly configured ondbus(asauthddoes not directly care about it).Uh oh!
There was an error while loading. Please reload this page.
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.
I see the point, but that wouldn't allow proper testing, especially if we want to do proper autopkgtests were you just install everything and then you run a client that would work as the system would be configured properly.
In fact
authddoes care about it, because if that would happen when we run the daemon, then we wouldn't be able of testing the case that authd does dbus-activation of the service when that you select the broker on the brokers list.Also, not having a script like this would imply that we rely on the autopkgtest script to do that, but IMHO it's not nice to maintain the same in two different places.
What we may want to do, in case, is to make the examplebrorker to do the conf setup in case that's not set, and I can do that, but I feel we should still provide a way to create what would be the real setup in a properly configured machine.
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.
Ah, also having those files installed doesn't allow anything but just having the service to own the name, and while these may be handled by the service itself, as I said, I'd prefer to be able to do dbus-activation (but only through systemd that it's not installed by default).