I've got a perl script which systematically changes permissions. The first thing the script does is remove all permissions. It does this by calling chmod(from perl). I did this as I found the set guid bit wouldn't clear unless I explicitly cleared it:
system('find',
$topdir,
'-exec', 'chmod', 'u-swrx,g-swrx,o-swrx', '{}', ';'
);
I set different permissions for groups and directories. Using find, I call it from perl as follows (in this case for directories):
system(
'find',
$topdir,
'-type', 'd',
'-exec', 'chmod', 'g=rx', '{}', ';'
);
Now even though I only set rx, when I check file permissions after the script has finished executing, the scripts appear to have rwx. Is there something I should look out for, as I don't quite follow why this is happening; I don't explicitly set it anywhere. I do set ACLs as well, but they all behave as expected. The only thing of note I see when I check with getfacl is mask::rwx and default:mask::rwx. Could that be what is causing the problem?
chmod, and a coreFile::Findmodule that works recursively much likefind. Kind of tidier and probably more flexible, etc. PlusFile::Findis worth learning how to use.chmodfor all objects anyway (firstfindcall) it makes sense to leave out find completely and usechmod -R ...instead (unless you are not root but then you should callfindwith the option-depth). The second call can be a lot faster by using-exec +(if yourfindsupports that). For debugging I recommend that you call chmod (viafind -name) for a single file and run the perl script through strace. That should tell you what happens at the system level.chmod g=rx filefor some file, and look what happens. Perhaps you aren't allowed to change permissions (you can change them only on your objects, unless you are root).