Lines 47-65
Link Here
|
47 |
logger -t ${name} "Starting ${name}" |
47 |
logger -t ${name} "Starting ${name}" |
48 |
touch ${dkimproxy_out_pidfile} |
48 |
touch ${dkimproxy_out_pidfile} |
49 |
chown ${dkimproxy_out_user} ${dkimproxy_out_pidfile} |
49 |
chown ${dkimproxy_out_user} ${dkimproxy_out_pidfile} |
50 |
logfile=`mktemp /tmp/${name}.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX` |
50 |
tmpfile=`mktemp /tmp/${name}.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX` |
51 |
su -m ${dkimproxy_out_user} -c "daemon -c -p ${dkimproxy_out_pidfile} \ |
51 |
su -m ${dkimproxy_out_user} -c "daemon -c -p ${dkimproxy_out_pidfile} \ |
52 |
%%PREFIX%%/bin/dkimproxy.out ${dkimproxy_out_flags}" \ |
52 |
%%PREFIX%%/bin/dkimproxy.out ${dkimproxy_out_flags}" \ |
53 |
> /dev/null 2> ${logfile} |
53 |
> /dev/null 2> ${tmpfile} |
54 |
sleep 1 # XXX: wait until dkimproxy start. |
54 |
# wait until dkimproxy start. |
55 |
logger -t ${name} "`cat ${logfile}`" |
55 |
while true |
56 |
err=`grep Error ${logfile}` |
56 |
do |
|
|
57 |
filesize=`ls -l ${tmpfile}|awk '{print $5}'` |
58 |
if [ ${filesize} -gt 0 ]; then |
59 |
break |
60 |
fi |
61 |
done |
62 |
|
63 |
logger -t ${name} "`cat ${tmpfile}`" |
64 |
err=`grep Error ${tmpfile}` |
57 |
if [ "${err}" ]; then |
65 |
if [ "${err}" ]; then |
58 |
echo "Failed to start ${name}." |
66 |
echo "Failed to start ${name}." |
59 |
echo "${err}" |
67 |
echo "${err}" |
60 |
rm -f ${dkimproxy_out_pidfile} |
68 |
rm -f ${dkimproxy_out_pidfile} |
|
|
69 |
else |
70 |
# To prevent DoS attack by dkimproxy_out_user. |
71 |
chown root:wheel ${dkimproxy_out_pidfile} |
61 |
fi |
72 |
fi |
62 |
rm -f ${logfile} |
73 |
rm -f ${tmpfile} |
63 |
} |
74 |
} |
64 |
|
75 |
|
65 |
dkimproxy_out_stop() |
76 |
dkimproxy_out_stop() |