29
29
30
30
#include <glib/gi18n.h>
31
31
#include <gtk/gtk.h>
32
+ #include <pwd.h>
33
+ #include <stdlib.h>
34
+ #include <sys/types.h>
35
+ #include <sys/wait.h>
36
+ #include <unistd.h>
32
37
#include "callbacks.h"
33
38
#include "installation-profile.h"
34
39
#include "interface-globals.h"
35
40
#include "window-graphics.h"
36
41
#include "welcome-screen.h"
37
42
#include "help-dialog.h"
38
43
44
+ #define XDG_OPEN "/usr/bin/xdg-open"
45
+
39
46
/*
40
47
* Signal handler connected up by Glade XML signal autoconnect
41
48
* for the release notes button clicked event.
@@ -46,19 +53,57 @@ on_releasenotesbutton_clicked(GtkWidget *widget,
46
53
{
47
54
GError * error = NULL ;
48
55
gboolean result ;
56
+ uid_t suid ;
57
+ int pid ;
58
+
59
+ result = FALSE;
60
+ /* The installer will typically be run as root under sudo,
61
+ but we don't want to run browser as root */
62
+
63
+ suid = geteuid ();
64
+ if (suid == 0 ) {
65
+ char * sudo_uid ;
66
+
67
+ sudo_uid = getenv ("SUDO_UID" );
68
+ if (sudo_uid )
69
+ suid = strtol (sudo_uid , (char * * )NULL , 10 );
70
+ }
71
+ pid = fork ();
72
+ if (pid == 0 ) {
73
+ if (suid > 0 && suid != geteuid ()) {
74
+ struct passwd pw ;
75
+
76
+ setuid (suid );
77
+ pw = getpwuid (suid );
78
+ if (pw != NULL ) {
79
+ if (pw -> pw_name != NULL ) {
80
+ setenv ("USERNAME" , pw -> pw_name , 1 );
81
+ setenv ("LOGNAME" , pw -> pw_name , 1 );
82
+ }
83
+ if (pw -> pw_dir != NULL ) {
84
+ setenv ("HOME" , pw -> pw_dir , 1 );
85
+ }
86
+ }
87
+ }
88
+ execl (XDG_OPEN , XDG_OPEN , RELEASENOTESURL , (char * )0 );
89
+ exit (-1 );
90
+ } else if (pid > 0 ) {
91
+ int status ;
92
+
93
+ waitpid (pid , & status , 0 );
94
+ if (WIFEXITED (status ) && WEXITSTATUS (status ) == 0 ) {
95
+ result = TRUE;
96
+ }
97
+ }
49
98
50
- result = gtk_show_uri (gtk_widget_get_screen (widget ),
51
- RELEASENOTESURL ,
52
- GDK_CURRENT_TIME ,
53
- & error );
54
99
if (result != TRUE) {
55
100
gui_install_prompt_dialog (
56
101
FALSE,
57
102
FALSE,
58
103
FALSE,
59
104
GTK_MESSAGE_ERROR ,
60
105
_ ("Unable to display release notes" ),
61
- error -> message );
106
+ NULL );
62
107
g_error_free (error );
63
108
}
64
109
return (TRUE);
0 commit comments