Skip to content

Commit 8bcf9bb

Browse files
committed
[rootssh] change socket access flags only when it exists
Prevent failure on Mac where operation with non-existing files/sockets leads to failure
1 parent 935283b commit 8bcf9bb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

config/rootssh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,17 @@ elif [[ "$1" == "--as-listener--" ]] ; then
5555
#remember processid to be able kill it
5656
nc_procid=$!
5757

58-
# protect socket and log file from reading
59-
chmod -f 0700 $listener_socket $listener_socket.log
58+
# protect log file from reading
59+
chmod -f 0700 $listener_socket.log
6060

61-
# remove netcat listening on socket
61+
# cleanup netcat listening on socket at the end
6262
trap "kill -SIGINT $nc_procid >/dev/null 2>&1; rm -f $listener_socket.log" 0 1 2 3 6
6363

6464
while [[ ($flag -ne 0) && (-f $listener_socket.log) ]] ; do
65+
# protect socket from reading
66+
if [ -S $listener_socket ] ; then
67+
chmod -f 0700 $listener_socket
68+
fi
6569

6670
line=$(sed "${NUM}q;d" $listener_socket.log)
6771

0 commit comments

Comments
 (0)