in reply to Re: Re: Re: Re: Permissions Utility Script for sysadmins - seeking comments
in thread Permissions Utility Script for sysadmins - seeking comments

Bother, I was right the first time, and looking at the wrong bit of code the second time.

The wanted_c routine is called once for each file, and in the original code it goes through a series of elsifs until it finds a match, so it will only act on the first match - the first combination of filetype and updatetype that is appropriate.

So to fix it you need to avoid that; the minimal fix would probably be something like this:

sub wanted_c { if (-d $_) { if ($d_mode) { change_mode($_, $d_mode); } if ($d_owner) { change_owner($_, $d_owner); } if ($d_group) { change_group($_, $d_group); } } elsif (-l $_) { ... } elsif (-f $_) { ... } }

The point is that the different filetypes are exclusive: you're only interested in the first type that matches, so an if/elsif chain is appropriate. The updatetypes are not exclusive: you want to act on each updatetype that is specified, so you much check each of them without jumping out on the first one. An if/elsif chain is not appropriate for that case.

Hugo