monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] Please review quickly [Fwd: [bug #19137] permission


From: Stephen Leake
Subject: Re: [Monotone-devel] Please review quickly [Fwd: [bug #19137] permissions on ~/.monotone/keys/ are too permissive]
Date: Sat, 14 Apr 2007 13:27:33 -0400
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt)

Nathaniel Smith <address@hidden> writes:

> On Wed, Apr 11, 2007 at 08:16:38PM +0200, Markus Schiltknecht wrote:
>> --- key_store.cc        70b97a9e2a06654ec641a1709c2a875cdfa603d5
>> +++ key_store.cc        fda46d5fa8a5b2a52421c1f83413a208e2c6401f
>> @@ -1,4 +1,5 @@
>>  #include <sstream>
>> +#include <sys/stat.h>
>> 
>>  #include "key_store.hh"
>>  #include "file_io.hh"
>> @@ -210,8 +211,12 @@ key_store::write_key(rsa_keypair_id cons
>>    data dat(oss.str());
>>    system_path file;
>>    get_key_file(ident, file);
>> +
>> +  // set a restrictive umask, write the file and reset umask
>> +  mode_t mask = umask(S_IRWXG|S_IRWXO);
>>    L(FL("writing key '%s' to file '%s' in dir '%s'") % ident % file % 
>> key_dir);
>>    write_data(file, dat, key_dir);
>> +  umask(mask);
>>  }
>
> What will this do on win32?

Fail to compile:

key_store.cc:216: error: `S_IRWXG' undeclared (first use this function)
key_store.cc:216: error: (Each undeclared identifier is reported only once for 
each function it appears in.)
key_store.cc:216: error: `S_IRWXO' undeclared (first use this function)
key_store.cc:216: error: `umask' undeclared (first use this function)

On a Solaris box I have access to, 'umask' is declared in
/include/sys/stat.h. On MinGW, it is not.

grep in MinGW shows no other header that has it. Apparently Perl has a
work-around for this; I didn't try to figure out what it is.

I suspect most Windows boxes are single-user, so permissions don't
actually matter. So we could just skip this for Windows.

This is my first time compiling monotone. Looking thru other code, it
seems the correct fix might be:

============================================================
--- key_store.cc
+++ key_store.cc
@@ -115,7 +115,7 @@ key_store::ensure_in_database(rsa_keypai
       I(app.db.public_key_exists(ident));
       return;
     }
-  
+
   if (app.db.put_key(ident, i->second.pub))
     L(FL("loaded public key '%s' into db") % ident);
 }
@@ -213,10 +213,18 @@ key_store::write_key(rsa_keypair_id cons
   get_key_file(ident, file);
 
   // set a restrictive umask, write the file and reset umask
+#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 */
 }
 
 bool

============================================================

-- 
-- Stephe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]