Hi

Here is a patch for the cheetah bug.
Not sure if the check on /proc/net/if_inet6 is the perfect solution or even
relevant in this situation
A review and some pointers would be much appreciated.

regards,
JP

Le 25 mars 2012 19:29, Eduardo Silva <[email protected]> a écrit :

> Hi,
>
> the right fix is that mk_api->config->listen_addr should never be NULL.
>
> regards,
>
> On Sun, Mar 25, 2012 at 12:03 AM, Sourabh Chandak <[email protected]>
> wrote:
> > Hi,
> >
> > Fixed the segmentation fault which occurred when the command to retrieve
> > global configuration is called.
> >
> > --
> > Sourabh Chandak
> >
> >
> >
>
>
>
> --
> Eduardo Silva
> http://edsiper.linuxchile.cl
> http://www.monkey-project.com
> _______________________________________________
> Monkey mailing list
> [email protected]
> http://lists.monkey-project.com/listinfo/monkey
>
From 4b0fea249192d613c767fb400902b9d4831a1e6d Mon Sep 17 00:00:00 2001
From: Jean-Paul Bonnet <popol@FullBottle.(none)>
Date: Sun, 25 Mar 2012 22:38:27 +0100
Subject: [PATCH] cheetah: segf when using config on default config

---
 plugins/cheetah/cmd.c   |    3 ++-
 src/include/mk_config.h |    3 ++-
 src/include/mk_utils.h  |    2 +-
 src/mk_config.c         |   10 +++++++---
 src/mk_utils.c          |   10 ++++++++++
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/plugins/cheetah/cmd.c b/plugins/cheetah/cmd.c
index b3a8e7c..b61ebe9 100644
--- a/plugins/cheetah/cmd.c
+++ b/plugins/cheetah/cmd.c
@@ -312,7 +312,8 @@ void mk_cheetah_cmd_config()
     CHEETAH_WRITE("\n-------------------");
     CHEETAH_WRITE("\nServer Port     : %i", mk_api->config->serverport);
     
-    if (strcmp(mk_api->config->listen_addr, "0.0.0.0") == 0) {
+    if (strcmp(mk_api->config->listen_addr, "0.0.0.0") ||
+        strcmp(mk_api->config->listen_addr, "::") == 0) {
         CHEETAH_WRITE("\nListen          : All interfaces");
     }
     else {
diff --git a/src/include/mk_config.h b/src/include/mk_config.h
index 7efb8fc..8a9af59 100644
--- a/src/include/mk_config.h
+++ b/src/include/mk_config.h
@@ -33,7 +33,8 @@
 #endif
 
 #define M_DEFAULT_CONFIG_FILE	"monkey.conf"
-#define MK_DEFAULT_LISTEN_ADDR NULL
+#define MK_DEFAULT_LISTEN_ADDR_IPV4 "0.0.0.0"
+#define MK_DEFAULT_LISTEN_ADDR_IPV6 "::"
 #define MK_WORKERS_DEFAULT 1
 
 #define VALUE_ON "on"
diff --git a/src/include/mk_utils.h b/src/include/mk_utils.h
index b52ca73..17df997 100644
--- a/src/include/mk_utils.h
+++ b/src/include/mk_utils.h
@@ -81,5 +81,5 @@ int mk_utils_worker_rename(const char *title);
 void mk_utils_stacktrace(void);
 #endif
 
-
+int mk_utils_file_exists(const char *path);
 #endif
diff --git a/src/mk_config.c b/src/mk_config.c
index e47f5c7..e4e2155 100644
--- a/src/mk_config.c
+++ b/src/mk_config.c
@@ -401,8 +401,10 @@ static void mk_config_read_files(char *path_conf, char *file_conf)
     /* Listen */
     config->listen_addr = mk_config_section_getval(section, "Listen", 
                                                    MK_CONFIG_VAL_STR);
-    if (!config->listen_addr) {
-        config->listen_addr = MK_DEFAULT_LISTEN_ADDR;
+    if (!config->listen_addr && mk_utils_file_exists("/proc/net/if_inet6")) {
+        config->listen_addr = MK_DEFAULT_LISTEN_ADDR_IPV6;
+    } else {
+        config->listen_addr = MK_DEFAULT_LISTEN_ADDR_IPV4;
     }
 
     /* Connection port */
@@ -672,7 +674,7 @@ void mk_config_set_init_values(void)
     config->max_keep_alive_request = 50;
     config->resume = MK_TRUE;
     config->standard_port = 80;
-    config->listen_addr = MK_DEFAULT_LISTEN_ADDR;
+    config->listen_addr = MK_DEFAULT_LISTEN_ADDR_IPV4;
     config->serverport = 2001;
     config->symlink = MK_FALSE;
     config->nhosts = 0;
@@ -770,3 +772,5 @@ void mk_config_sanity_check()
         close(fd);
     }
 }
+
+
diff --git a/src/mk_utils.c b/src/mk_utils.c
index be00b9c..f9fa68b 100644
--- a/src/mk_utils.c
+++ b/src/mk_utils.c
@@ -569,3 +569,13 @@ void mk_utils_stacktrace(void)
 
 }
 #endif
+
+int mk_utils_file_exists(const char* path) 
+{
+    int exist = access(path, F_OK);
+    if (exist == 0) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
-- 
1.7.4.1

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to