1
votes

I'm building my first sizable Linux program that I plan on uploading to the Ubuntu Software Center, and I've run into a problem: I assumed calling something like system("sudo mkdir /opt/test"); in a graphical program would automatically bring up the little dialog that asks for the root password, but it doesn't. I get the error: "sudo: no tty present and no askpass program specified"

So is my assumption that this is handled automatically when the user doesn't have access to a terminal incorrect? And if so, what is the default "askpass" program for Ubuntu, and how might I call it? Can I use gksudo?

I would really appreciate some help. Thanks!

1
The GUI doesn't use sudo, but any of a family of similar programsBen Voigt
I think you'll have the send a DBUS message to a XDG standard address, which askpass-type programs will reply with the GUI and status afterwards.Spidey
If my program is installed through the Ubuntu Software Center, will it be given the proper permissions to change things like /etc/environment? Using sudo apt-get install kdesudo would defeat the purpose of doing this graphically as my program would have to be root to install this dependency.ICoffeeConsumer

1 Answers

2
votes

I figured it out. You can use gksudo for this, and format the command to meet your needs.

system("gksudo mkdir testdir");