mirror of
https://github.com/go-shiori/shiori.git
synced 2026-04-25 14:35:52 +03:00
[GH-ISSUE #286] better systemd service file #208
Labels
No labels
component:backend
component:builds
component:builds
component:extension
component:frontend
component:readability
database
database:mysql
database:postgres
database:sqlite
feature:ebooks
github_actions
good first issue
hacktoberfest
note:duplicate?
note:fixed?
note:out-of-scope?
os:windows
priority:high
priority:low
pull-request
resolution:as-intended
resolution:cant-reproduce
resolution:duplicate
resolution:fixed
resolution:wontfix
tag:TBD
tag:big-task
tag:help-wanted
tag:huge-data
tag:meta
tag:more-info
tag:next
tag:no-stale
tag:requires-migrations
tag:research
tag:security 🛡️
tag:stale
tag:waiting-for-assignee
type:bug
type:documentation
type:enhancement
type:meta
type:ux
user:cli
user:web
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shiori#208
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @beac0n on GitHub (Dec 31, 2020).
Original GitHub issue: https://github.com/go-shiori/shiori/issues/286
I've created my own systemd service file with the following security settings in the [service] section:
I'm using the binary directly (so no docker).
I am also not using --portable (not on purpose, just forgot to add it).
I think when using --portable,
ProtectHome=truecan be added as well.I did not found a .service file in the code, just a snippet in the wiki.
I created this issue, because I didn't want to add any changes in the wiki without prior discussion.
@minijackson commented on GitHub (Jan 2, 2021):
Hello! I maintain the shiori service over at NixOS, and I also wanted to upstream a "hardened" version of the systemd service.
Here is what I've got, without the NixOS specific options:
shiori.service
In the nixos module, shiori actually runs under a chroot (using
RootDirectory), and bind mounts the necessary directories, but since I can't really assume the directory structure of other distributions, I removed it here.All in all, it is quite close to what you proposed. Two main differences that I see:
DynamicUser,StateDirectory, and the$SHIORI_DIR. With this, systemd can setProtectSystem=strict, and shiori can only write inside/var/lib/shiori, without having to use the--portableoption.I'd be quite happy to have an upstream systemd file with security options to follow, even if just to have multiple people testing that it works without issue, and keeping up to date with the systemd options.
@beac0n commented on GitHub (Jan 2, 2021):
Didn't know about the SHIORI_DIR env var. I will try to merge your suggestion with mine and post the updated service file 👍
@beac0n commented on GitHub (Jan 3, 2021):
shiori.service
The paragraph between
Group=shioriandCapabilityBoundingSet=CAP_NET_BIND_SERVICEare the settings, not included in my service file, but included in the service file provided by @minijacksonI tested it on my instance with arch linux, and it works great.
I also tested if adding a new bookmark and creating an archive works 👍
Result of
→ Overall exposure level for shiori.service: 1.2 OK 🙂
Which is pretty good :-)
Edit: @minijackson your
CapabilityBoundingSet=is empty. May I ask why? Does the service start with no capabilities? Afaik shiori starts a web service on some port. Therefore it needsCAP_NET_BIND_SERVICE?Edit 2:
We could also add
if shiori is behind a reverse proxy like nginx.
This does not seem to work. I get the following error when creating a bookmark:
failed to save bookmark: title must not be empty (500)@minijackson commented on GitHub (Jan 10, 2021):
So from
man 7 capabilities: "Bind a socket to Internet domain privileged ports (port numbers less than 1024).". Since on my server (and I believe most servers but I could be wrong), it uses the 8080 port, it does not need the capability.I'm not sure we can add
IPAddressDeny=any, doesn't shiori need to access the global network to fetch articles? I could have misunderstood the option, though. Have you tested this?@beac0n commented on GitHub (Jan 10, 2021):
Yes. Doesn't work, as stated in my last post:
@minijackson commented on GitHub (Jan 10, 2021):
Oh sorry I missed that part...
@beac0n commented on GitHub (Jan 11, 2021):
Final version:
shiori.service
What's the best way to solve this issue? Where do I have to put the service file? Just add it to the wiki?
@axelsimon commented on GitHub (Mar 5, 2021):
You could just edit the wiki to modify the suggested systemd unit file, but really, this is something that should be part of the repo itself. You could try to create a Pull Request and hopefully it will get merged!
@beac0n commented on GitHub (Mar 19, 2021):
I put it in the wiki as @axelsimon suggested.