Patchwork package_ipk: apply umask to control and conffiles

login
register
mail settings
Submitter Andreas Oberritter
Date March 10, 2012, 2:15 a.m.
Message ID <1331345726-9577-1-git-send-email-obi@opendreambox.org>
Download mbox | patch
Permalink /patch/22995/
State New
Headers show

Comments

Andreas Oberritter - March 10, 2012, 2:15 a.m.
* Explicitly set umask to 022. Otherwise the build system's
  umask leaks into the image.

Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
---
* I tried do_package_ipk[umask] = "022" first, but it didn't work.

 meta/classes/package_ipk.bbclass |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
Mark Hatle - March 12, 2012, 3:29 p.m.
On 3/9/12 8:15 PM, Andreas Oberritter wrote:
> * Explicitly set umask to 022. Otherwise the build system's
>    umask leaks into the image.

I'm surprised that do_package_ipk[umask] didn't work.  Perhaps its the way it's 
being invoked that is the issue.  (If bitbake doesn't run it, but something else 
does.. then the umask setting doesn't get used.)

As for the change of the umask, the changes appear to be specific to the ipk 
case.  Is this the desired behavior, or could deb and rpm suffer from similar 
issues?  (I'm not familiar enough with opkg to know how it handles umask 
settings during package install/rootfs construction..)

I believe that RPM sets a default umask when it goes through it's package 
installs/rootfs generation.  But does DEB?

--Mark

> Signed-off-by: Andreas Oberritter<obi@opendreambox.org>
> ---
> * I tried do_package_ipk[umask] = "022" first, but it didn't work.
>
>   meta/classes/package_ipk.bbclass |    4 ++++
>   1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
> index 565ef93..e7da07a 100644
> --- a/meta/classes/package_ipk.bbclass
> +++ b/meta/classes/package_ipk.bbclass
> @@ -317,7 +317,9 @@ python do_package_ipk () {
>   		controldir = os.path.join(root, 'CONTROL')
>   		bb.mkdirhier(controldir)
>   		try:
> +			mask = os.umask(022)
>   			ctrlfile = file(os.path.join(controldir, 'control'), 'w')
> +			os.umask(mask)
>   		except OSError:
>   			bb.utils.unlockfile(lf)
>   			raise bb.build.FuncFailed("unable to open control file for writing.")
> @@ -410,7 +412,9 @@ python do_package_ipk () {
>   		conffiles_str = localdata.getVar("CONFFILES", True)
>   		if conffiles_str:
>   			try:
> +				mask = os.umask(022)
>   				conffiles = file(os.path.join(controldir, 'conffiles'), 'w')
> +				os.umask(mask)
>   			except OSError:
>   				bb.utils.unlockfile(lf)
>   				raise bb.build.FuncFailed("unable to open conffiles for writing.")
Richard Purdie - March 12, 2012, 3:53 p.m.
On Mon, 2012-03-12 at 10:29 -0500, Mark Hatle wrote:
> On 3/9/12 8:15 PM, Andreas Oberritter wrote:
> > * Explicitly set umask to 022. Otherwise the build system's
> >    umask leaks into the image.
> 
> I'm surprised that do_package_ipk[umask] didn't work.  Perhaps its the way it's 
> being invoked that is the issue.  (If bitbake doesn't run it, but something else 
> does.. then the umask setting doesn't get used.)
> 
> As for the change of the umask, the changes appear to be specific to the ipk 
> case.  Is this the desired behavior, or could deb and rpm suffer from similar 
> issues?  (I'm not familiar enough with opkg to know how it handles umask 
> settings during package install/rootfs construction..)
> 
> I believe that RPM sets a default umask when it goes through it's package 
> installs/rootfs generation.  But does DEB?

I'm also a bit worried about this patch. I'd like to understand why a
task level umask doesn't work. That shouldn't even make any difference
since the permissions/owners/users from install should be getting
used...

Cheers,

Richard
Andreas Oberritter - March 12, 2012, 4:27 p.m.
On 12.03.2012 16:53, Richard Purdie wrote:
> On Mon, 2012-03-12 at 10:29 -0500, Mark Hatle wrote:
>> On 3/9/12 8:15 PM, Andreas Oberritter wrote:
>>> * Explicitly set umask to 022. Otherwise the build system's
>>>    umask leaks into the image.
>>
>> I'm surprised that do_package_ipk[umask] didn't work.  Perhaps its the way it's 
>> being invoked that is the issue.  (If bitbake doesn't run it, but something else 
>> does.. then the umask setting doesn't get used.)
>>
>> As for the change of the umask, the changes appear to be specific to the ipk 
>> case.  Is this the desired behavior, or could deb and rpm suffer from similar 
>> issues?  (I'm not familiar enough with opkg to know how it handles umask 
>> settings during package install/rootfs construction..)
>>
>> I believe that RPM sets a default umask when it goes through it's package 
>> installs/rootfs generation.  But does DEB?
> 
> I'm also a bit worried about this patch. I'd like to understand why a
> task level umask doesn't work. That shouldn't even make any difference
> since the permissions/owners/users from install should be getting
> used...

The two per-package files "conffiles" and "control" affected by this
patch don't get installed by recipes. package_ipk.bbclass creates them.

Regards,
Andreas
Andreas Oberritter - March 23, 2012, 8:17 p.m.
On 12.03.2012 16:53, Richard Purdie wrote:
> On Mon, 2012-03-12 at 10:29 -0500, Mark Hatle wrote:
>> On 3/9/12 8:15 PM, Andreas Oberritter wrote:
>>> * Explicitly set umask to 022. Otherwise the build system's
>>>    umask leaks into the image.
>>
>> I'm surprised that do_package_ipk[umask] didn't work.  Perhaps its the way it's 
>> being invoked that is the issue.  (If bitbake doesn't run it, but something else 
>> does.. then the umask setting doesn't get used.)
>>
>> As for the change of the umask, the changes appear to be specific to the ipk 
>> case.  Is this the desired behavior, or could deb and rpm suffer from similar 
>> issues?  (I'm not familiar enough with opkg to know how it handles umask 
>> settings during package install/rootfs construction..)
>>
>> I believe that RPM sets a default umask when it goes through it's package 
>> installs/rootfs generation.  But does DEB?
> 
> I'm also a bit worried about this patch. I'd like to understand why a
> task level umask doesn't work. That shouldn't even make any difference
> since the permissions/owners/users from install should be getting
> used...
> 
> Cheers,
> 
> Richard

Richard,

can you please give some advise on how to continue with this issue?

Regards,
Andreas
Richard Purdie - March 26, 2012, 11:34 a.m.
On Fri, 2012-03-23 at 21:17 +0100, Andreas Oberritter wrote:
> On 12.03.2012 16:53, Richard Purdie wrote:
> > On Mon, 2012-03-12 at 10:29 -0500, Mark Hatle wrote:
> >> On 3/9/12 8:15 PM, Andreas Oberritter wrote:
> >>> * Explicitly set umask to 022. Otherwise the build system's
> >>>    umask leaks into the image.
> >>
> >> I'm surprised that do_package_ipk[umask] didn't work.  Perhaps its the way it's 
> >> being invoked that is the issue.  (If bitbake doesn't run it, but something else 
> >> does.. then the umask setting doesn't get used.)
> >>
> >> As for the change of the umask, the changes appear to be specific to the ipk 
> >> case.  Is this the desired behavior, or could deb and rpm suffer from similar 
> >> issues?  (I'm not familiar enough with opkg to know how it handles umask 
> >> settings during package install/rootfs construction..)
> >>
> >> I believe that RPM sets a default umask when it goes through it's package 
> >> installs/rootfs generation.  But does DEB?
> > 
> > I'm also a bit worried about this patch. I'd like to understand why a
> > task level umask doesn't work. That shouldn't even make any difference
> > since the permissions/owners/users from install should be getting
> > used...
>
> can you please give some advise on how to continue with this issue?

I understand half the problem now, the files with the issues are ones
created during the package_ipk task. That addresses one of my big
concerns.

The second thing I'd like to understand is why a task level umask
doesn't resolve this. Looking at what you tried, this might be as simple
as a typo:

do_package_ipk[umask] = "022"

when you really want:

do_package_write_ipk[umask] = "022"

If that works, lets set this for deb and rpm too so we're consistent and
I'll merge that patch :)

Cheers,

Richard

Patch

diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index 565ef93..e7da07a 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -317,7 +317,9 @@  python do_package_ipk () {
 		controldir = os.path.join(root, 'CONTROL')
 		bb.mkdirhier(controldir)
 		try:
+			mask = os.umask(022)
 			ctrlfile = file(os.path.join(controldir, 'control'), 'w')
+			os.umask(mask)
 		except OSError:
 			bb.utils.unlockfile(lf)
 			raise bb.build.FuncFailed("unable to open control file for writing.")
@@ -410,7 +412,9 @@  python do_package_ipk () {
 		conffiles_str = localdata.getVar("CONFFILES", True)
 		if conffiles_str:
 			try:
+				mask = os.umask(022)
 				conffiles = file(os.path.join(controldir, 'conffiles'), 'w')
+				os.umask(mask)
 			except OSError:
 				bb.utils.unlockfile(lf)
 				raise bb.build.FuncFailed("unable to open conffiles for writing.")