[PATCH] virtinst: don't expect non-root users to have block device access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
attached patch drops the assumption that a non-root user has read access
to the guest OSes partition - he doesn't need to since all interaction
is handled via libvirt and giving the user read access for a simple MBR
block read test seems like overkill. Please apply if appropriate, patch
is against current hg.
Cheers,
 -- Guido

# HG changeset patch
# User agx@xxxxxxxxxxx
# Date 1201618288 -3600
# Node ID 96a103cd78dc7616a2e1e54f2e100fe156bebafd
# Parent  5109856f3bedf3b8eff7f78ce881b39bf8d30029
Don't fail if a non root user can't read from the block device due to insufficient permissions

diff -r 5109856f3bed -r 96a103cd78dc virtinst/DistroManager.py
--- a/virtinst/DistroManager.py	Thu Jan 10 20:34:27 2008 -0500
+++ b/virtinst/DistroManager.py	Tue Jan 29 15:51:28 2008 +0100
@@ -22,6 +22,7 @@
 
 import logging
 import os
+import errno
 import gzip
 import re
 import struct
@@ -239,7 +240,14 @@ class DistroInstaller(Guest.Installer):
 
     def post_install_check(self, guest):
         # Check for the 0xaa55 signature at the end of the MBR
-        fd = os.open(guest._install_disks[0].path, os.O_RDONLY)
+        try:
+            fd = os.open(guest._install_disks[0].path, os.O_RDONLY)
+        except OSError, (err, msg):
+            logging.debug("Failed to open guest disk: %s" % msg)
+            if err == errno.EACCES and os.geteuid() != 0:
+                return True # non root might not have access to block devices
+            else:
+                raise
         buf = os.read(fd, 512)
         os.close(fd)
         return len(buf) == 512 and struct.unpack("H", buf[0x1fe: 0x200]) == (0xaa55,)
@@ -284,7 +292,14 @@ class PXEInstaller(Guest.Installer):
 
     def post_install_check(self, guest):
         # Check for the 0xaa55 signature at the end of the MBR
-        fd = os.open(guest._install_disks[0].path, os.O_RDONLY)
+        try:
+            fd = os.open(guest._install_disks[0].path, os.O_RDONLY)
+        except OSError, (err, msg):
+            logging.debug("Failed to open guest disk: %s" % msg)
+            if err == errno.EACCES and os.geteuid() != 0:
+                return True # non root might not have access to block devices
+            else:
+                raise
         buf = os.read(fd, 512)
         os.close(fd)
         return len(buf) == 512 and struct.unpack("H", buf[0x1fe: 0x200]) == (0xaa55,)

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]