Skip to content

Remove requirement to run as root on Linux #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions multibootusb
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ Example for installing syslinux to target USB disk:
def start_gui():
from scripts import mbusb_gui
gen.log('Starting multibootusb GUI...')
if platform.system() == 'Linux':
if os.getuid() != 0:
gen.log('\n\nAdmin privilege is required to run multibootusb.\n If you are running from source try '
'\'sudo python3 ./multibootusb\'\n or you can try \'multibootusb-pkexec\' (post install)\n\n',
info=False, debug=True)
mbusb_gui.main_gui()


Expand Down
13 changes: 4 additions & 9 deletions scripts/mbusb_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,13 +1048,8 @@ def main_gui():
# ui_about = Ui_About()
# ui = Ui_MainWindow()

if platform.system() == 'Linux' and os.getuid() != 0:
show_admin_info()
sys.exit(2)

else:
window = AppGui()
window.show()
window.setWindowTitle("MultiBootUSB - " + mbusb_version())
window.setWindowIcon(QtGui.QIcon(resource_path(os.path.join("data", "tools", "multibootusb.png"))))
window = AppGui()
window.show()
window.setWindowTitle("MultiBootUSB - " + mbusb_version())
window.setWindowIcon(QtGui.QIcon(resource_path(os.path.join("data", "tools", "multibootusb.png"))))
sys.exit(app.exec_())
2 changes: 1 addition & 1 deletion scripts/osdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def gpt_device(self, dev_name):
lang = os.getenv('LANG')
encoding = lang.rsplit('.')[-1] if lang else 'utf-8'
raise RuntimeError(str(_err_out, encoding))
subprocess.check_call(['partprobe', disk_dev])
udisks.rescan(disk_dev)
if b'msdos' in _cmd_out:
return False
if b'gpt' in _cmd_out:
Expand Down
14 changes: 14 additions & 0 deletions scripts/udisks.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ def device(self, device_node_path):

raise ValueError('%r not known to UDisks2'%device_node_path)

def rescan(self, node_path):
# Rescan partition table
import dbus
mgr = self.bus.get_object('org.freedesktop.UDisks2',
'/org/freedesktop/UDisks2/Manager')
dev_paths = mgr.ResolveDevice({'path': node_path}, {}, dbus_interface='org.freedesktop.UDisks2.Manager')
for dev in dev_paths:
bd = self.bus.get_object('org.freedesktop.UDisks2', dev)
bd.Rescan('', dbus_interface='org.freedesktop.UDisks2.Block')

def mount(self, device_node_path, remounted=None):
mp = node_mountpoint(str(device_node_path))
if mp:
Expand Down Expand Up @@ -207,6 +217,10 @@ def umount(node_path):
u.unmount(node_path)


def rescan(node_path):
u = get_udisks()
u.rescan(node_path)

def test_udisks(ver=None):
import sys
dev = sys.argv[1]
Expand Down