From 1b651a947f2274f43a261eda66b6f5ada6210404 Mon Sep 17 00:00:00 2001 From: Robert Wiley Date: Wed, 6 Jun 2018 13:19:55 -0400 Subject: [PATCH] Added esudo. --- esudo/DEBIAN/conffiles | 2 + esudo/DEBIAN/control | 12 + esudo/DEBIAN/postinst | 27 ++ esudo/DEBIAN/postrm | 14 + esudo/etc/esudo/service | 1 + esudo/etc/sudoers.d/esudo-properties | 1 + esudo/usr/bin/esudo | 23 ++ esudo/usr/bin/esudo-gksu | 25 ++ esudo/usr/bin/esudo-properties | 193 ++++++++++ esudo/usr/bin/gksu | 23 ++ esudo/usr/bin/gksudo | 23 ++ .../python2.7/dist-packages/esudo/__init__.py | 1 + .../python2.7/dist-packages/esudo/esudo.py | 360 ++++++++++++++++++ .../applications/esudo-properties.desktop | 12 + esudo/usr/share/applications/esudo.desktop | 12 + esudo/usr/share/doc/esudo/changelog.gz | Bin 0 -> 349 bytes esudo/usr/share/doc/esudo/copyright | 39 ++ esudo/usr/share/lintian/overrides/esudo | 4 + 18 files changed, 772 insertions(+) create mode 100644 esudo/DEBIAN/conffiles create mode 100755 esudo/DEBIAN/control create mode 100755 esudo/DEBIAN/postinst create mode 100755 esudo/DEBIAN/postrm create mode 100644 esudo/etc/esudo/service create mode 100644 esudo/etc/sudoers.d/esudo-properties create mode 100755 esudo/usr/bin/esudo create mode 100755 esudo/usr/bin/esudo-gksu create mode 100755 esudo/usr/bin/esudo-properties create mode 100755 esudo/usr/bin/gksu create mode 100755 esudo/usr/bin/gksudo create mode 100644 esudo/usr/lib/python2.7/dist-packages/esudo/__init__.py create mode 100755 esudo/usr/lib/python2.7/dist-packages/esudo/esudo.py create mode 100644 esudo/usr/share/applications/esudo-properties.desktop create mode 100644 esudo/usr/share/applications/esudo.desktop create mode 100644 esudo/usr/share/doc/esudo/changelog.gz create mode 100644 esudo/usr/share/doc/esudo/copyright create mode 100644 esudo/usr/share/lintian/overrides/esudo diff --git a/esudo/DEBIAN/conffiles b/esudo/DEBIAN/conffiles new file mode 100644 index 0000000..6c839d9 --- /dev/null +++ b/esudo/DEBIAN/conffiles @@ -0,0 +1,2 @@ +/etc/esudo/service +/etc/sudoers.d/esudo-properties diff --git a/esudo/DEBIAN/control b/esudo/DEBIAN/control new file mode 100755 index 0000000..502a7d9 --- /dev/null +++ b/esudo/DEBIAN/control @@ -0,0 +1,12 @@ +Package: esudo +Version: 1.39bodhi8 +Section: admin +Priority: optional +Architecture: all +Depends: sudo, python, python-efl, python-pam +Maintainer: Jeff Hoogland +Homepage: https://github.com/JeffHoogland/esudo +Description: Elementary graphical frontend for sudo elementary + This package provides an elementary front-end for sudo (esudo), + allowing users to give a password and run graphical commands as root + without needing to invoke su or sudo in a terminal emulator. diff --git a/esudo/DEBIAN/postinst b/esudo/DEBIAN/postinst new file mode 100755 index 0000000..de559fb --- /dev/null +++ b/esudo/DEBIAN/postinst @@ -0,0 +1,27 @@ +#!/bin/sh +set -e + +#mv /usr/bin/gksu /usr/bin/gksu-original +#cp -s -f /usr/bin/esudo /usr/bin/gksudo +#cp -s -f /usr/bin/esudo /usr/bin/gksu + +FILE="/usr/bin/pkexec" + +if [ -f $FILE ]; +then + echo "File $FILE exists, replacing it with esudo" + mv /usr/bin/pkexec /usr/bin/pkexec-old +else + echo "File $FILE does not exist." +fi + +ln -s /usr/bin/esudo $FILE + +SUDOER='/etc/sudoers.d/esudo-properties' +CONFIG='/etc/esudo/service' + +chmod 0440 $SUDOER +chown root $SUDOER +chgrp root $SUDOER +chown -R root $CONFIG +chgrp -R root $CONFIG diff --git a/esudo/DEBIAN/postrm b/esudo/DEBIAN/postrm new file mode 100755 index 0000000..34bfa3e --- /dev/null +++ b/esudo/DEBIAN/postrm @@ -0,0 +1,14 @@ +#!/bin/sh +set -e + +rm /usr/bin/pkexec + +FILE="/usr/bin/pkexec-old" + +if [ -f $FILE ]; +then + echo "File $FILE exists, moving it back now that esudo is removed" + mv /usr/bin/pkexec-old /usr/bin/pkexec +else + echo "File $FILE does not exist." +fi diff --git a/esudo/etc/esudo/service b/esudo/etc/esudo/service new file mode 100644 index 0000000..7864d0d --- /dev/null +++ b/esudo/etc/esudo/service @@ -0,0 +1 @@ +sudo diff --git a/esudo/etc/sudoers.d/esudo-properties b/esudo/etc/sudoers.d/esudo-properties new file mode 100644 index 0000000..0021377 --- /dev/null +++ b/esudo/etc/sudoers.d/esudo-properties @@ -0,0 +1 @@ +ALL ALL=NOPASSWD: /usr/bin/esudo-properties diff --git a/esudo/usr/bin/esudo b/esudo/usr/bin/esudo new file mode 100755 index 0000000..b59dbb5 --- /dev/null +++ b/esudo/usr/bin/esudo @@ -0,0 +1,23 @@ +#!/usr/bin/python + +"eSudo launcher" + +import esudo.esudo as esudo +from efl import elementary +import sys +import os + +elementary.init() + +cmd = " ".join(sys.argv[1:]) + +#Make sure we aren't already running as root +if os.geteuid() != 0: + #if we aren't show a GUI to get user password + start = esudo.eSudo(cmd) +else: + #If we are - just fire the command + os.system(cmd) + +elementary.run() +elementary.shutdown() diff --git a/esudo/usr/bin/esudo-gksu b/esudo/usr/bin/esudo-gksu new file mode 100755 index 0000000..6582da4 --- /dev/null +++ b/esudo/usr/bin/esudo-gksu @@ -0,0 +1,25 @@ +#!/usr/bin/python + +"eSudo launcher" + +import esudo.esudo as esudo +from efl import elementary +import sys +import os + +if sys.argv[1] == "--desktop": + cmd = " ".join(sys.argv[4:]) +else: + cmd = " ".join(sys.argv[1:]) +cmd = "gksu-original %s" % cmd + +#Make sure we aren't already running as root +if os.geteuid() != 0: + #if we aren't show a GUI to get user password + start = esudo.eSudo(cmd) +else: + #If we are - just fire the command + os.system(cmd) + +elementary.run() +elementary.shutdown() diff --git a/esudo/usr/bin/esudo-properties b/esudo/usr/bin/esudo-properties new file mode 100755 index 0000000..677d8ff --- /dev/null +++ b/esudo/usr/bin/esudo-properties @@ -0,0 +1,193 @@ +#!/usr/bin/python +from efl import evas +from efl import elementary +from efl.elementary.window import Window, ELM_WIN_DIALOG_BASIC +from efl.elementary.background import Background +from efl.elementary.box import Box +from efl.elementary.label import Label +from efl.elementary.button import Button +from efl.elementary.hoversel import Hoversel +from efl.elementary.separator import Separator + +# TODO: formatting fixes + +"""eSudo Properties - Part of eSudo package + + Written by : AntCer """ + +def current_service(): + try: + with open("/etc/esudo/service") as readonly: + text = readonly.readline().rstrip() #Be sure to truncate newline + except IOError as e: + if e.errno == errno.ENOENT: + + print("Error: esudo improperly installed or configured, attemping to fix.\n") + text = '' + else: + print("Unknown error: perhaps reinstall esudo.") + return text + +def set_service(service): + + with open("/etc/esudo/service", "w") as f: + f.write("{0}\n".format(service)) + +class eSudo_Properties(): + def __init__(self, SERVICES, service): + #~ self.SERVICES = SERVICES = {'su' : None, 'sudo' : None, 'passwd' : None, 'login' : None, 'cron' : None} + self.SERVICES = SERVICES + self.default = 'sudo' + + if service: + self.change(None, service) + elementary.exit() + else: + win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC) + win.title = "eSudo Properties" + win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL + win.resize(300, 150) + win.callback_delete_request_add(lambda o: elementary.exit()) + win.show() + win.activate() + + bg = Background(win) + bg.size_hint_weight = 1.0, 1.0 + win.resize_object_add(bg) + bg.show() + + bz = Box(win) + bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + bz.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL + win.resize_object_add(bz) + bz.show() + + fil = Box(win) + fil.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.2 + bz.pack_end(fil) + fil.show() + + lb = Label(win) + lb.scale = 1.2 + lb.text = "Authentification" + lb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 + lb.size_hint_align = 0.0, evas.EVAS_HINT_FILL + bz.pack_end(lb) + lb.show() + + hz = Box(win) + hz.horizontal = True + hz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 + hz.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL + bz.pack_end(hz) + hz.show() + + lb = Label(win) + lb.text = "Service: " + lb.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + lb.size_hint_align = 0.8, evas.EVAS_HINT_FILL + hz.pack_end(lb) + lb.show() + + hs = Hoversel(win) + hs.hover_parent_set(win) + if not self.text: + set_service(self.default) + hs.text_set(self.text) + for service in SERVICES.keys(): + SERVICES[service] = hs.item_add(service) + hs.callback_selected_add(self.change) + hs.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + hs.size_hint_align = -0.1, evas.EVAS_HINT_FILL + hz.pack_end(hs) + hs.show() + + sep = Separator(win) + sep.horizontal = True + bz.pack_end(sep) + sep.show() + + fil = Box(win) + fil.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + bz.pack_end(fil) + fil.show() + + #~ lb = Label(win) + #~ lb.text = "Screen Display" + #~ lb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 + #~ lb.size_hint_align = 0.0, evas.EVAS_HINT_FILL + #~ bz.pack_end(lb) + #~ lb.show() + + bt = Button(win) + bt.text = "Close" + bt.callback_clicked_add(lambda o: elementary.exit()) + bt.size_hint_align = 1.0, evas.EVAS_HINT_FILL + bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 + bz.pack_end(bt) + bt.show() + + @property + def text(self): + return current_service() + + def change(self, hs, lstitem): + if hs: + for service in self.SERVICES.keys(): + if self.SERVICES[service] == lstitem: + hs.text_set(service) + set_service(service) + break + else: + service = lstitem + set_service(service) + print("Successfully changed authentification service to {0}".format(service)) + + +if __name__ == "__main__": + import argparse + import errno + import os + + # Some variables to make life easier + SERVICES = {'sudo': None, + 'passwd': None, + 'login': None} + SERVICE_FLAG = 'list' + SERVICE_CHOICES = SERVICES.keys() + SERVICE_CHOICES.append(SERVICE_FLAG) + + # Parse command line options + parser = argparse.ArgumentParser(description="Configures properties for eSudo, an Elementary frontend for 'sudo'. If no arguments are given and called as root, opens a configuration window for esudo.") + parser.add_argument("-s", "--service", const = SERVICE_FLAG, nargs='?',choices=SERVICE_CHOICES, + dest='service', + help = "If no service or list is specified, returns a list of services. If a valid argument other than 'list' is given and esudo is called as root, changes authentication service ") + args = parser.parse_args() + + # Get Current service and attempt to fix it if broken + text = current_service() + + if not text or text not in SERVICES.keys(): + if os.geteuid() != 0: + print text, SERVICES.keys(), len(text) + print("Error: please run with sudo.") + exit(1) + print text + text = 'sudo' + set_service(text) + + # if service option is 'list' list available servies + if args.service == SERVICE_FLAG: + for service in sorted(SERVICES.keys()): + print(service) + print("\nCurrent esudo authentification service selected: {0}".format(text)) + # otherwise start GUI + else: + if os.geteuid() != 0: + print("Error: please run with sudo.") + exit(1) + elementary.init() + eSudo_Properties(SERVICES, args.service) + elementary.run() + elementary.shutdown() diff --git a/esudo/usr/bin/gksu b/esudo/usr/bin/gksu new file mode 100755 index 0000000..b59dbb5 --- /dev/null +++ b/esudo/usr/bin/gksu @@ -0,0 +1,23 @@ +#!/usr/bin/python + +"eSudo launcher" + +import esudo.esudo as esudo +from efl import elementary +import sys +import os + +elementary.init() + +cmd = " ".join(sys.argv[1:]) + +#Make sure we aren't already running as root +if os.geteuid() != 0: + #if we aren't show a GUI to get user password + start = esudo.eSudo(cmd) +else: + #If we are - just fire the command + os.system(cmd) + +elementary.run() +elementary.shutdown() diff --git a/esudo/usr/bin/gksudo b/esudo/usr/bin/gksudo new file mode 100755 index 0000000..b59dbb5 --- /dev/null +++ b/esudo/usr/bin/gksudo @@ -0,0 +1,23 @@ +#!/usr/bin/python + +"eSudo launcher" + +import esudo.esudo as esudo +from efl import elementary +import sys +import os + +elementary.init() + +cmd = " ".join(sys.argv[1:]) + +#Make sure we aren't already running as root +if os.geteuid() != 0: + #if we aren't show a GUI to get user password + start = esudo.eSudo(cmd) +else: + #If we are - just fire the command + os.system(cmd) + +elementary.run() +elementary.shutdown() diff --git a/esudo/usr/lib/python2.7/dist-packages/esudo/__init__.py b/esudo/usr/lib/python2.7/dist-packages/esudo/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/esudo/usr/lib/python2.7/dist-packages/esudo/__init__.py @@ -0,0 +1 @@ + diff --git a/esudo/usr/lib/python2.7/dist-packages/esudo/esudo.py b/esudo/usr/lib/python2.7/dist-packages/esudo/esudo.py new file mode 100755 index 0000000..9184d4c --- /dev/null +++ b/esudo/usr/lib/python2.7/dist-packages/esudo/esudo.py @@ -0,0 +1,360 @@ +#!/usr/bin/python +# encoding: utf-8 + +"""eSudo - a GUI sudo tool in python and elementary + +Base code by AntCer, polished by Jeff Hoogland +Something actually useful done by Kai Huuhko +""" + +import os +import getpass +import PAM +from HTMLParser import HTMLParser +from efl import ecore +from efl import evas +from efl import elementary +from efl.elementary.window import Window, ELM_WIN_DIALOG_BASIC +from efl.elementary.background import Background +from efl.elementary.box import Box +from efl.elementary.label import Label +from efl.elementary.popup import Popup +from efl.elementary.frame import Frame +from efl.elementary.separator import Separator +from efl.elementary.entry import Entry, markup_to_utf8 +from efl.elementary.button import Button +from efl.elementary.innerwindow import InnerWindow +import logging + +logging.basicConfig() +log = logging.getLogger("eSudo") +log.setLevel(logging.WARN) + +#----Popups +def pw_error_popup(en): + win = en.top_widget_get() + popup = Popup(win) + popup.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + popup.part_text_set("title,text", "Error") + popup.text = "Incorrect Password!
Please try again." + log.error("eSudo Error: Incorrect Password. Please try again.") + popup.timeout = 3.0 + popup.show() + +#----eSudo +class eSudo(object): + def __init__(self, + command=None, win=None, + start_callback=None, end_callback=None, + *args, **kwargs): + if not win: + nowindow = True + win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC) + win.title = "eSudo" + win.borderless = True + win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL + win.resize(300, 200) + win.callback_delete_request_add(lambda o: elementary.exit()) + win.layer_set(11) + #~ win.fullscreen = True + win.show() + win.activate() + + bg = Background(win) + bg.size_hint_weight = 1.0, 1.0 + win.resize_object_add(bg) + bg.show() + + self.embedded = False + else: + nowindow = False + self.embedded = True + + self.cmd = command + self.start_cb = start_callback if callable(start_callback) else None + self.end_cb = end_callback if callable(end_callback) else None + self.args = args + self.kwargs = kwargs + +#--------eSudo Window + bz = Box(win) + if nowindow: + bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 + else: + bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND + bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0 + bz.show() + + if nowindow: + lbl = Label(win) + lbl.style = "marker" + lbl.color = 170, 170, 170, 255 + lbl.size_hint_align = 0.5, 0.0 + lbl.scale = 2.0 + lbl.text = "eSudo" + bz.pack_end(lbl) + lbl.show() + + sep = Separator(win) + sep.horizontal = True + bz.pack_end(sep) + sep.show() + + fr = Frame(win) + fr.text = "Command:" + fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0 + bz.pack_end(fr) + fr.show() + + if nowindow: + sep = Separator(win) + sep.horizontal = True + bz.pack_end(sep) + sep.show() + + self.cmdline = cmdline = Entry(win) + cmdline.elm_event_callback_add(self.entry_event) + cmdline.single_line = True + if self.cmd: + cmdline.text = self.cmd + cmdline.editable = False + fr.content = cmdline + cmdline.scrollable_set(True) + cmdline.show() + + if nowindow: + fr = Frame(win) + fr.text = "Password:" + fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0 + bz.pack_end(fr) + fr.show() + else: + bz1 = Box(win) + bz.pack_end(bz1) + bz1.show() + + lb = Label(win) + lb.text = "Password:" + lb.size_hint_align = 0.0, 0.5 + bz1.pack_end(lb) + lb.show() + + en = self.en = Entry(win) + en.name = "password" + en.elm_event_callback_add(self.entry_event) + en.single_line = True + en.password = True + en.show() + + if nowindow: + fr.content = en + else: + bz1.pack_end(en) + + sep = Separator(win) + sep.horizontal = True + bz.pack_end(sep) + sep.show() + + btnb = Box(win) + btnb.horizontal = True + btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 + btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL + bz.pack_end(btnb) + btnb.show() + + bt = Button(win) + bt.text = "Cancel" + bt.callback_clicked_add(self.esudo_cancel, en) + bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL + bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 + btnb.pack_end(bt) + bt.show() + + bt = Button(win) + bt.text = "OK" + bt.callback_clicked_add(self.password_check, en) + bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL + bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 + btnb.pack_end(bt) + bt.show() + + self.iw = iw = InnerWindow(win) + iw.content = bz + iw.show() + iw.activate() + if self.cmd: + en.focus = True + + def entry_event(self, obj, entry, event_type, event, *args): + if event_type == evas.EVAS_CALLBACK_KEY_UP: + if event.keyname == "Return": + if entry.name == "password": + self.password_check(None, entry) + else: + self.en.focus = True + elif event.keyname == "Escape": + self.close() + + return True + +#--------Password Checker + def password_check(self, bt, en): + if not self.cmdline.entry: + return + +#------------Sets Password + def pam_conv(auth, query_list, userData): + password = HTMLParser().unescape(en.entry.encode('utf8')) + resp = [] + for i in range(len(query_list)): + query, type = query_list[i] + if type == PAM.PAM_PROMPT_ECHO_ON or \ + type == PAM.PAM_PROMPT_ECHO_OFF: + val = password + resp.append((val, 0)) + elif type == PAM.PAM_PROMPT_ERROR_MSG or \ + type == PAM.PAM_PROMPT_TEXT_INFO: + resp.append(('', 0)) + else: + return None + return resp + +#------------Username & Service To Use + username = getpass.getuser() + + with open("/etc/esudo/service") as file: + service = file.readline()[:-1] + +#------------Start Password Test + auth = PAM.pam() + auth.start(service) + auth.set_item(PAM.PAM_USER, username) + auth.set_item(PAM.PAM_CONV, pam_conv) + try: + auth.authenticate() + auth.acct_mgmt() + except PAM.error, resp: + pw_error_popup(en) + en.entry = "" + en.focus = True + return + except Exception: + log.exception("Internal error! File bug report.") + else: + self.esudo_ok(bt, en) + +#--------eSudo Cancel Button + def esudo_cancel(self, bt, en): + en.entry = "" + self.close() + + def close(self): + self.iw.delete() if self.embedded else elementary.exit() + +#--------eSudo OK Button + def esudo_ok(self, bt, en): + password = HTMLParser().unescape(en.entry.encode('utf8')) + if '"' in self.cmdline.entry: + #cmd = HTMLParser().unescape(self.cmdline.entry.encode('utf8')) + cmd = markup_to_utf8(self.cmdline.entry) + else: + cmd = self.cmdline.entry + cmdprts = cmd.split(" ") + cmdnum = len(cmdprts) + log.info("Starting '%s'..." % cmd) + + #This seems to break a lot of commands - what was it supposed to do? + ''' + if cmdnum > 1: + command = cmdprts[0] + for i in range(cmdnum): + if i > 0: + path = " ".join(cmdprts[i:]) + if os.path.exists(path): + cmd = "%s '%s'" % (command, path) + break + + try: + arguments = self.kwargs["cmdargs"] + cmd = "%s %s" % (cmd, arguments) + except Exception: + pass''' + + #Old method. Using -E is cleaner + #if not os.path.exists("/tmp/libesudo"): + # os.makedirs("/tmp/libesudo") + #command = "cp /home/%s/.Xauthority /tmp/libesudo"%getpass.getuser() + #ecore.Exe(command, ecore.ECORE_EXE_PIPE_READ|ecore.ECORE_EXE_PIPE_ERROR|ecore.ECORE_EXE_PIPE_WRITE) + + #command = "cp -a /home/%s/.elementary /tmp/libesudo"%getpass.getuser() + #ecore.Exe(command, ecore.ECORE_EXE_PIPE_READ|ecore.ECORE_EXE_PIPE_ERROR|ecore.ECORE_EXE_PIPE_WRITE) + + #self.run_command("HOME='/tmp/libesudo' ; sudo -S %s" % (cmd), password) + if cmd.split()[0] == 'pcmanfm': + self.run_command("HOME=/root sudo -S %s" % (cmd), password) + else: + self.run_command("sudo -ES %s" % (cmd), password) + +#--------Run Command + def run_command(self, command, password): + self.cmd_exe = cmd = ecore.Exe( + command, + ecore.ECORE_EXE_PIPE_READ | + ecore.ECORE_EXE_PIPE_ERROR | + ecore.ECORE_EXE_PIPE_WRITE + ) + cmd.on_add_event_add(self.command_started) + cmd.on_data_event_add(self.received_data) + cmd.on_error_event_add(self.received_error, password) + cmd.on_del_event_add(self.command_done) + + def command_started(self, cmd, event, *args, **kwargs): + log.info("Command started.\n") + if self.start_cb: + try: + self.start_cb(self.win, *self.args, **self.kwargs) + except Exception: + log.exception() + self.iw.hide() if self.embedded else self.win.hide() + + def received_data(self, cmd, event, *args, **kwargs): + if not "\n" == event.data: + log.debug(event.data) + + def received_error(self, cmd, event, *args, **kwargs): + if not "sudo" in event.data: + log.debug("Error: %s" % event.data) + else: + password = args[0] + cmd.send(str(password)+"\n") + + def command_done(self, cmd, event, *args, **kwargs): + log.info("Command done.") + + if self.end_cb: + try: + self.end_cb( + event.exit_code, self.win, *self.args, **self.kwargs + ) + except Exception: + log.exception() + self.close() + +if __name__ == "__main__": + import sys + + new_arg = [] + for i in sys.argv[1:]: + if ' ' in i: + i = '"'+ i + '"' + new_arg.append(i) + cmd = " ".join(new_arg) + + elementary.init() + + start = eSudo(cmd) + + elementary.run() + elementary.shutdown() diff --git a/esudo/usr/share/applications/esudo-properties.desktop b/esudo/usr/share/applications/esudo-properties.desktop new file mode 100644 index 0000000..4b4b49b --- /dev/null +++ b/esudo/usr/share/applications/esudo-properties.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Hidden=false +Exec=sudo esudo-properties +Icon=gconfeditor +Type=Application +Categories=Settings; +NoDisplay=true +StartupNotify=true +Comment=Configure properties of eSudo. +Terminal=false +Name=eSudo Properties +Comment[en_US]=Configure properties of eSudo. diff --git a/esudo/usr/share/applications/esudo.desktop b/esudo/usr/share/applications/esudo.desktop new file mode 100644 index 0000000..c838c0c --- /dev/null +++ b/esudo/usr/share/applications/esudo.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Hidden=false +Exec=esudo +Icon=system-users +Type=Application +Categories=System; +NoDisplay=true +StartupNotify=true +Comment=An elementary frontend for sudo written in py-efls. +Terminal=false +Name=eSudo +Comment[en_US]=An elementary frontend for sudo written in py-efls. diff --git a/esudo/usr/share/doc/esudo/changelog.gz b/esudo/usr/share/doc/esudo/changelog.gz new file mode 100644 index 0000000000000000000000000000000000000000..6767de30a052c970b4b7a9ea1c7c7c4912dc1d14 GIT binary patch literal 349 zcmV-j0iymNiwFP!000021C`Rk$1;#}6EvWbbt?GL3Cp;Dn#ir1UXs7p7y zA<3e7`)*Vy6h*xonBnj-GgP_E;w~5rC#lUgD(NCs)+qS^SFXv(<|(I4xxCW>?(tn@ zqNWThTjI5yM?7G@)$ilWrc~BgDoqU@8%^}GPt?k|-9Xy>8CX)*0~=xH3_=zpzUJ|W zhhy|v%zP02qZWXF&E8|Gv@wI v;piMEIK|O+d$7D4RV$%Uk|t5z`Yhh@MzVE`_BZm5$ + +License: GPL-3.0+ + +Files: debian/* +Copyright: 2015 Robert Wiley +License: GPL-3.0+ + +License: GPL-3.0+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + . + Please see the COPYING.PLAIN for a plain-english explanation of this notice + and it's intent. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/esudo/usr/share/lintian/overrides/esudo b/esudo/usr/share/lintian/overrides/esudo new file mode 100644 index 0000000..dd80f23 --- /dev/null +++ b/esudo/usr/share/lintian/overrides/esudo @@ -0,0 +1,4 @@ +# Suppress a harmless lintian warnings +esudo: binary-without-manpage +esudo: desktop-command-not-in-package +esudo: maintainer-script-should-not-use-recursive-chown-or-chmod