File pacemaker-libcrmservice-follow-LSB-header-block.patch of Package pacemaker.14737
commit b877c1553aaad55a94e8a7046f3db1b9dca14a8e
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Fri Oct 13 15:17:33 2017 -0500
Low: libcrmservice: follow LSB standard for header block more strictly
Header block keywords are case-sensitive, and the header must start
with the "### BEGIN INIT INFO" delimiter.
This avoids problems when a line contains "# description:" before the
LSB header block (e.g. in a "chkconfig:"-style header).
Index: pacemaker-1.1.16+20170320.77ea74d/lib/lrmd/lrmd_client.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/lib/lrmd/lrmd_client.c
+++ pacemaker-1.1.16+20170320.77ea74d/lib/lrmd/lrmd_client.c
@@ -1654,6 +1654,9 @@ stonith_get_metadata(const char *provide
" </special>\n" \
"</resource-agent>\n"
+/* See "Comment Conventions for Init Scripts" in the LSB core specification at:
+ * http://refspecs.linuxfoundation.org/lsb.shtml
+ */
#define LSB_INITSCRIPT_INFOBEGIN_TAG "### BEGIN INIT INFO"
#define LSB_INITSCRIPT_INFOEND_TAG "### END INIT INFO"
#define PROVIDES "# Provides:"
@@ -1687,7 +1690,7 @@ stonith_get_metadata(const char *provide
static inline gboolean
lsb_meta_helper_get_value(const char *line, char **value, const char *prefix)
{
- if (!*value && !strncasecmp(line, prefix, strlen(prefix))) {
+ if (!*value && !strncmp(line, prefix, strlen(prefix))) {
*value = (char *)xmlEncodeEntitiesReentrant(NULL, BAD_CAST line+strlen(prefix));
return TRUE;
}
@@ -1710,6 +1713,7 @@ lsb_get_metadata(const char *type, char
char *s_dscrpt = NULL;
char *xml_l_dscrpt = NULL;
int offset = 0;
+ bool in_header = FALSE;
int max = 2048;
char description[max];
@@ -1727,6 +1731,16 @@ lsb_get_metadata(const char *type, char
/* Enter into the lsb-compliant comment block */
while (fgets(buffer, sizeof(buffer), fp)) {
+ // Ignore lines up to and including the block delimiter
+ if (!strncmp(buffer, LSB_INITSCRIPT_INFOBEGIN_TAG,
+ strlen(LSB_INITSCRIPT_INFOBEGIN_TAG))) {
+ in_header = TRUE;
+ continue;
+ }
+ if (!in_header) {
+ continue;
+ }
+
/* Now suppose each of the following eight arguments contain only one line */
if (lsb_meta_helper_get_value(buffer, &provides, PROVIDES)) {
continue;
@@ -1754,7 +1768,9 @@ lsb_get_metadata(const char *type, char
}
/* Long description may cross multiple lines */
- if (offset == 0 && (0 == strncasecmp(buffer, DESCRIPTION, strlen(DESCRIPTION)))) {
+ if ((offset == 0) // haven't already found long description
+ && !strncmp(buffer, DESCRIPTION, strlen(DESCRIPTION))) {
+
/* Between # and keyword, more than one space, or a tab
* character, indicates the continuation line.
*
@@ -1777,12 +1793,13 @@ lsb_get_metadata(const char *type, char
xml_l_dscrpt = (char *)xmlEncodeEntitiesReentrant(NULL, BAD_CAST(description));
}
- if (!strncasecmp(buffer, LSB_INITSCRIPT_INFOEND_TAG, strlen(LSB_INITSCRIPT_INFOEND_TAG))) {
- /* Get to the out border of LSB comment block */
+ // Stop if we leave the header block
+ if (!strncmp(buffer, LSB_INITSCRIPT_INFOEND_TAG,
+ strlen(LSB_INITSCRIPT_INFOEND_TAG))) {
break;
}
if (buffer[0] != '#') {
- break; /* Out of comment block in the beginning */
+ break;
}
}
fclose(fp);