From 71c0c3f20ae03c18e8f40284a0242fb404b76991 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Thu, 21 Feb 2019 15:23:46 -0500 Subject: [PATCH] Avoid failing to chown non-existent Unix-domain sockets Changing ownership of sockets that doesn't exist isn't a great practice. A better approach would be to apply os.chown() to the file descriptor of the open socket, but at the very least dkimpy-milter shouldn't crash the way it currently does if the socket isn't already present. --- dkimpy_milter/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dkimpy_milter/util.py b/dkimpy_milter/util.py index abab538..17857d6 100644 --- a/dkimpy_milter/util.py +++ b/dkimpy_milter/util.py @@ -160,7 +160,8 @@ def own_socketfile(milterconfig): offset = 5 if offset is not None: - os.chown(sockname[offset:], user, group) + if os.path.exists(sockname[offset:]): + os.chown(sockname[offset:], user, group) def read_keyfile(milterconfig, keytype):