Yes it works!
Sorry for the long wait.

Seeing it is applied to the current version in svn (revision 436), I
tested that one. Using a Windows client and a Linux binary server/policy
host, the problem I previously reported is now gone.

I thought it might be interesting to try it the other way around, to
request files from a Windows binary server from a Linux client. I wasn't
able to test that because of a bug in the basic functionality. I'll
report that bug in another email.

Cheers, 
PER

-----Original Message-----
From: Mark Burgess [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 04, 2007 10:32 AM
To: Per Christian Henden
Cc: [email protected]
Subject: Re: Windows cfagent file path bug and quick fix


You could try this patch for src/filenames.c which uses your
suggestion. Does this work as expected?

Per Christian Henden wrote:
> 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

-- 
Mark Burgess

Professor of Network and System Administration
Oslo University College

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  [EMAIL PROTECTED]
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to