Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
systemd: use LogsDirecoty= to persist data
Browse files Browse the repository at this point in the history
Previously used `StateDirectory=` to persist pinger specific
data across bootups. It turns out that systemd does not allow
sharing state directory across different dynamic users. An example
would be:

```
$ systemd-run --pty --property=DynamicUser=yes --property=StateDirectory=wuff /bin/sh
$ systemd-run --pty --property=DynamicUser=yes --property=StateDirectory=wuff /bin/sh
```

Reference: http://0pointer.net/blog/dynamic-users-with-systemd.html
Signed-off-by: Allen Bai <abai@redhat.com>
  • Loading branch information
Allen Bai committed Nov 26, 2019
1 parent 4387efa commit ecf60b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions dist/systemd/fedora-coreos-pinger.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ After=network-online.target
DynamicUser=yes
Type=oneshot
RemainAfterExit=yes
LogsDirectory=fedora-coreos-pinger
ExecStart=/usr/libexec/fedora-coreos-pinger

[Install]
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn main() -> Fallible<()> {

// spawn thread for monitoring timestamp and sending report daily
let daily_thread = thread::spawn(move || -> Fallible<()> {
const DAILY_TIMESTAMP_FILE: &str = r#"/var/lib/fedora-coreos-pinger/timestamp_daily"#;
const DAILY_TIMESTAMP_FILE: &str = r#"/var/log/fedora-coreos-pinger/timestamp_daily"#;
const SECS_PER_12_HOURS: Duration = Duration::from_secs(12 * 60 * 60);
loop {
let clock = util::Clock::read_timestamp(DAILY_TIMESTAMP_FILE)?;
Expand All @@ -133,7 +133,7 @@ fn main() -> Fallible<()> {
// spawn thread for monitoring timestamp and sending report monthly
let monthly_thread = thread::spawn(move || -> Fallible<()> {
const MONTHLY_TIMESTAMP_FILE: &str =
r#"/var/lib/fedora-coreos-pinger/timestamp_monthly"#;
r#"/var/log/fedora-coreos-pinger/timestamp_monthly"#;
const SECS_PER_15_DAYS: Duration = Duration::from_secs(15 * 24 * 60 * 60);
loop {
let clock = util::Clock::read_timestamp(MONTHLY_TIMESTAMP_FILE)?;
Expand Down

0 comments on commit ecf60b2

Please sign in to comment.