All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] toaster: localhostbectrl Pass DATABASE_URL in via the process environment
@ 2015-11-13 15:28 Elliot Smith
  0 siblings, 0 replies; 3+ messages in thread
From: Elliot Smith @ 2015-11-13 15:28 UTC (permalink / raw)
  To: bitbake-devel

Instead of putting the DATABASE_URL as part of the command for launching
the bitbake observer process set it as part of environment.

This fixes two issues 1. Where the value isn't quoted and therefore will be
interpreted in the shell and 2. Anyone being able to see the value of
DATABASE_URL in the process tree.

[YOCTO #8669]

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
---
 bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index b5cf559..854a6bb 100644
--- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -48,7 +48,6 @@ class LocalhostBEController(BuildEnvironmentController):
 
     def __init__(self, be):
         super(LocalhostBEController, self).__init__(be)
-        self.dburl = settings.getDATABASE_URL()
         self.pokydirname = None
         self.islayerset = False
 
@@ -126,9 +125,17 @@ class LocalhostBEController(BuildEnvironmentController):
                     port = i.split(" ")[-1]
                     logger.debug("localhostbecontroller: Found bitbake server port %s" % port)
 
-        cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && DATABASE_URL=%s %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % (self.pokydirname, self.be.builddir, self.dburl, own_bitbake)
+        cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % \
+                (self.pokydirname, self.be.builddir, own_bitbake)
+
+        # Use a copy of the current environment and add the DATABASE_URL
+        # for the bitbake observer process.
+        env = os.environ.copy()
+        env['DATABASE_URL'] = settings.getDATABASE_URL()
+
         with open(toaster_ui_log_filepath, "a+") as f:
-            p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True, stdout=f, stderr=f)
+            p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True,
+                                 stdout=f, stderr=f, env=env)
 
         def _toaster_ui_started(filepath, filepos = 0):
             if not os.path.exists(filepath):
-- 
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



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

* Re: [PATCH] toaster: localhostbectrl Pass DATABASE_URL in via the process environment
  2015-11-12 18:06 Michael Wood
@ 2015-11-13 15:34 ` Smith, Elliot
  0 siblings, 0 replies; 3+ messages in thread
From: Smith, Elliot @ 2015-11-13 15:34 UTC (permalink / raw)
  To: Michael Wood; +Cc: toaster

[-- Attachment #1: Type: text/plain, Size: 2904 bytes --]

On 12 November 2015 at 18:06, Michael Wood <michael.g.wood@intel.com> wrote:

> Instead of putting the DATABASE_URL as part of the command for launching
> the bitbake observer process set it as part of environment.
>

Submitted to bitbake-devel and added to toaster-next.

Elliot



>
> This fixes two issues 1. Where the value isn't quoted and therefore will be
> interpreted in the shell and 2. Anyone being able to see the value of
> DATABASE_URL in the process tree.
>
> [YOCTO #8669]
>
> Signed-off-by: Michael Wood <michael.g.wood@intel.com>
> ---
>  bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
> b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
> index b5cf559..854a6bb 100644
> --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
> +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
> @@ -48,7 +48,6 @@ class LocalhostBEController(BuildEnvironmentController):
>
>      def __init__(self, be):
>          super(LocalhostBEController, self).__init__(be)
> -        self.dburl = settings.getDATABASE_URL()
>          self.pokydirname = None
>          self.islayerset = False
>
> @@ -126,9 +125,17 @@ class
> LocalhostBEController(BuildEnvironmentController):
>                      port = i.split(" ")[-1]
>                      logger.debug("localhostbecontroller: Found bitbake
> server port %s" % port)
>
> -        cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s &&
> DATABASE_URL=%s %s --observe-only -u toasterui --remote-server=0.0.0.0:-1
> -t xmlrpc\"" % (self.pokydirname, self.be.builddir, self.dburl, own_bitbake)
> +        cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && %s
> --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % \
> +                (self.pokydirname, self.be.builddir, own_bitbake)
> +
> +        # Use a copy of the current environment and add the DATABASE_URL
> +        # for the bitbake observer process.
> +        env = os.environ.copy()
> +        env['DATABASE_URL'] = settings.getDATABASE_URL()
> +
>          with open(toaster_ui_log_filepath, "a+") as f:
> -            p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True,
> stdout=f, stderr=f)
> +            p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True,
> +                                 stdout=f, stderr=f, env=env)
>
>          def _toaster_ui_started(filepath, filepos = 0):
>              if not os.path.exists(filepath):
> --
> 2.1.4
>
> --
> _______________________________________________
> toaster mailing list
> toaster@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>



-- 
Elliot Smith
Software Engineer
Intel Open Source Technology Centre

[-- Attachment #2: Type: text/html, Size: 4033 bytes --]

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

* [PATCH] toaster: localhostbectrl Pass DATABASE_URL in via the process environment
@ 2015-11-12 18:06 Michael Wood
  2015-11-13 15:34 ` Smith, Elliot
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Wood @ 2015-11-12 18:06 UTC (permalink / raw)
  To: toaster

Instead of putting the DATABASE_URL as part of the command for launching
the bitbake observer process set it as part of environment.

This fixes two issues 1. Where the value isn't quoted and therefore will be
interpreted in the shell and 2. Anyone being able to see the value of
DATABASE_URL in the process tree.

[YOCTO #8669]

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index b5cf559..854a6bb 100644
--- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -48,7 +48,6 @@ class LocalhostBEController(BuildEnvironmentController):
 
     def __init__(self, be):
         super(LocalhostBEController, self).__init__(be)
-        self.dburl = settings.getDATABASE_URL()
         self.pokydirname = None
         self.islayerset = False
 
@@ -126,9 +125,17 @@ class LocalhostBEController(BuildEnvironmentController):
                     port = i.split(" ")[-1]
                     logger.debug("localhostbecontroller: Found bitbake server port %s" % port)
 
-        cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && DATABASE_URL=%s %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % (self.pokydirname, self.be.builddir, self.dburl, own_bitbake)
+        cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % \
+                (self.pokydirname, self.be.builddir, own_bitbake)
+
+        # Use a copy of the current environment and add the DATABASE_URL
+        # for the bitbake observer process.
+        env = os.environ.copy()
+        env['DATABASE_URL'] = settings.getDATABASE_URL()
+
         with open(toaster_ui_log_filepath, "a+") as f:
-            p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True, stdout=f, stderr=f)
+            p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True,
+                                 stdout=f, stderr=f, env=env)
 
         def _toaster_ui_started(filepath, filepos = 0):
             if not os.path.exists(filepath):
-- 
2.1.4



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

end of thread, other threads:[~2015-11-13 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 15:28 [PATCH] toaster: localhostbectrl Pass DATABASE_URL in via the process environment Elliot Smith
  -- strict thread matches above, loose matches on Subject: below --
2015-11-12 18:06 Michael Wood
2015-11-13 15:34 ` Smith, Elliot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.