03-chmod-chown
03-chmod-chown
Jan Schaumann
[email protected]
https://stevens.netmeister.org/631/
CS631 - Advanced Programming in the UNIX Environment
Changes the permission bits on the le. Must be either euid 0 or euid == st_uid.
mode can be any of the bits from our discussion of st_mode as well as:
• S_ISUID – setuid • S_IRWXU – user read, write and execute
• S_ISGID – setgid • S_IRWXG – group read, write and execute
• S_ISVTX – sticky bit (aka “saved text”) • S_IRWXO – other read, write and execute
2
Jan Schaumann 2022-01-18
fi
fl
CS631 - Advanced Programming in the UNIX Environment
3
Jan Schaumann 2022-01-18
CS631 - Advanced Programming in the UNIX Environment
Changes st_uid and st_gid for a le. Generally requires euid 0. (Some SVR4’s let users chown
their les to anybody. POSIX allows either, depending on _POSIX_CHOWN_RESTRICTED.)
owner or group can be -1 to indicate that it should remain the same.
Non-superusers can change the st gid eld if both:
• euid == st_uid; and
• owner == st_uid and group == egid (or one of the supplementary group IDs)
4
Jan Schaumann 2022-01-18
fi
fi
fi
fl
CS631 - Advanced Programming in the UNIX Environment
5
Jan Schaumann 2022-01-18
CS631 - Advanced Programming in the UNIX Environment
chmod(2) and chown(2) consistently follow the semantics of the other calls we've seen.
Only root can change the owner of a le, but the owner may change the group
ownership of a le.
Coming up next: default le ownership and permissions for newly created les.
6
Jan Schaumann 2022-01-18
fi
fi
fi
fi
fi
fi
fi