-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
cjdns: Improving systemd unit description #20177
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
Conversation
@spacekitteh, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ehmry, @joachifm and @edolstra to be potential reviewers. |
Why is the bindsTo needed? |
Because it requires networking to be up before it can create a connection. If you have a slow-starting network connection, then cjdns will fail if it's started too soon after starting networking. If networking goes down, then having cjdns running is pointless; I'm also not sure if it can even re-establish a connection after losing the network yet. It's also a security thing - if networking goes down and cjdns doesn't properly reauthenticate peers when it's re-established, an attacker could perform a MITM. |
|
Depending on |
Yeah, I changed it to that. It still seems to have issues. Apparently network-online.target comes up before the connection is properly established (for my hardware), so the service tries rebooting (too quickly) and hits the start up rate limit. But due to having a "Restart=" option set, combined with rate limiting being different from the default, it doesn't attempt any further restarts. Then the same thing happens with the cjdns-resume.service. I can't figure this out - I don't understand why rate limiting combined with restart means don't restart after being rate limited! |
I guess I could just disable start rate limiting. I'll give that a try. |
Well, it works now. \o/ I squashed the commits. |
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.
LGTM
I haven't tested but the submitter says that it works for them, so that works for me.
@groxxda what do you think of the current state? |
I don't use cjdns so I cannot say anything about the issues @spacekitteh experienced. I don't know why ordering after network-online does not work, that may be a bug in the networking module. Of course I'd favor fixing the real issue and not working around it in clients with unlimited restarts, but that's just my opinion. |
Is it good to merge? |
Note my comment about systemd unit descriptions. |
@edolstra Where? |
${config.systemd.package}/bin/systemctl systemctl reset-failed cjdns.service | ||
${config.systemd.package}/bin/systemctl restart cjdns.service | ||
"; | ||
postStop = "${config.systemd.package}/bin/systemctl systemctl reset-failed cjdns-restart.service"; |
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.
systemctl systemctl
should have no effect in:
${config.systemd.package}/bin/systemctl systemctl reset-failed cjdns-restart.service
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 also think reset-failed
is not needed: StartLimitInterval = 0
in the other unit already does the job - so it will restart on its own eventually when it crashed. I first thought why the hack restart
is needed at all for cjdns but apparently this is compliant with upstream:
https://github.com/cjdelisle/cjdns/blob/master/contrib/systemd/cjdns-resume.service
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.
Whoops, I forgot to remove that line
|
||
script = | ||
" | ||
${config.systemd.package}/bin/systemctl systemctl reset-failed cjdns.service |
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.
same as below
@@ -241,10 +258,13 @@ in | |||
| ${pkg}/bin/cjdroute | |||
'' | |||
); | |||
|
|||
|
|||
onFailure = ["cjdns-restart.service"]; |
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.
Why is that needed?
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.
Becuase cjdns requires the network to actually be online.
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.
From understanding this is the job of Restart = "always";
, which does the same, right?
I don't think an attacker can perform an MITM: cjdns does end-to-end authentication based on addresses. |
@cjdelisle is it possible to implement a signal handler for SIGUSR2 to reconnect to its peers? That would make the cjdns-restart.service cleaner IMHO. |
after = ["sleep.target" "network-online.target"]; | ||
|
||
script = | ||
" |
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.
Looks like this should either be a single-line string, or use
script = ''
double single quotes
'';
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.
After rethinking I just deleted the -restart service altogether.
whitespace
Merged in 016fa06, thank you for your effort and time on this :) |
\o/ |
Motivation for this change
Makes cjdns actually require networking.