Index: cluster_mgr.c =================================================================== RCS file: /cvs/cluster/cluster/ccs/daemon/cluster_mgr.c,v retrieving revision 1.10.2.5 diff -u -r1.10.2.5 cluster_mgr.c --- cluster_mgr.c 18 Jan 2005 16:53:06 -0000 1.10.2.5 +++ cluster_mgr.c 9 Jun 2005 06:23:11 -0000 @@ -86,6 +86,7 @@ static int handle_cluster_message(int fd){ int error = 0; int afd= -1; + int cfd= NULL; FILE *fp = NULL; int unlock=0; char *buffer = NULL; @@ -154,9 +155,15 @@ goto fail; } - fp = fopen("/etc/cluster/cluster.conf-update", "w"); + cfd = open("/etc/cluster/cluster.conf-update", O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP); + if(!cfd){ + log_sys_err("Unable to open file /etc/cluster/cluster.conf-update"); + error = -errno; + goto fail; + } + fp = fdopen(cfd, "w"); if(!fp){ - log_sys_err("Unable to open /etc/cluster/cluster.conf-update"); + log_sys_err("Unable to open stream /etc/cluster/cluster.conf-update"); error = -errno; goto fail; } @@ -204,9 +211,15 @@ goto fail; } - fp = fopen("/etc/cluster/.cluster.conf", "w"); + cfd = open("/etc/cluster/cluster.conf-update", O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP); + if(!cfd){ + log_sys_err("Unable to open file /etc/cluster/cluster.conf-update"); + error = -errno; + goto fail; + } + fp = fdopen(cfd, "w"); if(!fp){ - log_sys_err("Unable to open /etc/cluster/.cluster.conf"); + log_sys_err("Unable to open stream /etc/cluster/.cluster.conf"); error = -errno; goto fail; } @@ -231,6 +244,9 @@ if(fp){ fclose(fp); } + if(fd){ + close(fd); + } if(afd >= 0){ msg_close(afd); } Index: cnx_mgr.c =================================================================== RCS file: /cvs/cluster/cluster/ccs/daemon/cnx_mgr.c,v retrieving revision 1.24.2.6.2.2 diff -u -r1.24.2.6.2.2 cnx_mgr.c --- cnx_mgr.c 26 May 2005 16:55:37 -0000 1.24.2.6.2.2 +++ cnx_mgr.c 9 Jun 2005 06:23:11 -0000 @@ -154,6 +154,8 @@ fd_set rset; struct timeval tv; xmlDocPtr tmp_doc = NULL; + int cfd = NULL; + FILE *f = NULL; ENTER("broadcast_for_doc"); @@ -411,7 +413,6 @@ if(write_to_disk){ struct stat stat_buf; - FILE *f; /* We did not have a copy available or we found a newer one, so write it out */ /* ATTENTION -- its bad if we fail here, because we have an in-memory version ** @@ -427,21 +428,27 @@ error = -ENOTDIR; goto fail; } - f = fopen("/etc/cluster/cluster.conf", "w"); + cfd = open("/etc/cluster/cluster.conf", O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP); + if(!cfd){ + log_sys_err("Unable to open file /etc/cluster/cluster.conf"); + error = -errno; + goto fail; + } + f = fdopen(cfd, "w"); if(!f){ - log_sys_err("Unable to open /etc/cluster/cluster.conf"); + log_sys_err("Unable to open stream /etc/cluster/cluster.conf"); error = -errno; goto fail; } if(xmlDocDump(f, master_doc->od_doc) < 0){ error = -EIO; - fclose(f); goto fail; } - fclose(f); } fail: + if(f) fclose(f); + if(cfd) close(cfd); if(ch) free(ch); if(bdoc) free(bdoc); if(tmp_doc) xmlFreeDoc(tmp_doc);