Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/cgi-src40 In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15349/adminserver/admserv/cgi-src40
Modified Files: config.c Log Message: Resolves: bug 248184 Bug Description: adminserver: The config CGI program does not preserve Listen IP addr Reviewed by: ??? Fix Description: Move the existing code into a new function. This function will set the Listen directive IP and port, preserving any existing values. Platforms tested: RHEL4, FC6 Flag Day: no Doc impact: no
Index: config.c =================================================================== RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/config.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- config.c 6 Jul 2007 18:06:19 -0000 1.12 +++ config.c 13 Jul 2007 19:47:15 -0000 1.13 @@ -99,6 +99,43 @@ static int change_server_uid(PsetHndl pset, char* newuname); #endif
+static int +update_port_addr(char *port, char *addr) +{ + char line[BIG_LINE]; + char *val = read_conf("console.conf", "Listen"); + char *ptr = NULL; + int err; + + if (val) { + ptr = strchr(val, ':'); + } + + if (ptr) { + *ptr = '\0'; + ++ptr; /* ptr points to the start of the port number in host:port */ + } else if (val) { + ptr = val; /* Listen only specifies the port number */ + val = "0.0.0.0"; /* default listen on all interfaces */ + } else { + /* console.conf should always have Listen with the server port */ + ptr = "80"; /* default httpd port? */ + val = "0.0.0.0"; + } + /* + If ip address is not defined, it means that server should + listen on all interfaces. This is dependant upon console + to always include the port string first. + */ + PR_snprintf(line, sizeof(line), "%s:%s", + (addr && *addr) ? addr : val, + (port && *port) ? port : ptr); + err = update_conf("console.conf", "Listen", line); + PL_strfree(val); + + return err; +} + int main(int argc, char *argv[]) { int _ai = ADMUTIL_Init(); @@ -451,7 +488,7 @@ } if(err == 0) { - err = update_conf("console.conf", "Listen", valptr); + err = update_port_addr(valptr, NULL); /* update port only */ }
if (err < 0) @@ -495,34 +532,7 @@ rpt_err(APP_ERROR, error_info, NULL, NULL); } else { - char line[BIG_LINE]; - char *val = read_conf("console.conf", "Listen"); - char *ptr = NULL; - - if (val) { - ptr = strchr(val, ':'); - } - - if (ptr) { - ++ptr; /* ptr points to the start of the port number in host:port */ - } else if (val) { - ptr = val; /* Listen only specifies the port number */ - } else { - /* console.conf should always have Listen with the server port */ - ptr = "80"; /* default httpd port? */ - } - /* - If ip address is not defined, it means that server should - listen on all interfaces. This is dependant upon console - to always include the port string first. - */ - if (valptr && valptr[0] ) { - PR_snprintf(line, sizeof(line), "%s:%s", valptr, ptr); - } else { - PR_snprintf(line, sizeof(line), "0.0.0.0:%s", ptr); - } - err = update_conf("console.conf", "Listen", line); - PL_strfree(val); + err = update_port_addr(NULL, valptr); /* update address only */ } }
389-commits@lists.fedoraproject.org