Skip to content

Commit

Permalink
Better generation of random names for reply FIFO.
Browse files Browse the repository at this point in the history
Related to issue #257
  • Loading branch information
bogdan-iancu committed Jul 25, 2014
1 parent 33c9d48 commit 7078c0f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions scripts/opensipsctl.fifo
Expand Up @@ -50,8 +50,7 @@ fifo_cmd()
merr "fifo_cmd must take at least command name as parameter"
exit 1
fi
name=opensips_receiver_$$
path=$CHROOT_DIR/tmp/$name

if [ ! -w $OSIPS_FIFO ]; then
merr "Error opening OpenSIPS's FIFO $OSIPS_FIFO"
merr "Make sure you have the line 'modparam(\"mi_fifo\", \"fifo_name\", \"$OSIPS_FIFO\")' in your config"
Expand All @@ -61,14 +60,15 @@ fifo_cmd()
fi
exit 2
fi
if ! test -p $path; then
mkfifo $path
if [ $? -ne 0 ] ; then
merr "error opening read fifo $path"
exit 3
fi
chmod a+w $path
fi

# generate a random and unique filename
while :
do
suffix=$(od -An -N4 -tx4 /dev/urandom | tr -d " ")
(mkfifo --mode=a+w $CHROOT_DIR/tmp/osips_rply_$suffix) &>/dev/null && break
done
name=osips_rply_$suffix
path=$CHROOT_DIR/tmp/$name

# construct the command now
CMD=":$1:$name\n";
Expand Down

0 comments on commit 7078c0f

Please sign in to comment.