Tomas-M / linux-live

Linux Live Kit
http://www.linux-live.org/
1.01k stars 253 forks source link

ssh.service: set correct file access #180

Closed lars18th closed 3 years ago

lars18th commented 3 years ago

When the SSH key files comes from rootcopy dir the file access are incorrect. So it will be desirable to set the correct file access level (based on defaults) before starting the SSH service. Without this patch it's impossible to add some user custom keys to the rootcopy from a readonly storage (for example an ISO image). This fixes the problem.

lars18th commented 3 years ago

Hi @Tomas-M ,

Based on https://groups.google.com/g/slax-users/c/mlWYX6SwZ3E

Tomas-M commented 3 years ago

I would prefer to do this part differently - in the preinit part, to make it more universal, because there may be many more files which will need to set their permissions differently from rootcopy.

lars18th commented 3 years ago

I would prefer to do this part differently - in the preinit part, to make it more universal, because there may be many more files which will need to set their permissions differently from rootcopy.

OK. I think you're right and this will be preferable. 👍 I hope you'll include this solution soon.

Regards.

lars18th commented 2 years ago

Hi @Tomas-M ,

I would prefer to do this part differently - in the preinit part, to make it more universal, because there may be many more files which will need to set their permissions differently from rootcopy.

You forget to fix this?

Tomas-M commented 2 years ago

In order to set permissions for files in rootcopy directory, user should provide /slax/rootcopy/run/preinit.sh script, a newly added feature, will be in Slax since version 11.2.2 or 11.3.0 (not released yet), introduced by https://github.com/Tomas-M/linux-live/commit/d1292e97e6c73a93a5ddfb7d6affc6ffe6e95efa This preinit script is called before init starts. It can contain something like this:

    #!/bin/sh
    # $1 is the union directory, before root is switched
    chmod 600 $1/etc/ssh/ssh_host_*_key
    chmod 644 $1/etc/ssh/ssh_host_*_key.pub