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

- Preprocessor flags to control user, group and directory for
configuration files removed.

- Environment variables for the same thing added:
OPENAIS_AISPARSER_FILE
OPENAIS_AMF_CONFIG_FILE
OPENAIS_TOTEM_AUTHKEY_FILE

- Make depend target in exec makefile updated with missing source files.




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

Hans Feldt 20 лет назад
Родитель
Сommit
a5019f2edc
7 измененных файлов с 110 добавлено и 83 удалено
  1. 0 15
      Makefile.inc
  2. 78 49
      exec/Makefile
  3. 8 3
      exec/aisparser.c
  4. 11 7
      exec/amfconfig.c
  5. 5 4
      exec/keygen.c
  6. 2 2
      exec/mainconfig.c
  7. 6 3
      exec/totemconfig.c

+ 0 - 15
Makefile.inc

@@ -31,21 +31,6 @@ endif
 # OPENAIS_PROFILE
 # OPENAIS_PROFILE
 # OPENAIS_COVERAGE
 # OPENAIS_COVERAGE
 
 
-# OPENAIS_USER, OPENAIS_GROUP default to ais
-#
-ifndef OPENAIS_USER
-	OPENAIS_USER=ais
-endif
-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
 # default CFLAGS, LDFLAGS
 #
 #
 CFLAGS = 
 CFLAGS = 

+ 78 - 49
exec/Makefile

@@ -43,10 +43,6 @@ ifeq (${OPENAIS_COMPAT}, LINUX)
 	LDFLAGS += -ldl
 	LDFLAGS += -ldl
 endif
 endif
 
 
-# OPENAIS_USER, OPENAIS_GROUP, OPENAIS_CONFDIR
-#
-CFLAGS += -DOPENAIS_USER=\"${OPENAIS_USER}\" -DOPENAIS_GROUP=\"${OPENAIS_GROUP}\" -DOPENAIS_CONFDIR=\"${OPENAIS_CONFDIR}\"
-
 # Totem objects
 # Totem objects
 TOTEM_SRC = aispoll.c totemip.c totemnet.c totemrrp.c totemsrp.c totemmrp.c totempg.c tlist.c crypto.c wthread.c
 TOTEM_SRC = aispoll.c totemip.c totemnet.c totemrrp.c totemsrp.c totemmrp.c totempg.c tlist.c crypto.c wthread.c
 TOTEM_OBJS = aispoll.o totemip.o totemnet.o totemrrp.o totemsrp.o totemmrp.o totempg.o tlist.o crypto.o wthread.o
 TOTEM_OBJS = aispoll.o totemip.o totemnet.o totemrrp.o totemsrp.o totemmrp.o totempg.o tlist.o crypto.o wthread.o
@@ -186,7 +182,7 @@ clean:
 	rm -f aisexec $(OBJS) *.o *.lcrso libtotem_pg.so.1.0 libtotem_pg.so.1 libtotem_pg.so libtotem_pg.a gmon.out keygen keygen.o openais-instantiate *.da *.bb *.bbg
 	rm -f aisexec $(OBJS) *.o *.lcrso libtotem_pg.so.1.0 libtotem_pg.so.1 libtotem_pg.so libtotem_pg.a gmon.out keygen keygen.o openais-instantiate *.da *.bb *.bbg
 
 
 depend:
 depend:
-	makedepend -Y -- $(CFLAGS) $(CPPFLAGS) $(EXEC_SRC) $(TOTEM_SRC) > /dev/null 2>&1
+	makedepend -Y -- $(CFLAGS) $(CPPFLAGS) $(EXEC_SRC) $(TOTEM_SRC) $(LCR_SRC) > /dev/null 2>&1
 
 
 # - fPIC rules required for service handler shared objects
 # - fPIC rules required for service handler shared objects
 ../lcr/lcr_ifact.o: ../lcr/lcr_ifact.c
 ../lcr/lcr_ifact.o: ../lcr/lcr_ifact.c
@@ -264,49 +260,82 @@ totemconfig.o: totemconfig.c
 
 
 # DO NOT DELETE
 # DO NOT DELETE
 
 
-main.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
-main.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
-main.o: ../include/queue.h totempg.h aispoll.h totemsrp.h mempool.h amfconfig.h
-main.o: main.h ../include/saClm.h service.h 
-main.o: ../include/saEvt.h swab.h print.h
-clm.o: ../include/saAis.h ../include/saClm.h ../include/saAis.h
-clm.o: ../include/ipc_evs.h  ../include/saClm.h ../include/ipc_gen.h
-clm.o: ../include/ipc_clm.h ../include/list.h ../include/queue.h aispoll.h
-clm.o: totempg.h totemsrp.h amfconfig.h main.h service.h 
-clm.o:  ../include/saEvt.h mempool.h print.h
-amf.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
-amf.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
-amf.o: ../include/queue.h totempg.h aispoll.h totemsrp.h mempool.h util.h
-amf.o: amfconfig.h main.h ../include/saClm.h service.h
-amf.o:  ../include/saEvt.h print.h
-ckpt.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
-ckpt.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
-ckpt.o: ../include/queue.h aispoll.h mempool.h util.h amfconfig.h totempg.h
-ckpt.o: totemsrp.h main.h ../include/saClm.h service.h 
-ckpt.o:  ../include/saEvt.h print.h
-evt.o: ../include/ipc_evt.h ../include/saAis.h ../include/saEvt.h
-evt.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
-evt.o: ../include/queue.h util.h ../include/saAis.h aispoll.h mempool.h
-evt.o: amfconfig.h totempg.h totemsrp.h main.h  ../include/saClm.h
-evt.o: ../include/ipc_evs.h service.h 
-evt.o: ../include/saEvt.h swab.h print.h
-evs.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
-evs.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
-evs.o: ../include/queue.h aispoll.h totempg.h totemsrp.h amfconfig.h main.h 
-evs.o: ../include/saClm.h service.h 
-evs.o: ../include/saEvt.h mempool.h print.h
-amfconfig.o: ../include/saAis.h ../include/list.h util.h amfconfig.h aispoll.h
-amfconfig.o: totempg.h totemsrp.h mempool.h print.h ../include/saClm.h
-amfconfig.o: ../include/saAis.h
-print.o: print.h ../include/saAis.h ../include/saClm.h
-print.o: ../include/saAis.h amfconfig.h ../include/list.h aispoll.h totempg.h
-print.o: totemsrp.h
-mempool.o: ../include/list.h mempool.h
-util.o: ../include/saAis.h ../include/list.h util.h
-aispoll.o: aispoll.h ../include/list.h  ../include/saAis.h tlist.h
-totemsrp.o: aispoll.h totemsrp.h ../include/queue.h ../include/sq.h
-totemsrp.o: ../include/list.h  ../include/saAis.h swab.h crypto.h
-totempg.o: totempg.h aispoll.h totemsrp.h swab.h
+aispoll.o: aispoll.h ../include/list.h ../include/hdb.h tlist.h
+totemip.o: totemip.h swab.h
+totemnet.o: aispoll.h totemnet.h totem.h totemip.h wthread.h
+totemnet.o: ../include/queue.h ../include/sq.h ../include/list.h
+totemnet.o: ../include/hdb.h swab.h crypto.h
+totemrrp.o: ../include/queue.h ../include/sq.h ../include/list.h
+totemrrp.o: ../include/hdb.h swab.h aispoll.h totemnet.h totem.h totemip.h
+totemrrp.o: totemrrp.h
+totemsrp.o: aispoll.h totemsrp.h totem.h totemip.h totemrrp.h wthread.h
+totemsrp.o: ../include/queue.h ../include/sq.h ../include/list.h
+totemsrp.o: ../include/hdb.h swab.h crypto.h
+totemmrp.o: totem.h totemip.h totemsrp.h aispoll.h
+totempg.o: ../include/hdb.h totempg.h aispoll.h totemsrp.h totem.h totemip.h
+totempg.o: totemmrp.h swab.h
 tlist.o: ../include/list.h tlist.h
 tlist.o: ../include/list.h tlist.h
-hdb.o:  ../include/saAis.h
 crypto.o: crypto.h
 crypto.o: crypto.h
+wthread.o: wthread.h ../include/queue.h
+evs.o: ../include/saAis.h ../include/ipc_gen.h ../exec/totemip.h
+evs.o: ../include/ipc_evs.h ../include/saAis.h ../include/evs.h
+evs.o: ../include/ipc_gen.h ../include/list.h ../include/queue.h
+evs.o: ../lcr/lcr_comp.h aispoll.h totempg.h totemsrp.h totem.h totemip.h
+evs.o: main.h ../include/saClm.h mainconfig.h objdb.h mempool.h service.h
+evs.o: print.h
+clm.o: ../include/saAis.h ../include/saClm.h ../include/saAis.h
+clm.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_clm.h
+clm.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
+clm.o: ../include/queue.h ../lcr/lcr_comp.h aispoll.h totempg.h totemsrp.h
+clm.o: totem.h totemip.h main.h mainconfig.h objdb.h mempool.h service.h
+clm.o: print.h
+amf.o: ../include/saAis.h ../include/saAmf.h ../include/saAis.h
+amf.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_amf.h
+amf.o: ../include/ipc_gen.h ../include/ais_amf.h ../include/list.h
+amf.o: ../include/queue.h ../lcr/lcr_comp.h totempg.h aispoll.h totemsrp.h
+amf.o: totem.h totemip.h mempool.h util.h amfconfig.h main.h
+amf.o: ../include/saClm.h mainconfig.h objdb.h service.h print.h
+ckpt.o: ../include/saAis.h ../include/saCkpt.h ../include/ipc_ckpt.h
+ckpt.o: ../include/saAis.h ../include/saCkpt.h ../include/ipc_gen.h
+ckpt.o: ../include/list.h ../include/queue.h ../include/hdb.h
+ckpt.o: ../lcr/lcr_comp.h aispoll.h service.h totem.h totemip.h objdb.h
+ckpt.o: mempool.h util.h main.h ../include/saClm.h ../include/ipc_gen.h
+ckpt.o: ../exec/totemip.h mainconfig.h totemsrp.h totempg.h print.h
+evt.o: ../include/hdb.h ../include/ipc_evt.h ../include/saAis.h
+evt.o: ../include/saEvt.h ../include/saClm.h ../include/ipc_gen.h
+evt.o: ../include/list.h ../include/queue.h ../lcr/lcr_comp.h util.h
+evt.o: ../include/saAis.h service.h totem.h totemip.h objdb.h aispoll.h
+evt.o: mempool.h main.h ../include/saClm.h ../include/ipc_gen.h
+evt.o: ../exec/totemip.h mainconfig.h totemsrp.h totempg.h swab.h print.h
+lck.o: service.h totem.h totemip.h objdb.h ../include/saAis.h
+lck.o: ../include/saLck.h ../include/ipc_lck.h ../include/saAis.h
+lck.o: ../include/saLck.h ../include/ipc_gen.h ../include/list.h
+lck.o: ../include/queue.h ../lcr/lcr_comp.h aispoll.h mempool.h util.h main.h
+lck.o: ../include/saClm.h ../include/ipc_gen.h ../exec/totemip.h mainconfig.h
+lck.o: totemsrp.h totempg.h print.h
+msg.o: ../include/saAis.h ../include/saMsg.h ../include/ipc_msg.h
+msg.o: ../include/saAis.h ../include/saMsg.h ../include/ipc_gen.h
+msg.o: ../include/list.h ../include/queue.h ../lcr/lcr_comp.h service.h
+msg.o: totem.h totemip.h objdb.h aispoll.h mempool.h util.h main.h
+msg.o: ../include/saClm.h ../include/ipc_gen.h ../exec/totemip.h mainconfig.h
+msg.o: totemsrp.h totempg.h print.h
+cfg.o: ../include/saAis.h ../include/openaisCfg.h ../include/saAis.h
+cfg.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_cfg.h
+cfg.o: ../include/ipc_gen.h ../include/openaisCfg.h ../include/list.h
+cfg.o: ../include/queue.h ../lcr/lcr_comp.h service.h totem.h totemip.h
+cfg.o: objdb.h totempg.h aispoll.h totemsrp.h mempool.h util.h print.h
+cfg.o: mainconfig.h
+cpg.o: ../include/saAis.h ../include/saClm.h ../include/saAis.h
+cpg.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_cpg.h
+cpg.o: ../include/ipc_gen.h ../include/list.h ../include/queue.h
+cpg.o: ../lcr/lcr_comp.h aispoll.h totempg.h totemsrp.h totem.h totemip.h
+cpg.o: main.h mainconfig.h objdb.h mempool.h service.h jhash.h swab.h print.h
+amfconfig.o: ../include/saAis.h ../include/saAmf.h ../include/saAis.h
+amfconfig.o: ../include/ipc_amf.h ../include/ipc_gen.h ../include/ais_amf.h
+amfconfig.o: ../include/list.h util.h amfconfig.h aispoll.h mempool.h totem.h
+amfconfig.o: totemip.h
+aisparser.o: ../lcr/lcr_comp.h objdb.h config.h mempool.h ../include/list.h
+vsf_ykd.o: main.h ../include/saAis.h ../include/saClm.h ../include/saAis.h
+vsf_ykd.o: ../include/queue.h ../include/ipc_gen.h ../exec/totemip.h
+vsf_ykd.o: mainconfig.h ../include/list.h aispoll.h totemsrp.h totem.h
+vsf_ykd.o: totemip.h totempg.h objdb.h print.h swab.h vsf.h ../lcr/lcr_comp.h

+ 8 - 3
exec/aisparser.c

@@ -183,13 +183,18 @@ static int read_config_file_into_objdb(
 	char **error_string)
 	char **error_string)
 {
 {
 	FILE *fp;
 	FILE *fp;
+	char *filename;
 	char *error_reason = error_string_response;
 	char *error_reason = error_string_response;
 	int res;
 	int res;
 
 
-	fp = fopen (OPENAIS_CONFDIR "/openais.conf", "r");
+	filename = getenv("OPENAIS_AISPARSER_FILE");
+	if (!filename)
+		filename = "etc/ais/openais.conf";
+
+	fp = fopen (filename, "r");
 	if (fp == 0) {
 	if (fp == 0) {
-		sprintf (error_reason, "Can't read file %s/openais.conf reason = (%s)\n",
-			 OPENAIS_CONFDIR, strerror (errno));
+		sprintf (error_reason, "Can't read file %s reason = (%s)\n",
+			 filename, strerror (errno));
 		*error_string = error_reason;
 		*error_string = error_reason;
 		return -1;
 		return -1;
 	}
 	}

+ 11 - 7
exec/amfconfig.c

@@ -244,6 +244,7 @@ extern int openais_amf_config_read (char **error_string)
 {
 {
 	char line[255];
 	char line[255];
 	FILE *fp;
 	FILE *fp;
+	char *filename;
 	amf_parse_t current_parse = AMF_HEAD;
 	amf_parse_t current_parse = AMF_HEAD;
 	int line_number = 0;
 	int line_number = 0;
 	char *loc;
 	char *loc;
@@ -254,17 +255,20 @@ extern int openais_amf_config_read (char **error_string)
 	struct amf_comp *amf_comp = 0;
 	struct amf_comp *amf_comp = 0;
 	struct amf_si *amf_si = 0;
 	struct amf_si *amf_si = 0;
 	struct amf_healthcheck *amf_healthcheck = 0;
 	struct amf_healthcheck *amf_healthcheck = 0;
-        struct amf_comp_csi_type_name *csi_type_name = 0;
-        struct amf_csi *amf_csi = 0;
-        struct amf_csi_name_value *csi_name_value = NULL;
+	struct amf_comp_csi_type_name *csi_type_name = 0;
+	struct amf_csi *amf_csi = 0;
+	struct amf_csi_name_value *csi_name_value = NULL;
 
 
+	filename = getenv("OPENAIS_AMF_CONFIG_FILE");
+	if (!filename)
+		filename = "etc/ais/groups.conf";
 
 
-	fp = fopen (OPENAIS_CONFDIR "/groups.conf", "r");
+	fp = fopen (filename, "r");
 
 
 	if (fp == 0) {
 	if (fp == 0) {
 		sprintf (error_string_response,
 		sprintf (error_string_response,
-			"Can't read %s/groups.conf file reason = (%s).\n",
-			 OPENAIS_CONFDIR, strerror (errno));
+			"Can't read %s file reason = (%s).\n",
+			 filename, strerror (errno));
 		*error_string = error_string_response;
 		*error_string = error_string_response;
 		return (-1);
 		return (-1);
 	}
 	}
@@ -633,7 +637,7 @@ extern int openais_amf_config_read (char **error_string)
 
 
 parse_error:
 parse_error:
 	sprintf (error_string_response,
 	sprintf (error_string_response,
-		"parse error at %s/groups.conf:%d.\n", OPENAIS_CONFDIR, line_number);
+		"parse error at %s: %d.\n", filename, line_number);
 	*error_string = error_string_response;
 	*error_string = error_string_response;
 	fclose (fp);
 	fclose (fp);
 	return (-1);
 	return (-1);

+ 5 - 4
exec/keygen.c

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

+ 2 - 2
exec/mainconfig.c

@@ -248,10 +248,10 @@ int openais_main_config_read (
 
 
 	/* Default user/group */
 	/* Default user/group */
 	if (!main_config->user)
 	if (!main_config->user)
-		main_config->user = OPENAIS_USER;
+		main_config->user = "ais";
 
 
 	if (!main_config->group)
 	if (!main_config->group)
-		main_config->group = OPENAIS_GROUP;
+		main_config->group = "ais";
 
 
 	if ((main_config->logmode & LOG_MODE_FILE) && main_config->logfile == 0) {
 	if ((main_config->logmode & LOG_MODE_FILE) && main_config->logfile == 0) {
 		error_reason = "logmode set to 'file' but no logfile specified";
 		error_reason = "logmode set to 'file' but no logfile specified";

+ 6 - 3
exec/totemconfig.c

@@ -212,8 +212,8 @@ extern int totem_config_read (
 
 
 		if (interface_max == totem_config->interface_count) {
 		if (interface_max == totem_config->interface_count) {
 			sprintf (error_reason,
 			sprintf (error_reason,
-				 "%d is too many interfaces in %s/network.conf",
-				 totem_config->interface_count, OPENAIS_CONFDIR);
+				 "%d is too many configured interfaces",
+				 totem_config->interface_count);
 			goto parse_error;
 			goto parse_error;
 		}
 		}
 
 
@@ -554,7 +554,10 @@ int totem_config_keyread (
 
 
 	/* In desperation we read the default filename */
 	/* In desperation we read the default filename */
 	if (!got_key) {
 	if (!got_key) {
-		res = read_keyfile(OPENAIS_CONFDIR "/authkey", totem_config, error_string);
+		char *filename = getenv("OPENAIS_TOTEM_AUTHKEY_FILE");
+		if (!filename)
+			filename = "etc/ais/authkey";
+		res = read_keyfile(filename, totem_config, error_string);
 		if (res)
 		if (res)
 			goto key_error;
 			goto key_error;