[node-patches] Change in ovirt-node[master]: Basic sanity checking for user input to edit-node

rbarry at redhat.com rbarry at redhat.com
Tue Oct 22 18:30:37 UTC 2013


Ryan Barry has uploaded a new change for review.

Change subject: Basic sanity checking for user input to edit-node
......................................................................

Basic sanity checking for user input to edit-node

Previously, edit-node didn't verify whether input was actually
RPMs or appeared to be yum repositories. Add these checks.

Change-Id: I05995fa62038db92b43939d087dcb9dcdcce5175
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=993525
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M tools/edit-node
1 file changed, 7 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/09/20409/1

diff --git a/tools/edit-node b/tools/edit-node
index b6b1274..816b814 100755
--- a/tools/edit-node
+++ b/tools/edit-node
@@ -1110,8 +1110,8 @@
         if not options.repo:
             return True
         else:
-            if os.path.isfile(options.repo) and not \
-                    options.repo.lower().endswith(".iso"):
+            if os.path.isfile(options.repo) and \
+                    options.repo.lower().endswith(".repo"):
                 cmd = "mkdir -p %s/etc/yum.repos.d" % self._instroot
                 f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
                                      stderr=STDOUT)
@@ -1275,6 +1275,11 @@
         remoteinstall = []
         for pkg in pkgs:
             if os.path.isfile(pkg):
+                filetype = subprocess.Popen("/usr/bin/file %s" % pkg,
+                                            shell=True, stdout=subprocess.PIPE
+                ).communicate()[0]
+                if not re.match(r'^.*?:\sRPM.*', filetype):
+                    break
                 os.system("mkdir %s/tmp/yumrepo" % self._instroot)
                 os.system("touch %s/tmp/yumrepo/%s" % (self._instroot,
                           os.path.basename(pkg)))


-- 
To view, visit http://gerrit.ovirt.org/20409
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I05995fa62038db92b43939d087dcb9dcdcce5175
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list