<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>mizzy.org: mod_dosdetector &#12434; Apache 2.0 &#31995;&#12391;&#21205;&#12363;&#12377;&#12497;&#12483;&#12481;</title>
    <link>http://blog.mizzy.org/articles/2007/07/26/mod_dosdetector_for_apache_20</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>mod_dosdetector &#12434; Apache 2.0 &#31995;&#12391;&#21205;&#12363;&#12377;&#12497;&#12483;&#12481;</title>
      <description>&lt;p&gt;&lt;a href="http://sourceforge.net/projects/moddosdetector/"&gt;mod_dosdetecter 0.2&lt;/a&gt; &#12434; Apache 2.0 &#31995;&#12391;&#21205;&#12363;&#12377;&#12497;&#12483;&#12481;&#12434;&#26360;&#12356;&#12390;&#12415;&#12383;&#12290;&#20462;&#27491;&#12509;&#12452;&#12531;&#12488;&#12399;&#12289;&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;/usr/local/apache/include/pcreposix.h:41: error: redeclaration of enumerator `REG_BADBR&amp;#8217; &#12392;&#12356;&#12387;&#12383;&#12456;&#12521;&#12540;&#12364;&#22823;&#37327;&#12395;&#20986;&#12390;&#12367;&#12427;&#12364;&#12289;&#12371;&#12428;&#12399; /usr/include/regex.h &#12392;&#23459;&#35328;&#12364;&#37325;&#35079;&#12375;&#12390;&#12356;&#12427;&#12383;&#12417;&#12290;&#12394;&#12398;&#12391;&#12289;#include &amp;lt;regex.h&amp;gt; &#12399;&#21066;&#38500;&#12290;&lt;/li&gt;
		&lt;li&gt;ap_regmatch_t &#27083;&#36896;&#20307;&#12392; ap_regex_t &#27083;&#36896;&#20307;&#12399; 2.2 &#31995;&#12395;&#12398;&#12415;&#23384;&#22312;&#12375;&#12289;2.0 &#31995;&#12395;&#12399;&#23384;&#22312;&#12375;&#12394;&#12356;&#12290;&#12394;&#12398;&#12391;&#12381;&#12428;&#12382;&#12428;&#12289;regmatch_t, regex_t &#12395;&#32622;&#12365;&#25563;&#12360;&#12427;&#12290;&lt;/li&gt;
		&lt;li&gt;apr_shm_remove &#12399; 2.2&#31995; &#12391;&#12375;&#12363;&#20351;&#12360;&#12394;&#12356;&#12398;&#12391;&#12289;&#12381;&#12398;&#12383;&#12417;&#12398;&#20462;&#27491;&#12434; &lt;a href="http://mod-fcgid.cvs.sourceforge.net/mod-fcgid/mod_fcgid/arch/unix/fcgid_proctbl_unix.c?r1=1.7&amp;#38;r2=1.8"&gt;mod_fcgid &#12398;&#12477;&#12540;&#12473;&lt;/a&gt; &#12363;&#12425;&#12497;&#12463;&#12427;&#12290;&lt;/li&gt;
		&lt;li&gt;set_ignore_contenttype_config() &#12364;&#12475;&#12464;&#12501;&#12457;&#12427;&#12398;&#12391;&#20462;&#27491;&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;=== mod_dosdetector.c
==================================================================
--- mod_dosdetector.c    (revision 804)
+++ mod_dosdetector.c    (local)
@@ -28,7 +28,6 @@
 #include &amp;lt;arpa/inet.h&amp;gt;
 //#include &amp;lt;netinet/in.h&amp;gt;
 #include &amp;lt;time.h&amp;gt;
-#include &amp;lt;regex.h&amp;gt;
 #include "httpd.h" 
 #include "http_config.h" 
 #include "http_request.h" 
@@ -41,6 +40,7 @@
 #include "apr_strings.h" 
 #include "apr_shm.h" 
 #include "apr_thread_mutex.h" 
+#include "apr_version.h" 

 //#define _DEBUG

@@ -102,7 +102,90 @@
 static apr_global_mutex_t *lock = NULL;
 static apr_shm_t *shm = NULL;

+/* apr version 0.x not support apr_shm_remove, I have to copy it from apr version 1.x */
+#if (APR_MAJOR_VERSION &amp;lt; 1)
+#ifdef HAVE_SYS_MMAN_H
+#include &amp;lt;sys/mman.h&amp;gt;
+#endif
+#ifdef HAVE_SYS_IPC_H
+#include &amp;lt;sys/ipc.h&amp;gt;
+#endif
+#ifdef HAVE_SYS_MUTEX_H
+#include &amp;lt;sys/mutex.h&amp;gt;
+#endif
+#ifdef HAVE_SYS_SHM_H
+#include &amp;lt;sys/shm.h&amp;gt;
+#endif
+#if !defined(SHM_R)
+#define SHM_R 0400
+#endif
+#if !defined(SHM_W)
+#define SHM_W 0200
+#endif
+#ifdef HAVE_SYS_FILE_H
+#include &amp;lt;sys/file.h&amp;gt;
+#endif

+static apr_status_t apr_shm_remove(const char *filename, apr_pool_t * pool)
+{
+#if APR_USE_SHMEM_SHMGET
+    apr_status_t status;
+    apr_file_t *file;
+    key_t shmkey;
+    int shmid;
+#endif
+
+#if APR_USE_SHMEM_MMAP_TMP
+    return apr_file_remove(filename, pool);
+#endif
+#if APR_USE_SHMEM_MMAP_SHM
+    if (shm_unlink(filename) == -1) {
+        return errno;
+    }
+    return APR_SUCCESS;
+#endif
+#if APR_USE_SHMEM_SHMGET
+    /* Presume that the file already exists; just open for writing */
+    status = apr_file_open(&amp;#38;file, filename, APR_WRITE,
+                           APR_OS_DEFAULT, pool);
+    if (status) {
+        return status;
+    }
+
+    /* ftok() (on solaris at least) requires that the file actually
+     * exist before calling ftok(). */
+    shmkey = ftok(filename, 1);
+    if (shmkey == (key_t) - 1) {
+        goto shm_remove_failed;
+    }
+
+    apr_file_close(file);
+
+    if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) &amp;lt; 0) {
+        goto shm_remove_failed;
+    }
+
+    /* Indicate that the segment is to be destroyed as soon
+     * as all processes have detached. This also disallows any
+     * new attachments to the segment. */
+    if (shmctl(shmid, IPC_RMID, NULL) == -1) {
+        goto shm_remove_failed;
+    }
+    return apr_file_remove(filename, pool);
+
+  shm_remove_failed:
+    status = errno;
+    /* ensure the file has been removed anyway. */
+    apr_file_remove(filename, pool);
+    return status;
+#endif
+
+    /* No support for anonymous shm */
+    return APR_ENOTIMPL;
+}
+#endif                            /* APR_MAJOR_VERSION&amp;lt;1 */
+
+
 static apr_status_t cleanup_shm(void *not_used)
 {
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Notice: cleaning up shared memory");
@@ -261,8 +344,8 @@

     address = r-&amp;gt;connection-&amp;gt;remote_ip;

-    ap_regmatch_t regmatch[AP_MAX_REG_MATCH];
-    ap_regex_t **contenttype_regexp = (ap_regex_t **) cfg-&amp;gt;contenttype_regexp-&amp;gt;elts;
+    regmatch_t regmatch[AP_MAX_REG_MATCH];
+    regex_t **contenttype_regexp = (regex_t **) cfg-&amp;gt;contenttype_regexp-&amp;gt;elts;
     for (i = 0; i &amp;lt; cfg-&amp;gt;contenttype_regexp-&amp;gt;nelts; i++) {
         if(!ap_regexec(contenttype_regexp[i], content_type, AP_MAX_REG_MATCH, regmatch, 0)){
             //ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, 0, "ignoring content-type: %s", content_type);
@@ -390,15 +473,13 @@
                      const char *arg)
 {
     dosdetector_dir_config *cfg = (dosdetector_dir_config *) mconfig;
-    char **ignore_contenttype = (char **) cfg-&amp;gt;ignore_contenttype-&amp;gt;elts;
+    regex_t *regexp;
+    char *type;

-    *(char **) apr_array_push(cfg-&amp;gt;ignore_contenttype) = apr_pstrdup(parms-&amp;gt;pool, arg);
-
-    int i;
-    regex_t *regexp;
-    for (i = 0; i &amp;lt; cfg-&amp;gt;ignore_contenttype-&amp;gt;nelts; i++) {
-        regexp = (regex_t *)ap_pregcomp(parms-&amp;gt;pool, (char *)ignore_contenttype[i], REG_EXTENDED|REG_ICASE);
-        *(regex_t **)apr_array_push(cfg-&amp;gt;contenttype_regexp) = regexp;
+    while (*arg) {
+      type = ap_getword_conf(parms-&amp;gt;pool, &amp;#38;arg);
+      regexp = ap_pregcomp(parms-&amp;gt;pool, type, REG_EXTENDED|REG_ICASE);
+      *(regex_t **)apr_array_push(cfg-&amp;gt;contenttype_regexp) = regexp;
     }

     return NULL;
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;2.0 &#31995;&#12391;&#12418; 2.2 &#31995;&#12391;&#12418;&#12393;&#12387;&#12385;&#12391;&#12418;&#21205;&#12367;&#12424;&#12358;&#12395;&#20462;&#27491;&#12375;&#12383;&#26041;&#12364;&#12356;&#12356;&#12435;&#12384;&#12429;&#12358;&#12369;&#12393;&#12289;&#12381;&#12428;&#12399;&#12414;&#12383;&#20170;&#24230;&#12290;&lt;/p&gt;</description>
      <pubDate>Thu, 26 Jul 2007 22:32:00 +0900</pubDate>
      <guid isPermaLink="false">urn:uuid:a856d6cd-83df-4db2-ae82-161db221c6ef</guid>
      <author>Gosuke Miyashita</author>
      <link>http://blog.mizzy.org/articles/2007/07/26/mod_dosdetector_for_apache_20</link>
      <category>linux</category>
    </item>
    <item>
      <title>"mod_dosdetector &#12434; Apache 2.0 &#31995;&#12391;&#21205;&#12363;&#12377;&#12497;&#12483;&#12481;" by &#12358;&#12363;&#12356;&#12385;&#12419;&#12435;</title>
      <description>&lt;p&gt;mod_dosdetector &#12395;&#12388;&#12356;&#12390;&#35519;&#12409;&#12390;&#12356;&#12414;&#12377;&#12290;
CentOS 4 / Apache 2.0 &#12391;&#36939;&#29992;&#12375;&#12390;&#12356;&#12414;&#12375;&#12390;&#12289;mod_dosdetector &#12434;&#12467;&#12531;&#12497;&#12452;&#12523;&#12375;&#12424;&#12358;&#12392;&#12375;&#12390;&#12418;&#12394;&#12363;&#12394;&#12363;&#12391;&#12365;&#12414;&#12379;&#12435;&#12391;&#12375;&#12383;&#12364;&#12289;&#12372;&#25552;&#20379;&#12356;&#12383;&#12384;&#12356;&#12383;&#12497;&#12483;&#12481;&#12391;&#35211;&#20107;&#12467;&#12531;&#12497;&#12452;&#12523;&#12391;&#12365;&#12414;&#12375;&#12383;&#12290;
&#12354;&#12426;&#12364;&#12392;&#12358;&#12372;&#12374;&#12356;&#12414;&#12375;&#12383;&#12290;
&#12375;&#12363;&#12375;&#12289;&#35373;&#23450;&#26041;&#27861;&#12364;&#12356;&#12414;&#12356;&#12385;&#20998;&#12363;&#12425;&#12378;&#12371;&#12414;&#12387;&#12390;&#12356;&#12414;&#12377;&#12290;&#12424;&#12429;&#12375;&#12369;&#12428;&#12400;&#35373;&#23450;&#26041;&#27861;&#12434;&#12372;&#25945;&#25480;&#12356;&#12383;&#12384;&#12369;&#12394;&#12356;&#12391;&#12375;&#12423;&#12358;&#12363;&#65311;
&#12424;&#12429;&#12375;&#12367;&#12362;&#12397;&#12364;&#12356;&#12375;&#12414;&#12377;&#12290;&lt;/p&gt;</description>
      <pubDate>Wed, 19 Sep 2007 09:21:34 +0900</pubDate>
      <guid isPermaLink="false">urn:uuid:a8d4ff60-8f3f-4505-93cc-ed3f9fe2b135</guid>
      <link>http://blog.mizzy.org/articles/2007/07/26/mod_dosdetector_for_apache_20#comment-3654</link>
    </item>
  </channel>
</rss>
