Jump to content

Photo

Suggestions for esudo


  • Please log in to reply
8 replies to this topic

#1 Nils

Nils

    Member

  • Members
  • 8 posts
  • LocationSweden

Posted 22 October 2015 - 04:09 PM

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(),
             self.rnd_dir)
        ecore.Exe(command, ecore.ECORE_EXE_PIPE_READ |
                            ecore.ECORE_EXE_PIPE_ERROR |
                            ecore.ECORE_EXE_PIPE_WRITE)

        self.run_command(
        "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)
        os.rmdir(self.rnd_dir)
        if self.end_cb:

----- That's it.

and gksu/gksudo can look like this

#!/usr/bin/python

"eSudo launcher"

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

elementary.init()

if sys.argv[1] == "--description":
    cmd = "".join(sys.argv[3:])
else:
    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)
    sys.exit(0)

elementary.run()
elementary.shutdown()

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





A big thank you to everyone who contributes to Bodhi Linux


#2 Jeff

Jeff

    Lead Developer

  • Developer
  • 12351 posts
  • LocationBloomington, IL

Posted 22 October 2015 - 04:23 PM

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!



#3 Nils

Nils

    Member

  • Members
  • 8 posts
  • LocationSweden

Posted 22 October 2015 - 07:29 PM

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.



#4 Jeff

Jeff

    Lead Developer

  • Developer
  • 12351 posts
  • LocationBloomington, IL

Posted 22 October 2015 - 08:11 PM

It isn't too bad to get started with. A lot of the stuff is point and click. You just fork the repo, make your changes, commit the changes, and then make a pull request.

 

I actually wrote a quick intro to github here -> http://it.toolbox.co...ro-to-git-70035



#5 Jeff

Jeff

    Lead Developer

  • Developer
  • 12351 posts
  • LocationBloomington, IL

Posted 24 October 2015 - 05:55 AM

Tested your change tonight - does not have the same effect as the original code.



#6 Nils

Nils

    Member

  • Members
  • 8 posts
  • LocationSweden

Posted 24 October 2015 - 04:34 PM

What is the problem?



#7 Jeff

Jeff

    Lead Developer

  • Developer
  • 12351 posts
  • LocationBloomington, IL

Posted 24 October 2015 - 04:41 PM

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



#8 Nils

Nils

    Member

  • Members
  • 8 posts
  • LocationSweden

Posted 24 October 2015 - 07:47 PM

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.



#9 Jeff

Jeff

    Lead Developer

  • Developer
  • 12351 posts
  • LocationBloomington, IL

Posted 24 October 2015 - 09:12 PM

Yea - sadly that isn't a good solution. 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users