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.
This commit is contained in:
Daniel Kahn Gillmor
2019-02-21 15:23:46 -05:00
parent a9a6893c89
commit 71c0c3f20a
+1
View File
@@ -160,6 +160,7 @@ def own_socketfile(milterconfig):
offset = 5 offset = 5
if offset is not None: if offset is not None:
if os.path.exists(sockname[offset:]):
os.chown(sockname[offset:], user, group) os.chown(sockname[offset:], user, group)