Re: [devel] [PATCH 1 of 1] osaf: port existing daemonization and nid process to systemd new-style daemon [#455]
Ack, Will push this on your behalf. Mathi. - ajo...@genband.com wrote: README | 11 +++ contrib/plmc/config/plmcboot.service.in | 2 +- contrib/plmc/config/plmcd.service.in| 2 +- osaf/services/infrastructure/nid/config/opensafd.service.in | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) Jun 2 16:55:57 linux-po6q osafrded[16114]: Started Jun 2 16:55:57 linux-po6q osafrded[16114]: Creation of real-time thread 'OSAF_TMR' FAILED - 'Operation not permitted' Jun 2 16:55:57 linux-po6q osafrded[16114]: ER ncs_core_agents_startup FAILED Jun 2 16:55:57 linux-po6q opensafd[16086]: ER Failed Jun 2 16:55:57 linux-po6q opensafd[16086]: ER Going for recovery Jun 2 16:55:57 linux-po6q opensafd[16086]: ER Trying To RESPAWN /usr/lib64/opensaf/clc-cli/osaf-rded attempt #1 Jun 2 16:55:57 linux-po6q opensafd[16086]: ER Sending SIGKILL to RDE, pid=16106 Jun 2 16:55:57 linux-po6q osafrded[16114]: Exiting... Jun 2 16:56:12 linux-po6q osafrded[16133]: Started Linux distros that use a version of systemd 205 (OpenSUSE 12.1, OpenSUSE 12.2, Fedora = 19), fail to start opensafd because, by default, these versions of systemd do not assign any RT time budgets to the cpu cgroups for services. The solution is in two parts: (1) Create an opensafd.service file for use by systemd which has cgroup info in it. This cgroup info is not put into the service file if the systemd version is = 205. (2) Make plmcd a full systemd-enabled daemon. diff --git a/README b/README --- a/README +++ b/README @@ -688,6 +688,11 @@ the following command shall start the Op % /etc/init.d/opensafd start [start|stop|status] +If your distro uses systemd (e.g. OpenSUSE 12.1 or greater, Fedora 15 or +greater) use the following command to start the OpenSAF services: + +% systemctl [start|stop|status] opensafd.service + Commands to Start OpenSAF When PLM is enabled: == After a minimum configuration of @@ -703,6 +708,12 @@ The following commands shall be executed % /etc/init.d/opensafd start [start|stop|status] +If your distro uses systemd (e.g. OpenSUSE 12.1 or greater, Fedora 15 or +greater) use the following commands: + +% systemctl start plmcd.service +% systemctl [start|stop|status] opensafd.service + Note: Its not necessary to start OpenSAF if an entry to start OpenSAF is set/specified in the plmcd.conf file. diff --git a/contrib/plmc/config/plmcboot.service.in b/contrib/plmc/config/plmcboot.service.in --- a/contrib/plmc/config/plmcboot.service.in +++ b/contrib/plmc/config/plmcboot.service.in @@ -1,6 +1,6 @@ [Unit] Description=Send a UDP datagram to OpenSAF PLM controllers indicating the OS state -After=syslog.target network.target +After=remote-fs.target local-fs.target syslog.target network.target [Service] ExecStart=@sbindir@/plmcd -c @sysconfdir@/plmcd.conf -s diff --git a/contrib/plmc/config/plmcd.service.in b/contrib/plmc/config/plmcd.service.in --- a/contrib/plmc/config/plmcd.service.in +++ b/contrib/plmc/config/plmcd.service.in @@ -1,6 +1,6 @@ [Unit] Description=OpenSAF PLMC Daemon -After=syslog.target network.target plmcboot.service +After=local-fs.target remote-fs.target syslog.target network.target plmcboot.service Wants=plmcboot.service [Service] diff --git a/osaf/services/infrastructure/nid/config/opensafd.service.in b/osaf/services/infrastructure/nid/config/opensafd.service.in --- a/osaf/services/infrastructure/nid/config/opensafd.service.in +++ b/osaf/services/infrastructure/nid/config/opensafd.service.in @@ -1,6 +1,6 @@ [Unit] Description=OpenSAF daemon -After=syslog.target network.target +After=remote-fs.target local-fs.target syslog.target network.target [Service] ExecStart=@initscriptdir@/opensafd start -- Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 2 of 5] NTF: Adapt NTF common library to support long DNs [#873]
Hi Anders, Currently in ntfimcnd, the SaNameT arrived from IMM has null-terminated string, and not much code in ntfimcnd to deal with null or non-null terminated string. The problem is mostly between NTF and its other users, who send the notification/notifying objects and expect exactly the same ones in the callback, so as you suggested, it's dealt in ntf agent/library for now Another issue that I have to *clone* the string pointer inside long dn objects: - As sending notification, app allocates notification, use saAisNameLend to package the long dn object. At the end, app calls saNtfNotificationFree(), as result the ntfsv_free_header() will free these long dn objects. At this moment, ntfsv_free_header() does not have to worry the string pointer since app will free it - In case of callback, the ntf agent allocates a new notification and also new long dn objects are allocated. At the end of receiving callback, the app also calls saNtfNotificationFree() to free the received notification in callback, ... ntfsv_free_header() now has to free the string pointer in these long dn objects. Both cases in ntfsv_free_header(), if I can distinguish notification generated by app or ntf agent (in callback), I would not have to clone the string pointer. Thanks, Minh On 7/7/2014 6:22 PM, Anders Bjornerstedt wrote: Anders Bjornerstedt wrote: About null terminated or not strings in SaNameT. The IMM handles this issue like this (not BEFORE the long DN support). That should have been: (note BEFORE the long DN support). /AndersBj 1) The actual max length of DNs supported by the IMM is 255 bytes, not 256. This is to allow all SaNameT values to be null termianted which is a HUGE simplification in all internal code for trace/log etc. 2) An SaNameT that arrives over the IMMA API from a user can of course not be assumed to be null terminated. But all IMMA APIs that do receive an SaNameT from the user will check that the length is at most 255 bytes and then actually write a terminating null byte into the SaNameT struct. 3) Only the agent/library code should need to deal with the (quite frankly stupid) SaNameT type. Server code should not use SaNaameT. So I really dont like to see the code in either library or server getting ccomplicated just because some SaNameT received from a user may not be null terminated. Plug that problem at the source close to the user API. Given that this is done, you should be able to use the lend and borrow functions and avoid any unnecessary cloning/copying. Ntf may have legacy code (messages etc) that use SaNameT in the server. Even if you have that and thus use SaNameT more than is really needed, I strongly suggest you null terminate SaNameTs close to the source (the ntf agent/library user), also for NTF. /AndesBj minhchau wrote: Please find comments inline Thanks, Minh On 7/4/2014 9:48 PM, Zoran Milinkovic wrote: Hi, Find my comments inline started with [Zoran]. -Original Message- From: Minh Hon Chau [[1]mailto:minh.c...@dektech.com.au] Sent: den 2 juli 2014 07:50 To: Anders Widell; [2]mathi.naic...@oracle.com; Hans Feldt; [3]praveen.malv...@oracle.com Cc: [4]opensaf-devel@lists.sourceforge.net Subject: [devel] [PATCH 2 of 5] NTF: Adapt NTF common library to support long DNs [#873] osaf/libs/common/ntfsv/Makefile.am |1 + osaf/libs/common/ntfsv/include/ntfsv_mem.h |7 + osaf/libs/common/ntfsv/ntfsv_enc_dec.c | 37 -- osaf/libs/common/ntfsv/ntfsv_mem.c | 167 +++- 4 files changed, 191 insertions(+), 21 deletions(-) diff --git a/osaf/libs/common/ntfsv/Makefile.am b/osaf/libs/common/ntfsv/Makefile.am --- a/osaf/libs/common/ntfsv/Makefile.am +++ b/osaf/libs/common/ntfsv/Makefile.am @@ -23,6 +23,7 @@ SUBDIRS = include noinst_LTLIBRARIES = libntfsv_common.la libntfsv_common_la_CPPFLAGS = \ +-DSA_EXTENDED_NAME_SOURCE \ $(AM_CPPFLAGS) \ -I$(top_srcdir)/osaf/libs/common/ntfsv/include diff--gita/osaf/libs/common/ntfsv/include/ntfsv_mem.h b/osaf/libs/common/ntfsv/include/ntfsv_mem.h --- a/osaf/libs/common/ntfsv/include/ntfsv_mem.h +++ b/osaf/libs/common/ntfsv/include/ntfsv_mem.h @@ -97,6 +97,13 @@ extern C { void ntfsv_filter_obj_cr_del_free(SaNtfObjectCreateDeleteNotificationFilterT *f); void ntfsv_filter_attr_ch_free(SaNtfAttributeChangeNotificationFilterT *f); +SaAisErrorT ntfsv_sanamet_copy(SaNameT* pDes, SaNameT* pSrc); +bool ntfsv_sanamet_is_valid(const SaNameT* pName); +
[devel] [PATCH 5 of 7] NTF: Adapt NTF common library to support long DNs [#873] v2
osaf/libs/common/ntfsv/Makefile.am |1 + osaf/libs/common/ntfsv/include/ntfsv_mem.h |7 + osaf/libs/common/ntfsv/ntfsv_enc_dec.c | 37 -- osaf/libs/common/ntfsv/ntfsv_mem.c | 152 +++- 4 files changed, 176 insertions(+), 21 deletions(-) (1)Fix big endian issue in ntfs_sanamet_length. (2)Simplify ntfs_sanamet_strdup. (3)Fix memory bug in ntfsv_filter_header_free. diff --git a/osaf/libs/common/ntfsv/Makefile.am b/osaf/libs/common/ntfsv/Makefile.am --- a/osaf/libs/common/ntfsv/Makefile.am +++ b/osaf/libs/common/ntfsv/Makefile.am @@ -23,6 +23,7 @@ SUBDIRS = include noinst_LTLIBRARIES = libntfsv_common.la libntfsv_common_la_CPPFLAGS = \ + -DSA_EXTENDED_NAME_SOURCE \ $(AM_CPPFLAGS) \ -I$(top_srcdir)/osaf/libs/common/ntfsv/include diff --git a/osaf/libs/common/ntfsv/include/ntfsv_mem.h b/osaf/libs/common/ntfsv/include/ntfsv_mem.h --- a/osaf/libs/common/ntfsv/include/ntfsv_mem.h +++ b/osaf/libs/common/ntfsv/include/ntfsv_mem.h @@ -97,6 +97,13 @@ extern C { void ntfsv_filter_obj_cr_del_free(SaNtfObjectCreateDeleteNotificationFilterT *f); void ntfsv_filter_attr_ch_free(SaNtfAttributeChangeNotificationFilterT *f); + SaAisErrorT ntfsv_sanamet_copy(SaNameT* pDes, SaNameT* pSrc); + bool ntfsv_sanamet_is_valid(const SaNameT* pName); + void ntfsv_sanamet_clone_strptr(SaNameT* pName); + SaStringT ntfs_sanamet_strdup(SaNameT* pName); + size_t ntfs_sanamet_length(const SaNameT* pName); + void ntfs_sanamet_steal(SaStringT value, size_t length, SaNameT* pName); + void ntfs_sanamet_alloc(SaConstStringT value, size_t length, SaNameT* pName); #ifdef __cplusplus } #endif diff --git a/osaf/libs/common/ntfsv/ntfsv_enc_dec.c b/osaf/libs/common/ntfsv/ntfsv_enc_dec.c --- a/osaf/libs/common/ntfsv/ntfsv_enc_dec.c +++ b/osaf/libs/common/ntfsv/ntfsv_enc_dec.c @@ -18,6 +18,8 @@ #include ncsencdec_pub.h #include ntfsv_enc_dec.h #include ntfsv_mem.h +#include osaf_extended_name.h +#include saAis.h typedef union { uint32_t uint32_val; @@ -334,19 +336,22 @@ static uint32_t decodeSaNtfAttribute(NCS static uint32_t encodeSaNameT(NCS_UBAID *uba, uint8_t *p8, SaNameT *name) { uint32_t rv; - p8 = ncs_enc_reserve_space(uba, 2); if (!p8) { TRACE(ncs_enc_reserve_space failed); return NCSCC_RC_OUT_OF_MEM; } - if (name-length SA_MAX_NAME_LENGTH) { - LOG_ER(SaNameT length too long %hd, name-length); - osafassert(0); - } - ncs_encode_16bit(p8, name-length); - ncs_enc_claim_space(uba, 2); - rv = ncs_encode_n_octets_in_uba(uba, name-value, (uint32_t)name-length); + + if (!ntfsv_sanamet_is_valid(name)) { + LOG_ER(SaNameT is invalid); + osafassert(0); + } + + SaConstStringT value = osaf_extended_name_borrow(name); + size_t length = ntfs_sanamet_length(name); + ncs_encode_16bit(p8, length); + ncs_enc_claim_space(uba, 2); + rv = ncs_encode_n_octets_in_uba(uba, (uint8_t*) value, (uint32_t) length); return rv; } @@ -355,14 +360,22 @@ static uint32_t decodeSaNameT(NCS_UBAID uint8_t local_data[2]; uint32_t rv; p8 = ncs_dec_flatten_space(uba, local_data, 2); - name-length = ncs_decode_16bit(p8); - if (name-length SA_MAX_NAME_LENGTH) { - LOG_ER(SaNameT length too long: %hd, name-length); + size_t length = ncs_decode_16bit(p8); + if (length kMaxDnLength) { + LOG_ER(SaNameT length too long: %zu, length); /* this should not happen */ osafassert(0); } ncs_dec_skip_space(uba, 2); - rv = ncs_decode_n_octets_from_uba(uba, name-value, (uint32_t)name-length); + char* value = (char*) malloc(length + 1); + if (value == NULL) { + LOG_ER(Out of memory); + /* this should not happen */ + osafassert(0); + } + rv = ncs_decode_n_octets_from_uba(uba, (uint8_t*) value, (uint32_t) length); + value[length] = '\0'; + ntfs_sanamet_steal(value, length, name); return rv; } diff --git a/osaf/libs/common/ntfsv/ntfsv_mem.c b/osaf/libs/common/ntfsv/ntfsv_mem.c --- a/osaf/libs/common/ntfsv/ntfsv_mem.c +++ b/osaf/libs/common/ntfsv/ntfsv_mem.c @@ -18,6 +18,8 @@ #include saNtf.h #include stdlib.h #include ntfsv_mem.h +#include osaf_extended_name.h +#include saAis.h #include logtrace.h void ntfsv_free_header(const SaNtfNotificationHeaderT *notificationHeader) @@ -27,10 +29,14 @@ void ntfsv_free_header(const SaNtfNotifi free(notificationHeader-eventType); if (notificationHeader-eventTime != NULL) free(notificationHeader-eventTime); - if (notificationHeader-notificationObject != NULL) + if (notificationHeader-notificationObject != NULL) { +
[devel] [PATCH 0 of 7] Review Request for NTF: Support DNs longer than 255 bytes [#873] V2
Summary: NTF: Support DNs longer than 255 bytes [#873] V2 Review request for Trac Ticket(s): [#873] Peer Reviewer(s): AndersW, HansF, Praveen, Mathi, Zoran, AndersBj Pull request to: Affected branch(es): default Development branch: default Impacted area Impact y/n Docsn Build systemn RPM/packaging n Configuration files n Startup scripts n SAF servicesy OpenSAF servicesn Core libraries n Samples n Tests n Other n Comments (indicate scope for each y above): - This is patch series version 2: - Fix bugs in NTF common library - Adapt NTF tools to support long DNs - Add test cases for ntftest (testsuite 35) changeset 95f86bfa9ce44e0d54c6bc366a4705a727bccc28 Author: Minh Hon Chau minh.c...@dektech.com.au Date: Wed, 09 Jul 2014 14:35:06 +1000 NTF: Adapt NTF tools (ntfread, ntfsend, ntfsubscribe) to support long DNs [#873] changeset 745302d173e2b2149b8d7b18ee30d3c97dc54076 Author: Minh Hon Chau minh.c...@dektech.com.au Date: Wed, 09 Jul 2014 14:35:06 +1000 NTF: Adapt NTF osaf service to support long DNs [#873] changeset 2617d179148fdc65e2c460c27f674ffe9337d335 Author: Minh Hon Chau minh.c...@dektech.com.au Date: Wed, 09 Jul 2014 14:35:06 +1000 NTF: Adapt NTFIMCND to support long DNs [#873] changeset 04a3957641bf1da7ee374fb65f70b7497a912054 Author: Minh Hon Chau minh.c...@dektech.com.au Date: Wed, 09 Jul 2014 14:35:06 +1000 NTF: Add ntftest test cases for notification with long dn objects [#873] changeset 741dec0e28d58e9c3ffa636a65653220a3f7e831 Author: Minh Hon Chau minh.c...@dektech.com.au Date: Wed, 09 Jul 2014 14:35:06 +1000 NTF: Adapt NTF common library to support long DNs [#873] v2 (1)Fix big endian issue in ntfs_sanamet_length. (2)Simplify ntfs_sanamet_strdup. (3)Fix memory bug in ntfsv_filter_header_free. changeset f65bf3b4570d95d411970a6247b7ba1ab3d64f3c Author: Minh Hon Chau minh.c...@dektech.com.au Date: Wed, 09 Jul 2014 14:35:06 +1000 NTF: Adapt NTF API to support long DNs [#873] changeset 3d9821f070896d3d835cf92869aa77f7dbfd201d Author: Minh Hon Chau minh.c...@dektech.com.au Date: Wed, 09 Jul 2014 14:35:06 +1000 Temporary patch to solve compilation dependency This patch is not part of #873, it's made to solve the dependency since NTF is using immutil.c and saflog.c. NOTE that it will not be pushed together with #873 Added Files: tests/ntfsv/tet_longDnObject_notification.c Complete diffstat: -- osaf/libs/agents/saf/ntfa/Makefile.am |1 + osaf/libs/agents/saf/ntfa/ntfa_api.c| 25 +- osaf/libs/common/ntfsv/Makefile.am |1 + osaf/libs/common/ntfsv/include/ntfsv_mem.h |7 + osaf/libs/common/ntfsv/ntfsv_enc_dec.c | 37 ++- osaf/libs/common/ntfsv/ntfsv_mem.c | 152 - osaf/libs/saf/libSaNtf/Makefile.am |1 + osaf/services/saf/ntfsv/ntfimcnd/Makefile.am|2 + osaf/services/saf/ntfsv/ntfimcnd/ntfimcn_imm.c | 91 --- osaf/services/saf/ntfsv/ntfimcnd/ntfimcn_notifier.c | 54 ++-- osaf/services/saf/ntfsv/ntfs/Makefile.am|1 + osaf/services/saf/ntfsv/ntfs/NtfFilter.cc | 34 +- osaf/services/saf/ntfsv/ntfs/NtfLogger.cc |5 +- osaf/services/saf/ntfsv/ntfs/ntfs_evt.c |5 +- osaf/services/saf/ntfsv/ntfs/ntfs_main.c|5 + osaf/tools/safimm/src/immutil.c | 57 ++-- osaf/tools/saflog/src/saflog.c | 10 +- osaf/tools/safntf/include/ntfclient.h |1 + osaf/tools/safntf/ntfread/Makefile.am |6 +- osaf/tools/safntf/ntfread/ntfread.c | 23 +- osaf/tools/safntf/ntfsend/Makefile.am |6 +- osaf/tools/safntf/ntfsend/ntfsend.c | 29 +- osaf/tools/safntf/ntfsubscribe/Makefile.am |6 +- osaf/tools/safntf/ntfsubscribe/ntfsubscribe.c |4 + osaf/tools/safntf/src/Makefile.am |1 + osaf/tools/safntf/src/ntfclient.c | 53 ++-- tests/ntfsv/Makefile.am |3 +- tests/ntfsv/tet_longDnObject_notification.c | 784 +++ tests/unit_test_fw/inc/util.h |7 +- tests/unit_test_fw/src/Makefile.am |1 + tests/unit_test_fw/src/util.c | 14 +- 31 files changed, 1189 insertions(+), 237 deletions(-) Testing Commands: - ntftest Testing, Expected Results: -- All tests pass (plus testsuite
[devel] [PATCH 7 of 7] Temporary patch to solve compilation dependency
osaf/tools/safimm/src/immutil.c | 57 ++-- osaf/tools/saflog/src/saflog.c | 10 +- 2 files changed, 34 insertions(+), 33 deletions(-) This patch is not part of #873, it's made to solve the dependency since NTF is using immutil.c and saflog.c. NOTE that it will not be pushed together with #873 diff --git a/osaf/tools/safimm/src/immutil.c b/osaf/tools/safimm/src/immutil.c --- a/osaf/tools/safimm/src/immutil.c +++ b/osaf/tools/safimm/src/immutil.c @@ -15,11 +15,13 @@ * */ +#define _GNU_SOURCE +#ifndef SA_EXTENDED_NAME_SOURCE +#define SA_EXTENDED_NAME_SOURCE +#endif +#include immutil.h #include stdio.h #include unistd.h -#ifndef __USE_ISOC99 -#define __USE_ISOC99 // strtof and LLONG_MAX in older gcc versions like 4.3.2 -#endif #include stdlib.h #include string.h #include limits.h @@ -28,12 +30,10 @@ #include syslog.h #include errno.h -#include immutil.h - -#include logtrace.h +#include saAis.h +#include logtrace.h static const SaVersionT immVersion = { 'A', 2, 11 }; -size_t strnlen(const char *s, size_t maxlen); /* Memory handling functions */ #define CHUNK 4000 @@ -152,7 +152,7 @@ CcbUtilOperationData_t *ccbutil_ccbAddCr operation-param.create.className = dupSaImmClassNameT(clist, className); operation-param.create.parentName = dupSaNameT(clist, parentName); operation-param.create.attrValues = dupSaImmAttrValuesT_array(clist, attrValues); - operation-objectName.length = 0; + saAisNameLend(, operation-objectName); return operation; } @@ -212,8 +212,7 @@ CcbUtilOperationData_t *ccbutil_getCcbOp CcbUtilOperationData_t *opData = ccbutil_getNextCcbOp(ccbId, NULL); while (opData != NULL) { -if ((dn-length == opData-objectName.length) -(memcmp(dn-value, opData-objectName.value, dn-length) == 0)) + if (strcmp(saAisNameBorrow(dn), saAisNameBorrow(opData-objectName)) == 0) break; opData = ccbutil_getNextCcbOp(ccbId, opData); @@ -267,13 +266,10 @@ char const *immutil_getClassName(struct char const *immutil_getStringValue(char const *key, SaNameT const *name) { - static char buffer[SA_MAX_NAME_LENGTH + 1]; + const char* buffer = saAisNameBorrow(name); unsigned int klen; char *cp; - assert(name-length = SA_MAX_NAME_LENGTH); - memcpy(buffer, name-value, name-length); - buffer[name-length] = 0; assert(key != NULL); klen = strlen(key); assert(klen 1 || key[klen - 1] == '='); @@ -297,14 +293,13 @@ char const *immutil_getStringValue(char char const *immutil_getDnItem(SaNameT const *name, unsigned int index) { - static char buffer[SA_MAX_NAME_LENGTH + 1]; + static char* buffer = NULL; char *cp; char *value; + size_t size = strlen(saAisNameBorrow(name)) + 1; - assert(name-length = SA_MAX_NAME_LENGTH); - memcpy(buffer, name-value, name-length); - buffer[name-length] = 0; - + buffer = realloc(buffer, size); + memcpy(buffer, saAisNameBorrow(name), size); value = buffer; cp = strchr(value, ','); while (index 0) { @@ -494,10 +489,9 @@ const SaUint32T *immutil_getUint32Attr(c int immutil_matchName(SaNameT const *name, regex_t const *preg) { - char buffer[SA_MAX_NAME_LENGTH + 1]; + const char* buffer; assert(name != NULL preg != NULL); - memcpy(buffer, name-value, name-length); - buffer[name-length] = 0; + buffer = saAisNameBorrow(name); return regexec(preg, buffer, 0, NULL, 0); } @@ -510,8 +504,7 @@ SaAisErrorT immutil_update_one_rattr(SaI SaImmAttrValueT attrValues[] = { value }; SaNameT objectName; - strncpy((char *)objectName.value, dn, SA_MAX_NAME_LENGTH); - objectName.length = strlen((char *)objectName.value); + saAisNameLend(dn, objectName); attrMod.modType = SA_IMM_ATTR_VALUES_REPLACE; attrMod.modAttr.attrName = attributeName; @@ -665,13 +658,8 @@ void *immutil_new_attrValue(SaImmValueTy case SA_IMM_ATTR_SANAMET: { SaNameT *mynamet; len = strlen(str); - if (len SA_MAX_NAME_LENGTH) { - fprintf(stderr, too long SaNameT\n); - return NULL; - } attrValue = mynamet = malloc(sizeof(SaNameT)); - mynamet-length = len; - strncpy((char *)mynamet-value, str, SA_MAX_NAME_LENGTH); + saAisNameLend(len SA_MAX_UNEXTENDED_NAME_LENGTH ? str : strdup(str), mynamet); break; } case SA_IMM_ATTR_SASTRINGT: { @@ -741,8 +729,9 @@ static const SaNameT *dupSaNameT(struct SaNameT *copy; if (original == NULL) return NULL; + const char* value = saAisNameBorrow(original); copy = (SaNameT
[devel] [PATCH 3 of 7] NTF: Adapt NTFIMCND to support long DNs [#873]
osaf/services/saf/ntfsv/ntfimcnd/Makefile.am| 2 + osaf/services/saf/ntfsv/ntfimcnd/ntfimcn_imm.c | 91 +++- osaf/services/saf/ntfsv/ntfimcnd/ntfimcn_notifier.c | 54 ++-- 3 files changed, 78 insertions(+), 69 deletions(-) diff --git a/osaf/services/saf/ntfsv/ntfimcnd/Makefile.am b/osaf/services/saf/ntfsv/ntfimcnd/Makefile.am --- a/osaf/services/saf/ntfsv/ntfimcnd/Makefile.am +++ b/osaf/services/saf/ntfsv/ntfimcnd/Makefile.am @@ -27,6 +27,7 @@ osaf_execbindir = $(pkglibdir) osaf_execbin_PROGRAMS = osafntfimcnd osafntfimcnd_CPPFLAGS = \ + -DSA_EXTENDED_NAME_SOURCE \ $(AM_CPPFLAGS) \ -I$(top_srcdir)/osaf/libs/common/ntfsv/include \ -I$(top_srcdir)/osaf/libs/common/immsv/include @@ -39,6 +40,7 @@ osafntfimcnd_SOURCES = \ osafntfimcnd_LDADD = \ $(top_builddir)/osaf/tools/safimm/src/libimmutil.la \ $(top_builddir)/osaf/libs/core/libopensaf_core.la \ + $(top_builddir)/osaf/libs/common/ntfsv/libntfsv_common.la \ $(top_builddir)/osaf/libs/saf/libSaAmf/libSaAmf.la \ $(top_builddir)/osaf/libs/saf/libSaImm/libSaImmOi.la \ $(top_builddir)/osaf/libs/saf/libSaImm/libSaImmOm.la \ diff --git a/osaf/services/saf/ntfsv/ntfimcnd/ntfimcn_imm.c b/osaf/services/saf/ntfsv/ntfimcnd/ntfimcn_imm.c --- a/osaf/services/saf/ntfsv/ntfimcnd/ntfimcn_imm.c +++ b/osaf/services/saf/ntfsv/ntfimcnd/ntfimcn_imm.c @@ -25,11 +25,13 @@ #include unistd.h #include errno.h +#include saAis.h #include saNtf.h #include saAmf.h #include logtrace.h #include saf_error.h #include ncsgl_defs.h +#include osaf_extended_name.h #include saImmOm.h #include saImmOi.h @@ -54,9 +56,9 @@ static const SaImmOiImplementerNameT app /* Used with function get_rdn_attr_name() */ struct { - char attrName[SA_MAX_NAME_LENGTH]; - char saved_className[SA_MAX_NAME_LENGTH]; -} s_get_rdn_attr_name = {{0},{0}}; + char* attrName; + char* saved_className; +} s_get_rdn_attr_name = {NULL, NULL};; /* Used with function get_created_dn() */ struct s_get_created_dn { @@ -103,10 +105,17 @@ static char *get_rdn_attr_name(const SaI TRACE_ENTER(); /* Just return the name if already looked up */ - if (strcmp(className, s_get_rdn_attr_name.saved_className) == 0) { + if (s_get_rdn_attr_name.saved_className != NULL + strcmp(className, s_get_rdn_attr_name.saved_className) == 0) { goto done; } - strncpy(s_get_rdn_attr_name.saved_className, className, SA_MAX_NAME_LENGTH-1); + s_get_rdn_attr_name.saved_className = + realloc(s_get_rdn_attr_name.saved_className, strlen(className) + 1); + if (s_get_rdn_attr_name.saved_className == NULL) { + LOG_ER(Failed to realloc memory); + goto error; + } + memcpy(s_get_rdn_attr_name.saved_className, className, strlen(className) + 1); /* Get class description */ msecs_waited = 0; @@ -128,11 +137,17 @@ static char *get_rdn_attr_name(const SaI } /* Find the name of the attribute with the RDN flag set */ - s_get_rdn_attr_name.attrName[0] = '\0'; for (i=0; attrDescr[i] != NULL; i++) { if (attrDescr[i]-attrFlags SA_IMM_ATTR_RDN) { - strncpy(s_get_rdn_attr_name.attrName,attrDescr[i]-attrName,SA_MAX_NAME_LENGTH); - s_get_rdn_attr_name.attrName[SA_MAX_NAME_LENGTH-1] = '\0'; + s_get_rdn_attr_name.attrName = + realloc(s_get_rdn_attr_name.attrName, + strlen(attrDescr[i]-attrName) + 1); + if (s_get_rdn_attr_name.attrName == NULL) { + LOG_ER(Failed to realloc memory); + goto error; + } + memcpy(s_get_rdn_attr_name.attrName, attrDescr[i]-attrName + , strlen(attrDescr[i]-attrName) + 1); break; } } @@ -178,7 +193,7 @@ static SaNameT *get_created_dn(const SaI { int i = 0; - SaNameT object_rdn; + const char* object_rdn = ; char *attrName; TRACE_ENTER(); @@ -190,27 +205,30 @@ static SaNameT *get_created_dn(const SaI for (i=0; attr[i] != NULL; i++) { if( strcmp(attr[i]-attrName, attrName) == 0) { if (attr[i]-attrValueType == SA_IMM_ATTR_SASTRINGT) { - strncpy((char*)object_rdn.value, *((char**)attr[i]-attrValues[0]), - SA_MAX_NAME_LENGTH); - object_rdn.value[SA_MAX_NAME_LENGTH-1] = '\0'; - object_rdn.length = strlen((char*)object_rdn.value); + object_rdn = *((char**) attr[i]-attrValues[0]);
[devel] [PATCH 2 of 7] NTF: Adapt NTF osaf service to support long DNs [#873]
osaf/services/saf/ntfsv/ntfs/Makefile.am | 1 + osaf/services/saf/ntfsv/ntfs/NtfFilter.cc | 34 +- osaf/services/saf/ntfsv/ntfs/NtfLogger.cc | 5 +++- osaf/services/saf/ntfsv/ntfs/ntfs_evt.c | 5 ++- osaf/services/saf/ntfsv/ntfs/ntfs_main.c | 5 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/osaf/services/saf/ntfsv/ntfs/Makefile.am b/osaf/services/saf/ntfsv/ntfs/Makefile.am --- a/osaf/services/saf/ntfsv/ntfs/Makefile.am +++ b/osaf/services/saf/ntfsv/ntfs/Makefile.am @@ -39,6 +39,7 @@ osaf_execbindir = $(pkglibdir) osaf_execbin_PROGRAMS = osafntfd osafntfd_CPPFLAGS = \ + -DSA_EXTENDED_NAME_SOURCE \ $(AM_CPPFLAGS) \ -I$(top_srcdir)/osaf/libs/common/ntfsv/include \ -I$(top_srcdir)/osaf/tools/saflog/include diff --git a/osaf/services/saf/ntfsv/ntfs/NtfFilter.cc b/osaf/services/saf/ntfsv/ntfs/NtfFilter.cc --- a/osaf/services/saf/ntfsv/ntfs/NtfFilter.cc +++ b/osaf/services/saf/ntfsv/ntfs/NtfFilter.cc @@ -24,6 +24,7 @@ */ #include NtfFilter.hh +#include string #include logtrace.h #include ntfsv_mem.h @@ -115,22 +116,25 @@ bool NtfFilter::checkSourceIndicator(SaU */ bool NtfFilter::cmpSaNameT(SaNameT *n, SaNameT *n2) { - if (n-length != n2-length) { - if (n-length n2-length) { - char *rv, *p = strndup((char*)n-value, n-length); - char *p2 = strndup((char*)n2-value, n2-length); - rv = strstr(p2,p); - free(p); - free(p2); - if (rv) - return true; - } - return false; - } + bool rc; + char *str2, *str; + size_t length, length2; - if(memcmp(n-value, n2-value, n2-length) == 0) - return true; - return false; + rc = false; + str = ntfs_sanamet_strdup(n); + length = strlen(str); + str2 = ntfs_sanamet_strdup(n2); + length2 = strlen(str2); + + if (length != length2) { + if (length length2) + rc = strstr(str2, str) != NULL; + } else if(memcmp(str, str2, length) == 0) + rc = true; + + free(str); + free(str2); + return rc; } /** diff --git a/osaf/services/saf/ntfsv/ntfs/NtfLogger.cc b/osaf/services/saf/ntfsv/ntfs/NtfLogger.cc --- a/osaf/services/saf/ntfsv/ntfs/NtfLogger.cc +++ b/osaf/services/saf/ntfsv/ntfs/NtfLogger.cc @@ -21,12 +21,14 @@ */ #include sys/poll.h +#include saAis.h #include saLog.h #include NtfAdmin.hh #include NtfLogger.hh #include ntfs_com.h #include logtrace.h #include ntfsv_mem.h +#include osaf_extended_name.h /* * DEFINITIONS @@ -270,7 +272,8 @@ SaAisErrorT NtfLogger::logNotification(N SaAisErrorT NtfLogger::initLog() { SaAisErrorT result; -SaNameT alarmStreamName= {sizeof(SA_LOG_STREAM_ALARM), SA_LOG_STREAM_ALARM}; +SaNameT alarmStreamName; +osaf_extended_name_lend(SA_LOG_STREAM_ALARM, alarmStreamName); int first_try = 1; TRACE_ENTER(); diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c b/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c --- a/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c +++ b/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c @@ -20,6 +20,7 @@ #include limits.h #include ntfs.h #include ntfsv_enc_dec.h +#include ntfsv_mem.h #include ntfs_imcnutil.h @@ -341,10 +342,10 @@ static void print_header(SaNtfNotificati TRACE_1(eventType = %d, (int)*notificationHeader-eventType); /* Notification Object */ - TRACE_1(notificationObject.length = %u\n, notificationHeader-notificationObject-length); + TRACE_1(notificationObject.length = %zu\n, ntfs_sanamet_length(notificationHeader-notificationObject)); /* Notifying Object */ - TRACE_1(notifyingObject-length = %u\n, notificationHeader-notifyingObject-length); + TRACE_1(notifyingObject-length = %zu\n, ntfs_sanamet_length(notificationHeader-notifyingObject)); /* Notification Class ID */ TRACE_1(VendorID = %d\nmajorID = %d\nminorID = %d\n, diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_main.c b/osaf/services/saf/ntfsv/ntfs/ntfs_main.c --- a/osaf/services/saf/ntfsv/ntfs/ntfs_main.c +++ b/osaf/services/saf/ntfsv/ntfs/ntfs_main.c @@ -180,6 +180,11 @@ static uint32_t initialize() uint32_t rc = NCSCC_RC_SUCCESS;; TRACE_ENTER(); + /* Set extended SaNameT environment var*/ + if (setenv(SA_ENABLE_EXTENDED_NAMES, 1, 1) != 0) { + LOG_ER(Failed to enable Extended SaNameT); + goto done; + } /* Determine how this process was started, by NID or AMF */ if (getenv(SA_AMF_COMPONENT_NAME) == NULL) -- Open source