tobychui / arozos

Web Desktop Operating System for low power platforms, Now written in Go!
https://os.aroz.org
GNU General Public License v3.0
2.01k stars 145 forks source link

Run as root - disable "sudo" #148

Closed radim-ek closed 10 months ago

radim-ek commented 10 months ago

If user is root you don't neet a "sudo". And sometimes sudo is not installed.

Issue: https://github.com/tobychui/arozos/issues/130

tobychui commented 10 months ago

Cool! You mind updating the uninstaller script as well? That way I can test deploy both of them in VM and merge the changes in one PR. Thanks so much for the contribution!

radim-ek commented 10 months ago

I made uninstaller too, now. But dont know how to add to this Pull request. So there: https://github.com/tobychui/arozos/pull/149

tobychui commented 10 months ago

Your script works fine until the section where systemd service is installed. I encounter the following error when testing your modified script in VM (VirtualBox on Windows, Guest OS: Debian 11 amd64 )

Arozos launcher has been installed successfully!
Enter setup name (default: aroz):
Enter preferred listening port (default: 8080):
Setup name: aroz
Preferred listening port: 8080
start.sh created successfully!
Do you want to install ArozOS to systemd service? (y/n)y

Job for arozos.service failed because the control process exited with error code                                   .
See "systemctl status arozos.service" and "journalctl -xe" for details.
ArozOS installation completed!
Please continue the system setup at http://192.168.1.153:8080/
root@debian:~#
root@debian:~# ^C
root@debian:~# systemctl status arozos.service
● arozos.service - ArozOS Cloud Service
     Loaded: loaded (/etc/systemd/system/arozos.service; enabled; vendor preset>
     Active: activating (auto-restart) (Result: exit-code) since Sat 2024-01-27>
    Process: 817 ExecStartPre=/bin/sleep 10 (code=exited, status=200/CHDIR)
        CPU: 613us
lines 1-5/5 (END)...skipping...
● arozos.service - ArozOS Cloud Service
     Loaded: loaded (/etc/systemd/system/arozos.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2024-01-27 20:19:20 CST; 6s ago
    Process: 817 ExecStartPre=/bin/sleep 10 (code=exited, status=200/CHDIR)
        CPU: 613us
~

The systemd service file is as follows.

[Unit]
Description=ArozOS Cloud Service
After=systemd-networkd-wait-online.service
Wants=systemd-networkd-wait-online.service

[Service]
Type=simple
ExecStartPre=/bin/sleep 10
WorkingDirectory=/home/root/arozos/
ExecStart=/bin/bash /home/root/arozos/start.sh

Restart=always
RestartSec=10

Can you try figure out what might be the issue?

radim-ek commented 10 months ago

I found a problem and change installer file. Now you can try it :)

tobychui commented 10 months ago

@radim-ek I found another problem with your script.

root@debian:~/arozos# echo $HOMEDIR
/home/aroz

It seems the HOMEDIR you assigned do not nessarily means the root's home dir. Let say I login via a non-root user account (in my test environment it is "aroz"), and use su to elevate the current user to root. In the systemd service file, the following path was written.

[Service]
Type=simple
ExecStartPre=/bin/sleep 10
WorkingDirectory=/home/aroz/arozos/
ExecStart=/bin/bash /home/aroz/arozos/start.sh

I guess you might need to fix this first before I can merge this PR. Thanks!

radim-ek commented 10 months ago

``So, because you are still aroz and your HOME directory is /home/aroz and installed dir is same /home/aroz/arozos I think that all is OK. But I dont understand how is your "homedir" other than root. Maby because root has set home directory to "aroz"? This is my environment. I use "su - root" to elevate (https://i.imgur.com/ACEO6Wu.png) After install by elevate account root:

root@debian11:~# cat /etc/systemd/system/arozos.service 
[Unit]
Description=ArozOS Cloud Service
After=systemd-networkd-wait-online.service
Wants=systemd-networkd-wait-online.service

[Service]
Type=simple
ExecStartPre=/bin/sleep 10
WorkingDirectory=/root/arozos/
ExecStart=/bin/bash /root/arozos/start.sh
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
root@debian11:/home# pwd
/home
root@debian11:/home# cd $HOMEDIR
root@debian11:~# pwd
/root
root@debian11:~# 
logout
roott@debian11:~$ pwd
/home/roott
roott@debian11:~$ cd /home
roott@debian11:/home$ pwd
/home
roott@debian11:/home$ cd $HOMEDIR
roott@debian11:~$ pwd
/home/roott
roott@debian11:~$ 
tobychui commented 10 months ago

Interesting, maybe it is my test environment setup issue. @yeungalan you got time to test this out?