rpms/cfengine/devel cfengine-2.1.22-autotools.patch, NONE, 1.1 cfengine-2.1.22-os_detection.patch, NONE, 1.1 cfengine-selinux.patch, NONE, 1.1 cfengine.spec, 1.24, 1.25

Jeff Sheltren (sheltren) fedora-extras-commits at redhat.com
Fri Apr 13 12:58:32 UTC 2007


Author: sheltren

Update of /cvs/extras/rpms/cfengine/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv23085

Modified Files:
	cfengine.spec 
Added Files:
	cfengine-2.1.22-autotools.patch 
	cfengine-2.1.22-os_detection.patch cfengine-selinux.patch 
Log Message:
Add patches for selinux support, fix configure.ac for newer autotools, and detect newer fedora/redhat dists


cfengine-2.1.22-autotools.patch:

--- NEW FILE cfengine-2.1.22-autotools.patch ---
--- cfengine-2.1.22/configure.ac.autotools	2007-04-13 05:03:39.000000000 -0700
+++ cfengine-2.1.22/configure.ac	2007-04-13 05:05:21.000000000 -0700
@@ -375,7 +375,7 @@
                             CPPFLAGS="$CPPFLAGS -I$d/include"
                             LDFLAGS="$LDFLAGS -L$d/lib"
                             PCRE_LIB="-lpcreposix"
-                            AC_MSG_RESULT = "$d"
+                            AC_MSG_RESULT($d)
                             break
                         fi
                     done
@@ -386,13 +386,13 @@
                 if test -f "${withval}/include/pcreposix.h" ; then
                     CPPFLAGS="$CPPFLAGS -I${withval}/include"
                     LDFLAGS="$LDFLAGS -L${withval}/lib"
-                    AC_MSG_RESULT = "${withval}"
+                    AC_MSG_RESULT(${withval})
                 else
                     AC_MSG_ERROR(Cannot find PCRE)
                 fi
                 fi
             else
-                AC_MSG_RESULT = "yes"
+                AC_MSG_RESULT(yes)
             fi
             LIBS="$LIBS -lpcreposix"
             AC_DEFINE(USE_PCRE, 1, [Define if PCRE is available.])

cfengine-2.1.22-os_detection.patch:

--- NEW FILE cfengine-2.1.22-os_detection.patch ---
--- cfengine-2.1.22/src/misc.c.fedora	2007-04-11 07:02:43.000000000 -0700
+++ cfengine-2.1.22/src/misc.c	2007-04-13 04:21:57.000000000 -0700
@@ -481,16 +481,24 @@
       AddClassToHeap(VBUFF);
       }
    }
-
+/* {Mandrake,Fedora} has a symlink at /etc/redhat-release pointing to
+ * /etc/{mandrake,fedora}-release, so we else-if around that
+ */
 if (stat("/etc/mandrake-release",&statbuf) != -1)
    {
    Verbose("This appears to be a mandrake system.\n");
    AddClassToHeap("Mandrake");
    linux_mandrake_version();
    }
-/* Mandrake has a symlink at /etc/redhat-release pointing to
- * /etc/mandrake-release, so we else-if around that
- */
+
+else if (stat("/etc/fedora-release",&statbuf) != -1)
+   {
+   Verbose("This appears to be a fedora system.\n");
+   AddClassToHeap("redhat");
+   AddClassToHeap("fedora");
+   linux_fedora_version();
+   }
+
 else if (stat("/etc/redhat-release",&statbuf) != -1)
    {
    Verbose("This appears to be a redhat system.\n");
@@ -524,6 +532,8 @@
    AddClassToHeap("UnitedLinux");
    }
 
+lsb_version();
+
 if (stat("/etc/vmware",&statbuf) != -1)
    {
    if (S_ISDIR(statbuf.st_mode))
@@ -540,13 +550,14 @@
 
 int linux_fedora_version(void)
 {
-#define FEDORA_ID "Fedora Core"
+#define FEDORA_ID "Fedora"
 
 #define RELEASE_FLAG "release "
 
 /* We are looking for one of the following strings...
  *
  * Fedora Core release 1 (Yarrow)
+ * Fedora release 7 (Zodfoobar)
  */
 
 #define FEDORA_REL_FILENAME "/etc/fedora-release"
@@ -627,9 +638,10 @@
 #define REDHAT_AS21_ID "Red Hat Linux Advanced Server"
 #define REDHAT_ES_ID "Red Hat Enterprise Linux ES"
 #define REDHAT_WS_ID "Red Hat Enterprise Linux WS"
+#define REDHAT_C_ID "Red Hat Enterprise Linux Client"
+#define REDHAT_S_ID "Red Hat Enterprise Linux Server"
 #define MANDRAKE_ID "Linux Mandrake"
 #define MANDRAKE_10_1_ID "Mandrakelinux"
-#define FEDORA_ID "Fedora Core"
 #define WHITEBOX_ID "White Box Enterprise Linux"
 #define CENTOS_ID "CentOS"
 #define SCIENTIFIC_SL_ID "Scientific Linux SL"
@@ -642,9 +654,10 @@
  * Red Hat Linux Advanced Server release 2.1AS (Pensacola)
  * Red Hat Enterprise Linux AS release 3 (Taroon)
  * Red Hat Enterprise Linux WS release 3 (Taroon)
+ * Red Hat Enterprise Linux Client release 5 (Tikanga)
+ * Red Hat Enterprise Linux Server release 5 (Tikanga)
  * Linux Mandrake release 7.1 (helium)
  * Red Hat Enterprise Linux ES release 2.1 (Panama)
- * Fedora Core release 1 (Yarrow)
  * White Box Enterprise linux release 3.0 (Liberation)
  * Scientific Linux SL Release 4.0 (Beryllium)
  * CentOS release 4.0 (Final)
@@ -702,6 +715,16 @@
     vendor = "redhat";
     edition = "as";
     }
+ else if(!strncmp(relstring, REDHAT_S_ID, strlen(REDHAT_S_ID)))
+    {
+    vendor = "redhat";
+    edition = "s";
+    }
+ else if(!strncmp(relstring, REDHAT_C_ID, strlen(REDHAT_C_ID)))
+    {
+    vendor = "redhat";
+    edition = "c";
+    }
  else if(!strncmp(relstring, REDHAT_ID, strlen(REDHAT_ID)))
     {
     vendor = "redhat";
@@ -714,10 +737,6 @@
     {
     vendor = "mandrake";
     }
- else if(!strncmp(relstring, FEDORA_ID, strlen(FEDORA_ID)))
-    {
-    vendor = "fedora";
-    }
  else if(!strncmp(relstring, WHITEBOX_ID, strlen(WHITEBOX_ID)))
     {
     vendor = "whitebox";
@@ -813,9 +832,9 @@
 int linux_suse_version(void)
 {
 #define SUSE_REL_FILENAME "/etc/SuSE-release"
-#define SUSE_SLES8_ID "SuSE SLES-8"
-#define SUSE_SLES9_ID "SUSE LINUX Enterprise Server 9"
-#define SUSE_SLES_ID "SUSE LINUX Enterprise Server"
+/* Check if it's a SuSE Enterprise version (all in lowercase) */
+#define SUSE_SLES8_ID "suse sles-8"
+#define SUSE_SLES_ID  "suse linux enterprise server"
 #define SUSE_RELEASE_FLAG "linux "
 
 /* The full string read in from SuSE-release */
@@ -848,42 +867,38 @@
 
 Verbose("Looking for SuSE enterprise info in \"%s\"\n",relstring);
  
-if (!strncmp(relstring, SUSE_SLES8_ID, strlen(SUSE_SLES8_ID)))
+ /* Convert relstring to lowercase to handle rename of SuSE to 
+  * SUSE with SUSE 10.0. 
+  */
+
+for (i = 0; i < strlen(relstring); i++)
    {
-   classbuf[0] = '\0';
-   strcat(classbuf, "SLES8");
-   AddClassToHeap(classbuf);
+   relstring[i] = tolower(relstring[i]);
    }
-else if (!strncmp(relstring, SUSE_SLES9_ID, strlen(SUSE_SLES9_ID)))
+
+   /* Check if it's a SuSE Enterprise version (all in lowercase) */
+
+if (!strncmp(relstring, SUSE_SLES8_ID, strlen(SUSE_SLES8_ID)))
    {
    classbuf[0] = '\0';
-   strcat(classbuf, "SLES9");
+   strcat(classbuf, "SLES8");
    AddClassToHeap(classbuf);
    }
-
-  
-
-for (version = 9; version < 13; version++)
+else
    {
-   snprintf(vbuf,CF_BUFSIZE,"%s %d",SUSE_SLES_ID,version);
-   Debug("Checking for suse [%s]\n",vbuf);
-   
-   if (!strncmp(relstring, SUSE_SLES_ID, strlen(relstring)))
+   for (version = 9; version < 13; version++)
       {
-      snprintf(classbuf,CF_MAXVARSIZE,"SLES%d",version);
-      AddClassToHeap(classbuf);
+      snprintf(vbuf,CF_BUFSIZE,"%s %d ",SUSE_SLES_ID,version);
+      Debug("Checking for suse [%s]\n",vbuf);
+      
+      if (!strncmp(relstring, vbuf, strlen(vbuf)))
+         {
+         snprintf(classbuf,CF_MAXVARSIZE,"SLES%d",version);
+         AddClassToHeap(classbuf);
+         }
       }
    }
     
- /* Convert relstring to lowercase to handle rename of SuSE to 
-  * SUSE with SUSE 10.0. 
-  */
-
-for (i = 0; i < strlen(relstring); i++)
-   {
-   relstring[i] = tolower(relstring[i]);
-   }
-
  /* Determine release version. We assume that the version follows
   * the string "SuSE Linux" or "SUSE LINUX".
   */
@@ -1061,6 +1076,115 @@
 
 /******************************************************************/
 
+static void * lsb_release(const char *command, const char *key)
+
+{ char * info = NULL;
+ FILE * fp;
+
+snprintf(VBUFF, CF_BUFSIZE, "%s %s", command, key);
+if ((fp = cfpopen(VBUFF, "r")) == NULL)
+   {
+   return NULL;
+   }
+
+if (ReadLine(VBUFF, CF_BUFSIZE, fp))
+   {
+   char * buffer = VBUFF;
+   strsep(&buffer, ":");
+   
+   while((*buffer != '\0') && isspace(*buffer))
+      {
+      buffer++;
+      }
+   
+   info = buffer;
+   while((*buffer != '\0') && !isspace(*buffer))
+      {
+      *buffer = tolower(*buffer++);
+      }
+   
+   *buffer = '\0';
+   info = strdup(info);
+   }
+
+cfpclose(fp);
+return info;
+}
+
+
+/******************************************************************/
+
+int lsb_version(void)
+{
+#define LSB_RELEASE_COMMAND "lsb_release"
+
+char classname[CF_MAXVARSIZE];
+char *distrib  = NULL;
+char *release  = NULL;
+char *codename = NULL;
+int major = 0;
+int minor = 0;
+
+char *path, *dir, *rest;
+struct stat statbuf;
+
+path = rest = strdup(getenv("PATH"));
+for (; dir = strsep(&rest, ":") ;)
+    {
+    snprintf(VBUFF, CF_BUFSIZE, "%s/" LSB_RELEASE_COMMAND, dir);
+    if (stat(VBUFF,&statbuf) != -1)
+        {
+        free(path);
+        path = strdup(VBUFF);
+
+        Verbose("\nThis appears to be a LSB compliant system.\n");
+        AddClassToHeap("lsb_compliant");
+        break;
+        }
+    }
+
+if (!dir)
+    {
+    free(path);
+    return 1;
+    }
+
+if ((distrib  = lsb_release(path, "--id")) != NULL)
+    {
+    snprintf(classname, CF_MAXVARSIZE, "%s", distrib);
+    AddClassToHeap(classname);
+
+    if ((codename = lsb_release(path, "--codename")) != NULL)
+        {
+        snprintf(classname, CF_MAXVARSIZE, "%s_%s", distrib, codename);
+        AddClassToHeap(classname);
+        }
+
+    if ((release  = lsb_release(path, "--release")) != NULL)
+        {
+        switch (sscanf(release, "%d.%d\n", &major, &minor))
+            {
+            case 2:
+                snprintf(classname, CF_MAXVARSIZE, "%s_%u_%u", distrib, major, minor);
+                AddClassToHeap(classname);
+            case 1:
+                snprintf(classname, CF_MAXVARSIZE, "%s_%u", distrib, major);
+                AddClassToHeap(classname);
+            }
+        }
+
+    free(path);
+    return 0;
+    }
+else
+    {
+    free(path);
+    return 2;
+    }
+}
+
+/******************************************************************/
+
 int VM_version(void)
 
 { FILE *fp;

cfengine-selinux.patch:

--- NEW FILE cfengine-selinux.patch ---
--- cfengine-2.1.22/Makefile.in.selinux	2007-02-25 07:28:27.000000000 -0800
+++ cfengine-2.1.22/Makefile.in	2007-02-25 07:29:43.000000000 -0800
@@ -128,6 +128,7 @@
 LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIB_SELINUX = @LIB_SELINUX@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
 NEED_SETGID = @NEED_SETGID@
--- cfengine-2.1.22/configure.ac.selinux	2007-02-25 06:58:36.000000000 -0800
+++ cfengine-2.1.22/configure.ac	2007-02-25 07:45:46.000000000 -0800
@@ -537,6 +537,18 @@
 
 
 dnl ######################################################################
+dnl Give the chance to enable SELINUX
+dnl ######################################################################
+dnl 
+AC_ARG_ENABLE(selinux, dnl 
+               [  --enable-selinux              Enable use of the SELINUX libraries],
+               [AC_DEFINE(WITH_SELINUX, 1, [Define if you want to use SELINUX])
+               LIB_SELINUX="-lselinux"
+               LIBS="$LIBS $LIB_SELINUX"
+               AC_SUBST(LIB_SELINUX)])
+
+
+dnl ######################################################################
 dnl OS specific stuff
 dnl ######################################################################

--- cfengine-2.1.22/src/cf.defs.h.selinux	2007-02-25 12:03:59.000000000 -0800
+++ cfengine-2.1.22/src/cf.defs.h	2007-02-25 12:04:24.000000000 -0800
@@ -267,6 +267,9 @@
 # include <sched.h>
 #endif
 
+#ifdef WITH_SELINUX
+# include <selinux/selinux.h> 
+#endif
 
 /*******************************************************************/
 /* Various defines                                                 */
--- cfengine-2.1.22/src/item-file.c.selinux	2007-02-25 06:40:04.000000000 -0800
+++ cfengine-2.1.22/src/item-file.c	2007-02-25 12:11:39.000000000 -0800
@@ -107,6 +107,17 @@
   char stamp[CF_BUFSIZE]; 
   time_t STAMPNOW;
   STAMPNOW = time((time_t *)NULL);
+#ifdef WITH_SELINUX
+  int selinux_enabled=0;
+  security_context_t scontext=NULL;
+
+  selinux_enabled = (is_selinux_enabled()>0);
+  if(selinux_enabled)
+      {
+      /* get current security context */
+      getfilecon(file, &scontext);
+      }
+#endif
 
 if (stat(file,&statbuf) == -1)
    {
@@ -185,6 +196,13 @@
 chmod(file,statbuf.st_mode);                    /* Restore file permissions etc */
 chown(file,statbuf.st_uid,statbuf.st_gid);
 umask(mask); 
+#ifdef WITH_SELINUX
+if(selinux_enabled)
+    {
+    /* restore file context */
+    setfilecon(file,scontext);
+    }
+#endif
 return true;
 }
 
--- cfengine-2.1.22/src/image.c.selinux	2007-03-04 16:31:57.000000000 -0400
+++ cfengine-2.1.22/src/image.c	2007-03-18 09:31:48.000000000 -0400
@@ -1122,6 +1122,14 @@
 rsrcfork=0;
 #endif
 
+#ifdef WITH_SELINUX
+int selinux_enabled=0;
+/* need to keep track of security context of destination file (if any) */
+security_context_t scontext=NULL;
+struct stat cur_dest;
+int dest_exists;
+selinux_enabled = (is_selinux_enabled()>0);
+#endif
 
 Debug2("CopyReg(%s,%s)\n",source,dest);
 
@@ -1131,6 +1139,24 @@
    return false;
    }
 
+#ifdef WITH_SELINUX
+if(selinux_enabled)
+    {
+    dest_exists = stat(dest,&cur_dest);
+    if(dest_exists == 0)
+        {
+        /* get current security context of destination file */
+        getfilecon(dest,&scontext);
+        }
+    else
+        {
+        /* use default security context when creating destination file */
+        matchpathcon(dest,0,&scontext);
+        setfscreatecon(scontext);
+        }
+    }
+#endif
+
  /* Make an assoc array of inodes used to preserve hard links */
 
 linkable = CompressedArrayValue(ip->inode_cache,sstat.st_ino);
@@ -1438,7 +1464,24 @@
     utime(dest,&timebuf);
 #endif
     }
- 
+
+#ifdef WITH_SELINUX
+if(selinux_enabled)
+    {
+    if(dest_exists == 0)
+        {
+        /* set dest context to whatever it was before copy */
+        setfilecon(dest,scontext);
+        }
+    else
+        {
+        /* set create context back to default */
+        setfscreatecon(NULL);
+        }
+    freecon(scontext);
+    }
+#endif
+
  return true;
 }
 


Index: cfengine.spec
===================================================================
RCS file: /cvs/extras/rpms/cfengine/devel/cfengine.spec,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- cfengine.spec	31 Jan 2007 14:59:24 -0000	1.24
+++ cfengine.spec	13 Apr 2007 12:57:55 -0000	1.25
@@ -1,17 +1,22 @@
 Summary: A systems administration tool for networks
 Name: cfengine
 Version: 2.1.22
-Release: 1%{?dist}
+Release: 3%{?dist}
 License: GPL
 Group: Applications/System
 Source0: ftp://ftp.iu.hio.no/pub/cfengine/cfengine-2.1.22.tar.gz
 Source1: cfexecd
 Source2: cfservd
 Source3: cfenvd
+Patch0: cfengine-selinux.patch
+Patch1: cfengine-2.1.22-os_detection.patch
+Patch2: cfengine-2.1.22-autotools.patch
 URL: http://www.cfengine.org/
 BuildRequires: db4-devel,openssl-devel,texinfo,tetex,tetex-dvips,bison,flex,m4,libacl-devel
+BuildRequires: libselinux-devel,automake,autoconf
 Requires(post): /sbin/chkconfig, /sbin/install-info
-Requires(preun): /sbin/chkconfig, /sbin/install-info
+Requires(preun): /sbin/chkconfig, /sbin/install-info, /sbin/service
+Requires(postun): /sbin/service
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 %description
@@ -26,13 +31,17 @@
 
 %prep
 %setup -q
+%patch0 -p1 -b .selinux
+%patch1 -p1 -b .fedora
+%patch2 -p1 -b .autotools
 
 
 %build
-# Since /usr is managed by rpmdb, we can build stuff in there
-# instead of putting all this stuff under /usr/local
-# ./configure BERKELEY_DB_LIB=-ldb --prefix=/usr --infodir=/usr/share/info
-%configure BERKELEY_DB_LIB=-ldb --with-docs
+# need to run autoconf/automake since we patch configure for SELinux support
+aclocal
+autoconf --force
+automake --copy --force
+%configure BERKELEY_DB_LIB=-ldb --with-docs --enable-selinux
 make
 # Some of the example files have execute bit for some reason.
 chmod 644 inputs/*example
@@ -81,18 +90,28 @@
 /sbin/install-info --info-dir=%{_infodir} %{_infodir}/cfengine*.info* 2> /dev/null || :
 # add init files to chkconfig
 if [ "$1" = "1" ]; then
-	chkconfig --add cfenvd
-	chkconfig --add cfexecd
-	chkconfig --add cfservd
+	/sbin/chkconfig --add cfenvd
+	/sbin/chkconfig --add cfexecd
+	/sbin/chkconfig --add cfservd
 fi
 
 
 %preun
 if [ "$1" = "0" ]; then
-        /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/cfengine*.info* 2> /dev/null || :
-	chkconfig --del cfenvd
-	chkconfig --del cfexecd
-	chkconfig --del cfservd
+    /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/cfengine*.info* 2> /dev/null || :
+    /sbin/service cfenvd stop >/dev/null 2>&1 || :
+    /sbin/service cfexecd stop >/dev/null 2>&1 || :
+    /sbin/service cfservd stop >/dev/null 2>&1 || :
+	/sbin/chkconfig --del cfenvd
+	/sbin/chkconfig --del cfexecd
+	/sbin/chkconfig --del cfservd
+fi
+
+%postun
+if [ $1 -ge 1 ]; then
+    /sbin/service cfenvd condrestart >/dev/null 2>&1 || :
+    /sbin/service cfexecd condrestart >/dev/null 2>&1 || :
+    /sbin/service cfservd condrestart >/dev/null 2>&1 || :
 fi
 
 
@@ -111,13 +130,23 @@
 %{_sbindir}/*
 %{_mandir}/man8/*
 %{_infodir}/cfengine*
-%config %{_initrddir}/cfenvd
-%config %{_initrddir}/cfexecd
-%config %{_initrddir}/cfservd
+%{_initrddir}/cfenvd
+%{_initrddir}/cfexecd
+%{_initrddir}/cfservd
 %{_var}/%{name}
 
 
 %changelog
+* Fri Apr 13 2007 Jeff Sheltren <sheltren at cs.ucsb.edu> 2.1.22-3
+- Patch for OS detection for newer Fedora/RedHat releases (#235922)
+- Patch for updated autotools
+- Add service condrestart commands to postun
+- Add service stop commands to preun
+
+* Sun Feb 25 2007 Jeff Sheltren <sheltren at cs.ucsb.edu> 2.1.22-2
+- Patch for selinux support (#187120)
+- init scripts no longer marked as config files
+
 * Mon Jan 29 2007 Jeff Sheltren <sheltren at cs.ucsb.edu> 2.1.22-1
 - update to upstream 2.2.22
 




More information about the fedora-extras-commits mailing list