Просмотр исходного кода

Patch from Hans to fix up the configurable /var/run and /etc/ais directory
support.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@955 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 20 лет назад
Родитель
Сommit
856c745591
5 измененных файлов с 22 добавлено и 7 удалено
  1. 1 1
      exec/keygen.c
  2. 1 1
      exec/main.c
  3. 1 1
      exec/totemconfig.c
  4. 14 4
      test/clc_cli_script
  5. 5 0
      test/testamf1.c

+ 1 - 1
exec/keygen.c

@@ -64,7 +64,7 @@ int main (void) {
 	 */
 	res = read (random_fd, key, sizeof (key));
 	if (res == -1) {
-		perror ("Could not read /etc/ais/authkey");
+		perror ("Could not read /dev/random");
 		exit (1);
 	}
 

+ 1 - 1
exec/main.c

@@ -1209,7 +1209,7 @@ int main (int argc, char **argv)
 		}
 	}
 
-	res = totem_config_keyread ("/etc/ais/authkey", &openais_config.totem_config, &error_string);
+	res = totem_config_keyread (OPENAIS_CONFDIR "/authkey", &openais_config.totem_config, &error_string);
 	if (res == -1) {
 		log_printf (LOG_LEVEL_ERROR, error_string);
 		openais_exit_error (AIS_DONE_MAINCONFIGREAD);

+ 1 - 1
exec/totemconfig.c

@@ -471,7 +471,7 @@ int totem_config_validate (
 
 parse_error:
 	sprintf (error_string_response,
-		"parse error in /etc/ais/openais.conf: %s\n", error_reason);
+		"parse error in %s/openais.conf: %s\n", OPENAIS_CONFDIR, error_reason);
 	*error_string = error_string_response;
 	return (-1);
 }

+ 14 - 4
test/clc_cli_script

@@ -39,15 +39,25 @@ instantiate() {
 }
 
 terminate() {
-	echo clc_cli_script terminating up component $SA_AMF_COMPONENT_NAME on PID `cat /var/run/openais_cleanup_$SA_AMF_COMPONENT_NAME`
-	kill -15 `cat /var/run/openais_cleanup_$SA_AMF_COMPONENT_NAME`
+	if [ -w /var/run ]; then
+		PIDFILEPATH=/var/run
+	else
+		PIDFILEPATH=/tmp
+	fi
+	echo clc_cli_script terminating up component $SA_AMF_COMPONENT_NAME on PID `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
+	kill -15 `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
 	RETVAL=$?
 	return $RETVAL
 }
 
 cleanup() {
-	echo clc_cli_script cleaning up component $SA_AMF_COMPONENT_NAME on PID `cat /var/run/openais_cleanup_$SA_AMF_COMPONENT_NAME`
-	kill -9 `cat /var/run/openais_cleanup_$SA_AMF_COMPONENT_NAME`
+	if [ -w /var/run ]; then
+		PIDFILEPATH=/var/run
+	else
+		PIDFILEPATH=/tmp
+	fi
+	echo clc_cli_script cleaning up component $SA_AMF_COMPONENT_NAME on PID `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
+	kill -9 `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
 	RETVAL=$?
 	return $RETVAL
 }

+ 5 - 0
test/testamf1.c

@@ -225,6 +225,11 @@ void write_pid (void) {
 	
 	sprintf (filename,  "/var/run/openais_cleanup_%s", compNameGlobal.value);
 	fd = open (filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
+	if (fd == -1) {
+		printf("Failed using /var/run for pid file, using /tmp\n");
+		sprintf (filename,  "/tmp/openais_cleanup_%s", compNameGlobal.value);
+		fd = open (filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
+	}
 	sprintf (pid, "%d", getpid());
 	res = write (fd, pid, strlen (pid));
 	close (fd);