rejetto / hfs

HFS is a web file server to run on your computer. Share folders or even a single file thanks to the virtual file system.
GNU General Public License v3.0
2.29k stars 227 forks source link

Running HFS as non-root #712

Closed garro95 closed 2 months ago

garro95 commented 2 months ago

Not sure it's worth mentioning in the installation guide, but I was able to make HFS run as a service on a linux box using a non privileged user.

The process is quite straight-forward and it works on Ubuntu 24.04 LTS:

  1. Create a new non-privileged user for hfs and create a directory to use as hfs' cwd:
    sudo adduser --system hfs
    sudo mkdir /var/lib/hfs
  2. Move HFS deliverable files in system directories:
    sudo mv hfs /usr/local/bin/
    sudo mv plugins/ /var/lib/hfs/plugins
  3. Change the owner of /var/lib/hfs:
    sudo chown hfs:nogroup /var/lib/hfs 
  4. Set capability to hfs executable to open low-numbered ports:
    sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/hfs
  5. Create systemd service unit as follows:
    
    [Unit]
    Description=HFS
    After=network.target

[Service] Type=simple User=hfs Restart=always ExecStart=/usr/local/bin/hfs --cwd /var/lib/hfs

[Install] WantedBy=multi-user.target


Continue as in https://github.com/rejetto/hfs?tab=readme-ov-file#on-linux, point 3.
rejetto commented 2 months ago

hey, thanks for you contribution! i think a good place for this is the wiki, and i think i'll move all the "service" documentation there, and then link the page from the readme. I reported your content at https://github.com/rejetto/hfs/wiki/Service-installation Would you care to make all the changes you see fit?

garro95 commented 2 months ago

Thank you for accepting it. I will propose any further changes in the wiki you linked