Bug 55750 - Running `univention-app list` as Administrator throws traceback for `/etc/machine.secret`
Running `univention-app list` as Administrator throws traceback for `/etc/mac...
Status: NEW
Product: UCS
Classification: Unclassified
Component: App Center
UCS 5.0
Other Linux
: P5 minor (vote)
: ---
Assigned To: App Center maintainers
App Center maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2023-02-23 14:02 CET by J Leadbetter
Modified: 2023-02-23 14:02 CET (History)
0 users

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 1: Cosmetic issue or missing function but workaround exists
Who will be affected by this bug?: 5: Will affect all installed domains
How will those affected feel about the bug?: 1: Nuisance – not a big deal but noticeable
User Pain: 0.029
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description J Leadbetter univentionstaff 2023-02-23 14:02:28 CET
## Description

When using the `univention-app` command, running as an Administrator user, I get the following traceback if I run `univention-app list` without sudo:

```
[Errno 13] Keine Berechtigung: '/etc/machine.secret'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/univention/appcenter/actions/__init__.py", line 194, in call_with_namespace
    result = self.main(namespace)
  File "/usr/lib/python3/dist-packages/univention/appcenter/actions/list_apps.py", line 64, in main
    for app, versions, installations in self._list(args.app):
  File "/usr/lib/python3/dist-packages/univention/appcenter/actions/list_apps.py", line 136, in _list
    lo, pos = get_machine_connection()
  File "/usr/lib/python3/dist-packages/univention/appcenter/udm.py", line 144, in get_machine_connection
    return getMachineConnection()
  File "/usr/lib/python3/dist-packages/univention/admin/uldap.py", line 178, in getMachineConnection
    lo = univention.uldap.getMachineConnection(start_tls, decode_ignorelist=decode_ignorelist, ldap_master=ldap_master)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 172, in getMachineConnection
    bindpw = open(secret_file).read().rstrip('\n')
PermissionError: [Errno 13] Keine Berechtigung: '/etc/machine.secret'
Traceback (most recent call last):
  File "/usr/bin/univention-app", line 101, in <module>
    main()
  File "/usr/bin/univention-app", line 88, in main
    ret = action(args)
  File "/usr/lib/python3/dist-packages/univention/appcenter/actions/__init__.py", line 194, in call_with_namespace
    result = self.main(namespace)
  File "/usr/lib/python3/dist-packages/univention/appcenter/actions/list_apps.py", line 64, in main
    for app, versions, installations in self._list(args.app):
  File "/usr/lib/python3/dist-packages/univention/appcenter/actions/list_apps.py", line 136, in _list
    lo, pos = get_machine_connection()
  File "/usr/lib/python3/dist-packages/univention/appcenter/udm.py", line 144, in get_machine_connection
    return getMachineConnection()
  File "/usr/lib/python3/dist-packages/univention/admin/uldap.py", line 178, in getMachineConnection
    lo = univention.uldap.getMachineConnection(start_tls, decode_ignorelist=decode_ignorelist, ldap_master=ldap_master)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 172, in getMachineConnection
    bindpw = open(secret_file).read().rstrip('\n')
PermissionError: [Errno 13] Keine Berechtigung: '/etc/machine.secret'
```

## Expected Behavior

When running a command that does not have the appropriate permissions, it would be useful to get a helpful message (e.g., "Insufficient permissions. Please run this command as root") instead of a traceback. The traceback makes the user believe that something is broken, instead of switching to sudo.

## How to Reproduce

* SSH into a UCS machine as Administrator.
* Run `univention-app list`.
* Traceback appears.

NOTE: the UCS machine has both UCS@school and the Kelvin API installed, if that makes a difference.