Message236680
On Thu, Feb 26, 2015, at 09:41 AM, Paul Moore wrote:
>
> Paul Moore added the comment:
>
> Following on from that, the code to make an archive executable is
> currently
>
> os.chmod(new_archive, os.stat(new_archive).st_mode | stat.S_IEXEC)
>
> Should I use "... | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH"? If so,
> do I need to protect that with an "if not Windows" test? (I've tested the
> existing code and it does nothing on Windows, so I omitted the test at
> the moment). Is there any *other* way I should be making a file
> executable on Unix?
>
> (Side note: Maybe there should be an os.make_executable(pathname) or
> similar that does the right thing in a cross-platform way?)
The chmod + umask analog that will work not just on a newly created file
is
umask = os.umask(0) # must change umask to get umask
os.umask(umask) # restore previous umask
os.chmod(new_archive, os.stat(new_archive).st_mode |
((stat.stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH) & ~umask))
If I understand the man page correctly, "chmod +x filename" does exactly
the above. Depending on the umask the command may or may not create a
world / group / user executable file. |
|
Date |
User |
Action |
Args |
2015-02-26 15:57:08 | dholth | set | recipients:
+ dholth, paul.moore, Jim.Jewett, serhiy.storchaka, steve.dower |
2015-02-26 15:57:08 | dholth | link | issue23491 messages |
2015-02-26 15:57:08 | dholth | create | |
|