stages: 2/02-squashfs: apply some patches from Debian to make the ISO more reliable
[dragora.git] / patches / squashfs-tools / 0013-use-macros-not-raw-octal-with-chmod.patch
blob574a5bc75c3ec70b3ca2165e898da0c6d26f162b
1 Author: Tyler Hicks <tyhicks@canonical.com>
2 Origin: backport, https://sourceforge.net/p/squashfs/mailman/message/36343213/
3 Description: Using macros, rather than raw octal values, better conveys the
4 intent of masking off the setuid, setgid, and sticky bits.
5 Forwarded: yes
6 Bug-Ubuntu: https://launchpad.net/bugs/1779914
8 Index: squashfs-tools-4.3/squashfs-tools/unsquashfs.c
9 ===================================================================
10 --- squashfs-tools-4.3.orig/squashfs-tools/unsquashfs.c
11 +++ squashfs-tools-4.3/squashfs-tools/unsquashfs.c
12 @@ -821,6 +821,8 @@ int set_attributes(char *pathname, int m
13 unsigned int xattr, unsigned int set_mode)
15 struct utimbuf times = { time, time };
16 + /* Mode bits that are only useful with root privileges */
17 + mode_t root_mask = S_ISUID | S_ISGID | S_ISVTX;
19 if(utime(pathname, &times) == -1) {
20 ERROR("set_attributes: failed to set time on %s, because %s\n",
21 @@ -836,9 +838,9 @@ int set_attributes(char *pathname, int m
22 return FALSE;
24 } else
25 - mode &= ~07000;
26 + mode &= ~(root_mask);
28 - if((set_mode || (mode & 07000)) && chmod(pathname, (mode_t) mode) == -1) {
29 + if((set_mode || (mode & root_mask)) && chmod(pathname, (mode_t) mode) == -1) {
30 ERROR("set_attributes: failed to change mode %s, because %s\n",
31 pathname, strerror(errno));
32 return FALSE;