help-cfengine
[Top][All Lists]
Advanced

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

PATCH: for Re: How to define variables using a plugin


From: Adrian Phillips
Subject: PATCH: for Re: How to define variables using a plugin
Date: 01 Aug 2001 15:36:32 +0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

Heres the same patch for fixing copy using plug-in variables for
1.3.6 :-

diff -u -r cfengine-1.3.6/src/do.c cfengine-1.3.6.new/src/do.c
--- cfengine-1.3.6/src/do.c     Fri Jun  8 18:32:17 2001
+++ cfengine-1.3.6.new/src/do.c Wed Aug  1 10:43:41 2001
@@ -2046,19 +2046,22 @@
 { struct Image *ip;
   struct Item *svp;
   struct stat statbuf;
-  struct servent *server;
+  struct servent *serverent;
   int savesilent;
+  char path[bufsize];
+  char destination[bufsize];
+  char server[bufsize];
 
 Banner("Checking file images:");

-if ((server = getservbyname(CFENGINE_SERVICE,"tcp")) == NULL)
+if ((serverent = getservbyname(CFENGINE_SERVICE,"tcp")) == NULL)
    {
    CfLog(cfverbose,"Remember to register cfengine in /etc/services: cfengine 
5308/tcp\n","getservbyname");
    PORTNUMBER = htons((unsigned short)5308);
    }
 else
    {
-   PORTNUMBER = (unsigned short)(server->s_port); /* already in network order 
*/
+   PORTNUMBER = (unsigned short)(serverent->s_port); /* already in network 
order */
    }
  
 for (svp = VSERVERLIST; svp != NULL; svp=svp->next) /* order servers */
@@ -2090,7 +2094,21 @@
    
       IMAGEBACKUP = true;
       
-      Verbose("Checking copy from %s:%s to 
%s\n",ip->server,ip->path,ip->destination);
+         /* Convert any variables to their values */
+         if (IsVarString(ip->server))
+               ExpandVarstring(ip->server,server,"");
+         else
+               strncpy (server, ip->server, sizeof(server));
+         if (IsVarString(ip->path))
+               ExpandVarstring(ip->path,path,"");
+         else
+               strncpy (path, ip->path, sizeof(path));
+         if (IsVarString(ip->destination))
+               ExpandVarstring(ip->destination,destination,"");
+         else
+               strncpy (destination, ip->destination, sizeof(destination));    
        
+
+      Verbose("Checking copy from %s:%s to %s\n",server,path,destination);
       
       savesilent = SILENT;
       
@@ -2101,7 +2118,7 @@
       
       ResetOutputRoute(ip->log,ip->inform);
       
-      sprintf(VBUFF,"%.50s.%.50s",ip->path,ip->destination); /* Unique ID for 
copy locking */
+      snprintf(VBUFF,bufsize,"%.50s.%.50s",path,destination); /* Unique ID for 
copy locking */
 
       if 
(!GetLock(ASUniqueName("copy"),CanonifyName(VBUFF),VIFELAPSED,VEXPIREAFTER,VUQNAME,CFSTARTTIME))
         {
@@ -2112,9 +2129,9 @@
       
       IMAGEBACKUP = ip->backup;
       
-      if (cfstat(ip->path,&statbuf,ip) == -1)
+      if (cfstat(path,&statbuf,ip) == -1)
         {
-        sprintf(OUTPUT,"Can't stat %s in copy\n",ip->path);
+        snprintf(OUTPUT,bufsize*2,"Can't stat %s in copy\n",path);
         CfLog(cfinform,OUTPUT,"");
         ReleaseCurrentLock();
         SILENT = savesilent;
@@ -2122,7 +2139,7 @@
         continue;
         }
       
-      if (strncmp(ip->destination,"home",4) == 0)
+      if (strncmp(destination,"home",4) == 0)
         {
         HOMECOPY = true;          /* Don't send home backups to repository */
         CheckHomeImages(ip);
@@ -2136,11 +2153,11 @@
               {
               Verbose("%s: (Destination purging enabled)\n",VPREFIX);
               }
-           RecursiveImage(ip,ip->path,ip->destination,ip->recurse);
+           RecursiveImage(ip,path,destination,ip->recurse);
            }
         else
            {
-           if (! MakeDirectoriesFor(ip->destination))
+           if (! MakeDirectoriesFor(destination))
               {
               ReleaseCurrentLock();
               SILENT = savesilent;
@@ -2148,7 +2165,7 @@
               continue;
               }
            
-           CheckImage(ip->path,ip->destination,ip);
+           CheckImage(path,destination,ip);
            }
         }
       
Sincerely,

Adrian Phillips

-- 
Your mouse has moved.
Windows NT must be restarted for the change to take effect.
Reboot now?  [OK]



reply via email to

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