Patchwork [RFC,2/3] lib/bb/siggen.py: create permissive files and directories

login
register
mail settings
Submitter Joshua Lock
Date May 10, 2012, 12:22 a.m.
Message ID <4048abda9d53e155e0802663af9c78f542499e8e.1336608479.git.josh@linux.intel.com>
Download mbox | patch
Permalink /patch/27421/
State New
Headers show

Comments

Joshua Lock - May 10, 2012, 12:22 a.m.
Create signature files, and the directories which contain them, with
rwx for everyone so that they are easily shared with different users
of the same machine.

Signed-off-by: Joshua Lock <josh@linux.intel.com>
---
 bitbake/lib/bb/siggen.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Richard Purdie - May 10, 2012, 11:22 a.m.
On Wed, 2012-05-09 at 17:22 -0700, Joshua Lock wrote:
> Create signature files, and the directories which contain them, with
> rwx for everyone so that they are easily shared with different users
> of the same machine.
> 
> Signed-off-by: Joshua Lock <josh@linux.intel.com>
> ---
>  bitbake/lib/bb/siggen.py |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
> index 8c79b17..bd6d59b 100644
> --- a/bitbake/lib/bb/siggen.py
> +++ b/bitbake/lib/bb/siggen.py
> @@ -201,7 +201,12 @@ class SignatureGeneratorBasic(SignatureGenerator):
>              for dep in data['runtaskdeps']:
>                  data['runtaskhashes'][dep] = self.taskhash[dep]
>  
> -        p = pickle.Pickler(file(sigfile, "wb"), -1)
> +        # Create file with permissive (0777) read/write for easier sharing
> +        f = os.fdopen(os.open(sigfile, os.O_RDWR|os.O_CREAT), "wb")
> +        # os.open() and os.fdopen() are affected by the users umask so brute force
> +        # the permissions with a call to chmod
> +        os.chmod(sigfile, 0777)
> +        p = pickle.Pickler(f, -1)
>          p.dump(data)

Why not just run the chmod after the original pickle code? Its not as if
you avoid a race this way :/.

Cheers,

Richard
Joshua Lock - May 10, 2012, 4:10 p.m.
On 10/05/12 04:22, Richard Purdie wrote:
> On Wed, 2012-05-09 at 17:22 -0700, Joshua Lock wrote:
>> Create signature files, and the directories which contain them, with
>> rwx for everyone so that they are easily shared with different users
>> of the same machine.
>>
>> Signed-off-by: Joshua Lock<josh@linux.intel.com>
>> ---
>>   bitbake/lib/bb/siggen.py |    7 ++++++-
>>   1 files changed, 6 insertions(+), 1 deletions(-)
>>
>> diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
>> index 8c79b17..bd6d59b 100644
>> --- a/bitbake/lib/bb/siggen.py
>> +++ b/bitbake/lib/bb/siggen.py
>> @@ -201,7 +201,12 @@ class SignatureGeneratorBasic(SignatureGenerator):
>>               for dep in data['runtaskdeps']:
>>                   data['runtaskhashes'][dep] = self.taskhash[dep]
>>
>> -        p = pickle.Pickler(file(sigfile, "wb"), -1)
>> +        # Create file with permissive (0777) read/write for easier sharing
>> +        f = os.fdopen(os.open(sigfile, os.O_RDWR|os.O_CREAT), "wb")
>> +        # os.open() and os.fdopen() are affected by the users umask so brute force
>> +        # the permissions with a call to chmod
>> +        os.chmod(sigfile, 0777)
>> +        p = pickle.Pickler(f, -1)
>>           p.dump(data)
>
> Why not just run the chmod after the original pickle code? Its not as if
> you avoid a race this way :/.

Sure, that'd work as well.

Though from the general feedback it feels like this series is moot and 
all that we really want is a sanity check.

Cheers,
Joshua

Patch

diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index 8c79b17..bd6d59b 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -201,7 +201,12 @@  class SignatureGeneratorBasic(SignatureGenerator):
             for dep in data['runtaskdeps']:
                 data['runtaskhashes'][dep] = self.taskhash[dep]
 
-        p = pickle.Pickler(file(sigfile, "wb"), -1)
+        # Create file with permissive (0777) read/write for easier sharing
+        f = os.fdopen(os.open(sigfile, os.O_RDWR|os.O_CREAT), "wb")
+        # os.open() and os.fdopen() are affected by the users umask so brute force
+        # the permissions with a call to chmod
+        os.chmod(sigfile, 0777)
+        p = pickle.Pickler(f, -1)
         p.dump(data)
 
     def dump_sigs(self, dataCache):