Hi, 

I've been experimenting with cfengine on Windows and found that my
Windows clients would ask for files with wrong paths when asked to copy
files from a directory.


Example rule that fails

files:

        nt:: #dont set modes here
             $(master_cfinput)            dest=$(cf_install_dir)/inputs
                                          r=inf
                                          type=binary
                                          server=$(policyhost)
                                          trustkey=true

Reading the debug output it looks to me like cfagent on the Windows node
correctly retrieves a list of files in the folder $(master_cfinput) at
$(policyhost). It then asks for $(master_cfinput)\filename which is
wrong, because $(policyhost) is a UNIX server and that path is not valid
(/var/cfengine\filename -> stat fails). 

I wrote a small patch that rewrites the path separator from \ to / and
applied it on my Unix server ($policyhost) and then it worked, files
were found and copied to the Windows node. 

Attaching patch (work around). I realize the workaround may not be fit
for inclusion in cfengine, but hope it may be helpful to others facing
the same problem.

Suggestion / feature request: 
Could cfagent maybe look at the path separators in the source directory
specification ( $(master_cfinput) in the example above ) to determine
which separator to use instead of always using the system path
separator?
Example: When the source directory is /var/cfengine/masterinputs we
don't use the system path separator on Windows as we do now ('\') when
joining filename and path (-> /var/cfengine/masterinputs\cfagent.conf),
but the separator found in that path ('/')
(-> /var/cfengine/masterinputs/cfagent.conf).


Cheers, 

PER

--- cfservd.c	2007-01-25 21:54:54.000000000 +0100
+++ cfservd.c-new	2007-03-29 16:31:21.000000000 +0200
@@ -2094,8 +2094,17 @@
   int access = false;
   char realname[CF_BUFSIZE],path[CF_BUFSIZE],lastnode[CF_BUFSIZE];
   struct stat statbuf;
+  int sc;
 
 Debug("AccessControl(%s)\n",filename);
+
+/*fix filename to not have windows slashes */
+for (sc = 0; sc < CF_BUFSIZE; sc++){
+   if (filename[sc] == '\\'){
+      filename[sc] = '/';
+   }
+}
+
 memset(realname,0,CF_BUFSIZE);
 
 /* Separate path first, else this breaks for lastnode = symlink */
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to