[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] Please review quickly [Fwd: [bug #19137] permission
From: |
Nathaniel Smith |
Subject: |
Re: [Monotone-devel] Please review quickly [Fwd: [bug #19137] permissions on ~/.monotone/keys/ are too permissive] |
Date: |
Sat, 14 Apr 2007 10:45:40 -0700 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
On Sat, Apr 14, 2007 at 01:27:33PM -0400, Stephen Leake wrote:
> This is my first time compiling monotone. Looking thru other code, it
> seems the correct fix might be:
[...]
> +#ifndef WIN32
> + // umask not in MinGW. We assume MinGW boxes have single users, so
> + // this doesn't matter.
> mode_t mask = umask(S_IRWXG|S_IRWXO);
> +#endif /* WIN32 */
> +
> L(FL("writing key '%s' to file '%s' in dir '%s'") % ident % file %
> key_dir);
> write_data(file, dat, key_dir);
> +
> +#ifndef WIN32
> umask(mask);
> +#endif /* WIN32 */
[...]
No... it's entirely possible you found other code like this, alas, but
that code is wrong and misleading :-).
The correct fix would be adding something like
struct enable_restrictive_umask
{
enable_restrictive_umask();
~enable_restrictive_umask();
};
And then implementing those two methods twice, once somewhere in
win32/ and once somewhere in unix/, with either empty bodies or bodies
that call umask.
...Except that the unix version needs a field in there to temporarily
stash the old umask. After a little more looking around, it might be
far smarter to use fchmod(2) (inside an appropriate platform.hh
wrapper, of course) than to mess around with umask?
-- Nathaniel
--
Eternity is very long, especially towards the end.
-- Woody Allen