Launchpadlib support in Ubuntu Developer Tools
Stefan Potyra
stefan.potyra at informatik.uni-erlangen.de
Thu Jan 15 10:07:46 GMT 2009
Hi,
On Thursday 15 January 2009 01:48:44 Kees Cook wrote:
[..]
>
> Now I have to redeem my embarrassment by suggesting this as a way to avoid
> the create/chmod race when fchmod is unavailable:
>
> credfd = tempfile.NamedTemporaryFile(dir=os.path.dirname(credfile))
> launchpad.credentials.save(credfd)
> os.link(credfd.name, credfile)
> credfd.close()
>
> The link will fail if the target exists, and the close will clean up the
> original file. Wheee :)
how about simply using os.open() to avoid the race in the first place?
Or mangle the umask to the right thing before the (fd)open?
Cheers,
Stefan.
More information about the ubuntu-devel
mailing list