help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiling on OS X 10.4 ?


From: mattimustang
Subject: Re: Compiling on OS X 10.4 ?
Date: 22 Jun 2005 14:48:28 -0700
User-agent: G2/0.2

Hi,

I am maintainer for the fink cfengine package on darwin and i've
written this patch. I've based it on an earlier patch by Armin
Wolfermann with a few minor corrections. It will handle defaultroute
for DARWIN, FREEBSD, and OPENBSD. This should really be done properly
with route sockets and I may attempt that later. The patch also
corrects the string comparison of the exisitng route with the new one.
The old strstr() call would incorrectly see 192.168.0.1 and
192.168.0.100 as being the same IP.

This patch has been tested fully tested on darwin/macos x 10.4.1.

regards

matthew

diff -ur cfengine-2.1.15.orig/src/cf.extern.h
cfengine-2.1.15/src/cf.extern.h
--- cfengine-2.1.15.orig/src/cf.extern.h        2005-05-29
20:34:14.000000000 +1000
+++ cfengine-2.1.15/src/cf.extern.h     2005-06-22 22:52:29.000000000
+1000
@@ -29,6 +29,8 @@
 /*******************************************************************/


+#include "../pub/getopt.h"
+
 #if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined
BUILDTIN_GCC_THREAD)
 extern pthread_mutex_t MUTEX_SYSCALL;
 extern pthread_mutex_t MUTEX_LOCK;
Only in cfengine-2.1.15/src: cf.extern.h.orig
diff -ur cfengine-2.1.15.orig/src/ifconf.c cfengine-2.1.15/src/ifconf.c
--- cfengine-2.1.15.orig/src/ifconf.c   2005-03-19 04:05:24.000000000
+1100
+++ cfengine-2.1.15/src/ifconf.c        2005-06-22 23:14:11.000000000
+1000
@@ -404,7 +404,7 @@

    if ((strncmp(VBUFF,"default",7) == 0)||(strncmp(VBUFF,"0.0.0.0",7)
== 0))
       {
-      if (strstr(VBUFF,VDEFAULTROUTE->name))
+      if ((strncmp(VBUFF,VDEFAULTROUTE->name,15)) == 0)
          {
          Verbose("cfengine: default route is already set to
%s\n",VDEFAULTROUTE->name);
          defaultokay = 1;
@@ -445,15 +445,40 @@

 CfLog(cferror,"The default packet-route is incorrectly set, trying to
correct\n","");

-# if defined HAVE_RTENTRY || defined HAVE_ORTENTRY
+#if defined DARWIN || FREEBSD || OPENBSD
+if (VSYSTEMHARDCLASS == freebsd || VSYSTEMHARDCLASS == openbsd ||
VSYSTEMHARDCLASS == darwin)
+   {
+   Debug ("No raw socket protocol for BSD/Darwin -- faking with shell
commands\n");
+   if (defaultokay == 2)
+   {
+   ShellCommandReturnsZero("/sbin/route delete default");
+   }
+   snprintf(VBUFF,CF_MAXVARSIZE,"/sbin/route add default
%s",VDEFAULTROUTE->name);
+   if (ShellCommandReturnsZero(VBUFF))
+      {
+      CfLog(cfinform,"Setting default route","");
+      CfLog(cfinform,VBUFF,"");
+      }
+   else
+      {
+      CfLog(cferror,"Error setting route","");
+      }
+   return;
+   }
+
+#else

+#  if defined LINUX
 if ((sk = socket(AF_INET,SOCK_RAW,0)) == -1)
    {
    if (VSYSTEMHARDCLASS == linuxx)
       {
       Debug ("No raw socket protocol for linux -- faking with shell
commands\n");

+      if (defaultokay == 2)
+      {
       ShellCommandReturnsZero("/sbin/route del default");
+      }

       snprintf(VBUFF,CF_MAXVARSIZE,"/sbin/route add default gw
%s",VDEFAULTROUTE->name);

@@ -474,6 +499,8 @@
    FatalError("Error in SetDefaultRoute()");
    }

+#  else
+#    if defined HAVE_RTENTRY || defined HAVE_ORTENTRY
 sindst.sin_family = AF_INET;
 singw.sin_family = AF_INET;

@@ -497,13 +524,15 @@
    CfLog(cferror,OUTPUT,"");
    }

-# else
+#   else

 /* Socket routing - don't really know how to do this yet */

 Verbose("Sorry don't know how to do routing on this platform\n");
  
-# endif
+#    endif
+#  endif
+#endif
 }
 
 #else /* NT or IRIX */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]