Jump to content
Sign in to follow this  

Suggestions for esudo

Recommended Posts

I discovered this after the installation of sbackup-gtk.
Sbackup in admin mode started with a dbus error message.
But the problem is in esudo. It is "sudo -E" that causes the problem.

I used Ubuntu and gksudo to test the behavior, and then tried to
rewrite the code. Now it seems OK to me.

-----Here is my alterations.

import random
import string

----- This one, key_up/key_down is a fix for another problem, cursor positioning.

        if event_type == evas.EVAS_CALLBACK_KEY_DOWN:  # was _UP

----- This is the rewrite.

        #Old method. Using -E is cleaner. Now rewritten
        self.rnd_dir = u"/tmp/libesudo-" + self.random_char(6)
        os.makedirs(self.rnd_dir, 0700)
        command = "cp /home/%s/.Xauthority %s" % (getpass.getuser(),
        ecore.Exe(command, ecore.ECORE_EXE_PIPE_READ |
                            ecore.ECORE_EXE_PIPE_ERROR |

        "XAUTHORITY='%s/.Xauthority' ; sudo -EHS DBUS_SESSION_BUS_ADDRESS= %s"
             % (self.rnd_dir, cmd), password)

#--------Random string for directory name
    def random_char(self, y):
        return ''.join(random.choice(string.ascii_letters) for x in range(y))

#--------Run Command ----- end of changes

----- Next piece of changes.

    def command_done(self, cmd, event, *args, **kwargs):
        log.info("Command done.")

        os.remove('%s/.Xauthority' % self.rnd_dir)
        if self.end_cb:

----- That's it.

and gksu/gksudo can look like this


"eSudo launcher"

import esudo.esudo as esudo
from efl import elementary
import sys
import os


if sys.argv[1] == "--description":
    cmd = "".join(sys.argv[3:])
    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)
    #If we are - just fire the command


What do you think, is it useful?
Or totally unnecessary?

Share this post

Link to post
Share on other sites

Are you familiar with GitHub at all? If so can you make a pull request against the esudo repo with these changes so I can easily test them? If you can't I'll manually digest and implement all of these when time allows and get back to you.

If they provide the same functionality we have now, while fixing an issue you found I don't see why we wouldn't want to implement these changes.


Also - going to move this to the elementary applications sub-forum.


Thanks for the input!

Share this post

Link to post
Share on other sites

Hi Jeff


No I am not familiar with GitHub. So for now you have to do it the hard way.


I suppose I have to look into GitHub later if I am going to come up  with more additions/corrections.

  • Like 1

Share this post

Link to post
Share on other sites

Try launching epad or another elementary application with esudo with your change. It does not utilize the current user's elementary theme.

Share this post

Link to post
Share on other sites

Sorry, forgot to tell you that.

I solved it with "esudo elementary_config".

It is a sloppy solution, if user make changes, root has to do it also.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this