Merge pull request #121209 from mweinelt/pinnwand
This commit is contained in:
commit
d23610ae65
2 changed files with 56 additions and 23 deletions
|
@ -24,55 +24,80 @@ in
|
|||
Your <filename>pinnwand.toml</filename> as a Nix attribute set. Look up
|
||||
possible options in the <link xlink:href="https://github.com/supakeen/pinnwand/blob/master/pinnwand.toml-example">pinnwand.toml-example</link>.
|
||||
'';
|
||||
default = {
|
||||
# https://github.com/supakeen/pinnwand/blob/master/pinnwand.toml-example
|
||||
database_uri = "sqlite:///var/lib/pinnwand/pinnwand.db";
|
||||
preferred_lexeres = [];
|
||||
paste_size = 262144;
|
||||
paste_help = ''
|
||||
<p>Welcome to pinnwand, this site is a pastebin. It allows you to share code with others. If you write code in the text area below and press the paste button you will be given a link you can share with others so they can view your code as well.</p><p>People with the link can view your pasted code, only you can remove your paste and it expires automatically. Note that anyone could guess the URI to your paste so don't rely on it being private.</p>
|
||||
'';
|
||||
footer = ''
|
||||
View <a href="//github.com/supakeen/pinnwand" target="_BLANK">source code</a>, the <a href="/removal">removal</a> or <a href="/expiry">expiry</a> stories, or read the <a href="/about">about</a> page.
|
||||
'';
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.pinnwand = {
|
||||
description = "Pinnwannd HTTP Server";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
services.pinnwand.settings = {
|
||||
database_uri = mkDefault "sqlite:////var/lib/pinnwand/pinnwand.db";
|
||||
paste_size = mkDefault 262144;
|
||||
paste_help = mkDefault ''
|
||||
<p>Welcome to pinnwand, this site is a pastebin. It allows you to share code with others. If you write code in the text area below and press the paste button you will be given a link you can share with others so they can view your code as well.</p><p>People with the link can view your pasted code, only you can remove your paste and it expires automatically. Note that anyone could guess the URI to your paste so don't rely on it being private.</p>
|
||||
'';
|
||||
footer = mkDefault ''
|
||||
View <a href="//github.com/supakeen/pinnwand" target="_BLANK">source code</a>, the <a href="/removal">removal</a> or <a href="/expiry">expiry</a> stories, or read the <a href="/about">about</a> page.
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.services = let
|
||||
hardeningOptions = {
|
||||
User = "pinnwand";
|
||||
DynamicUser = true;
|
||||
|
||||
unitConfig.Documentation = "https://pinnwand.readthedocs.io/en/latest/";
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.pinnwand}/bin/pinnwand --configuration-path ${configFile} http --port ${toString(cfg.port)}";
|
||||
StateDirectory = "pinnwand";
|
||||
StateDirectoryMode = "0700";
|
||||
|
||||
AmbientCapabilities = [];
|
||||
CapabilityBoundingSet = "";
|
||||
DevicePolicy = "closed";
|
||||
DynamicUser = true;
|
||||
LockPersonality = true;
|
||||
MemoryDenyWriteExecute = true;
|
||||
PrivateDevices = true;
|
||||
PrivateUsers = true;
|
||||
ProcSubset = "pid";
|
||||
ProtectClock = true;
|
||||
ProtectControlGroups = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectHome = true;
|
||||
ProtectHostname = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
|
||||
ProtectProc = "invisible";
|
||||
RestrictAddressFamilies = [
|
||||
"AF_UNIX"
|
||||
"AF_INET"
|
||||
"AF_INET6"
|
||||
];
|
||||
RestrictNamespaces = true;
|
||||
RestrictRealtime = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = "@system-service";
|
||||
UMask = "0077";
|
||||
};
|
||||
|
||||
command = "${pkgs.pinnwand}/bin/pinnwand --configuration-path ${configFile}";
|
||||
in {
|
||||
pinnwand = {
|
||||
description = "Pinnwannd HTTP Server";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
unitConfig.Documentation = "https://pinnwand.readthedocs.io/en/latest/";
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${command} http --port ${toString(cfg.port)}";
|
||||
} // hardeningOptions;
|
||||
};
|
||||
|
||||
pinnwand-reaper = {
|
||||
description = "Pinnwand Reaper";
|
||||
startAt = "daily";
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${command} -vvvv reap"; # verbosity increased to show number of deleted pastes
|
||||
} // hardeningOptions;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ in
|
|||
client.wait_until_succeeds("ping -c1 server")
|
||||
|
||||
# make sure pinnwand is listening
|
||||
server.wait_until_succeeds("ss -lnp | grep ${toString port}")
|
||||
server.wait_for_open_port(${toString port})
|
||||
|
||||
# send the contents of /etc/machine-id
|
||||
response = client.succeed("steck paste /etc/machine-id")
|
||||
|
@ -75,6 +75,12 @@ in
|
|||
if line.startswith("Removal link:"):
|
||||
removal_link = line.split(":", 1)[1]
|
||||
|
||||
|
||||
# start the reaper, it shouldn't do anything meaningful here
|
||||
server.systemctl("start pinnwand-reaper.service")
|
||||
server.wait_until_fails("systemctl is-active -q pinnwand-reaper.service")
|
||||
server.log(server.execute("journalctl -u pinnwand-reaper -e --no-pager")[1])
|
||||
|
||||
# check whether paste matches what we sent
|
||||
client.succeed(f"curl {raw_url} > /tmp/machine-id")
|
||||
client.succeed("diff /tmp/machine-id /etc/machine-id")
|
||||
|
@ -82,5 +88,7 @@ in
|
|||
# remove paste and check that it's not available any more
|
||||
client.succeed(f"curl {removal_link}")
|
||||
client.fail(f"curl --fail {raw_url}")
|
||||
|
||||
server.log(server.succeed("systemd-analyze security pinnwand"))
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue