Hello folks,
I submitted case #324 on cfengine.org on what I believe is a really bad bug
that surfaces in copy_from routines. My files syntax is:
"/bb/bin/syncfs"
copy_from => copyit("/SOURCE/BB/BIN/syncfs"),
perms => mog("500", "root", "other");
This winds up renaming /bb/bin to /bb/bin.cf-moved when the following
conditions are true:
-) /bb/bin is a symbolic link, in my case /bb/bin points to a directory
/bb/sys/opbin, and,
-) /bb/bin/syncfs file does NOT exist
All my binaries are now referenced by /bb/bin.cf-moved and /bb/bin contains a
single program in it, syncfs. Wow, that's bad.
What happens in files_operator.c is:
if (lstat(pathbuf,&statbuf) != -1)
{
if (S_ISLNK(statbuf.st_mode))
At this point, pathbuf = "/bb/bin", which is a symbolic link, and since lstat
is called, statbuf contains information about the symlink itself, not what it
references. That's fine, and we enter that section of the code:
But then,
if (force) /* force in-the-way directories aside */
{
if (!S_ISDIR(statbuf.st_mode)) /* if the dir exists - no problem */
{
is where it all goes wrong, as statbuf still contains data about the symlink,
and the !S_ISDIR check becomes true since a symlink is not a directory. This
enters this section of code where it renames the symlink as /bb/bin.cf-moved
What is missing is a "stat" call on pathbuf prior to checking if its a
directory or not, to determine what the symbolic link is pointing to. If it's
pointing to a directory, the the !S_ISDIR call is false, and the code is not
entered.
Anyone have a fix? I checked both cfengine-3.0.5p1.tar.gz and
cfengine-3.1.0b2.tar.gz, they have the same issue.
Thanks, Jim
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine