summaryrefslogtreecommitdiffstats
path: root/ldap
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2007-10-18 01:22:29 +0000
committerRich Megginson <rmeggins@redhat.com>2007-10-18 01:22:29 +0000
commit33c33e1cfde3580cb74a7b69bf8c5e3545362c0b (patch)
treef67e4305224dc0ee4e86bfa53a0195726ffc017b /ldap
parent19cd513a509aa6e45361df774e74f2d39451e08a (diff)
downloadds-33c33e1cfde3580cb74a7b69bf8c5e3545362c0b.tar.gz
ds-33c33e1cfde3580cb74a7b69bf8c5e3545362c0b.tar.xz
ds-33c33e1cfde3580cb74a7b69bf8c5e3545362c0b.zip
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.
Diffstat (limited to 'ldap')
-rw-r--r--ldap/admin/src/scripts/dscreate.map.in1
-rw-r--r--ldap/ldif/template-dse.ldif.in1
-rw-r--r--ldap/servers/slapd/agtmmap.h3
-rw-r--r--ldap/servers/slapd/libglobs.c41
-rw-r--r--ldap/servers/slapd/proto-slap.h2
-rw-r--r--ldap/servers/slapd/slap.h2
-rw-r--r--ldap/servers/slapd/snmp_collator.c19
-rw-r--r--ldap/servers/snmp/main.c14
8 files changed, 76 insertions, 7 deletions
diff --git a/ldap/admin/src/scripts/dscreate.map.in b/ldap/admin/src/scripts/dscreate.map.in
index a475416a..7cb13f94 100644
--- a/ldap/admin/src/scripts/dscreate.map.in
+++ b/ldap/admin/src/scripts/dscreate.map.in
@@ -65,3 +65,4 @@ inst_dir = inst_dir
log_dir = log_dir
config_dir = config_dir
db_dir = db_dir
+run_dir = run_dir
diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in
index ba064d8e..c9b4556f 100644
--- a/ldap/ldif/template-dse.ldif.in
+++ b/ldap/ldif/template-dse.ldif.in
@@ -9,6 +9,7 @@ nsslapd-tmpdir: %tmp_dir%
nsslapd-certdir: %cert_dir%
nsslapd-ldifdir: %ldif_dir%
nsslapd-bakdir: %bak_dir%
+nsslapd-rundir: %run_dir%
nsslapd-instancedir: %inst_dir%
nsslapd-accesslog-logging-enabled: on
nsslapd-accesslog-maxlogsperdir: 10
diff --git a/ldap/servers/slapd/agtmmap.h b/ldap/servers/slapd/agtmmap.h
index 4ee660a8..e329324d 100644
--- a/ldap/servers/slapd/agtmmap.h
+++ b/ldap/servers/slapd/agtmmap.h
@@ -79,7 +79,8 @@ extern int errno;
#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
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 27075140..21ffa4c2 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -573,6 +573,10 @@ static struct config_get_and_set {
{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 @@ config_set_bakdir(const char *attrname, char *value, char *errorbuf, int apply)
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()
{
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 571f4edc..b27b74b4 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -326,6 +326,7 @@ int config_set_tmpdir( const char *attrname, char *value, char *errorbuf, int ap
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_tmpdir();
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();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index f10e8fb2..f1777eb8 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1727,6 +1727,7 @@ typedef struct _slapdEntryPoints {
#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 @@ typedef struct _slapdFrontendConfig {
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 */
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
index 016b55c8..0aadf9b6 100644
--- a/ldap/servers/slapd/snmp_collator.c
+++ b/ldap/servers/slapd/snmp_collator.c
@@ -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 snmp_collator_start()
{
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 @@ int snmp_collator_start()
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))
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 6648776e..8200d04d 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -318,6 +318,7 @@ load_config(char *conf_path)
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 @@ load_config(char *conf_path)
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 @@ load_config(char *conf_path)
} else {
printf("ldap-agent: malloc error processing config file\n");
error = 1;
+ free(instancename);
+ instancename = NULL;
goto close_and_exit;
}
}
@@ -350,6 +354,8 @@ load_config(char *conf_path)
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 @@ load_config(char *conf_path)
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 @@ load_config(char *conf_path)
}
}
+ free(instancename);
+ instancename = NULL;
/* We're done reading entries from dse_ldif now, so
* we can free entry */
free(entry);