repo: ngircd
action: commit
revision: 
path_from: 
revision_from: bc88b2cb06a1663210de5f517a99687713ec91c3:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit bc88b2cb06a1663210de5f517a99687713ec91c3
Author: Florian Westphal 
Date:   Sat Oct 17 14:31:27 2009 +0200

    configtest: print ssl config options even when unset

    Print "SSLOptionVar =" instead of omitting the option when
    running --configtest with ssl enabled.
    This better matches the behaviour of other options, e.g.  ChrootDir.

diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index c728d55f504a40f3020c593dd4afd49991e98500..
index ..2b592b16d3ce44931aff3b047198d3c50488234d 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -96,38 +96,42 @@ ConfSSL_Init(void)
 }

 static bool
-can_open(const char *name, const char *file)
+ssl_print_configvar(const char *name, const char *file)
 {
-	FILE *fp = fopen(file, "r");
+	FILE *fp;
+
+	if (!file) {
+		printf("  %s =\n", name);
+		return true;
+	}
+
+	fp = fopen(file, "r");
 	if (fp)
 		fclose(fp);
 	else
 		fprintf(stderr, "ERROR: %s \"%s\": %s\n",
 			name, file, strerror(errno));
+
+	printf("  %s = %s\n", name, file);
 	return fp != NULL;
 }

 static bool
 ConfSSL_Puts(void)
 {
-	bool ret = true;
+	bool ret;
+
+	ret = ssl_print_configvar("SSLKeyFile", Conf_SSLOptions.KeyFile);
+
+	if (!ssl_print_configvar("SSLCertFile", Conf_SSLOptions.CertFile))
+		ret = false;
+
+	if (!ssl_print_configvar("SSLDHFile", Conf_SSLOptions.DHFile))
+		ret = false;

-	if (Conf_SSLOptions.KeyFile) {
-		printf( "  SSLKeyFile = %s\n", Conf_SSLOptions.KeyFile);
-		ret = can_open("SSLKeyFile", Conf_SSLOptions.KeyFile);
-	}
-	if (Conf_SSLOptions.CertFile) {
-		printf( "  SSLCertFile = %s\n", Conf_SSLOptions.CertFile);
-		if (!can_open("SSLCertFile", Conf_SSLOptions.CertFile))
-			ret = false;
-	}
-	if (Conf_SSLOptions.DHFile) {
-		printf( "  SSLDHFile = %s\n", Conf_SSLOptions.DHFile);
-		if (!can_open("SSLDHFile", Conf_SSLOptions.DHFile))
-			ret = false;
-	}
 	if (array_bytes(&Conf_SSLOptions.KeyFilePassword))
-		puts("  SSLKeyFilePassword = "  );
+		puts("  SSLKeyFilePassword = ");
+
 	array_free_wipe(&Conf_SSLOptions.KeyFilePassword);

 	return ret;

-----END OF PAGE-----