Merging upstream version 0.5.3 (Closes: #805659 CVE-2015-8308).
[debian/lxdm.git] / src / config.c
index 3f92f7b..b051224 100644 (file)
@@ -125,24 +125,19 @@ static gboolean image_file_valid(const char *filename)
 static void update_face_image(GtkWidget *w)
 {
        GdkPixbuf *pixbuf;
-       char *path;
-       path=g_build_filename(user->pw_dir,".face",NULL);
-       if(access(path,R_OK))
-       {
-               g_free(path);
-               if(ui_nobody)
-                       pixbuf=gdk_pixbuf_new_from_file_at_scale(ui_nobody,48,48,FALSE,NULL);
-               if(!pixbuf)
-                       pixbuf=gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
+       char *path=g_build_filename(user->pw_dir,".face",NULL);
+       pixbuf=gdk_pixbuf_new_from_file_at_scale(path,48,48,FALSE,NULL);
+       g_free(path);
+       if(!pixbuf && ui_nobody)
+               pixbuf=gdk_pixbuf_new_from_file_at_scale(ui_nobody,48,48,FALSE,NULL);
+       if(!pixbuf)
+               pixbuf=gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
                                                "avatar-default", 48,GTK_ICON_LOOKUP_FORCE_SIZE,NULL);
-       }
-       else
+       if(pixbuf)
        {
-               pixbuf=gdk_pixbuf_new_from_file_at_scale(path,48,48,FALSE,NULL);
-               g_free(path);
+               gtk_image_set_from_pixbuf(GTK_IMAGE(w),pixbuf);
+               g_object_unref(pixbuf);
        }
-       gtk_image_set_from_pixbuf(GTK_IMAGE(w),pixbuf);
-       g_object_unref(pixbuf);
 }
 
 static void set_face_file(const char *filename)
@@ -159,15 +154,22 @@ static void set_face_file(const char *filename)
                if(g_file_get_contents(filename,&contents,&length,NULL))
                {
                        gchar *path=g_build_filename(user->pw_dir,".face",NULL);
+                       seteuid(user->pw_uid);
+                       setegid(user->pw_gid);
                        g_file_set_contents(path,contents,length,NULL);
-                       chown(path,user->pw_uid,user->pw_gid);
+                       seteuid(getuid());
+                       setegid(getgid());
                        g_free(path);
                }
        }
        else
        {
                gchar *path=g_build_filename(user->pw_dir,".face",NULL);
+               seteuid(user->pw_uid);
+               setegid(user->pw_gid);
                unlink(path);
+               seteuid(getuid());
+               setegid(getgid());
                g_free(path);
        }
        w=(GtkWidget*)gtk_builder_get_object(builder,"user-icon-image");
@@ -484,6 +486,82 @@ void prepare_bg(GtkBuilder *builder)
        g_signal_connect(w,"toggled",on_bg_type_toggled,NULL);
 }
 
+static void on_enable_pane_toggled(GtkToggleButton *button)
+{
+        int val;
+        val=gtk_toggle_button_get_active(button);
+        g_key_file_set_integer(config,"display","bottom_pane",val);
+        GtkWidget *w;
+        w=(GtkWidget*)gtk_builder_get_object(builder,"vbox2");
+        gtk_widget_set_sensitive(w,val?TRUE:FALSE);
+       dirty++;
+}
+
+static void prepare_enable_pane(GtkBuilder *builder)
+{
+        gint val;
+        GtkWidget *w;
+        w=(GtkWidget*)gtk_builder_get_object(builder,"lxdm-enable-bottom-pane");
+        val=g_key_file_get_integer(config,"display","bottom_pane",NULL);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),val?TRUE:FALSE);
+        if(!root) gtk_widget_set_sensitive(w,FALSE);
+        g_signal_connect(w,"toggled",G_CALLBACK(on_enable_pane_toggled),NULL);
+}
+
+static void prepare_vbox2(GtkBuilder *builder)
+{
+        gint val;
+        GtkWidget *w;
+        w=(GtkWidget*)gtk_builder_get_object(builder,"vbox2");
+        val=g_key_file_get_integer(config,"display","bottom_pane",NULL);
+        if(!root) 
+       {
+               gtk_widget_set_sensitive(w,FALSE);
+       }
+       else
+       {
+               gtk_widget_set_sensitive(w,val?TRUE:FALSE);
+       }
+}
+
+static void on_transparent_pane_toggled(GtkToggleButton *button)
+{
+        int val;
+        val=gtk_toggle_button_get_active(button);
+        g_key_file_set_integer(config,"display","transparent_pane",val);
+        dirty++;
+}
+
+static void prepare_transparent_pane(GtkBuilder *builder)
+{
+        gint val;
+        GtkWidget *w;
+        w=(GtkWidget*)gtk_builder_get_object(builder,"lxdm-transparent-pane");
+        val=g_key_file_get_integer(config,"display","transparent_pane",NULL);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),val?TRUE:FALSE);
+        if(!root) gtk_widget_set_sensitive(w,FALSE);
+        g_signal_connect(w,"toggled",G_CALLBACK(on_transparent_pane_toggled),NULL);
+}
+
+static void on_hide_sessions_toggled(GtkToggleButton *button)
+{
+        int val;
+        val=gtk_toggle_button_get_active(button);
+        g_key_file_set_integer(config,"display","hide_sessions",val);
+        dirty++;
+}
+
+static void prepare_hide_sessions(GtkBuilder *builder)
+{
+        gint val;
+        GtkWidget *w;
+        w=(GtkWidget*)gtk_builder_get_object(builder,"lxdm-hide-sessions");
+        val=g_key_file_get_integer(config,"display","hide_sessions",NULL);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),val?TRUE:FALSE);
+        if(!root) gtk_widget_set_sensitive(w,FALSE);
+        g_signal_connect(w,"toggled",G_CALLBACK(on_hide_sessions_toggled),NULL);
+}
+
 static void on_show_lang_toggled(GtkToggleButton *button)
 {
        int val;
@@ -522,6 +600,44 @@ static void prepare_show_keyboard(GtkBuilder *builder)
        g_signal_connect(w,"toggled",G_CALLBACK(on_show_keyboard_toggled),NULL);
 }
 
+static void on_hide_exit_toggled(GtkToggleButton *button)
+{
+        int val;
+        val=gtk_toggle_button_get_active(button);
+        g_key_file_set_integer(config,"display","hide_exit",val);
+        dirty++;
+}
+
+static void prepare_hide_exit(GtkBuilder *builder)
+{
+        gint val;
+        GtkWidget *w;
+        w=(GtkWidget*)gtk_builder_get_object(builder,"lxdm-hide-exit");
+        val=g_key_file_get_integer(config,"display","hide_exit",NULL);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),val?TRUE:FALSE);
+        if(!root) gtk_widget_set_sensitive(w,FALSE);
+        g_signal_connect(w,"toggled",G_CALLBACK(on_hide_exit_toggled),NULL);
+}
+
+static void on_hide_time_toggled(GtkToggleButton *button)
+{
+        int val;
+        val=gtk_toggle_button_get_active(button);
+        g_key_file_set_integer(config,"display","hide_time",val);
+        dirty++;
+}
+
+static void prepare_hide_time(GtkBuilder *builder)
+{
+        gint val;
+        GtkWidget *w;
+        w=(GtkWidget*)gtk_builder_get_object(builder,"lxdm-hide-time");
+        val=g_key_file_get_integer(config,"display","hide_time",NULL);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),val?TRUE:FALSE);
+        if(!root) gtk_widget_set_sensitive(w,FALSE);
+        g_signal_connect(w,"toggled",G_CALLBACK(on_hide_time_toggled),NULL);
+}
+
 static void on_show_userlist_toggled(GtkToggleButton *button)
 {
        int val;
@@ -553,8 +669,14 @@ GtkDialog *dialog_create(void)
        prepare_user_name(builder);
        prepare_user_autologin(builder);
        prepare_bg(builder);
+       prepare_enable_pane(builder);
+       prepare_vbox2(builder);
+       prepare_transparent_pane(builder);
+       prepare_hide_sessions(builder);
        prepare_show_lang(builder);
        prepare_show_keyboard(builder);
+       prepare_hide_exit(builder);
+       prepare_hide_time(builder);
        prepare_show_userlist(builder);
 
        return dlg;