Thursday, November 13, 2008

kdesudo vs. gksudo

So I've written a little Python script that deals with downloading pics from our camera - it puts them in a dated directory, auto-rotates them, etc. The usual stuff that a pre-made program does, but makes me feel more important and talented than just downloading a program that'll do it for me. I like to feel special.

Anyway, the point is that to achieve downloading goodness, my script needs root access in order to successfully talk to the camera. But it's a GUI - a visual point and click interface. With buttons! How to run sudo to give my camera-talking commands the power they need?

The answer is that there are a handful of graphical sudo tools out there - commands that will pop up a little window to accept your password and authenticate that way. The first one I tried was kdesudo, which seemed to work great. However, I noticed that when the camera downloaded, it would hack up a hairball on about every 16th image. The output for each image was 64 characters long, which when multiplied by 16 is 1024 - a common limit for some shell-related stuff, although not one I've run into in a while. Dead giveaway that something was hoopy somewhere.

After trying to pin this on Python's commands.getstatusoutput() for a while, I did some simple tests that showed that it was only a problem when run through kdesudo! It seems there's something in there with some kind of limit on output - not exactly sure what, because it would get so far, then choke, then continue with the next image on the next fresh line. Very odd.

Long boring story short, I swapped it out for gksudo, and my problems evaporated. gksudo ftw!

No comments: