Bug 57280 - UDM-REST leaves behind (temporary) directory and sockets /tmp/pymp-*/listener-*
Summary: UDM-REST leaves behind (temporary) directory and sockets /tmp/pymp-*/listener-*
Status: NEW
Alias: None
Product: UCS
Classification: Unclassified
Component: UDM - REST API
Version: UCS 5.0
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: UMC maintainers
QA Contact: UMC maintainers
URL:
Keywords:
Depends on: 50050
Blocks:
  Show dependency treegraph
 
Reported: 2024-05-14 07:31 CEST by Philipp Hahn
Modified: 2024-05-15 17:32 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Customer ID:
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2024-05-14 07:31:57 CEST
Each `systemctl restart univention-directory-manager-rest.service` leaves behind a (temporary) directory including a UNIX domain socket inode:

```console
# find /tmp/pymp-* -ls -type s -exec lsof {} +
  2357042      4 drwx------   2 root     root         4096 Mai 13 16:48 /tmp/pymp-92yvu7a_
  2357051      0 srwx------   1 root     root            0 Mai 13 16:48 /tmp/pymp-92yvu7a_/listener-is1zm1co
  2357014      4 drwx------   2 root     root         4096 Mai 13 16:48 /tmp/pymp-h7fj541c
  2357025      0 srwx------   1 root     root            0 Mai 13 16:48 /tmp/pymp-h7fj541c/listener-qyhjmww9
  2357093      4 drwx------   2 root     root         4096 Mai 14 05:13 /tmp/pymp-j1rtt2su
  2357094      0 srwx------   1 root     root            0 Mai 14 05:13 /tmp/pymp-j1rtt2su/listener-zdcmq7cr
  2357053      4 drwx------   2 root     root         4096 Mai 13 16:48 /tmp/pymp-lwilbd1e
  2357054      0 srwx------   1 root     root            0 Mai 13 16:48 /tmp/pymp-lwilbd1e/listener-r3rop7x8
  2357097      4 drwx------   2 root     root         4096 Mai 14 05:13 /tmp/pymp-uhrttm30
  2357098      0 srwx------   1 root     root            0 Mai 14 05:13 /tmp/pymp-uhrttm30/listener-kv0hjg8b
  2357080      4 drwx------   2 root     root         4096 Mai 14 05:13 /tmp/pymp-uktly30b
  2357092      0 srwx------   1 root     root            0 Mai 14 05:13 /tmp/pymp-uktly30b/listener-277wkk5o
COMMAND    PID USER   FD   TYPE             DEVICE SIZE/OFF     NODE NAME
/usr/bin/ 8845 root    8u  unix 0x0000000041a34a3b      0t0 29515014 /tmp/pymp-uktly30b/listener-277wkk5o type=STREAM
/usr/bin/ 8884 root    8u  unix 0x0000000001b63641      0t0 29514243 /tmp/pymp-j1rtt2su/listener-zdcmq7cr type=STREAM
/usr/bin/ 8901 root    8u  unix 0x000000006f0194d6      0t0 29515342 /tmp/pymp-uhrttm30/listener-kv0hjg8b type=STREA
```

1. A better place would be /run/univention-directory-manager-rest/ which is purged on each reboot
2. should be removed on shutdown.
Comment 1 Philipp Hahn univentionstaff 2024-05-15 15:21:15 CEST
The directory/socket is created by CPython:Lib/multiprocessing/util.py:get_temp_dir() and supposed to be cleaned up by `_temove_temp_dir()`, which is registered as a `Finalizer(…)` to be called on shutdown via `_exit_function()` registered via `atexit.register(…)`, but both `management/univention-directory-manager-rest/src/univention/admin/rest/__main__.py::Server.run()` and `management/univention-directory-manager-rest/src/univention/admin/rest/server/__init__.py::Gateway.main()` play dirty tricks with its internals and `atexit.unregister(_exit_function)` it.

This technical dept was created by https://forge.univention.org/bugzilla/show_bug.cgi?id=50050#c31 without providing any hint on WHY this is needed.

An easy solution might be to add
 [Service]
 PrivateTmp=yes
to management/univention-directory-manager-rest/debian/univention-directory-manager-rest.service and let systemd handle the deletion; see <man:systemd.exec(5)>