Skip to contentSkip to conversation

chunkd: add ForceHost

PATCH Applied Pete Zaitcev 2 participants 2 messages Sep 29, 2009 – Sep 30, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 chunkd: add ForceHost

Add the same crutch that tabled has, to help with misconfigured build machines.

server/config.c +6 -0
diff -urp -X dontdiff chunkd/server/config.c chunkd-force/server/config.c
@@ -256,6 +256,12 @@ static void cfg_elm_end (GMarkupParseCon
 		cc->text = NULL;
 	}
 
+	else if (!strcmp(element_name, "ForceHost") && cc->text) {
+		free(chunkd_srv.ourhost);
+		chunkd_srv.ourhost = cc->text;
+		cc->text = NULL;
+	}
+
 	else if (!strcmp(element_name, "Path") && cc->text) {
 		if (stat(cc->text, &st) < 0) {
 			applog(LOG_ERR, "stat(2) cfgfile Path '%s' failed: %s",
server/server.c +5 -1
diff -urp -X dontdiff chunkd/server/server.c chunkd-force/server/server.c
@@ -1284,7 +1284,11 @@ int main (int argc, char *argv[])
 	 * early as possible, so that tunables are available.
 	 */
 	read_config();
-	chunkd_srv.ourhost = get_hostname();
+	if (!chunkd_srv.ourhost)
+		chunkd_srv.ourhost = get_hostname();
+	else if (debugging)
+		applog(LOG_INFO, "Forcing local hostname to %s",
+		       chunkd_srv.ourhost);
 
 	/*
 	 * For example, backgrounding and PID file should be done early
test/server-test.cfg +1 -0
diff -urp -X dontdiff chunkd/test/server-test.cfg chunkd-force/test/server-test.cfg
@@ -1,4 +1,5 @@
 
+<ForceHost>localhost.localdomain</ForceHost>
 <SSL>
 	<PrivateKey>ssl-key.pem</PrivateKey>
 	<Cert>ssl-cert.pem</Cert>