bug-cfengine
[Top][All Lists]
Advanced

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

Re: [2.1.0p1] filedir.c:CheckCopiedFile() code weirdness


From: Mark . Burgess
Subject: Re: [2.1.0p1] filedir.c:CheckCopiedFile() code weirdness
Date: Sun, 11 Jan 2004 12:44:52 +0100 (MET)

These expressions seem ok as coded. THe plus and minus quantites
are never zero unless no mode string is set, in which case the
source file's mode is the new mode for the file.
M

On 14 Dec, address@hidden wrote:
> Not a confirmed bug but rather a request for clarification. Sent to bug-
> rather than help- since it's closely related to my earlier bug reports
> and patches.) In CheckCopiedFile() I see the following code:
> 
> if ((plus == 0) && (minus == 0))
>     {
>     newplus = sstat->st_mode & 07777 | plus;
>     newminus = ~(sstat->st_mode & 07777 & ~minus) & 07777;
>     
> CheckExistingFile(file,newplus,newminus,fixall,uidlist,gidlist,dstat,NULL,acl_aliases);
>     }
>  else
>     {
>     
> CheckExistingFile(file,plus,minus,fixall,uidlist,gidlist,dstat,NULL,acl_aliases);
>     }
> 
> I find this code rather strange since the expressions for newplus and
> newminus could have been written more simply (both |plus and &~minus 
> are no-ops in this context where plus==0 and minus==0).
> 
> One wonders if the conditional expression is correct as coded. This is
> really a question about the semantics of mode= attributes in copy:
> stanzas. I initially stumbled upon this while tracking down a bug
> whereby a mode 0777 source directory, together with mode=go-w in the
> stanza, would result in the destination directory being mode 0000.
> (I think my earlier RecursiveImage() patch will cure that problem.)
> 
> "mode=go-w" translates to (plus==0, minus==0022). As the code now
> stands, this will be relative to the current permissions of the
> destination file or directory. Is that correct behaviour, or should
> the specification be interpreted relative to the source permissions?
> 
> [As it turns out, I could get what I want with mode=644 since there
> is code in CheckExistingFile() to turn on the missing x bits on 
> directories. But I don't recall seeing that feature documented
> so I'd prefer not to rely on it. Nor does a mere workaround 
> make an acceptable answer.]
> 
> 
> _______________________________________________
> Bug-cfengine mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-cfengine



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  address@hidden
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





reply via email to

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