Is there a combine variant for chmod
and chgrp
that sets both permissions and groups in one single system call for each file?
There is no such a variant because the two operations chmod(2)
and chown(2)
are implemented by distinct system calls.
chmod
and chown
You might be looking for such a variant of chmod
and chown
because of security issues. If this is the case, you can use the following strategy:
This way you avoid potential security issues associated to successive calls to chmod
and chown
or to chown
and chmod
.
install
/open
trickThe only system call setting mode flags and ownership information at the same time might be open(2)
. So, you could use a process impersonating the target owner opening the file with the appropriate mode. This is probably what install
does, so if this is an option:
install
command.Doing this will break hard links, however. The solution based on chown
and chmod
does not have that issue.