summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--component_versions.mk12
-rw-r--r--components.mk11
-rw-r--r--internal_comp_deps.mk35
-rw-r--r--ldap/schema/00core.ldif3
-rw-r--r--ldap/servers/slapd/agtmmap.c10
-rw-r--r--ldap/servers/slapd/agtmmap.h5
-rw-r--r--ldap/servers/slapd/fedse.c3
-rw-r--r--ldap/servers/slapd/snmp_collator.c82
-rw-r--r--ldap/servers/slapd/snmp_collator.h12
-rw-r--r--ldap/servers/snmp/ldap-agent.c44
-rw-r--r--ldap/servers/snmp/ldap-agent.h5
-rw-r--r--ldap/servers/snmp/main.c85
12 files changed, 185 insertions, 122 deletions
diff --git a/component_versions.mk b/component_versions.mk
index 50e31f55..d0abbef6 100644
--- a/component_versions.mk
+++ b/component_versions.mk
@@ -34,7 +34,7 @@ ifndef DB_MAJOR_MINOR
DB_MAJOR_MINOR:=db42
endif
ifndef DB_VERSION
- DB_VERSION:=DS7.0
+ DB_VERSION:=20040813
endif
# DBM Library
@@ -103,7 +103,7 @@ endif
# setup sdk
ifndef SETUP_SDK_RELDATE
- SETUP_SDK_RELDATE = 20050317
+ SETUP_SDK_RELDATE = 20050330
endif
ifndef SETUPSDK_VER
SETUPSDK_VER = 70
@@ -128,7 +128,7 @@ ifndef ADMINUTIL_VER
ADMINUTIL_VER=70
endif
ifndef ADMINUTIL_RELDATE
- ADMINUTIL_RELDATE=20050316
+ ADMINUTIL_RELDATE=20050330
endif
ifndef ADMINUTIL_VERSDIR
@@ -143,11 +143,11 @@ ifndef LDAPCONSOLE_COMP
LDAPCONSOLE_COMP = ldapconsole$(LDAPCONSOLE_REL)
endif
ifndef LDAPCONSOLE_RELDATE
- LDAPCONSOLE_RELDATE=20050321
+ LDAPCONSOLE_RELDATE=20050330
endif
ifndef PERLDAP_VERSION
- PERLDAP_VERSION=20050325
+ PERLDAP_VERSION=20050330
endif
ifndef JSS_COMP
@@ -187,7 +187,7 @@ ifndef ICU_VERSDIR
ICU_VERSDIR=libicu_2_4
endif
ifndef ICU_RELDATE
- ICU_RELDATE=DS7.0
+ ICU_RELDATE=20040820
endif
# DOC
diff --git a/components.mk b/components.mk
index a5e51c52..437993b2 100644
--- a/components.mk
+++ b/components.mk
@@ -451,17 +451,6 @@ PACKAGE_SRC_DEST += $(wildcard $(DB_LIBPATH)/*.$(DLL_SUFFIX)) bin/slapd/server
### DB component (Berkeley DB) ############################
-### DOCS #################################
-# this is where the build looks for slapd docs
-DSDOC_DIR = $(ABS_ROOT)/../dist/dsdoc
-DSDOC_VERSDIR = $(DIR_NORM_VERSION)$(BUILD_MODE)
-DSDOC_RELEASE = $(COMPONENTS_DIR_DEV)/ldapserverdoc/$(DSDOC_VERSDIR)/$(DSDOC_RELDATE)
-
-DSDOC_CLIENTS = slapd_clients.zip
-DSDOC_COPYRIGHT = slapd_copyright.zip
-DSDOC_FILES = $(DSDOC_COPYRIGHT),$(DSDOC_CLIENTS)
-### DOCS END #############################
-
# must define dependencies last because they depend on the definitions above
ifeq ($(INTERNAL_BUILD), 1)
include $(BUILD_ROOT)/internal_comp_deps.mk
diff --git a/internal_comp_deps.mk b/internal_comp_deps.mk
index 956a9e1a..c4f79dec 100644
--- a/internal_comp_deps.mk
+++ b/internal_comp_deps.mk
@@ -175,8 +175,8 @@ ifndef LDAP_VERSION
LDAP_VERSION = $(LDAP_RELDATE)
endif
ifndef LDAP_SBC
-LDAP_SBC = $(COMPONENTS_DIR_DEV)
-#LDAP_SBC = $(COMPONENTS_DIR)
+#LDAP_SBC = $(COMPONENTS_DIR_DEV)
+LDAP_SBC = $(COMPONENTS_DIR)
endif
LDAPOBJDIR = $(FULL_RTL_OBJDIR)
# LDAP does not have PTH version, so here is the hack which treat non PTH
@@ -211,8 +211,8 @@ endif
endif # LDAPSDK_SOURCE_ROOT
ifndef SASL_SOURCE_ROOT
-SASL_RELEASE = $(COMPONENTS_DIR_DEV)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME)
-#SASL_RELEASE = $(COMPONENTS_DIR)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME)
+#SASL_RELEASE = $(COMPONENTS_DIR_DEV)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME)
+SASL_RELEASE = $(COMPONENTS_DIR)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME)
SASL_DEP = $(SASL_INCLUDE)/sasl.h
ifndef SASL_PULL_METHOD
SASL_PULL_METHOD = $(COMPONENT_PULL_METHOD)
@@ -291,8 +291,8 @@ endif # DB_SOURCE_ROOT
ADMINUTIL_VERSION=$(ADMINUTIL_RELDATE)
ADMINUTIL_BASE=adminsdk/$(ADMINUTIL_VERSDIR)/${ADMINUTIL_VERSION}
ADMSDKOBJDIR = $(FULL_RTL_OBJDIR)
-#ADMINUTIL_IMPORT=$(COMPONENTS_DIR)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
-ADMINUTIL_IMPORT=$(COMPONENTS_DIR_DEV)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
+ADMINUTIL_IMPORT=$(COMPONENTS_DIR)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
+#ADMINUTIL_IMPORT=$(COMPONENTS_DIR_DEV)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
# this is the base directory under which the component's files will be found
# during the build process
ADMINUTIL_BUILD_DIR=$(NSCP_DISTDIR_FULL_RTL)/adminutil
@@ -337,7 +337,8 @@ endif
# Net-SNMP
ifndef NETSNMP_SOURCE_ROOT
-NETSNMP_RELEASE = $(COMPONENTS_DIR_DEV)/net-snmp/$(NETSNMP_VER)/$(NSOBJDIR_NAME)
+#NETSNMP_RELEASE = $(COMPONENTS_DIR_DEV)/net-snmp/$(NETSNMP_VER)/$(NSOBJDIR_NAME)
+NETSNMP_RELEASE = $(COMPONENTS_DIR)/net-snmp/$(NETSNMP_VER)/$(NSOBJDIR_NAME)
NETSNMP_DEP = $(NETSNMP_INCDIR)/net-snmp/net-snmp-includes.h
ifndef NETSNMP_PULL_METHOD
NETSNMP_PULL_METHOD = $(COMPONENT_PULL_METHOD)
@@ -360,8 +361,8 @@ endif # NETSNMP_SOURCE_ROOT
# this is where the build looks for setupsdk components
SETUP_SDK_BUILD_DIR = $(NSCP_DISTDIR)/setupsdk
SETUPSDK_VERSION = $(SETUP_SDK_RELDATE)
-#SETUPSDK_RELEASE = $(COMPONENTS_DIR)/setupsdk/$(SETUPSDK_VERSDIR)/$(SETUPSDK_VERSION)/$(NSOBJDIR_NAME)
-SETUPSDK_RELEASE = $(COMPONENTS_DIR_DEV)/setupsdk/$(SETUPSDK_VERSDIR)/$(SETUPSDK_VERSION)/$(NSOBJDIR_NAME)
+SETUPSDK_RELEASE = $(COMPONENTS_DIR)/setupsdk/$(SETUPSDK_VERSDIR)/$(SETUPSDK_VERSION)/$(NSOBJDIR_NAME)
+#SETUPSDK_RELEASE = $(COMPONENTS_DIR_DEV)/setupsdk/$(SETUPSDK_VERSDIR)/$(SETUPSDK_VERSION)/$(NSOBJDIR_NAME)
SETUPSDK_LIBPATH = $(SETUP_SDK_BUILD_DIR)/lib
SETUPSDK_INCDIR = $(SETUP_SDK_BUILD_DIR)/include
SETUPSDK_BINPATH = $(SETUP_SDK_BUILD_DIR)/bin
@@ -571,7 +572,8 @@ endif
LDAPCONSOLEJAR = ds$(LDAPCONSOLE_REL).jar
LDAPCONSOLEJAR_EN = ds$(LDAPCONSOLE_REL)_en.jar
-LDAPCONSOLE_RELEASE=$(COMPONENTS_DIR_DEV)
+#LDAPCONSOLE_RELEASE=$(COMPONENTS_DIR_DEV)
+LDAPCONSOLE_RELEASE=$(COMPONENTS_DIR)
LDAPCONSOLE_JARDIR = $(LDAPCONSOLE_RELEASE)/ldapconsole/$(LDAPCONSOLE_COMP)$(BUILD_MODE)/$(LDAPCONSOLE_RELDATE)/jars
LDAPCONSOLE_DEP = $(CLASS_DEST)/$(LDAPCONSOLEJAR)
LDAPCONSOLE_FILES=$(LDAPCONSOLEJAR),$(LDAPCONSOLEJAR_EN)
@@ -593,7 +595,8 @@ endif
###########################################################
### Perldap package #######################################
-PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR_DEV)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32)
+#PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR_DEV)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32)
+PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32)
PERLDAP_ZIP_FILE = perldap14.zip
###########################################################
@@ -712,6 +715,16 @@ endif
### Admin Server END ######################################
### DOCS #################################
+# this is where the build looks for slapd docs
+DSDOC_DIR = $(ABS_ROOT)/../dist/dsdoc
+DSDOC_VERSDIR = $(DIR_NORM_VERSION)$(BUILD_MODE)
+#DSDOC_RELEASE = $(COMPONENTS_DIR_DEV)/ldapserverdoc/$(DSDOC_VERSDIR)/$(DSDOC_RELDATE)
+DSDOC_RELEASE = $(COMPONENTS_DIR)/ldapserverdoc/$(DSDOC_VERSDIR)/$(DSDOC_RELDATE)
+
+DSDOC_CLIENTS = slapd_clients.zip
+DSDOC_COPYRIGHT = slapd_copyright.zip
+DSDOC_FILES = $(DSDOC_COPYRIGHT),$(DSDOC_CLIENTS)
+
ifeq ($(BUILD_MODE), int)
DSDOC_GUIDES = slapd_guides.zip
DSDOC_FILES = $(DSDOC_COPYRIGHT),$(DSDOC_CLIENTS),$(DSDOC_GUIDES)
diff --git a/ldap/schema/00core.ldif b/ldap/schema/00core.ldif
index 4d04fcd7..1a7d95da 100644
--- a/ldap/schema/00core.ldif
+++ b/ldap/schema/00core.ldif
@@ -188,6 +188,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.235 NAME 'nsSNMPContact' DESC 'Netscape
attributeTypes: ( 2.16.840.1.113730.3.1.236 NAME 'nsSNMPDescription' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.237 NAME 'nsSNMPMasterHost' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.238 NAME 'nsSNMPMasterPort' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.593 NAME 'nsSNMPName' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.241 NAME 'displayName' DESC 'inetOrgPerson attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'RFC 2798' )
attributeTypes: ( 2.16.840.1.113730.3.1.242 NAME 'nsSystemIndex' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.327 NAME 'nsIndexType' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' )
@@ -316,7 +317,7 @@ objectClasses: ( 2.16.840.1.113730.3.2.39 NAME 'nsslapdConfig' DESC 'Netscape de
objectClasses: ( 2.16.840.1.113730.3.2.40 NAME 'directoryServerFeature' DESC 'Netscape defined objectclass' SUP top MAY ( oid $ cn $ multiLineDescription ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.41 NAME 'nsslapdPlugin' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsslapd-pluginPath $ nsslapd-pluginInitFunc $ nsslapd-pluginType $ nsslapd-pluginId $ nsslapd-pluginVersion $ nsslapd-pluginVendor $ nsslapd-pluginDescription $ nsslapd-pluginEnabled ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.42 NAME 'vlvIndex' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ vlvSort ) MAY ( vlvEnabled $ vlvUses ) X-ORIGIN 'Netscape Directory Server' )
-objectClasses: ( 2.16.840.1.113730.3.2.43 NAME 'nsSNMP' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSNMPEnabled ) MAY ( nsSNMPOrganization $ nsSNMPLocation $ nsSNMPContact $ nsSNMPDescription $ nsSNMPMasterHost $ nsSNMPMasterPort ) X-ORIGIN 'Netscape Directory Server' )
+objectClasses: ( 2.16.840.1.113730.3.2.43 NAME 'nsSNMP' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSNMPEnabled ) MAY ( nsSNMPOrganization $ nsSNMPLocation $ nsSNMPContact $ nsSNMPDescription $ nsSNMPName $ nsSNMPMasterHost $ nsSNMPMasterPort ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.44 NAME 'nsIndex' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSystemIndex ) MAY ( description $ nsIndexType $ nsMatchingRule ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.84 NAME 'cosDefinition' DESC 'Netscape defined objectclass' SUP top MAY ( costargettree $ costemplatedn $ cosspecifier $ cosattribute $ aci $ cn $ uid ) X-ORIGIN 'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113719.2.142.6.1.1 NAME 'ldapSubEntry' DESC 'LDAP Subentry class, version 1' SUP top STRUCTURAL MAY ( cn ) X-ORIGIN 'LDAP Subentry Internet Draft' )
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index c67282cb..453e999d 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -357,6 +357,16 @@ agt_mread_stats (int hdl, struct hdr_stats_t *pHdrInfo, struct ops_stats_t *pDsO
pHdrInfo->updateTime = pfile_stats->hdr_stats.updateTime;
strncpy(pHdrInfo->dsVersion, pfile_stats->hdr_stats.dsVersion,
(sizeof(pHdrInfo->dsVersion)/sizeof(char)) - 1);
+ strncpy(pHdrInfo->dsName, pfile_stats->hdr_stats.dsName,
+ (sizeof(pHdrInfo->dsName)/sizeof(char)) - 1);
+ strncpy(pHdrInfo->dsDescription, pfile_stats->hdr_stats.dsDescription,
+ (sizeof(pHdrInfo->dsDescription)/sizeof(char)) - 1);
+ strncpy(pHdrInfo->dsOrganization, pfile_stats->hdr_stats.dsOrganization,
+ (sizeof(pHdrInfo->dsOrganization)/sizeof(char)) - 1);
+ strncpy(pHdrInfo->dsLocation, pfile_stats->hdr_stats.dsLocation,
+ (sizeof(pHdrInfo->dsLocation)/sizeof(char)) - 1);
+ strncpy(pHdrInfo->dsContact, pfile_stats->hdr_stats.dsContact,
+ (sizeof(pHdrInfo->dsContact)/sizeof(char)) - 1);
}
if (pDsOpsTbl != NULL) {
diff --git a/ldap/servers/slapd/agtmmap.h b/ldap/servers/slapd/agtmmap.h
index 330475e9..f3cf81d1 100644
--- a/ldap/servers/slapd/agtmmap.h
+++ b/ldap/servers/slapd/agtmmap.h
@@ -72,6 +72,11 @@ struct hdr_stats_t{
time_t startTime;
time_t updateTime;
char dsVersion[100];
+ char dsName[30];
+ char dsDescription[30];
+ char dsOrganization[30];
+ char dsLocation[30];
+ char dsContact[30];
};
struct ops_stats_t{
diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c
index f636a530..bf75fc0a 100644
--- a/ldap/servers/slapd/fedse.c
+++ b/ldap/servers/slapd/fedse.c
@@ -105,8 +105,9 @@ static const char *internal_entries[] =
"dn:cn=SNMP,cn=config\n"
"objectclass:top\n"
"objectclass:nsSNMP\n"
- "cn:SNMP\n"
+ "cn:SNMP\n"
"nsSNMPEnabled:on\n"
+ "nsSNMPName:\n"
"nsSNMPOrganization:\n"
"nsSNMPLocation:\n"
"nsSNMPContact:\n"
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
index 3c0f5e65..7613edb0 100644
--- a/ldap/servers/slapd/snmp_collator.c
+++ b/ldap/servers/slapd/snmp_collator.c
@@ -35,6 +35,9 @@
char *make_ds_url(char *host, int port);
void print_snmp_interaction_table();
int search_interaction_table(char *dsURL, int *isnew);
+static void loadConfigStats();
+static Slapi_Entry *getConfigEntry( Slapi_Entry **e );
+static void freeConfigEntry( Slapi_Entry **e );
/* snmp stats stuff */
struct agt_stats_t *stats=NULL;
@@ -81,6 +84,9 @@ int snmp_collator_init(){
stats->hdr_stats.restarted = 0;
stats->hdr_stats.startTime = time(0); /* This is a bit off, hope it's ok */
+ /* load config stats */
+ loadConfigStats();
+
/* point these at the mmaped data */
g_get_global_snmp_vars()->ops_tbl.dsAnonymousBinds = &(stats->ops_stats.dsAnonymousBinds);
g_get_global_snmp_vars()->ops_tbl.dsUnAuthBinds = &(stats->ops_stats.dsUnAuthBinds);
@@ -380,10 +386,11 @@ int snmp_collator_start()
}
}
-
+/* read config entry for entity table data */
+
/* point stats struct at mmap data */
- stats = (struct agt_stats_t *) mmap_tbl [hdl].fp;
+ stats = (struct agt_stats_t *) mmap_tbl [hdl].fp;
/* initialize stats data */
@@ -605,7 +612,78 @@ snmp_as_entry(Slapi_Entry *e)
add_counter_to_value(e,"SlaveHits",stats->entries_stats.dsSlaveHits);
}
+static void
+loadConfigStats() {
+ Slapi_Entry *entry = NULL;
+ char *name = NULL;
+ char *desc = NULL;
+ char *org = NULL;
+ char *loc = NULL;
+ char *contact = NULL;
+
+ /* Read attributes from SNMP config entry */
+ getConfigEntry( &entry );
+ if ( entry != NULL ) {
+ name = slapi_entry_attr_get_charptr( entry, SNMP_NAME_ATTR );
+ desc = slapi_entry_attr_get_charptr( entry, SNMP_DESC_ATTR );
+ org = slapi_entry_attr_get_charptr( entry, SNMP_ORG_ATTR );
+ loc = slapi_entry_attr_get_charptr( entry, SNMP_LOC_ATTR );
+ contact = slapi_entry_attr_get_charptr( entry, SNMP_CONTACT_ATTR );
+ freeConfigEntry( &entry );
+ }
+
+ /* Load stats into table */
+ if ( name != NULL) {
+ strncpy(stats->hdr_stats.dsName, name,
+ (sizeof(stats->hdr_stats.dsName)/sizeof(char)) - 1);
+ }
+
+ if ( desc != NULL) {
+ strncpy(stats->hdr_stats.dsDescription, desc,
+ (sizeof(stats->hdr_stats.dsDescription)/sizeof(char)) - 1);
+ }
+
+ if ( org != NULL) {
+ strncpy(stats->hdr_stats.dsOrganization, org,
+ (sizeof(stats->hdr_stats.dsOrganization)/sizeof(char)) - 1);
+ }
+
+ if ( loc != NULL) {
+ strncpy(stats->hdr_stats.dsLocation, loc,
+ (sizeof(stats->hdr_stats.dsLocation)/sizeof(char)) - 1);
+ }
+
+ if ( contact != NULL) {
+ strncpy(stats->hdr_stats.dsContact, contact,
+ (sizeof(stats->hdr_stats.dsContact)/sizeof(char)) - 1);
+ }
+
+ /* Free strings */
+ slapi_ch_free((void **) &name);
+ slapi_ch_free((void **) &desc);
+ slapi_ch_free((void **) &org);
+ slapi_ch_free((void **) &loc);
+ slapi_ch_free((void **) &contact);
+}
+static Slapi_Entry *
+getConfigEntry( Slapi_Entry **e ) {
+ Slapi_DN sdn;
+
+ slapi_sdn_init_dn_byref( &sdn, SNMP_CONFIG_DN );
+ slapi_search_internal_get_entry( &sdn, NULL, e,
+ plugin_get_default_component_id());
+ slapi_sdn_done( &sdn );
+ return *e;
+}
+
+static void
+freeConfigEntry( Slapi_Entry **e ) {
+ if ( (e != NULL) && (*e != NULL) ) {
+ slapi_entry_free( *e );
+ *e = NULL;
+ }
+}
diff --git a/ldap/servers/slapd/snmp_collator.h b/ldap/servers/slapd/snmp_collator.h
index 77dd4bc1..d9406518 100644
--- a/ldap/servers/slapd/snmp_collator.h
+++ b/ldap/servers/slapd/snmp_collator.h
@@ -5,6 +5,18 @@
* END COPYRIGHT BLOCK **/
/******************************************************************************
*
+* defines
+*
+******************************************************************************/
+#define SNMP_CONFIG_DN "cn=SNMP,cn=config"
+#define SNMP_NAME_ATTR "nsSNMPName"
+#define SNMP_DESC_ATTR "nsSNMPDescription"
+#define SNMP_ORG_ATTR "nsSNMPOrganization"
+#define SNMP_LOC_ATTR "nsSNMPLocation"
+#define SNMP_CONTACT_ATTR "nsSNMPContact"
+
+/******************************************************************************
+*
* function prototypes
*
******************************************************************************/
diff --git a/ldap/servers/snmp/ldap-agent.c b/ldap/servers/snmp/ldap-agent.c
index 12bc5db4..b2a62afe 100644
--- a/ldap/servers/snmp/ldap-agent.c
+++ b/ldap/servers/snmp/ldap-agent.c
@@ -40,8 +40,6 @@ init_ldap_agent(void)
{
server_instance *serv_p = NULL;
stats_table_context *new_row = NULL;
- int err;
- int stats_hdl = -1;
/* Define and create the table */
initialize_stats_table();
@@ -229,7 +227,6 @@ load_stats_table(netsnmp_cache *cache, void *foo)
{
server_instance *serv_p = NULL;
stats_table_context *ctx = NULL;
- netsnmp_variable_list *vars = NULL;
time_t previous_start;
int previous_state;
int stats_hdl = -1;
@@ -527,14 +524,13 @@ dsEntityTable_get_value(netsnmp_request_info *request,
{
netsnmp_variable_list *var = request->requestvb;
stats_table_context *context = (stats_table_context *) item;
- server_instance *server = (server_instance *) context->entity_tbl;
switch (table_info->colnum) {
case COLUMN_DSENTITYDESCR:
snmp_set_var_typed_value(var, ASN_OCTET_STR,
- (u_char *) server->description,
- strlen(server->description));
+ (u_char *) context->hdr_tbl.dsDescription,
+ strlen(context->hdr_tbl.dsDescription));
break;
case COLUMN_DSENTITYVERS:
@@ -545,26 +541,26 @@ dsEntityTable_get_value(netsnmp_request_info *request,
case COLUMN_DSENTITYORG:
snmp_set_var_typed_value(var, ASN_OCTET_STR,
- (u_char *) server->org,
- strlen(server->org));
+ (u_char *) context->hdr_tbl.dsOrganization,
+ strlen(context->hdr_tbl.dsOrganization));
break;
case COLUMN_DSENTITYLOCATION:
snmp_set_var_typed_value(var, ASN_OCTET_STR,
- (u_char *) server->location,
- strlen(server->location));
+ (u_char *) context->hdr_tbl.dsLocation,
+ strlen(context->hdr_tbl.dsLocation));
break;
case COLUMN_DSENTITYCONTACT:
snmp_set_var_typed_value(var, ASN_OCTET_STR,
- (u_char *) server->contact,
- strlen(server->contact));
+ (u_char *) context->hdr_tbl.dsContact,
+ strlen(context->hdr_tbl.dsContact));
break;
case COLUMN_DSENTITYNAME:
snmp_set_var_typed_value(var, ASN_OCTET_STR,
- (u_char *) server->name,
- strlen(server->name));
+ (u_char *) context->hdr_tbl.dsName,
+ strlen(context->hdr_tbl.dsName));
break;
default:/* We shouldn't get here */
@@ -614,8 +610,8 @@ send_DirectoryServerDown_trap(server_instance *serv_p)
snmp_varlist_add_variable(&var_list,
dsEntityDescr_oid,
OID_LENGTH(dsEntityDescr_oid), ASN_OCTET_STR,
- (u_char *) serv_p->description,
- strlen(serv_p->description));
+ (u_char *) ctx->hdr_tbl.dsDescription,
+ strlen(ctx->hdr_tbl.dsDescription));
snmp_varlist_add_variable(&var_list,
dsEntityVers_oid,
OID_LENGTH(dsEntityVers_oid), ASN_OCTET_STR,
@@ -625,14 +621,14 @@ send_DirectoryServerDown_trap(server_instance *serv_p)
dsEntityLocation_oid,
OID_LENGTH(dsEntityLocation_oid),
ASN_OCTET_STR,
- (u_char *) serv_p->location,
- strlen(serv_p->location));
+ (u_char *) ctx->hdr_tbl.dsLocation,
+ strlen(ctx->hdr_tbl.dsLocation));
snmp_varlist_add_variable(&var_list,
dsEntityContact_oid,
OID_LENGTH(dsEntityContact_oid),
ASN_OCTET_STR,
- (u_char *) serv_p->contact,
- strlen(serv_p->contact));
+ (u_char *) ctx->hdr_tbl.dsContact,
+ strlen(ctx->hdr_tbl.dsContact));
/* Send the trap */
send_v2trap(var_list);
@@ -679,8 +675,8 @@ send_DirectoryServerStart_trap(server_instance *serv_p)
snmp_varlist_add_variable(&var_list,
dsEntityDescr_oid,
OID_LENGTH(dsEntityDescr_oid), ASN_OCTET_STR,
- (u_char *) serv_p->description,
- strlen(serv_p->description));
+ (u_char *) ctx->hdr_tbl.dsDescription,
+ strlen(ctx->hdr_tbl.dsDescription));
snmp_varlist_add_variable(&var_list,
dsEntityVers_oid,
OID_LENGTH(dsEntityVers_oid), ASN_OCTET_STR,
@@ -690,8 +686,8 @@ send_DirectoryServerStart_trap(server_instance *serv_p)
dsEntityLocation_oid,
OID_LENGTH(dsEntityLocation_oid),
ASN_OCTET_STR,
- (u_char *) serv_p->location,
- strlen(serv_p->location));
+ (u_char *) ctx->hdr_tbl.dsLocation,
+ strlen(ctx->hdr_tbl.dsLocation));
/* Send the trap */
send_v2trap(var_list);
diff --git a/ldap/servers/snmp/ldap-agent.h b/ldap/servers/snmp/ldap-agent.h
index 250a3d60..084d3623 100644
--- a/ldap/servers/snmp/ldap-agent.h
+++ b/ldap/servers/snmp/ldap-agent.h
@@ -39,11 +39,6 @@ typedef struct server_instance_s {
int server_state;
char *stats_file;
char *dse_ldif;
- char *description;
- char *org;
- char *location;
- char *contact;
- char *name;
struct server_instance_s *next;
} server_instance;
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 3d5e654d..9836b066 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -111,8 +111,9 @@ main (int argc, char *argv[]) {
strcat((char *) log_hdl->token, LDAP_AGENT_LOGFILE);
}
} else {
- /* agent-logdir not set, so write locally */
- log_hdl->token = strdup(LDAP_AGENT_LOGFILE);
+ /* agent-logdir not set */
+ printf("ldap-agent: Error determining log directory.\n");
+ exit(1);
}
netsnmp_enable_filelog(log_hdl, 1);
@@ -202,6 +203,13 @@ load_config(char *conf_path)
char *p = NULL;
char *p2 = NULL;
+ /* Make sure we are getting an absolute path */
+ if (*conf_path != '/') {
+ printf("ldap-agent: Error opening config file: %s\n", conf_path);
+ printf("ldap-agent: You must specify the absolute path to your config file\n");
+ exit(1);
+ }
+
/* Open config file */
if ((conf_file = fopen(conf_path, "r")) == NULL) {
printf("ldap-agent: Error opening config file: %s\n", conf_path);
@@ -211,10 +219,19 @@ load_config(char *conf_path)
/* set pidfile path */
for (p = (conf_path + strlen(conf_path) - 1); p >= conf_path; p--) {
if (*p == '/') {
+ /* set pidfile path */
if ((pidfile = malloc((p - conf_path) +
strlen(LDAP_AGENT_PIDFILE) + 2)) != NULL) {
strncpy(pidfile, conf_path, (p - conf_path + 1));
strcat(pidfile, LDAP_AGENT_PIDFILE);
+ } else {
+ printf("ldap-agent: malloc error processing config file\n");
+ exit(1);
+ }
+
+ /* set default logdir to location of config file */
+ if ((agent_logdir = malloc((p - conf_path) + 1)) != NULL) {
+ strncpy(agent_logdir, conf_path, (p - conf_path));
break;
} else {
printf("ldap-agent: malloc error processing config file\n");
@@ -236,6 +253,11 @@ load_config(char *conf_path)
strcpy(agentx_master, p);
}
} else if ((p = strstr(line, "agent-logdir")) != NULL) {
+ /* free the default logdir setting */
+ if (agent_logdir != NULL) {
+ free(agent_logdir);
+ }
+
/* load agent-logdir setting */
p = p + 12;
if ((p = strtok(p, " \t\n")) != NULL) {
@@ -259,65 +281,6 @@ load_config(char *conf_path)
if ((serv_p->dse_ldif = malloc(strlen(p) + 17)) != NULL) {
snprintf(serv_p->dse_ldif, strlen(p) + 17, "%s/config/dse.ldif", p);
}
-
- /* second token is the name */
- p = p2;
- if((p2 = strchr(p, ':')) != NULL) {
- *p2 = '\0';
- ++p2;
- if ((serv_p->name = malloc(strlen(p) + 1)) != NULL)
- snprintf(serv_p->name, strlen(p) + 1, "%s", p);
- } else {
- printf("ldap-agent: Invalid config file\n");
- exit(1);
- }
-
- /* third token is the description */
- p = p2;
- if((p2 = strchr(p, ':')) != NULL) {
- *p2 = '\0';
- ++p2;
- if ((serv_p->description = malloc(strlen(p) + 1)) != NULL)
- snprintf(serv_p->description, strlen(p) + 1, "%s", p);
- } else {
- printf("ldap-agent: Invalid config file\n");
- exit(1);
- }
-
- /* fourth token is the org */
- p = p2;
- if((p2 = strchr(p, ':')) != NULL) {
- *p2 = '\0';
- ++p2;
- if ((serv_p->org = malloc(strlen(p) + 1)) != NULL)
- snprintf(serv_p->org, strlen(p) + 1, "%s", p);
- } else {
- printf("ldap-agent: Invalid config file\n");
- exit(1);
- }
-
- /* fifth token is the location */
- p = p2;
- if((p2 = strchr(p, ':')) != NULL) {
- *p2 = '\0';
- ++p2;
- if ((serv_p->location = malloc(strlen(p) + 1)) != NULL)
- snprintf(serv_p->location, strlen(p) + 1, "%s", p);
- } else {
- printf("ldap-agent: Invalid config file\n");
- exit(1);
- }
-
- /* sixth token is the contact */
- p = p2;
- if((p2 = strchr(p, '\n')) != NULL) {
- *p2 = '\0';
- if ((serv_p->contact = malloc(strlen(p) + 1)) != NULL)
- snprintf(serv_p->contact, strlen(p) + 1, "%s", p);
- } else {
- printf("ldap-agent: Invalid config file\n");
- exit(1);
- }
}
/* Open dse.ldif */