Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3959/ldapserver/ldap/servers/slapd
Modified Files:
agtmmap.h libglobs.c proto-slap.h slap.h snmp_collator.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: agtmmap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/agtmmap.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- agtmmap.h 10 Nov 2006 23:45:40 -0000 1.10
+++ agtmmap.h 18 Oct 2007 01:22:29 -0000 1.11
@@ -79,7 +79,8 @@
#if !defined(_MAX_PATH)
#define _MAX_PATH 256
#endif
-#define AGT_STATS_FILE "slapd.stats"
+#define AGT_STATS_EXTENSION ".stats"
+#define AGT_STATS_FILE "slapd" AGT_STATS_EXTENSION
#define AGT_MJR_VERSION 1
#define AGT_MNR_VERSION 0
Index: libglobs.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/libglobs.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- libglobs.c 5 Oct 2007 17:00:04 -0000 1.22
+++ libglobs.c 18 Oct 2007 01:22:29 -0000 1.23
@@ -573,6 +573,10 @@
{CONFIG_SASLPATH_ATTRIBUTE, config_set_saslpath,
NULL, 0,
(void**)&global_slapdFrontendConfig.saslpath, CONFIG_STRING, (ConfigGetFunc)config_get_saslpath},
+ /* parameterizing run dir */
+ {CONFIG_RUNDIR_ATTRIBUTE, config_set_rundir,
+ NULL, 0,
+ (void**)&global_slapdFrontendConfig.rundir, CONFIG_STRING, (ConfigGetFunc)config_get_rundir},
{CONFIG_REWRITE_RFC1274_ATTRIBUTE, config_set_rewrite_rfc1274,
NULL, 0,
(void**)&global_slapdFrontendConfig.rewrite_rfc1274, CONFIG_ON_OFF, NULL},
@@ -4728,6 +4732,43 @@
CFG_UNLOCK_WRITE(slapdFrontendConfig);
return retVal;
}
+
+char *
+config_get_rundir()
+{
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+ char *retVal;
+
+ CFG_LOCK_READ(slapdFrontendConfig);
+ retVal = config_copy_strval(slapdFrontendConfig->rundir);
+ CFG_UNLOCK_READ(slapdFrontendConfig);
+
+ return retVal;
+}
+
+int
+config_set_rundir(const char *attrname, char *value, char *errorbuf, int apply)
+{
+ int retVal = LDAP_SUCCESS;
+ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+ if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
+ if (!apply) {
+ return retVal;
+ }
+
+ CFG_LOCK_WRITE(slapdFrontendConfig);
+ slapi_ch_free((void **)&slapdFrontendConfig->rundir);
+
+ slapdFrontendConfig->rundir = slapi_ch_strdup(value);
+
+ CFG_UNLOCK_WRITE(slapdFrontendConfig);
+ return retVal;
+}
+
char *
config_get_saslpath()
{
Index: proto-slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- proto-slap.h 18 Oct 2007 00:08:34 -0000 1.30
+++ proto-slap.h 18 Oct 2007 01:22:29 -0000 1.31
@@ -326,6 +326,7 @@
int config_set_certdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldifdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_bakdir( const char *attrname, char *value, char *errorbuf, int apply );
+int config_set_rundir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_saslpath( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_attrname_exceptions( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_hash_filters( const char *attrname, char *value, char *errorbuf, int apply );
@@ -438,6 +439,7 @@
char *config_get_certdir();
char *config_get_ldifdir();
char *config_get_bakdir();
+char *config_get_rundir();
char *config_get_saslpath();
char **config_get_errorlog_list();
char **config_get_accesslog_list();
Index: slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slap.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- slap.h 18 Oct 2007 00:08:34 -0000 1.29
+++ slap.h 18 Oct 2007 01:22:29 -0000 1.30
@@ -1727,6 +1727,7 @@
#define CONFIG_LDIFDIR_ATTRIBUTE "nsslapd-ldifdir"
#define CONFIG_BAKDIR_ATTRIBUTE "nsslapd-bakdir"
#define CONFIG_SASLPATH_ATTRIBUTE "nsslapd-saslpath"
+#define CONFIG_RUNDIR_ATTRIBUTE "nsslapd-rundir"
#define CONFIG_SSLCLIENTAUTH_ATTRIBUTE "nsslapd-SSLclientAuth"
#define CONFIG_SSL_CHECK_HOSTNAME_ATTRIBUTE "nsslapd-ssl-check-hostname"
#define CONFIG_HASH_FILTERS_ATTRIBUTE "nsslapd-hash-filters"
@@ -1906,6 +1907,7 @@
char *certdir; /* full path name of directory containing cert files */
char *ldifdir; /* full path name of directory containing ldif files */
char *bakdir; /* full path name of directory containing bakup files */
+ char *rundir; /* where pid, snmp stats, and ldapi files go */
char *saslpath; /* full path name of directory containing sasl plugins */
int attrname_exceptions; /* if true, allow questionable attribute names */
int rewrite_rfc1274; /* return attrs for both v2 and v3 names */
Index: snmp_collator.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/snmp_collator.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- snmp_collator.c 18 Oct 2007 00:08:34 -0000 1.11
+++ snmp_collator.c 18 Oct 2007 01:22:29 -0000 1.12
@@ -60,6 +60,7 @@
#include "prlock.h"
#include "prerror.h"
#include "prcvar.h"
+#include "plstr.h"
#include "snmp_collator.h"
#include "../snmp/ntagt/nslagtcom_nt.h"
@@ -397,8 +398,10 @@
{
int err;
- char *statspath = config_get_tmpdir();
+ char *statspath = config_get_rundir();
char *lp = NULL;
+ char *instdir = config_get_configdir();
+ char *instname = NULL;
/*
* Get directory for our stats file
@@ -407,10 +410,18 @@
statspath = slapi_ch_strdup("/tmp");
}
- PR_snprintf(szStatsFile, sizeof(szStatsFile), "%s/%s",
- statspath, AGT_STATS_FILE);
+ instname = PL_strrstr(instdir, "slapd-");
+ if (!instname) {
+ instname = PL_strrstr(instdir, "/");
+ if (instname) {
+ instname++;
+ }
+ }
+ PR_snprintf(szStatsFile, sizeof(szStatsFile), "%s/%s%s",
+ statspath, instname, AGT_STATS_EXTENSION);
tmpstatsfile = szStatsFile;
- slapi_ch_free((void **) &statspath);
+ slapi_ch_free_string(&statspath);
+ slapi_ch_free_string(&instname);
/* open the memory map */
if ((err = agt_mopen_stats(tmpstatsfile, O_RDWR, &hdl) != 0))