Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] Fix mode +st on TMPDIR when creating it
@ 2015-08-28 22:34 Alex Franco
  2015-08-31 16:02 ` Benjamin Esquivel
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Franco @ 2015-08-28 22:34 UTC (permalink / raw)
  To: openembedded-core

A sanity check fails when TMPDIR has setuid, setgid set. It was
proposed to fix this on TMPDIR creation instead of failing with
a sanity test only. This patch handles removal of those special
bits (and additonally, the sticky bit) from BUILDDIR and TMPDIR
when these directories are created.

[YOCTO #7669]

Signed-off-by: Alex Franco <alejandro.franco@linux.intel.com>
---
 meta/classes/sanity.bbclass | 5 +++++
 scripts/oe-setup-builddir   | 1 +
 2 files changed, 6 insertions(+)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index ef90fc8..2864318 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -686,6 +686,7 @@ def check_sanity_version_change(status, d):
     status.addresult(check_not_nfs(tmpdir, "TMPDIR"))
 
 def check_sanity_everybuild(status, d):
+    import os, stat
     # Sanity tests which test the users environment so need to run at each build (or are so cheap
     # it makes sense to always run them.
 
@@ -839,6 +840,10 @@ def check_sanity_everybuild(status, d):
                 status.addresult("Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir)
     else:
         bb.utils.mkdirhier(tmpdir)
+        # Remove setuid, setgid and sticky bits from TMPDIR
+        os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISUID)
+        os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISGID)
+        os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISVTX)
         with open(checkfile, "w") as f:
             f.write(tmpdir)
 
diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir
index add0b50..f5b7e4e 100755
--- a/scripts/oe-setup-builddir
+++ b/scripts/oe-setup-builddir
@@ -24,6 +24,7 @@ if [ -z "$BUILDDIR" ]; then
 fi
 
 mkdir -p "$BUILDDIR/conf"
+chmod -R -st "$BUILDDIR" 
 
 if [ ! -d "$BUILDDIR" ]; then
     echo >&2 "Error: The builddir ($BUILDDIR) does not exist!"
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix mode +st on TMPDIR when creating it
  2015-08-28 22:34 [PATCH] Fix mode +st on TMPDIR when creating it Alex Franco
@ 2015-08-31 16:02 ` Benjamin Esquivel
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Esquivel @ 2015-08-31 16:02 UTC (permalink / raw)
  To: Alex Franco, openembedded-core

Looks good, would you check this via an autobuilder on-demand build?

Benjamin

On Fri, 2015-08-28 at 17:34 -0500, Alex Franco wrote:
> A sanity check fails when TMPDIR has setuid, setgid set. It was
> proposed to fix this on TMPDIR creation instead of failing with
> a sanity test only. This patch handles removal of those special
> bits (and additonally, the sticky bit) from BUILDDIR and TMPDIR
> when these directories are created.
> 
> [YOCTO #7669]
> 
> Signed-off-by: Alex Franco <alejandro.franco@linux.intel.com>
> ---
>  meta/classes/sanity.bbclass | 5 +++++
>  scripts/oe-setup-builddir   | 1 +
>  2 files changed, 6 insertions(+)
> 
> diff --git a/meta/classes/sanity.bbclass
> b/meta/classes/sanity.bbclass
> index ef90fc8..2864318 100644
> --- a/meta/classes/sanity.bbclass
> +++ b/meta/classes/sanity.bbclass
> @@ -686,6 +686,7 @@ def check_sanity_version_change(status, d):
>      status.addresult(check_not_nfs(tmpdir, "TMPDIR"))
>  
>  def check_sanity_everybuild(status, d):
> +    import os, stat
>      # Sanity tests which test the users environment so need to run
> at each build (or are so cheap
>      # it makes sense to always run them.
>  
> @@ -839,6 +840,10 @@ def check_sanity_everybuild(status, d):
>                  status.addresult("Error, TMPDIR has changed
> location. You need to either move it back to %s or rebuild\n" %
> saved_tmpdir)
>      else:
>          bb.utils.mkdirhier(tmpdir)
> +        # Remove setuid, setgid and sticky bits from TMPDIR
> +        os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISUID)
> +        os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISGID)
> +        os.chmod(tmpdir, os.stat(tmpdir).st_mode & ~ stat.S_ISVTX)
>          with open(checkfile, "w") as f:
>              f.write(tmpdir)
>  
> diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir
> index add0b50..f5b7e4e 100755
> --- a/scripts/oe-setup-builddir
> +++ b/scripts/oe-setup-builddir
> @@ -24,6 +24,7 @@ if [ -z "$BUILDDIR" ]; then
>  fi
>  
>  mkdir -p "$BUILDDIR/conf"
> +chmod -R -st "$BUILDDIR" 
>  
>  if [ ! -d "$BUILDDIR" ]; then
>      echo >&2 "Error: The builddir ($BUILDDIR) does not exist!"


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-31 16:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-28 22:34 [PATCH] Fix mode +st on TMPDIR when creating it Alex Franco
2015-08-31 16:02 ` Benjamin Esquivel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox