Skip to contentSkip to conversation

toaster: localhostbectrl Pass DATABASE_URL in via the process environment

PATCH In review Michael Wood 2 participants 2 messages Nov 12, 2015 – Nov 13, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: localhostbectrl Pass DATABASE_URL in via the process environment

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]

---
 bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +10 -3
index b5cf559..854a6bb 100644
@@ -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):
Signature · 1 line
2.1.4
#1 lore raw
Quoted 3 lines · Michael Wood

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

Quoted 60 lines

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]

---
 bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +0 -1
index b5cf559..854a6bb 100644
@@ -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

bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +8 -3
-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)

bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +2 -1
+            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
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre