summaryrefslogtreecommitdiffstats
path: root/tests/bugs/nfs/socket-as-fifo.py
blob: 2c8ef26a804f222a9cad4a58300f5ed8b5f9ef83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python3
#
# Create a unix domain socket and test if it is a socket (and not a fifo/pipe).
#
# Author: Niels de Vos <ndevos@redhat.com>
#

from __future__ import print_function
import os
import stat
import sys
import socket

ret = 1

if len(sys.argv) != 2:
        print('Usage: %s <socket>' % (sys.argv[0]))
        sys.exit(ret)

path = sys.argv[1]

sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(path)

stbuf = os.stat(path)
mode = stbuf.st_mode

if stat.S_ISSOCK(mode):
        ret = 0

sock.close()
os.unlink(path)

sys.exit(ret)