Skip to content

Commit

Permalink
Merge pull request #11 from NethServer/rootless
Browse files Browse the repository at this point in the history
Rootless implementation
  • Loading branch information
gsanchietti authored Sep 27, 2023
2 parents abec562 + 6a79a1e commit d307d62
Show file tree
Hide file tree
Showing 27 changed files with 234 additions and 375 deletions.
3 changes: 1 addition & 2 deletions build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ buildah add "${container}" imageroot /imageroot
buildah add "${container}" ui/dist /ui
# Setup the entrypoint, ask to reserve one TCP port with the label and set a rootless container
buildah config --entrypoint=/ \
--label="org.nethserver.authorizations=traefik@any:routeadm node:fwadm" \
--label="org.nethserver.authorizations=traefik@any:routeadm node:tunadm" \
--label="org.nethserver.tcp-ports-demand=5" \
--label="org.nethserver.rootfull=1" \
--label="org.nethserver.images=ghcr.io/nethserver/nethsecurity-vpn:$tag ghcr.io/nethserver/nethsecurity-api:$tag ghcr.io/nethserver/nethsecurity-ui:$tag ghcr.io/nethserver/nethsecurity-proxy:$tag docker.io/grafana/promtail:2.7.1" \
"${container}"
# Commit the image
Expand Down
22 changes: 5 additions & 17 deletions imageroot/actions/configure-module/20configure
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
#!/usr/bin/env python3

#
# Copyright (C) 2022 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

import json
Expand Down Expand Up @@ -95,3 +80,6 @@ rules = [
]
ports = [f"{ports[4]}/tcp"] # promtail port
agent.add_custom_zone(tun, tun, ports, rules)

network = agent.read_envfile('network.env')
agent.add_tun(network.get('OVPN_TUN'), f'{server_address}/{bits}')
23 changes: 4 additions & 19 deletions imageroot/actions/configure-module/80start_services
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
#!/bin/bash

#
# Copyright (C) 2022 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

# If the control reaches this step, the service can be enabled and started

systemctl enable ${MODULE_ID}.service
systemctl restart ${MODULE_ID}.service
systemctl --user enable controller.service
systemctl --user restart controller.service
21 changes: 3 additions & 18 deletions imageroot/actions/create-module/20initialize
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
#!/bin/bash

#
# Copyright (C) 2022 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

exec 1>&2 # Send any output to stderr, to not alter the action response protocol
Expand All @@ -34,7 +19,7 @@ secret=$(uuidgen | sha256sum | awk '{print $1}')

cat << EOF > network.env
OVPN_UDP_PORT=$ovpn_udp_port
OVPN_TUN=nsc$num
OVPN_TUN=tunnsc$num
API_PORT=$api_port
API_BIND_IP=127.0.0.1
LISTEN_ADDRESS=127.0.0.1:$api_port
Expand Down
32 changes: 0 additions & 32 deletions imageroot/actions/create-module/30systemd

This file was deleted.

19 changes: 2 additions & 17 deletions imageroot/actions/create-module/40firewall
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
#!/usr/bin/env python3

#
# Copyright (C) 2022 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

import os
Expand Down
19 changes: 2 additions & 17 deletions imageroot/actions/destroy-module/20destroy
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
#!/usr/bin/env python3

#
# Copyright (C) 2021 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

# Remove traefik route
Expand Down
19 changes: 2 additions & 17 deletions imageroot/actions/destroy-module/40firewall
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
#!/usr/bin/env python3

#
# Copyright (C) 2022 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

import os
Expand Down
29 changes: 5 additions & 24 deletions imageroot/actions/destroy-module/50systemd
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
#!/bin/bash -x
#!/bin/bash

#
# Copyright (C) 2022 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

exec 1>&2 # Send any output to stderr, to not alter the action response protocol

#
# We must stop and clean up what we installed in the "create-module" action
#
systemctl disable --now "${MODULE_ID}.service"
rm -vf /etc/systemd/system/${MODULE_ID}-*.service
systemctl daemon-reload
# Stop the controller to free the tun device
systemctl --user disable --now controller.service
12 changes: 12 additions & 0 deletions imageroot/actions/destroy-module/60tun
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3

#
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

import os
import agent

network = agent.read_envfile('network.env')
agent.remove_tun(network.get('OVPN_TUN'))
19 changes: 2 additions & 17 deletions imageroot/actions/get-configuration/20read
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
#!/usr/bin/env python3

#
# Copyright (C) 2022 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

import json
Expand Down
33 changes: 0 additions & 33 deletions imageroot/systemd/controller-api.service

This file was deleted.

7 changes: 0 additions & 7 deletions imageroot/systemd/controller-metrics-exporter.path

This file was deleted.

9 changes: 0 additions & 9 deletions imageroot/systemd/controller-metrics-exporter.service

This file was deleted.

30 changes: 0 additions & 30 deletions imageroot/systemd/controller-promtail.service

This file was deleted.

Loading

0 comments on commit d307d62

Please sign in to comment.