Hello Michael I've tracked down the source of the problem, and think I've created an appropriate patch. The function RunAsSudoUserCommand() was dereferencing a NULL pointer when failing to check for the return value of getenv("SUDO_UID");
I was launching Synaptic with gksu which does not set this environment variable, so getenv returned NULL. I do not use sudo on my system (though did add myself as a sudoer to confirm this behaviour and test my changes). Launching as a real root user caused the same crash. We should not launch the browsers/help viewers as root, so I've provided a fallback behaviour. The function RunAsSudoUserCommand() is currently called by the following three methods (none of which should run their command with effective root, as they are launching end-user-configurable software / web browsers) RGMainWindow::cbHelpAction RGPkgDetailsWindow::cbOpenLink RGPkgDetailsWindow::cbOpenHomepage The patch I've provided solves the crash problem and the security problem (it specifically checks whether the user is effective root, and returns false if it is) Comments are welcome. It's not devastatingly beautiful, but seems to serve its purpose. All the Best Luke
diff --git a/gtk/rgutils.cc b/gtk/rgutils.cc index e00ab89..0c4fe21 100644 --- a/gtk/rgutils.cc +++ b/gtk/rgutils.cc @@ -29,7 +29,7 @@ #include <cstdlib> #include <cstring> #include <pwd.h> - +#include <assert.h> #include <iostream> #include "i18n.h" @@ -138,13 +138,29 @@ bool RunAsSudoUserCommand(std::vector<const gchar*> cmd) std::cerr << "Empty command for RunAsSudoUserCommand" << std::endl; return true; } - + bool getuidbyname = false; // try pkexec first, then sudo sudo_user = getenv("PKEXEC_UID"); + if (sudo_user == NULL) { sudo_user = getenv("SUDO_UID"); } - pwd = getpwuid(atoi(sudo_user)); + if (sudo_user == NULL) { + sudo_user = getenv("USER"); + getuidbyname = true; + } + if (sudo_user == NULL) { + return false; + } + if(strncmp("root", sudo_user, strlen("root")) == 0){ + return false; + } + if(!getuidbyname){ + pwd = getpwuid(atoi(sudo_user)); + } + else{ + pwd = getpwnam(sudo_user); + } sudo_user = pwd->pw_name; #if 0 // does not work for some reason if(FileExists("/usr/bin/pkexec") && sudo_user != NULL)