From 856c74559182f1d272870df71befed55c65100c5 Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Fri, 24 Mar 2006 18:25:55 +0000 Subject: [PATCH] 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 --- exec/keygen.c | 2 +- exec/main.c | 2 +- exec/totemconfig.c | 2 +- test/clc_cli_script | 18 ++++++++++++++---- test/testamf1.c | 5 +++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/exec/keygen.c b/exec/keygen.c index 23a230ce..21752556 100644 --- a/exec/keygen.c +++ b/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); } diff --git a/exec/main.c b/exec/main.c index 5f4d508f..f61b1b86 100644 --- a/exec/main.c +++ b/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); diff --git a/exec/totemconfig.c b/exec/totemconfig.c index 1f2a3b1f..704ced97 100644 --- a/exec/totemconfig.c +++ b/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); } diff --git a/test/clc_cli_script b/test/clc_cli_script index 6674b4c4..8eee6c61 100755 --- a/test/clc_cli_script +++ b/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 } diff --git a/test/testamf1.c b/test/testamf1.c index 2131c4c0..ad842bd3 100644 --- a/test/testamf1.c +++ b/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);