fizwit/filesystem-reporting-tools

pwalk error code on "unable to setuid root; not all files will be processed"

malcook opened this issue · 1 comments

John,

I've sleuthed past all this:

It appears that pwalk returns error code 1 when it reports "unable to setuid root; not all files will be processed" but that this does not terminate processing.

Does it report this even if the current non-root process has read access to all files being scanned?

In other words, might it report this even if all files WILL be processed?

Of does pwalk only try to elevate to root upon finding files it can not stat?

Finally, upon finding files it can not stat, can you please confirm that pwalk otherwise completes scanning all other files that it can reach?

Or not?

I am finding that pwalk is returning a different number of lines before failing with error 1. I assume this is due to the error being raised in one thread, while other threads are emitting a variable number of results dependiing of file access times.

I'm hoping to find a way to allow pwalk to continue without failing upon failing to setuid root.

Any chance of that?

I now see that it is exiting when running as non-root upon encountering a dir which I lack privs to read, at line 165

if ( (dirp = opendir( cur->dname )) == NULL ) {
    exit ( 1 );
}

I tried changing that to simply return and it seems to accomodate my needs perfectly, but I wanted to check the logic with you.

Perhaps pwalk should take an option to skip unreadable directories (with a warning message) and only return in that case, other wise exit (1), still with an error message.

My C is decades old - mostly coding by example now - else I would offer a pull request with some new option processing as above.

What think you?

Thanks,

Malcolm

accepted your pull request. pwalk will continue to scan if it encounters permissions issues.