1

I am encountering an issue on my Raspberry Pi when trying to use the timedatectl command. When I execute timedatectl status I get the following error message:

spaikon@raspberrypi:~ $ timedatectl status
Failed to query server: Transport endpoint is not connected
spaikon@raspberrypi:~ $ sudo timedatectl status
Failed to query server: The name org.freedesktop.timedate1 was not provided by any .service files

 $ sudo timedatectl show
Failed to parse bus message: No route to host

 $ sudo systemctl status systemd-timedated.service
● systemd-timedated.service - Time & Date Service
     Loaded: loaded (/lib/systemd/system/systemd-timedated.service; static)
     Active: inactive (dead)
       Docs: man:systemd-timedated.service(8)
             man:localtime(5)
             man:org.freedesktop.timedate1(5)

I've tried to find a solution online, but haven't had any luck so far. I'm not sure what these errors mean or how to resolve them. Has anyone else encountered this issue and found a solution?

Any help would be greatly appreciated.

Thank you in advance!

Edit:

 $ sudo systemctl status systemd-timedated.service
● systemd-timedated.service - Time & Date Service
     Loaded: loaded (/lib/systemd/system/systemd-timedated.service; static)
     Active: inactive (dead)
       Docs: man:systemd-timedated.service(8)
             man:localtime(5)
             man:org.freedesktop.timedate1(5)

$ sudo timedatectl
Failed to query server: The name org.freedesktop.timedate1 was not provided by any .service files

$ dlocate -S systemd-timedated.service
systemd: /lib/systemd/system/systemd-timedated.service
systemd: /usr/share/man/man8/systemd-timedated.service.8.gz

Edit 2: Resonse from systemd-timedate Resoponse from

 $ journalctl -fu  systemd-timedated.service
-- Journal begins at Thu 2023-06-08 20:47:15 EEST. --
Jun 09 12:07:52 raspberrypi systemd[1]: Starting Time & Date Service...
Jun 09 12:07:52 raspberrypi systemd-timedated[46085]: /lib/systemd/systemd-timedated: error while loading shared libraries: li                          bsystemd-shared-247.so: cannot open shared object file: Permission denied
Jun 09 12:07:52 raspberrypi systemd[1]: systemd-timedated.service: Main process exited, code=exited, status=127/n/a
Jun 09 12:07:52 raspberrypi systemd[1]: systemd-timedated.service: Failed with result 'exit-code'.
Jun 09 12:07:52 raspberrypi systemd[1]: Failed to start Time & Date Service.

Edit 3:

$ namei -mov /lib/systemd/libsystemd-shared-247.so
f: /lib/systemd/libsystemd-shared-247.so
drwx------ spaikon spaikon /
lrwxrwxrwx root    root    lib -> usr/lib
drwxr-xr-x root    root      usr
drwxr-xr-x root    root      lib
drwxr-xr-x root    root    systemd
-rw-r--r-- root    root    libsystemd-shared-247.so

1 Answer 1

1

org.freedesktop.timedate1 is a D-Bus name that appears in the definition of the systemd-timedated.service.

systemctl cat systemd-timedated.service | grep org.freedesktop.timedate1

Documentation=man:org.freedesktop.timedate1(5)
BusName=org.freedesktop.timedate1

systemd-timedated.service is supposed to be started by systemd only when something calls for it on the system D-Bus. And that is exactly what the timedatectl command does:

root@raspiw2:/home/pi# systemctl status systemd-timedated.service
● systemd-timedated.service - Time & Date Service
     Loaded: loaded (/lib/systemd/system/systemd-timedated.service; static)
     Active: inactive (dead)
       Docs: man:systemd-timedated.service(8)
             man:localtime(5)
             man:org.freedesktop.timedate1(5)

root@raspiw2:/home/pi# timedatectl
               Local time: Fri 2023-06-09 17:57:26 EEST
           Universal time: Fri 2023-06-09 14:57:26 UTC
                 RTC time: n/a
                Time zone: Europe/Helsinki (EEST, +0300)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

root@raspiw2:/home/pi# systemctl status systemd-timedated.service
● systemd-timedated.service - Time & Date Service
     Loaded: loaded (/lib/systemd/system/systemd-timedated.service; static)
     Active: active (running) since Fri 2023-06-09 17:57:26 EEST; 5s ago
       Docs: man:systemd-timedated.service(8)
             man:localtime(5)
             man:org.freedesktop.timedate1(5)
   Main PID: 1284 (systemd-timedat)
      Tasks: 1 (limit: 2057)
        CPU: 328ms
     CGroup: /system.slice/systemd-timedated.service
             └─1284 /lib/systemd/systemd-timedated

Jun 09 17:57:26 raspiw2 systemd[1]: Starting Time & Date Service...
Jun 09 17:57:26 raspiw2 systemd[1]: Started Time & Date Service.

systemd-timedated.service is part of the main systemd package, so the error messages would suggest the service definition has been changed or removed. Have you perhaps set the service as masked, or maybe even deleted it altogether?

dlocate -S systemd-timedated.service
systemd: /lib/systemd/system/systemd-timedated.service
systemd: /usr/share/man/man8/systemd-timedated.service.8.gz

The output from journalctl -fu systemd-timedated.service indicates a permission issue with a system library (split to multiple lines for clarity):

Jun 09 12:07:52 raspberrypi systemd-timedated[46085]: /lib/systemd/systemd-timedated: 
error while loading shared libraries: 
libsystemd-shared-247.so: cannot open shared object file: 
Permission denied

This library should be at /lib/systemd/libsystemd-shared-247.so.

You can list the permissions of that file and all the parent directories at once with namei -mov /lib/systemd/libsystemd-shared-247.so. The output should be:

f: /lib/systemd/libsystemd-shared-247.so
drwxr-xr-x root root /
drwxr-xr-x root root lib
drwxr-xr-x root root systemd
-rw-r--r-- root root libsystemd-shared-247.so

If the read permissions of the file or the read and access (r-x) permissions of any of the parent directories are lost, use chmod to restore them.


$ namei -mov /lib/systemd/libsystemd-shared-247.so
f: /lib/systemd/libsystemd-shared-247.so
drwx------ spaikon spaikon /
[...]

The other permissions seem correct, but it looks like the ownership of the root directory has been accidentally set to "spaikon" and permissions to that user only. That is clearly not correct.

Since the systemd-timedated.service definition includes a number of security restrictions, even though the service runs as root, it will not have access to the full set of root privileges. The most relevant restriction here is CapabilityBoundingSet=CAP_SYS_TIME: it excludes CAP_DAC_OVERRIDE, which is the capability that gives root its power to ignore file and directory permission checks. Without it, the systemd child process that is responsible for starting /lib/systemd/systemd-timedated must respect file and directory permissions even if it's technically running as the root user.

To fix the permissions, run the following two commands, in this order:

sudo chmod go+rx /
sudo chown root:root /
5
  • "I believe I initially had that service masked. I attempted to unmask it using the systemctl unmask command, but it seems to have deleted the service instead. Could you guide me on how to rectify this?"
    – Nir Vana
    Jun 11 at 17:33
  • Depending on the distribution, the service file should be in either /lib/systemd/system/ or /usr/lib/systemd/system/. If it is actually missing, run apt reinstall systemd to ensure all the files of the systemd package are present and intact. If that does not help, run systemctl cat systemd-timedated.service to view the full service definition: does it include the BusName= line described in my answer above?
    – telcoM
    Jun 11 at 20:09
  • Oh there actually is /lib/systemd/system/systemd-timedated.service with BusName=org.freedesktop.timedate1 I also added response message
    – Nir Vana
    Jun 12 at 6:15
  • added permissions, there are seem to be similar
    – Nir Vana
    Jun 12 at 9:01
  • Much appreciated.
    – Nir Vana
    Jun 12 at 11:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .