[Initng-svn] r2394 - initng/plugins/bash_launcher

svn at initng.thinktux.net svn at initng.thinktux.net
Mon Dec 12 22:59:25 CET 2005


Author: jimmy
Date: Mon Dec 12 22:59:24 2005
New Revision: 2394

Modified:
   initng/plugins/bash_launcher/initng_bash_launcher.c
Log:
A bug in bash_launcher.



Modified: initng/plugins/bash_launcher/initng_bash_launcher.c
==============================================================================
--- initng/plugins/bash_launcher/initng_bash_launcher.c	(original)
+++ initng/plugins/bash_launcher/initng_bash_launcher.c	Mon Dec 12 22:59:24 2005
@@ -80,15 +80,23 @@
     /* get the arguments if any */
     args = active_db_get_string_var(&SCRIPT_OPT, process->pt->name, service);
 
+    printf("initng_bash(%s, %s, %s);\n", service->name, e, args);
     return (bash_exec(process, service, e, args));
 }
 
 
 static void bash_this(const char *bash_code, active_h * s, const char *args)
 {
+    /* temporary argv */
+    char **argtmp;
+    
+    
     D_("bash_this(%s);\n", s->name);
+    
+
     /* Todo : move bash_this into initng_bash_launcher and parse args properly\n" */
-    char **argtmp;
+
+    /* allocate, and fill the temp argv */
     argtmp = (char **) initng_calloc(8, sizeof(char *));
     argtmp[0] =
         (char *) initng_calloc(1, sizeof(char) * (15 + strlen(s->name)));
@@ -97,15 +105,34 @@
     strcat(argtmp[0], "]");
     argtmp[1] = i_strdup("-c");
     argtmp[2] = i_strdup(bash_code);
-    argtmp[3] = s->name;
-    argtmp[4] = i_strdup(args);
+    argtmp[3] = i_strdup(s->name);
+    
+    if(args)
+	argtmp[4] = i_strdup(args);
     argtmp[5] = NULL;
+    
+    /* execute */
     execve("/bin/sh", argtmp, new_environ(s));
-    free(argtmp[0]);
+    
+    /* free them all */
+    {
+	int i=0;
+	while(argtmp[i])
+	{
+	    free(argtmp[i]);
+	    argtmp[i]=NULL;
+	    i++;
+	}
+    }
     free(argtmp);
+    
+    /* put an error message up */
     F_("bash_this(): child died!\n EEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRROOOOOOOOOORR!\n");
-    /* exit 1, why???, to emit signal? */
+
+    /* system free */
     initng_free();
+
+    /* exit 1, to emit an false signal */
     _exit(1);
 }                                           /* end fork_and_exec() */
 
@@ -141,6 +168,7 @@
         return (TRUE);
     }
 
+    F_("bash_exec, did not get a pid!\n");
     process_to_exec->pid = 0;
     return (FALSE);
 


More information about the Initng-svn mailing list