[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Make sure plugin variables are being used for copy
From: |
Adrian Phillips |
Subject: |
[PATCH] Make sure plugin variables are being used for copy |
Date: |
05 Feb 2002 13:23:13 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 |
This I sent earlier (several weeks ago) for 1.6.3.
diff -urN cfengine-2.0.a16/src/do.c cfengine-2.0.a16.new/src/do.c
--- cfengine-2.0.a16/src/do.c Thu Jan 17 22:12:50 2002
+++ cfengine-2.0.a16.new/src/do.c Fri Feb 1 11:56:14 2002
@@ -2235,17 +2235,20 @@
{ 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];
-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 */
@@ -2287,7 +2290,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;
@@ -2298,7 +2315,7 @@
ResetOutputRoute(ip->log,ip->inform);
- snprintf(VBUFF,bufsize,"%.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))
{
@@ -2309,9 +2326,9 @@
IMAGEBACKUP = ip->backup;
- if (cfstat(ip->path,&statbuf,ip) == -1)
+ if (cfstat(path,&statbuf,ip) == -1)
{
- snprintf(OUTPUT,bufsize*2,"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;
@@ -2319,7 +2336,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);
@@ -2333,11 +2350,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,'f'))
+ if (! MakeDirectoriesFor(destination,'f'))
{
ReleaseCurrentLock();
SILENT = savesilent;
@@ -2345,7 +2362,7 @@
continue;
}
- CheckImage(ip->path,ip->destination,ip);
+ CheckImage(path,destination,ip);
}
}
--
Your mouse has moved.
Windows NT must be restarted for the change to take effect.
Reboot now? [OK]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Make sure plugin variables are being used for copy,
Adrian Phillips <=