You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
498 B
Python

#!/usr/bin/env python3
import socket
import sys
import array
skname = sys.argv[1]
sk = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sk.connect(skname)
data, anc, _flags, _addr = sk.recvmsg(100, 100)
print(data.decode())
_level, _type, fdarr = anc[0]
arr = array.array('i')
arr.frombytes(fdarr)
f = open(arr[0])
print(next(f))
input('reply?')
protos = open('/etc/protocols')
sk.sendmsg([b'hello!'],
[(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array('i', [protos.fileno()]))],
)
sk.close()