Procházet zdrojové kódy

Patch from Hans
This patch (against r950) makes it possible to change the directory
where aisexec searches for configuration files. Pretty much in line with
the possibility to specify user and group. Just do:

make OPENAIS_CONFDIR=/tmp/ais



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

Steven Dake před 20 roky
rodič
revize
ab640472a5
6 změnil soubory, kde provedl 32 přidání a 22 odebrání
  1. 6 0
      Makefile.inc
  2. 2 2
      exec/Makefile
  3. 4 3
      exec/amfconfig.c
  4. 4 5
      exec/keygen.c
  5. 7 5
      exec/mainconfig.c
  6. 9 7
      exec/totemconfig.c

+ 6 - 0
Makefile.inc

@@ -40,6 +40,12 @@ ifndef OPENAIS_GROUP
 	OPENAIS_GROUP=ais
 endif
 
+# OPENAIS_CONFDIR, directory where configuration files are stored
+#
+ifndef OPENAIS_CONFDIR
+	OPENAIS_CONFDIR=/etc/ais
+endif
+
 # default CFLAGS, LDFLAGS
 #
 CFLAGS = 

+ 2 - 2
exec/Makefile

@@ -43,9 +43,9 @@ ifeq (${OPENAIS_COMPAT}, LINUX)
 	LDFLAGS += -ldl
 endif
 
-# OPENAIS_USER, OPENAISGROUP
+# OPENAIS_USER, OPENAIS_GROUP, OPENAIS_CONFDIR
 #
-CFLAGS += -DOPENAIS_USER=\"${OPENAIS_USER}\" -DOPENAIS_GROUP=\"${OPENAIS_GROUP}\" 
+CFLAGS += -DOPENAIS_USER=\"${OPENAIS_USER}\" -DOPENAIS_GROUP=\"${OPENAIS_GROUP}\" -DOPENAIS_CONFDIR=\"${OPENAIS_CONFDIR}\"
 
 # Totem objects
 TOTEM_SRC = aispoll.c totemip.c totemnet.c totemrrp.c totemsrp.c totemmrp.c totempg.c totemconfig.c tlist.c crypto.c wthread.c

+ 4 - 3
exec/amfconfig.c

@@ -225,10 +225,11 @@ extern int openais_amf_config_read (char **error_string)
 	struct amf_si *amf_si = 0;
 	struct amf_healthcheck *amf_healthcheck = 0;
 
-	fp = fopen ("/etc/ais/groups.conf", "r");
+	fp = fopen (OPENAIS_CONFDIR "/groups.conf", "r");
 	if (fp == 0) {
 		sprintf (error_string_response,
-			"Can't read /etc/ais/groups.conf file reason = (%s).\n", strerror (errno));
+			"Can't read %s/groups.conf file reason = (%s).\n",
+			 OPENAIS_CONFDIR, strerror (errno));
 		*error_string = error_string_response;
 		return (-1);
 	}
@@ -525,7 +526,7 @@ extern int openais_amf_config_read (char **error_string)
 
 parse_error:
 	sprintf (error_string_response,
-		"parse error at /etc/groups.conf:%d.\n", line_number);
+		"parse error at %s/groups.conf:%d.\n", OPENAIS_CONFDIR, line_number);
 	*error_string = error_string_response;
 	fclose (fp);
 	return (-1);

+ 4 - 5
exec/keygen.c

@@ -51,7 +51,6 @@ int main (void) {
 		printf ("Error: Authorization key must be generated as root user.\n");
 		exit (1);
 	}
-	mkdir ("/etc/ais", 0700);
 
 	printf ("Gathering %lu bits for key from /dev/random.\n", sizeof (key) * 8);
 	random_fd = open ("/dev/random", O_RDONLY);
@@ -72,9 +71,9 @@ int main (void) {
 	/*
 	 * Open key
 	 */
-	authkey_fd = open ("/etc/ais/authkey", O_CREAT|O_WRONLY);
+	authkey_fd = open (OPENAIS_CONFDIR "/authkey", O_CREAT|O_WRONLY);
 	if (authkey_fd == -1) {
-		perror ("Could not create /etc/ais/authkey");
+		perror ("Could not create " OPENAIS_CONFDIR "/authkey");
 		exit (1);
 	}
 	/*
@@ -83,14 +82,14 @@ int main (void) {
 	fchown (authkey_fd, 0, 0);
 	fchmod (authkey_fd, 0400);
 
-	printf ("Writing openais key to /etc/ais/authkey.\n");
+	printf ("Writing openais key to " OPENAIS_CONFDIR "/authkey.\n");
 
 	/*
 	 * Write key
 	 */
 	res = write (authkey_fd, key, sizeof (key));
 	if (res == -1) {
-		perror ("Could not write /etc/ais/authkey");
+		perror ("Could not write " OPENAIS_CONFDIR "/authkey");
 		exit (1);
 	}
 	

+ 7 - 5
exec/mainconfig.c

@@ -153,10 +153,11 @@ extern int openais_main_config_read (char **error_string,
 	char *error_reason = error_string_response;
 
 	memset (openais_config, 0, sizeof (struct openais_config));
-	fp = fopen ("/etc/ais/openais.conf", "r");
+	fp = fopen (OPENAIS_CONFDIR "/openais.conf", "r");
 	if (fp == 0) {
 		parse_done = 1;
-		sprintf (error_reason, "Can't read file reason = (%s)\n", strerror (errno));
+		sprintf (error_reason, "Can't read file %s/openais.conf reason = (%s)\n",
+			 OPENAIS_CONFDIR, strerror (errno));
 		*error_string = error_reason;
 		return -1;
 	}
@@ -318,11 +319,12 @@ extern int openais_main_config_read (char **error_string,
 parse_error:
 	if (parse_done) {
 		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);
 	} else {
 		sprintf (error_string_response,
-			"parse error in /etc/ais/openais.conf: %s (line %d).\n",
-			error_reason, line_number);
+			"parse error in %s/openais.conf: %s (line %d).\n",
+			OPENAIS_CONFDIR, error_reason, line_number);
 	}
 	*error_string = error_string_response;
 	fclose (fp);

+ 9 - 7
exec/totemconfig.c

@@ -156,11 +156,12 @@ extern int totem_config_read (
 
 	totem_config->secauth = 1;
 
-	fp = fopen ("/etc/ais/openais.conf", "r");
+	fp = fopen (OPENAIS_CONFDIR "/openais.conf", "r");
 
 	if (fp == 0) {
 		parse_done = 1;
-		sprintf (error_reason, "Can't read file reason = (%s)\n", strerror (errno));
+		sprintf (error_reason, "Can't read file %s reason = (%s)\n",
+			 OPENAIS_CONFDIR, strerror (errno));
 		*error_string = error_reason;
 		return -1;
 	}
@@ -233,8 +234,8 @@ extern int totem_config_read (
 			if ((loc = strstr_rs (line, "bindnetaddr:"))) {
 				if (interface_max == totem_config->interface_count) {
 					sprintf (error_reason,
-						"%d is too many interfaces in /etc/ais/network.conf",
-					totem_config->interface_count);
+						"%d is too many interfaces in %s/network.conf",
+						 OPENAIS_CONFDIR, totem_config->interface_count);
 					goto parse_error;
 				}
 				res = totemip_parse (&totem_config->interfaces[totem_config->interface_count].bindnet, loc);
@@ -288,11 +289,12 @@ extern int totem_config_read (
 parse_error:
 	if (parse_done) {
 		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);
 	} else {
 		sprintf (error_string_response,
-			"parse error in /etc/ais/openais.conf: %s (line %d).\n",
-			error_reason, line_number);
+			"parse error in %s/openais.conf: %s (line %d).\n",
+			 OPENAIS_CONFDIR, error_reason, line_number);
 	}
 	*error_string = error_string_response;
 	fclose (fp);