Nathan,
Nathan Scott wrote:
> Tim and I were just having a look through this & we have a
> couple of questions/observations:
>
> - the descent algorithm you've used seems to be breadth-first,
> rather than depth-first ... was this your intention? (your
> mail suggests not). We agree it should be depth first (easily
> fixed by moving the call to walk_dir up to the top of set_acl);
Hmm. Sorry. I'm mixing metaphors again. Then again, perhaps I just
don't know my breadth from my depth ;-).
Just after having submitted it, I realized that it would probably be
more efficient to chdir into and out of directories. However, this is
much more complicated, once having thought of it. You'd have to keep a
directory stack, as ".." isn't always where you wish to "return" to
(consider chacl -r u::rwx,g::rx,u::r w/x/y/z/). I'll leave
implementation of that to the reader ;-).
> - trying to understand your '-D_FILE_OFFSET_BITS=64' problem -
> I think we do need this, I just can't understand how this was
> failing for you (can you give more details?) - I have a rh6.2
> system here and it seems to work for the (limited) test cases
> we tried.
Okay, my /usr/include/dirent.h includes <bits/dirent.h>, in which I
see:
struct dirent
{
#ifndef __USE_FILE_OFFSET64
__ino_t d_ino;
__off_t d_off;
#else
__ino64_t d_ino;
__off64_t d_off;
#endif
unsigned short int d_reclen;
unsigned char d_type;
char d_name[256]; /* We must not include limits.h! */
};
Compiling chacl.c WITH -D_FILE_OFFSET_BITS=64 gets me file names of
"". Using gdb, I can see "..", and later on, the other file names.
Compiling WITHOUT -D_FILE_OFFSET_BITS=64 gets me proper file names.
Searching /usr/include for "__USE_FILE_OFFSET64" yields (among others),
"features.h". It is features.h that contains the snippet:
#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
# define __USE_FILE_OFFSET64 1
#endif
Thus, I conclude that chacl.c is using a struct dirent whose size
doesn't match (is larger than) what readdir(3) is returning, no?
> We looked through the fileutils-4.1 code and that seems to
> define _FILE_OFFSET_BITS to 64 (via config.h) on redhat 6.2
> also...
That's fine. I'm probably doing something wrong, but the fix is not
obvious to me.
> Otherwise, the patch looks fine - I'll probably check it in
> shortly.
Yep, at this time (Monday AM Eastern US Daylight), I can see your
'TAKE'.
> thanks.
Happy to be of service.
--
"Men occasionally stumble over the truth, but most of them pick
themselves up and hurry off as if nothing had happened."
-- Winston Churchill
Danny
|