Linux installer: Also fix the execute bits in the umask if the user runs the installer with a umask that prevents files from being world executable.

Merge branch 'master' of https://github.com/jgoguen/calibre
This commit is contained in:
Kovid Goyal 2018-06-23 08:45:50 +05:30
commit efa7e9e0b1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 4 deletions

View File

@ -694,9 +694,12 @@ def check_umask():
mask = os.umask(18) # 18 = 022
os.umask(mask)
forbid_user_read = mask & stat.S_IRUSR
forbid_user_exec = mask & stat.S_IXUSR
forbid_group_read = mask & stat.S_IRGRP
forbid_group_exec = mask & stat.S_IXGRP
forbid_other_read = mask & stat.S_IROTH
if forbid_user_read or forbid_group_read or forbid_other_read:
forbid_other_exec = mask & stat.S_IXOTH
if forbid_user_read or forbid_user_exec or forbid_group_read or forbid_group_exec or forbid_other_read or forbid_other_exec:
prints(
'WARNING: Your current umask disallows reading of files by some users,'
' this can cause system breakage when running the installer because'
@ -709,7 +712,7 @@ def check_umask():
break
prints('Response', q, 'not understood')
if q == 'f':
mask = mask & ~stat.S_IRUSR & ~stat.S_IRGRP & ~stat.S_IROTH
mask = mask & ~stat.S_IRUSR & ~stat.S_IXUSR & ~stat.S_IRGRP & ~stat.S_IXGRP & ~stat.S_IROTH & ~stat.S_IXOTH
os.umask(mask)
prints('umask changed to: {:03o}'.format(mask))
elif q == 'i':

View File

@ -743,9 +743,12 @@ def check_umask():
mask = os.umask(18) # 18 = 022
os.umask(mask)
forbid_user_read = mask & stat.S_IRUSR
forbid_user_exec = mask & stat.S_IXUSR
forbid_group_read = mask & stat.S_IRGRP
forbid_group_exec = mask & stat.S_IXGRP
forbid_other_read = mask & stat.S_IROTH
if forbid_user_read or forbid_group_read or forbid_other_read:
forbid_other_exec = mask & stat.S_IXOTH
if forbid_user_read or forbid_user_exec or forbid_group_read or forbid_group_exec or forbid_other_read or forbid_other_exec:
prints(
'WARNING: Your current umask disallows reading of files by some users,'
' this can cause system breakage when running the installer because'
@ -758,7 +761,7 @@ def check_umask():
break
prints('Response', q, 'not understood')
if q == 'f':
mask = mask & ~stat.S_IRUSR & ~stat.S_IRGRP & ~stat.S_IROTH
mask = mask & ~stat.S_IRUSR & ~stat.S_IXUSR & ~stat.S_IRGRP & ~stat.S_IXGRP & ~stat.S_IROTH & ~stat.S_IXOTH
os.umask(mask)
prints('umask changed to: {:03o}'.format(mask))
elif q == 'i':