archlinux / contrib

Arch contrib scripts
GNU General Public License v2.0
64 stars 19 forks source link

checkservices: Unable to parse pid file for getty@tty1.service #44

Closed cloudlena closed 3 months ago

cloudlena commented 3 years ago

When running checkservices, I am getting the following error:

$ sudo checkservices
:: Run pacdiff
:: Reload systemd
:: Services with broken maps files
Error:: Unable to parse pid file for getty@tty1.service.
Found: 0
:: Services missing on the system bus
Found: 0
:: List failed units

Am I doing something wrong? This seems like a common service to have.

lahwaacz commented 3 years ago

checkservices started as a script for headless servers where people log in only via SSH. In case you log in via a graphical display manager, checkservices might detect that it needs to be restarted, which would terminate the entire session. Same for polkit.service, systemd-logind.service and maybe others (IIRC). The missing PID file for getty@tty1.service just coincidentally avoids this.

cloudlena commented 3 years ago

@lahwaacz, thanks a lot for the clarification! Is there any sensible way to deal with this? I'm running Arch with Sway.

aminvakil commented 3 years ago

What do you think about asking for confirmation (Are you sure?) if it wants to run on a graphical arch?

I can create a PR for this.

Foxboron commented 3 years ago

I'd rather we have a list of ignored services and add things like getty@tty.service to it.

lahwaacz commented 3 years ago

What do you think about asking for confirmation (Are you sure?) if it wants to run on a graphical arch?

checkservices already asks for confirmation before restarting services, but all services are grouped and restarted together...

aminvakil commented 3 years ago

I'd rather we have a list of ignored services and add things like getty@tty.service to it.

I'm not sure, aren't there other services which may break by restarting in a desktop environment?

What do you think about asking for confirmation (Are you sure?) if it wants to run on a graphical arch?

checkservices already asks for confirmation before restarting services, but all services are grouped and restarted together...

I was thinking of check the output of systemctl get-default and warn again if it's graphical.target.

lahwaacz commented 3 years ago

I was thinking of check the output of systemctl get-default and warn again if it's graphical.target.

You can have an active session, graphical or not, even with plain multi-user.target.

Foxboron commented 3 years ago

We are straying a bit from the issue. Keeping track of pid-less services is the goal, and this should be fairly simple to have as a filtered list in the code and omit them from the get_services code.

@aminvakil did you want to try implement this?

aminvakil commented 3 years ago

Does checking if systemctl show --property MainPID --value ${service} returns 0 or not suitable?

Foxboron commented 3 years ago

I don't think so?

λ ~ » systemctl show getty@tty1.service | grep PID
GuessMainPID=yes
MainPID=404
ControlPID=0
ExecMainPID=404
λ ~ » systemctl show bolt.service | grep PID
GuessMainPID=yes
MainPID=1406
ControlPID=0
ExecMainPID=1406
aminvakil commented 3 years ago
$ sudo systemctl show getty@tty1.service | grep PID
GuessMainPID=yes
MainPID=0
ControlPID=0
ExecMainPID=0
$ sudo systemctl show bolt.service | grep PID
GuessMainPID=yes
MainPID=0
ControlPID=0
ExecMainPID=0

Can this maybe somehow be related to linux-hardened?

cloudlena commented 3 years ago

If it helps, I'm not using linux-hardened, just bare bones linux.

aminvakil commented 3 years ago

If it helps, I'm not using linux-hardened, just bare bones linux.

Honestly I really don't think so, this is just a wild guess, and I meant returning 0 for MainPID when linux-hardened is used.

lahwaacz commented 3 years ago

@aminvakil Obviously, if you don't have getty@tty1.service active, systemctl shows its MainPID as 0.

aminvakil commented 3 years ago

@lahwaacz Sorry for late response, yes, it was not active.