<div dir="ltr">Included. Thanks!<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-12 7:07 GMT+01:00 weiqiang.yang <span dir="ltr"><<a href="mailto:scutweiqiang.yang@gmail.com" target="_blank">scutweiqiang.yang@gmail.com</a>></span>:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">when /var/run/ossec-hids is created by ossec-hids-*.init script, it's default permission is 755 and it's owned by root:root<br>


in that case ossec-agentd process won't be able to create the pid file, as it's running by "ossec" user<br>
<br>
so I think we should adjust the owner and permission when creating /var/run/ossec-hids, below is my solution for this, please take a look at it, thanks.<br>
<br>
diff --git a/debian/ossec-hids-agent.init b/debian/ossec-hids-agent.init<br>
index f28b907..832f7c7 100755<br>
--- a/debian/ossec-hids-agent.init<br>
+++ b/debian/ossec-hids-agent.init<br>
@@ -25,6 +25,9 @@<br>
 PATH=/sbin:/usr/sbin:/bin:/usr/bin<br>
 DESC="OSSEC Host-based Intrusion Detection System agent"<br>
 NAME=ossec-hids-agent<br>
+USER=ossec<br>
+GROUP=ossec<br>
+PIDFILE=/var/run/ossec-hids<br>
 DAEMON=/usr/lib/ossec/ossec-agentd<br>
 DAEMON_ARGS=""<br>
 SCRIPTNAME=/etc/init.d/$NAME<br>
@@ -55,7 +58,11 @@ test $DEBIAN_SCRIPT_DEBUG && set -v -x<br>
 [ ! -e "${DIRECTORY}" ] && exit 0<br>
<br>
 # Create the directory for the pidfiles<br>
-[ ! -e /var/run/ossec-hids ] && mkdir -p /var/run/ossec-hids<br>
+if [ ! -e ${PIDFILE} ] ; then<br>
+    mkdir -p ${PIDFILE}<br>
+    chown ${USER}:${GROUP} ${PIDFILE}<br>
+    chmod 755 ${PIDFILE}<br>
+fi<br>
<br>
 # Log file for the ossec-control file<br>
 LOGDIR=${DIRECTORY}/logs<br>
diff --git a/debian/ossec-hids-local.init b/debian/ossec-hids-local.init<br>
index b7aed02..dbf986e 100755<br>
--- a/debian/ossec-hids-local.init<br>
+++ b/debian/ossec-hids-local.init<br>
@@ -25,6 +25,9 @@<br>
 PATH=/sbin:/usr/sbin:/bin:/usr/bin<br>
 DESC="OSSEC Host-based Intrusion Detection System local"<br>
 NAME=ossec-hids-local<br>
+USER=ossec<br>
+GROUP=ossec<br>
+PIDFILE=/var/run/ossec-hids<br>
 DAEMON=/usr/lib/ossec/ossec-agentd<br>
 DAEMON_ARGS=""<br>
 SCRIPTNAME=/etc/init.d/$NAME<br>
@@ -55,7 +58,11 @@ test $DEBIAN_SCRIPT_DEBUG && set -v -x<br>
 [ ! -e "${DIRECTORY}" ] && exit 0<br>
<br>
 # Create the directory for the pidfiles<br>
-[ ! -e /var/run/ossec-hids ] && mkdir -p /var/run/ossec-hids<br>
+if [ ! -e ${PIDFILE} ] ; then<br>
+    mkdir -p ${PIDFILE}<br>
+    chown ${USER}:${GROUP} ${PIDFILE}<br>
+    chmod 755 ${PIDFILE}<br>
+fi<br>
<br>
 # Log file for the ossec-control file<br>
 LOGDIR=${DIRECTORY}/logs<br>
diff --git a/debian/ossec-hids-server.init b/debian/ossec-hids-server.init<br>
index 3db624a..096567d 100755<br>
--- a/debian/ossec-hids-server.init<br>
+++ b/debian/ossec-hids-server.init<br>
@@ -25,6 +25,9 @@<br>
 PATH=/sbin:/usr/sbin:/bin:/usr/bin<br>
 DESC="OSSEC Host-based Intrusion Detection System server"<br>
 NAME=ossec-hids-server<br>
+USER=ossec<br>
+GROUP=ossec<br>
+PIDFILE=/var/run/ossec-hids<br>
 DAEMON=/usr/lib/ossec/ossec-agentd<br>
 DAEMON_ARGS=""<br>
 SCRIPTNAME=/etc/init.d/$NAME<br>
@@ -55,7 +58,11 @@ test $DEBIAN_SCRIPT_DEBUG && set -v -x<br>
 [ ! -e "${DIRECTORY}" ] && exit 0<br>
<br>
 # Create the directory for the pidfiles<br>
-[ ! -e /var/run/ossec-hids ] && mkdir -p /var/run/ossec-hids<br>
+if [ ! -e ${PIDFILE} ] ; then<br>
+    mkdir -p ${PIDFILE}<br>
+    chown ${USER}:${GROUP} ${PIDFILE}<br>
+    chmod 755 ${PIDFILE}<br>
+fi<br>
<br>
 # Log file for the ossec-control file<br>
 LOGDIR=${DIRECTORY}/logs<br>
<br>
<br>
<br>_______________________________________________<br>
Pkg-ossec-devel mailing list<br>
<a href="mailto:Pkg-ossec-devel@lists.alioth.debian.org">Pkg-ossec-devel@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ossec-devel" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ossec-devel</a><br></blockquote></div><br><br clear="all"><br>

-- <br>Jose Antonio Quevedo Muñoz<br>Key fingerprint: C88A AAFA CF91 F556 E1D5  52FC C3D7 3C5D 8224 5822<br>--<br>Ever tried. Ever failed. No matter.<br>Try again. Fail again. Fail better.<br>~ Samuel Beckett ~<br>
</div>