[Fedora-directory-commits] ldapserver/ldap/servers/snmp main.c, 1.12, 1.13

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Thu Oct 18 01:22:31 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/servers/snmp
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3959/ldapserver/ldap/servers/snmp

Modified Files:
	main.c 
Log Message:
Resolves: bug 250179
Description: tmpwatch whacks stats
Reviewed by: nkinder (Thanks!)
Fix Description: move the snmp slapd.stats file to run_dir (/var/run/dirsrv) and rename to slapd-instance.stats.  Had to add nsslapd-rundir to cn=config in order for ldap-agent to be able to get it.
Doc: Yes, we need to document the new attribute nsslapd-rundir.



Index: main.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/snmp/main.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- main.c	15 Oct 2007 19:19:32 -0000	1.12
+++ main.c	18 Oct 2007 01:22:29 -0000	1.13
@@ -318,6 +318,7 @@
             int got_tmpdir = 0;
             int lineno = 0;
             char *entry = NULL;
+            char *instancename = NULL;
 
             /* Allocate a server_instance */
             if ((serv_p = malloc(sizeof(server_instance))) == NULL) {
@@ -330,6 +331,7 @@
             p = p + 6;
             if ((p = strtok(p, " \t\n")) != NULL) {
                 /* first token is the instance name */
+                instancename = strdup(p);
                 serv_p->dse_ldif = malloc(strlen(p) + strlen(SYSCONFDIR) +
                                            strlen(PACKAGE_NAME) + 12);
                 if (serv_p->dse_ldif != NULL) {
@@ -341,6 +343,8 @@
                 } else {
                     printf("ldap-agent: malloc error processing config file\n");
                     error = 1;
+                    free(instancename);
+                    instancename = NULL;
                     goto close_and_exit;
                 }
             }
@@ -350,6 +354,8 @@
                 printf("ldap-agent: Error opening server config file: %s\n",
                         serv_p->dse_ldif);
                 error = 1;
+                free(instancename);
+                instancename = NULL;
                 goto close_and_exit;
             }
 
@@ -376,16 +382,18 @@
                         if (strcmp(attr, "nsslapd-port") == 0) {
                             serv_p->port = atol(val);
                             got_port = 1;
-                        } else if (strcmp(attr, "nsslapd-tmpdir") == 0) {
+                        } else if (strcmp(attr, "nsslapd-rundir") == 0) {
                             serv_p->stats_file = malloc(vlen + 13);
                             if (serv_p->stats_file != NULL) {
                                 snprintf(serv_p->stats_file, vlen + 13,
-                                         "%s/slapd.stats", val);
+                                         "%s/%s.stats", instancename, val);
                                 serv_p->stats_file[(vlen + 12)] = (char)0;
                             } else {
                                 printf("ldap-agent: malloc error processing config file\n");
                                 free(entry);
                                 error = 1;
+                                free(instancename);
+                                instancename = NULL;
                                 goto close_and_exit;
                             }
                             got_tmpdir = 1;
@@ -404,6 +412,8 @@
                 }
             }
 
+            free(instancename);
+            instancename = NULL;
             /* We're done reading entries from dse_ldif now, so
              * we can free entry */
             free(entry);




More information about the Fedora-directory-commits mailing list