Page MenuHomeVyOS Platform

`show ntp sources` Command Broken
Open, NormalPublicBUG

Description

It looks like privileges are not allowing the show ntp sources command to work on 1.4:

vyos@cr01-vyos:~$ show ntp sources
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/ntp.py", line 159, in <module>
    res = vyos.opmode.run(sys.modules[__name__])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/opmode.py", line 263, in run
    res = func(**args)
          ^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/ntp.py", line 133, in show_sources
    return cmd(command)
           ^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/utils/process.py", line 155, in cmd
    raise OSError(code, feedback)
PermissionError: [Errno 1] failed to run command: chronyc sources -v
returned: 506 Cannot talk to daemon
exit code: 1

Running the command as sudo fixes the issue, so I'm guessing the command underneath needs to be run either as root, or as _chrony:

vyos@cr01-vyos:~$ sudo chronyc sources -v

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* ns02.ac.trae32566.org         2   6   377    12   +591us[ +812us] +/-   27ms
^- ns01.ac.trae32566.org         2   6   377    11   +320us[ +320us] +/-   38ms

Details

Difficulty level
Easy (less than an hour)
Version
1.4.0
Why the issue appeared?
Implementation mistake
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Event Timeline

c-po triaged this task as Normal priority.
c-po changed Difficulty level from Unknown (require assessment) to Easy (less than an hour).
c-po changed Why the issue appeared? from Will be filled on close to Implementation mistake.
c-po edited projects, added VyOS 1.4 Sagitta (1.4.1), VyOS 1.5 Circinus, Restricted Project; removed VyOS 1.4 Sagitta (1.4.0).

I can not immediately recreate the issue:

vyos@vyos:~$ show ver
Version:          VyOS 1.4.0
Release train:    sagitta
Release flavor:   generic

Built by:         Sentrium S.L.
Built on:         Tue 04 Jun 2024 09:23 UTC
vyos@vyos:~$ show ntp sources
.-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^- server3.njk.aero              2  10   377   35m   -344us[ -302us] +/-   40ms
^* server1b.meinberg.de          2  10   377   266   +133us[ +201us] +/-   10ms

But we should try to avoid a backtrace in any case and use a proper error message