Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH 0/1] small fix for DeployImageDialog
@ 2012-06-25  8:47 Kang Kai
  2012-06-25  8:47 ` [PATCH 1/1] hig.py: use module tempfile to create temp file Kang Kai
  0 siblings, 1 reply; 2+ messages in thread
From: Kang Kai @ 2012-06-25  8:47 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Zhenfeng.Zhao

Hi,

There is a warning caused by using os.temp(). Use module tempfile to replace it.

Regards,
Kai

The following changes since commit e0a70547069fe7e8a2d6bdaffc985fb172d46c31:

  perl: Allow perl to cross build and native build in a directory named "t" (2012-06-18 17:33:04 +0100)

are available in the git repository at:
  git://git.pokylinux.org/poky-contrib kangkai/distro
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/distro

Kang Kai (1):
  hig.py: use module tempfile to create temp file

 bitbake/lib/bb/ui/crumbs/hig.py |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

-- 
1.7.5.4




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

* [PATCH 1/1] hig.py: use module tempfile to create temp file
  2012-06-25  8:47 [PATCH 0/1] small fix for DeployImageDialog Kang Kai
@ 2012-06-25  8:47 ` Kang Kai
  0 siblings, 0 replies; 2+ messages in thread
From: Kang Kai @ 2012-06-25  8:47 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Zhenfeng.Zhao

I am sorry that use os.tmpname which casue a security warning.
Follow Darren's suggestion to use tempfile.NamedTemporaryFile instead.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 bitbake/lib/bb/ui/crumbs/hig.py |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
index b586b6c..2001ff4 100644
--- a/bitbake/lib/bb/ui/crumbs/hig.py
+++ b/bitbake/lib/bb/ui/crumbs/hig.py
@@ -28,6 +28,7 @@ import os
 import re
 import shlex
 import subprocess
+import tempfile
 from bb.ui.crumbs.hobcolor import HobColors
 from bb.ui.crumbs.hobwidget import hcc, hic, HobViewTable, HobInfoButton, HobButton, HobAltButton, HobIconChecker
 from bb.ui.crumbs.progressbar import HobProgressBar
@@ -869,21 +870,16 @@ class DeployImageDialog (CrumbsDialog):
             if combo_item and combo_item != self.__dummy_usb__ and self.image_path:
                 cmdline = bb.ui.crumbs.utils.which_terminal()
                 if cmdline:
-                    tmpname = os.tmpnam()
+                    tmpfile = tempfile.NamedTemporaryFile()
                     cmdline += "\"sudo dd if=" + self.image_path + \
-                                " of=" + combo_item + "; echo $? > " + tmpname + "\""
+                                " of=" + combo_item + "; echo $? > " + tmpfile.name + "\""
                     subprocess.call(shlex.split(cmdline))
 
-                    # if file tmpname not exists, that means there is something wrong with xterm
-                    # user can get the error message from xterm so no more warning need.
-                    if os.path.exists(tmpname):
-                        tmpfile = open(tmpname)
-                        if int(tmpfile.readline().strip()) == 0:
-                            lbl = "<b>Deploy image successfully.</b>"
-                        else:
-                            lbl = "<b>Failed to deploy image.</b>\nPlease check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (self.image_path, combo_item)
-                        tmpfile.close()
-                        os.remove(tmpname)
+                    if int(tmpfile.readline().strip()) == 0:
+                        lbl = "<b>Deploy image successfully.</b>"
+                    else:
+                        lbl = "<b>Failed to deploy image.</b>\nPlease check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (self.image_path, combo_item)
+                    tmpfile.close()
             else:
                 if not self.image_path:
                     lbl = "<b>No selection made.</b>\nYou have not selected an image to deploy."
-- 
1.7.5.4




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

end of thread, other threads:[~2012-06-25  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-25  8:47 [PATCH 0/1] small fix for DeployImageDialog Kang Kai
2012-06-25  8:47 ` [PATCH 1/1] hig.py: use module tempfile to create temp file Kang Kai

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