Select Git revision
Forked from
protokollsystem / proto3
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
nullmailer-queuec.py 756 B
#!/usr/bin/env python3
import socket
import sys
SERVER_SOCKET = '/run/nullmailer/queued.sock'
# reference implementation from docs.python.org; will be in v3.9
if not hasattr(socket.socket, 'send_fds'):
import array
def send_fds(sock, msg, fds):
ancdata = [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", fds).tobytes())]
return sock.sendmsg([msg], ancdata)
socket.socket.send_fds = send_fds
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
sock.connect(SERVER_SOCKET)
except socket.error as msg:
print(msg)
sys.exit(255)
ret = 255
try:
sock.send_fds((1).to_bytes(4, 'big'), [sys.stdin.fileno()])
ret = int.from_bytes(sock.recv(1024), 'big')
finally:
sock.close()
sys.exit(ret)