Bug#725885:

2013-11-06 Thread Luke Drummond
Hi Michael

gksu appears to not set any of the same environment variables, so I
put the strncmp("root", ...) call in there and return false.  The
behaviour I chose is to do nothing if we can't assume a non-priveleged
user.  The user experience though is that Synaptic silently does
nothing.  I don't think this is a good thing, but perhaps a dialogue
box could be shown saying something like "You need to launch this
program with sudo to use that command..." or somesuch.

Apparently gksu doesn't set any of the expected environment variables,
so that is why I added the extra tests. see
http://stackoverflow.com/questions/15101854/keep-user-env-variables-executing-gksu
for a similar discussion.

With my patch applied, and Synaptic run with gksu or under
proper-root, clicking the links silently does nothing. When using
sudo, or running without any privileges the proper behaviour is
encountered. and the browser is launched with the proper user account.

I'm happy to help you on adding a dialogue for "can't launch browser
as root user" if you like ( though my gtk-chops are pretty limited),
so let me know if I can help more.

All the Best

Luke

On 6 November 2013 06:42, Michael Vogt  wrote:
> On Mon, Nov 04, 2013 at 03:49:43AM +, Luke Drummond wrote:
>> Hello Michael
> Hi Luke,
>
> thanks for your bugreport and your patch!
>
>> 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.
>
> Indeed, thanks for finding and fixing this! Will $USER provide the
> name of the real user or will it contain "root" when gksu uses it?
>
>> 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.
> [..]
>
> It looks fine and I commited it locally. My only question would be if
> getenv("USER"); may give us the "real" user. If not I will try to
> think if there is any other way to find this out.
>
> Thanks,
>  Michael


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#725885:

2013-11-05 Thread Michael Vogt
On Mon, Nov 04, 2013 at 03:49:43AM +, Luke Drummond wrote:
> Hello Michael
Hi Luke,

thanks for your bugreport and your patch!
 
> 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.

Indeed, thanks for finding and fixing this! Will $USER provide the
name of the real user or will it contain "root" when gksu uses it?
 
> 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.
[..]

It looks fine and I commited it locally. My only question would be if
getenv("USER"); may give us the "real" user. If not I will try to
think if there is any other way to find this out.

Thanks,
 Michael


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#725885: Retitle

2013-11-05 Thread Filipus Klutiero

retitle 725885 crashes when trying to visit homepage while not running via sudo
tags 725885 + patch

--
Filipus Klutiero
http://www.philippecloutier.com


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#725885:

2013-11-03 Thread Luke Drummond
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 
 #include 
 #include 
-
+#include 
 #include 
 
 #include "i18n.h"
@@ -138,13 +138,29 @@ bool RunAsSudoUserCommand(std::vector 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)


Bug#725885: [synaptic] crashes when trying to visit homepage (KDE)

2013-10-09 Thread Filipus Klutiero

Package: synaptic
Version: 0.80.4
Severity: normal

Many packages define their homepage. For example, filelight does. Synaptic now 
displays a curious Visit Homepage link for these packages (initially looks like 
a simple link, but looks like a button when clicked). When I click this button, 
Synaptic not only fails to open the requested homepage, but crashes:


Program received signal SIGSEGV, Segmentation fault.
0xf6ce898c in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
(gdb) backtrace
#0  0xf6ce898c in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
#1  0xf6ce8740 in strtol () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
#2  0x0806fb6a in ?? ()
#3  0x0808a971 in ?? ()
#4  0xf79c2783 in ?? () from /usr/lib/i386-linux-gnu/libgtk-3.so.0
#5  0xf741a69e in g_closure_invoke () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#6  0xf742c149 in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#7  0xf7433884 in g_signal_emit_valist () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#8  0xf7433dd3 in g_signal_emit () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#9  0xf79b7c3d in ?? () from /usr/lib/i386-linux-gnu/libgtk-3.so.0
#10 0xf741c319 in g_cclosure_marshal_VOID__VOIDv () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#11 0xf7419077 in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#12 0xf741a8de in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#13 0xf7433237 in g_signal_emit_valist () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#14 0xf7433dd3 in g_signal_emit () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#15 0xf78da48a in gtk_button_clicked () from 
/usr/lib/i386-linux-gnu/libgtk-3.so.0
#16 0xf78db1c0 in ?? () from /usr/lib/i386-linux-gnu/libgtk-3.so.0
#17 0xf741c319 in g_cclosure_marshal_VOID__VOIDv () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#18 0xf7419077 in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#19 0xf741a8de in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#20 0xf7433237 in g_signal_emit_valist () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#21 0xf7433dd3 in g_signal_emit () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#22 0xf78d99ce in ?? () from /usr/lib/i386-linux-gnu/libgtk-3.so.0
#23 0xf79bff16 in ?? () from /usr/lib/i386-linux-gnu/libgtk-3.so.0
#24 0xf74191c4 in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#25 0xf741a69e in g_closure_invoke () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#26 0xf742bda0 in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#27 0xf7433884 in g_signal_emit_valist () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#28 0xf7433dd3 in g_signal_emit () from 
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#29 0xf7afee5b in ?? () from /usr/lib/i386-linux-gnu/libgtk-3.so.0
#30 0xf79bddb5 in ?? () from /usr/lib/i386-linux-gnu/libgtk-3.so.0
#31 0xf79bfbe0 in gtk_main_do_event () from 
/usr/lib/i386-linux-gnu/libgtk-3.so.0
#32 0xf77c2c5c in ?? () from /usr/lib/i386-linux-gnu/libgdk-3.so.0
#33 0xf77eedf2 in ?? () from /usr/lib/i386-linux-gnu/libgdk-3.so.0
#34 0xf735042e in g_main_context_dispatch () from 
/lib/i386-linux-gnu/libglib-2.0.so.0
#35 0xf73507d8 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#36 0xf7350c3b in g_main_loop_run () from /lib/i386-linux-gnu/libglib-2.0.so.0
#37 0xf79bee85 in gtk_main () from /usr/lib/i386-linux-gnu/libgtk-3.so.0
#38 0x080592a3 in ?? ()
#39 0xf6ccd8c5 in __libc_start_main () from 
/lib/i386-linux-gnu/i686/cmov/libc.so.6
#40 0x0805b700 in ?? ()
(gdb)



Synaptic can still help to reach the homepage as one can right-click the link 
and copy the URL.

I use KDE 4.10. This happens for 2 users on 2 tested. All homepages appear to 
be affected.

--- System information. ---
Architecture: i386
Kernel: Linux 3.10-3-amd64

Debian Release: jessie/sid
990 testing http.us.debian.org
500 unstable http.us.debian.org
1 experimental debian.mirror.iweb.ca

--- Package information. ---
Depends (Version) | Installed
=-+-==
libapt-inst1.5 (>= 0.8.16~exp12) | 0.9.11.4
libapt-pkg4.12 (>= 0.9.11.3) | 0.9.11.4
libatk1.0-0 (>= 1.12.4) | 2.10.0-2
libc6 (>= 2.3.6-6~) | 2.17-93
libcairo-gobject2 (>= 1.10.0) | 1.12.16-2
libcairo2 (>= 1.2.4) | 1.12.16-2
libept1.4.12 (>= 1.0.9) | 1.0.9
libgcc1 (>= 1:4.1.1) | 1:4.8.1-10
libgdk-pixbuf2.0-0 (>= 2.22.0) | 2.28.2-1
libglib2.0-0 (>= 2.16.0) | 2.36.4-1
libgtk-3-0 (>= 3.0.0) | 3.8.4-1
libpango-1.0-0 (>= 1.14.0) | 1.32.5-5+b1
libpangocairo-1.0-0 (>= 1.14.0) | 1.32.5-5+b1
libstdc++6 (>= 4.6) | 4.8.1-10
libvte-2.90-9 (>= 1:0.27.2) | 1:0.34.8-1
libx11-6 | 2:1.6.1-1
libxapian22 | 1.2.15-2
libxext6 | 2:1.3.2-1
zlib1g (>= 1:1.1.4) | 1:1.2.8.dfsg-1
hicolor-icon-theme | 0.12-1


Recommends (Version) | Installed
==-+-=
gksu | 2.0.2-6
OR kdebase-bin |
OR policykit-1 | 0.105-3
libgtk2-perl (>= 1:1.130) |
rarian-compat | 0.8.1-5


Suggests (Version) | Installed
==-+-===
dwww |
men