1 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/panel-addto.c gnome-panel-2.27.91/gnome-panel/panel-addto.c 2 --- gnome-panel-2.27.91.old/gnome-panel/panel-addto.c 2009-08-26 17:27:48.018970000 +0100 3 +++ gnome-panel-2.27.91/gnome-panel/panel-addto.c 2009-08-26 17:33:56.113982000 +0100 4 @@ -571,9 +571,10 @@ panel_addto_make_applet_model (PanelAddt 5 dialog, NULL); 6 } 7 8 -static void panel_addto_make_application_list (GSList **parent_list, 9 +static gint panel_addto_make_application_list (GSList **parent_list, 10 GMenuTreeDirectory *directory, 11 const char *filename); 12 +static void panel_addto_dialog_free_item_info (PanelAddtoItemInfo *item_info); 13 14 static void 15 panel_addto_prepend_directory (GSList **parent_list, 16 @@ -581,6 +582,7 @@ panel_addto_prepend_directory (GSList 17 const char *filename) 18 { 19 PanelAddtoAppList *data; 20 + gint entries_added = 0; 21 22 data = g_new0 (PanelAddtoAppList, 1); 23 24 @@ -600,9 +602,16 @@ panel_addto_prepend_directory (GSList 25 * So the iid is built when we select the row. 26 */ 27 28 - *parent_list = g_slist_prepend (*parent_list, data); 29 - 30 - panel_addto_make_application_list (&data->children, directory, filename); 31 + entries_added = panel_addto_make_application_list (&data->children, directory, filename); 32 + if (entries_added > 0) { 33 + /*Only prepend if there are entries */ 34 + *parent_list = g_slist_prepend (*parent_list, data); 35 + } 36 + else { 37 + /* Free data as not being appended */ 38 + panel_addto_dialog_free_item_info (&data->item_info); 39 + g_free (data); 40 + } 41 } 42 43 static void 44 @@ -624,12 +633,13 @@ panel_addto_prepend_entry (GSList 45 *parent_list = g_slist_prepend (*parent_list, data); 46 } 47 48 -static void 49 +static gint 50 panel_addto_prepend_alias (GSList **parent_list, 51 GMenuTreeAlias *alias, 52 const char *filename) 53 { 54 GMenuTreeItem *aliased_item; 55 + gint entry = 0; 56 57 aliased_item = gmenu_tree_alias_get_item (alias); 58 59 @@ -641,9 +651,14 @@ panel_addto_prepend_alias (GSList 60 break; 61 62 case GMENU_TREE_ITEM_ENTRY: 63 - panel_addto_prepend_entry (parent_list, 64 - GMENU_TREE_ENTRY (aliased_item), 65 - filename); 66 + 67 + if (panel_lockdown_is_allowed_menu_entry 68 + (GMENU_TREE_ENTRY (aliased_item))) { 69 + panel_addto_prepend_entry (parent_list, 70 + GMENU_TREE_ENTRY (aliased_item), 71 + filename); 72 + entry = 1; 73 + } 74 break; 75 76 default: 77 @@ -651,15 +666,17 @@ panel_addto_prepend_alias (GSList 78 } 79 80 gmenu_tree_item_unref (aliased_item); 81 + return entry; 82 } 83 84 -static void 85 +static gint 86 panel_addto_make_application_list (GSList **parent_list, 87 GMenuTreeDirectory *directory, 88 const char *filename) 89 { 90 GSList *items; 91 GSList *l; 92 + gint number_entries = 0; 93 94 items = gmenu_tree_directory_get_contents (directory); 95 96 @@ -670,11 +687,15 @@ panel_addto_make_application_list (GSLis 97 break; 98 99 case GMENU_TREE_ITEM_ENTRY: 100 - panel_addto_prepend_entry (parent_list, l->data, filename); 101 + if (panel_lockdown_is_allowed_menu_entry (l->data)) { 102 + panel_addto_prepend_entry (parent_list, l->data, filename); 103 + number_entries = number_entries + 1; 104 + } 105 break; 106 107 case GMENU_TREE_ITEM_ALIAS: 108 - panel_addto_prepend_alias (parent_list, l->data, filename); 109 + number_entries = number_entries + 110 + panel_addto_prepend_alias (parent_list, l->data, filename); 111 break; 112 113 default: 114 @@ -687,6 +708,8 @@ panel_addto_make_application_list (GSLis 115 g_slist_free (items); 116 117 *parent_list = g_slist_reverse (*parent_list); 118 + 119 + return number_entries; 120 } 121 122 static void 123 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/panel-lockdown.h gnome-panel-2.27.91/gnome-panel/panel-lockdown.h 124 --- gnome-panel-2.27.91.old/gnome-panel/panel-lockdown.h 2009-08-26 17:27:47.990078000 +0100 125 +++ gnome-panel-2.27.91/gnome-panel/panel-lockdown.h 2009-08-26 17:34:10.921311000 +0100 126 @@ -25,8 +25,11 @@ 127 #ifndef __PANEL_LOCKDOWN_H__ 128 #define __PANEL_LOCKDOWN_H__ 129 130 +#include <libgnome/gnome-desktop-item.h> 131 #include <glib.h> 132 #include <glib-object.h> 133 +#include <gmenu-tree.h> 134 +#include "launcher.h" 135 136 G_BEGIN_DECLS 137 138 @@ -39,13 +42,56 @@ gboolean panel_lockdown_get_disable_lock 139 gboolean panel_lockdown_get_disable_log_out (void); 140 gboolean panel_lockdown_get_disable_force_quit (void); 141 142 +gboolean panel_lockdown_get_restrict_application_launching (void); 143 +GSList *panel_lockdown_get_allowed_applications (void); 144 + 145 gboolean panel_lockdown_is_applet_disabled (const char *iid); 146 +gboolean panel_lockdown_is_allowed_application (const gchar *app); 147 148 void panel_lockdown_notify_add (GCallback callback_func, 149 gpointer user_data); 150 void panel_lockdown_notify_remove (GCallback callback_func, 151 gpointer user_data); 152 153 +gchar *panel_lockdown_get_stripped_exec (const gchar *full_exec); 154 +gchar *panel_lockdown_get_exec_from_ditem (GnomeDesktopItem *ditem); 155 +gboolean panel_lockdown_ditem_in_allowed_applications (GnomeDesktopItem *ditem); 156 +gboolean panel_lockdown_is_disabled_command_line (const gchar *term_cmd); 157 + 158 +/** 159 + * Returns true if the ditem corresponds to an application whose use has been 160 + * disallowed by the administrator (tests whether restrictions are in place 161 + * and if the ditem matches the allowed applications list). 162 + */ 163 +gboolean panel_lockdown_is_forbidden_app (GnomeDesktopItem *ditem); 164 +/** 165 + * Returns true if the ditem corresponds to either an application whose use 166 + * has been disallowed by the administrator (same as previous function) or 167 + * a shell when command line use has been restricted. 168 + */ 169 +gboolean panel_lockdown_is_forbidden_ditem (GnomeDesktopItem *ditem); 170 +/** 171 + * Returns true if the command line corresponds to an application whose use 172 + * has been disallowed by the administrator. 173 + */ 174 +gboolean panel_lockdown_is_forbidden_command (const gchar *command); 175 + 176 +/** 177 + * Returns true if the menu entry corresponds to an application whose use 178 + * has been allowed by the administrator. 179 + */ 180 +gboolean panel_lockdown_is_allowed_menu_entry (GMenuTreeEntry *entry); 181 + 182 +/** 183 + * Returns true if the launcher application has been disallowed by the administrator. 184 + */ 185 +gboolean panel_lockdown_is_forbidden_launcher (Launcher *launcher); 186 + 187 +/** 188 + * Returns true if the key_file application has been disallowed by the administrator. 189 + */ 190 +gboolean panel_lockdown_is_forbidden_key_file (GKeyFile *key_file); 191 + 192 G_END_DECLS 193 194 #endif /* __PANEL_LOCKDOWN_H__ */ 195 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/panel-menu-items.h gnome-panel-2.27.91/gnome-panel/panel-menu-items.h 196 --- gnome-panel-2.27.91.old/gnome-panel/panel-menu-items.h 2009-08-26 17:27:47.989560000 +0100 197 +++ gnome-panel-2.27.91/gnome-panel/panel-menu-items.h 2009-08-26 17:34:22.060144000 +0100 198 @@ -90,6 +90,8 @@ void panel_desktop_menu_item_set_panel ( 199 void panel_menu_items_append_lock_logout (GtkWidget *menu); 200 void panel_menu_item_activate_desktop_file (GtkWidget *menuitem, 201 const char *path); 202 +void panel_place_menu_item_recreate_menu (GtkWidget *widget); 203 +void panel_desktop_menu_item_recreate_menu (PanelDesktopMenuItem *desktop_item); 204 205 G_END_DECLS 206 207 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/Makefile.am gnome-panel-2.27.91/gnome-panel/Makefile.am 208 --- gnome-panel-2.27.91.old/gnome-panel/Makefile.am 2009-08-26 17:27:47.958497000 +0100 209 +++ gnome-panel-2.27.91/gnome-panel/Makefile.am 2009-08-26 17:34:33.698263000 +0100 210 @@ -165,6 +165,8 @@ gnome_desktop_item_edit_SOURCES = \ 211 panel-ditem-editor.c \ 212 panel-marshal.c \ 213 panel-util.c \ 214 + panel-lockdown.c \ 215 + panel-gconf.c \ 216 xstuff.c 217 218 gnome_desktop_item_edit_LDFLAGS = -export-dynamic 219 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/panel-action-button.c gnome-panel-2.27.91/gnome-panel/panel-action-button.c 220 --- gnome-panel-2.27.91.old/gnome-panel/panel-action-button.c 2009-08-26 17:27:47.940413000 +0100 221 +++ gnome-panel-2.27.91/gnome-panel/panel-action-button.c 2009-08-26 17:40:26.368224000 +0100 222 @@ -207,8 +207,11 @@ panel_action_shutdown_reboot_is_disabled 223 static void 224 panel_action_run_program (GtkWidget *widget) 225 { 226 - panel_run_dialog_present (gtk_widget_get_screen (widget), 227 - gtk_get_current_event_time ()); 228 + if (!panel_lockdown_get_restrict_application_launching () && 229 + !panel_lockdown_get_disable_command_line ()) { 230 + panel_run_dialog_present (gtk_widget_get_screen (widget), 231 + gtk_get_current_event_time ()); 232 + } 233 } 234 235 /* Search For Files 236 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/panel-menu-bar.c gnome-panel-2.27.91/gnome-panel/panel-menu-bar.c 237 --- gnome-panel-2.27.91.old/gnome-panel/panel-menu-bar.c 2009-08-26 17:27:47.961196000 +0100 238 +++ gnome-panel-2.27.91/gnome-panel/panel-menu-bar.c 2009-08-26 17:35:05.241962000 +0100 239 @@ -69,6 +69,8 @@ enum { 240 PROP_ORIENTATION, 241 }; 242 243 +static GObjectClass *parent_class = NULL; 244 + 245 static void panel_menu_bar_update_text_gravity (PanelMenuBar *menubar); 246 247 static gboolean 248 @@ -132,6 +132,32 @@ panel_menu_bar_setup_tooltip (PanelMenuB 249 } 250 251 static void 252 +panel_menu_bar_parent_set (GtkWidget *widget, 253 + GtkWidget *previous_parent); 254 + 255 +static void 256 +panel_menubar_recreate_menus (PanelMenuBar *menubar) 257 +{ 258 + if (menubar->priv->applications_menu != NULL) { 259 + while (GTK_MENU_SHELL (menubar->priv->applications_menu)->children) { 260 + gtk_widget_destroy ( 261 + GTK_MENU_SHELL (menubar->priv->applications_menu)->children->data); 262 + } 263 + menubar->priv->applications_menu = 264 + create_applications_menu ("applications.menu", NULL, TRUE); 265 + gtk_menu_item_set_submenu 266 + (GTK_MENU_ITEM (menubar->priv->applications_item), 267 + menubar->priv->applications_menu); 268 + 269 + panel_place_menu_item_recreate_menu(menubar->priv->places_item); 270 + panel_desktop_menu_item_recreate_menu( 271 + (PanelDesktopMenuItem *)menubar->priv->desktop_item); 272 + 273 + panel_menu_bar_parent_set ((GtkWidget *)menubar, NULL); 274 + } 275 +} 276 + 277 +static void 278 panel_menu_bar_init (PanelMenuBar *menubar) 279 { 280 GtkWidget *image; 281 @@ -164,6 +190,8 @@ panel_menu_bar_init (PanelMenuBar *menub 282 menubar->priv->desktop_item); 283 284 panel_menu_bar_setup_tooltip (menubar); 285 + panel_lockdown_notify_add (G_CALLBACK (panel_menubar_recreate_menus), 286 + menubar); 287 288 panel_menu_bar_update_text_gravity (menubar); 289 g_signal_connect (menubar, "screen-changed", 290 @@ -172,6 +236,15 @@ panel_menu_bar_init (PanelMenuBar *menub 291 } 292 293 static void 294 +panel_menu_bar_finalize (GObject *object) 295 +{ 296 + panel_lockdown_notify_remove (G_CALLBACK (panel_menubar_recreate_menus), 297 + object); 298 + 299 + parent_class->finalize (object); 300 +} 301 + 302 +static void 303 panel_menu_bar_get_property (GObject *object, 304 guint prop_id, 305 GValue *value, 306 @@ -274,10 +347,13 @@ panel_menu_bar_class_init (PanelMenuBarC 307 308 gobject_class->get_property = panel_menu_bar_get_property; 309 gobject_class->set_property = panel_menu_bar_set_property; 310 + gobject_class->finalize = panel_menu_bar_finalize; 311 312 widget_class->parent_set = panel_menu_bar_parent_set; 313 widget_class->size_allocate = panel_menu_bar_size_allocate; 314 315 + parent_class = g_type_class_peek_parent (klass); 316 + 317 g_type_class_add_private (klass, sizeof (PanelMenuBarPrivate)); 318 319 g_object_class_install_property ( 320 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/gnome-desktop-item-edit.c gnome-panel-2.27.91/gnome-panel/gnome-desktop-item-edit.c 321 --- gnome-panel-2.27.91.old/gnome-panel/gnome-desktop-item-edit.c 2009-08-26 17:27:48.019780000 +0100 322 +++ gnome-panel-2.27.91/gnome-panel/gnome-desktop-item-edit.c 2009-08-26 17:41:37.134321000 +0100 323 @@ -21,7 +21,6 @@ GConfClient *panel_gconf_get_client (voi 324 #include "panel-config-global.h" 325 gboolean panel_global_config_get_tooltips_enabled (void) { return FALSE; } 326 #include "panel-lockdown.h" 327 -gboolean panel_lockdown_get_disable_lock_screen (void) { return FALSE; } 328 329 static int dialogs = 0; 330 static gboolean create_new = FALSE; 331 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/panel-lockdown.c gnome-panel-2.27.91/gnome-panel/panel-lockdown.c 332 --- gnome-panel-2.27.91.old/gnome-panel/panel-lockdown.c 2009-08-26 17:27:47.989262000 +0100 333 +++ gnome-panel-2.27.91/gnome-panel/panel-lockdown.c 2009-08-26 17:50:44.869236000 +0100 334 @@ -28,13 +28,16 @@ 335 336 #include <string.h> 337 #include "panel-gconf.h" 338 +#include <libpanel-util/panel-keyfile.h> 339 340 -#define N_LISTENERS 6 341 +#define N_LISTENERS 8 342 343 #define PANEL_GLOBAL_LOCKDOWN_DIR "/apps/panel/global" 344 #define DESKTOP_GNOME_LOCKDOWN_DIR "/desktop/gnome/lockdown" 345 #define PANEL_GLOBAL_LOCKED_DOWN_KEY PANEL_GLOBAL_LOCKDOWN_DIR "/locked_down" 346 #define DISABLE_COMMAND_LINE_KEY DESKTOP_GNOME_LOCKDOWN_DIR "/disable_command_line" 347 +#define RESTRICT_APPLICATION_LAUNCHING_KEY DESKTOP_GNOME_LOCKDOWN_DIR "/restrict_application_launching" 348 +#define ALLOWED_APPLICATIONS_KEY DESKTOP_GNOME_LOCKDOWN_DIR "/allowed_applications" 349 #define DISABLE_LOCK_SCREEN_KEY DESKTOP_GNOME_LOCKDOWN_DIR "/disable_lock_screen" 350 #define DISABLE_LOG_OUT_KEY PANEL_GLOBAL_LOCKDOWN_DIR "/disable_log_out" 351 #define DISABLE_FORCE_QUIT_KEY PANEL_GLOBAL_LOCKDOWN_DIR "/disable_force_quit" 352 @@ -48,6 +51,9 @@ typedef struct { 353 guint disable_lock_screen : 1; 354 guint disable_log_out : 1; 355 guint disable_force_quit : 1; 356 + guint restrict_application_launching : 1; 357 + 358 + GSList *allowed_applications; 359 360 GSList *disabled_applets; 361 362 @@ -56,6 +62,12 @@ typedef struct { 363 GSList *closures; 364 } PanelLockdown; 365 366 +static const gchar *command_line_execs[] = { 367 + "/usr/bin/gnome-terminal", 368 + "/usr/bin/xterm" 369 +}; 370 +#define NUMBER_COMMAND_LINE_EXECS 2 371 + 372 static PanelLockdown panel_lockdown = { 0, }; 373 374 375 @@ -63,9 +75,17 @@ static inline void 376 panel_lockdown_invoke_closures (PanelLockdown *lockdown) 377 { 378 GSList *l; 379 + GSList *copy = NULL; 380 381 - for (l = lockdown->closures; l; l = l->next) 382 + copy = g_slist_copy (lockdown->closures); 383 + for (l = copy; l != NULL; l = l->next) { 384 + if (g_slist_find (lockdown->closures, l->data)) { 385 + g_closure_ref (l->data); 386 g_closure_invoke (l->data, NULL, 0, NULL, NULL); 387 + g_closure_unref (l->data); 388 + } 389 + } 390 + g_slist_free (copy); 391 } 392 393 static void 394 @@ -166,6 +186,50 @@ disabled_applets_notify (GConfClient * 395 panel_lockdown_invoke_closures (lockdown); 396 } 397 398 +static void 399 +restrict_application_launching_notify (GConfClient *client, 400 + guint cnxn_id, 401 + GConfEntry *entry, 402 + PanelLockdown *lockdown) 403 +{ 404 + if (!entry->value || entry->value->type != GCONF_VALUE_BOOL) 405 + return; 406 + 407 + lockdown->restrict_application_launching = 408 + gconf_value_get_bool (entry->value); 409 + 410 + panel_lockdown_invoke_closures (lockdown); 411 +} 412 + 413 + 414 +static void 415 +allowed_applications_notify (GConfClient *client, 416 + guint cnxn_id, 417 + GConfEntry *entry, 418 + PanelLockdown *lockdown) 419 +{ 420 + GSList *l; 421 + 422 + if (!entry->value || entry->value->type != GCONF_VALUE_LIST || 423 + gconf_value_get_list_type (entry->value) != GCONF_VALUE_STRING) 424 + return; 425 + 426 + for (l = lockdown->allowed_applications; l; l = l->next) 427 + g_free (l->data); 428 + g_slist_free (lockdown->allowed_applications); 429 + lockdown->allowed_applications = NULL; 430 + 431 + for (l = gconf_value_get_list (entry->value); l; l = l->next) { 432 + const char *iid = gconf_value_get_string (l->data); 433 + 434 + lockdown->allowed_applications = 435 + g_slist_prepend (lockdown->allowed_applications, 436 + g_strdup (iid)); 437 + } 438 + 439 + panel_lockdown_invoke_closures (lockdown); 440 +} 441 + 442 static gboolean 443 panel_lockdown_load_bool (PanelLockdown *lockdown, 444 GConfClient *client, 445 @@ -215,6 +279,28 @@ panel_lockdown_load_disabled_applets (Pa 446 return retval; 447 } 448 449 +static GSList * 450 +panel_lockdown_load_allowed_applications (PanelLockdown *lockdown, 451 + GConfClient *client, 452 + int listener) 453 +{ 454 + GSList *retval; 455 + 456 + retval = gconf_client_get_list (client, 457 + ALLOWED_APPLICATIONS_KEY, 458 + GCONF_VALUE_STRING, 459 + NULL); 460 + 461 + lockdown->listeners [listener] = 462 + gconf_client_notify_add (client, 463 + ALLOWED_APPLICATIONS_KEY, 464 + (GConfClientNotifyFunc) allowed_applications_notify, 465 + lockdown, 466 + NULL, NULL); 467 + 468 + return retval; 469 +} 470 + 471 void 472 panel_lockdown_init (void) 473 { 474 @@ -273,6 +359,18 @@ panel_lockdown_init (void) 475 client, 476 i++); 477 478 + panel_lockdown.restrict_application_launching = 479 + panel_lockdown_load_bool (&panel_lockdown, 480 + client, 481 + RESTRICT_APPLICATION_LAUNCHING_KEY, 482 + (GConfClientNotifyFunc) restrict_application_launching_notify, 483 + i++); 484 + 485 + panel_lockdown.allowed_applications = 486 + panel_lockdown_load_allowed_applications (&panel_lockdown, 487 + client, 488 + i++); 489 + 490 g_assert (i == N_LISTENERS); 491 492 panel_lockdown.initialized = TRUE; 493 @@ -294,6 +392,13 @@ panel_lockdown_finalize (void) 494 g_slist_free (panel_lockdown.disabled_applets); 495 panel_lockdown.disabled_applets = NULL; 496 497 + for (l = panel_lockdown.allowed_applications; l; l = l->next) { 498 + g_free (l->data); 499 + } 500 + 501 + g_slist_free (panel_lockdown.allowed_applications); 502 + panel_lockdown.allowed_applications = NULL; 503 + 504 for (i = 0; i < N_LISTENERS; i++) { 505 if (panel_lockdown.listeners [i]) 506 gconf_client_notify_remove (client, 507 @@ -371,6 +476,36 @@ panel_lockdown_is_applet_disabled (const 508 return FALSE; 509 } 510 511 +gboolean 512 +panel_lockdown_get_restrict_application_launching (void) 513 +{ 514 + g_assert (panel_lockdown.initialized != FALSE); 515 + 516 + return panel_lockdown.restrict_application_launching; 517 +} 518 + 519 +GSList * 520 +panel_lockdown_get_allowed_applications (void) 521 +{ 522 + g_assert (panel_lockdown.initialized == TRUE); 523 + 524 + return panel_lockdown.allowed_applications; 525 +} 526 + 527 +gboolean 528 +panel_lockdown_is_allowed_application (const gchar *app) 529 +{ 530 + GSList *l; 531 + 532 + g_assert (panel_lockdown.initialized != FALSE); 533 + 534 + for (l = panel_lockdown.allowed_applications; l; l = l->next) 535 + if (!strcmp (l->data, app)) 536 + return TRUE; 537 + 538 + return FALSE; 539 +} 540 + 541 static GClosure * 542 panel_lockdown_notify_find (GSList *closures, 543 GCallback callback_func, 544 @@ -440,3 +575,161 @@ panel_lockdown_notify_remove (GCallback 545 546 g_closure_unref (closure); 547 } 548 + 549 +gchar * 550 +panel_lockdown_get_stripped_exec (const gchar *full_exec) 551 +{ 552 + gchar *str1, *str2, *retval, *p; 553 + 554 + str1 = g_strdup (full_exec); 555 + p = strtok (str1, " "); 556 + 557 + if (p != NULL) 558 + str2 = g_strdup (p); 559 + else 560 + str2 = g_strdup (full_exec); 561 + 562 + g_free (str1); 563 + 564 + if (g_path_is_absolute (str2)) 565 + retval = g_strdup (str2); 566 + else 567 + retval = g_strdup (g_find_program_in_path ((const gchar *)str2)); 568 + g_free (str2); 569 + 570 + return retval; 571 +} 572 + 573 +gchar * 574 +panel_lockdown_get_exec_from_ditem (GnomeDesktopItem *ditem) 575 +{ 576 + const char *full_exec; 577 + gchar *retval = NULL; 578 + 579 + full_exec = gnome_desktop_item_get_string (ditem, 580 + GNOME_DESKTOP_ITEM_EXEC); 581 + 582 + if (full_exec != NULL) 583 + retval = panel_lockdown_get_stripped_exec (full_exec); 584 + 585 + return retval; 586 +} 587 + 588 +gboolean 589 +panel_lockdown_ditem_in_allowed_applications (GnomeDesktopItem *ditem) 590 +{ 591 + gboolean retval = FALSE; 592 + gchar *stripped_exec; 593 + 594 + stripped_exec = panel_lockdown_get_exec_from_ditem (ditem); 595 + 596 + if (stripped_exec != NULL) { 597 + retval = panel_lockdown_is_allowed_application (stripped_exec); 598 + g_free (stripped_exec); 599 + } 600 + 601 + return retval; 602 +} 603 + 604 +gboolean 605 +panel_lockdown_is_disabled_command_line (const gchar *term_cmd) 606 +{ 607 + int i = 0; 608 + gboolean retval = FALSE; 609 + 610 + for (i=0; i<NUMBER_COMMAND_LINE_EXECS; i++) { 611 + if (!strcmp (command_line_execs [i], term_cmd)) { 612 + retval = TRUE; 613 + break; 614 + } 615 + } 616 + 617 + return retval; 618 +} 619 + 620 +gboolean 621 +panel_lockdown_is_forbidden_app(GnomeDesktopItem *ditem) { 622 + g_return_val_if_fail (ditem != NULL, TRUE) ; 623 + return panel_lockdown_get_restrict_application_launching () && 624 + !panel_lockdown_ditem_in_allowed_applications (ditem) ; 625 +} 626 + 627 +gboolean 628 +panel_lockdown_is_forbidden_ditem(GnomeDesktopItem *ditem) 629 +{ 630 + g_return_val_if_fail (ditem != NULL, TRUE) ; 631 + if (panel_lockdown_is_forbidden_app (ditem)) { return TRUE ; } 632 + if (panel_lockdown_get_disable_command_line ()) { 633 + char *stripped = panel_lockdown_get_exec_from_ditem (ditem) ; 634 + 635 + if (stripped != NULL) { 636 + gboolean retCode = 637 + panel_lockdown_is_disabled_command_line (stripped) ; 638 + 639 + g_free (stripped) ; 640 + return retCode ; 641 + } 642 + } 643 + return FALSE ; 644 +} 645 + 646 +gboolean 647 +panel_lockdown_is_forbidden_command (const char *command) 648 +{ 649 + g_return_val_if_fail (command != NULL, TRUE) ; 650 + return panel_lockdown_get_restrict_application_launching () && 651 + !panel_lockdown_is_allowed_application (command) ; 652 +} 653 + 654 +gboolean 655 +panel_lockdown_is_allowed_menu_entry (GMenuTreeEntry *entry) 656 +{ 657 + const char *path; 658 + GnomeDesktopItem *item = NULL ; 659 + 660 + if (!panel_lockdown_get_restrict_application_launching ()) 661 + return TRUE; 662 + 663 + path = gmenu_tree_entry_get_desktop_file_path (entry) ; 664 + 665 + if (path != NULL) { 666 + item = gnome_desktop_item_new_from_file (path, 0, NULL) ; 667 + if (item != NULL) { 668 + gboolean retCode = !panel_lockdown_is_forbidden_ditem (item) ; 669 + 670 + gnome_desktop_item_unref (item) ; 671 + return retCode ; 672 + } 673 + } 674 + return TRUE ; 675 +} 676 + 677 +gboolean 678 +panel_lockdown_is_forbidden_launcher (Launcher *launcher) 679 +{ 680 + return (panel_lockdown_is_forbidden_key_file(launcher->key_file)); 681 +} 682 + 683 +gboolean 684 +panel_lockdown_is_forbidden_key_file (GKeyFile *key_file) 685 +{ 686 + gchar *full_exec; /* Executable including possible arguments */ 687 + gchar *stripped_exec; /* Executable with arguments stripped away */ 688 + gboolean retval = FALSE; 689 + 690 + /* If restrict_application_launching not set on return TRUE */ 691 + if (!panel_lockdown_get_restrict_application_launching ()) { 692 + return retval; 693 + } 694 + 695 + if (key_file != NULL) 696 + { 697 + full_exec = panel_key_file_get_string (key_file, "Exec"); 698 + if (full_exec != NULL) { 699 + stripped_exec = panel_lockdown_get_stripped_exec (full_exec); 700 + retval = panel_lockdown_is_forbidden_command (stripped_exec); 701 + g_free (stripped_exec); 702 + } 703 + } 704 + return retval; 705 +} 706 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/panel-menu-items.c gnome-panel-2.27.91/gnome-panel/panel-menu-items.c 707 --- gnome-panel-2.27.91.old/gnome-panel/panel-menu-items.c 2009-08-26 17:27:47.973492000 +0100 708 +++ gnome-panel-2.27.91/gnome-panel/panel-menu-items.c 2009-08-26 17:36:15.979872000 +0100 709 @@ -157,6 +157,21 @@ panel_menu_items_append_from_desktop (Gt 710 char *icon; 711 char *name; 712 char *comment; 713 + GnomeDesktopItem *ditem; 714 + 715 + /* If restricted application, then don't append */ 716 + if (g_path_is_absolute (path)) 717 + ditem = gnome_desktop_item_new_from_file (path, 0, NULL); 718 + else 719 + ditem = gnome_desktop_item_new_from_basename (path, 0, NULL); 720 + if (ditem != NULL && panel_lockdown_is_forbidden_ditem (ditem)) { 721 + gnome_desktop_item_unref (ditem); 722 + return; 723 + } 724 + 725 + if (ditem != NULL) { 726 + gnome_desktop_item_unref (ditem); 727 + } 728 729 path_freeme = NULL; 730 731 @@ -1073,7 +1088,7 @@ panel_place_menu_item_create_menu (Panel 732 return places_menu; 733 } 734 735 -static void 736 +void 737 panel_place_menu_item_recreate_menu (GtkWidget *widget) 738 { 739 PanelPlaceMenuItem *place_item; 740 @@ -1181,7 +1196,7 @@ panel_desktop_menu_item_create_menu (Pan 741 return desktop_menu; 742 } 743 744 -static void 745 +void 746 panel_desktop_menu_item_recreate_menu (PanelDesktopMenuItem *desktop_item) 747 { 748 if (desktop_item->priv->menu) { 749 @@ -1548,8 +1563,11 @@ panel_menu_items_append_lock_logout (Gtk 750 tooltip = NULL; 751 } 752 753 - item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT, 754 - label, tooltip); 755 + if (!panel_lockdown_get_disable_log_out ()) { 756 + item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT, 757 + label, tooltip); 758 + } 759 + 760 g_free (label); 761 g_free (tooltip); 762 763 @@ -1575,5 +1593,21 @@ void 764 panel_menu_item_activate_desktop_file (GtkWidget *menuitem, 765 const char *path) 766 { 767 + GnomeDesktopItem *ditem; 768 + 769 + if (g_path_is_absolute (path)) 770 + ditem = gnome_desktop_item_new_from_file (path, 0, NULL); 771 + else 772 + ditem = gnome_desktop_item_new_from_basename (path, 0, NULL); 773 + 774 + if (ditem != NULL && panel_lockdown_is_forbidden_ditem (ditem)) { 775 + gnome_desktop_item_unref (ditem); 776 + return; /* Don't launch as it's a forbidden desktop file */ 777 + } 778 + 779 + if (ditem != NULL) { 780 + gnome_desktop_item_unref (ditem); 781 + } 782 + 783 panel_launch_desktop_file (path, menuitem_to_screen (menuitem), NULL); 784 } 785 /jds/bin/diff -uprN gnome-panel-2.27.91.old/gnome-panel/launcher.c gnome-panel-2.27.91/gnome-panel/launcher.c 786 --- gnome-panel-2.27.91.old/gnome-panel/launcher.c 2009-08-26 17:27:47.942300000 +0100 787 +++ gnome-panel-2.27.91/gnome-panel/launcher.c 2009-08-26 17:56:11.860620000 +0100 788 @@ -105,6 +105,9 @@ launch_url (Launcher *launcher) 789 g_return_if_fail (launcher != NULL); 790 g_return_if_fail (launcher->key_file != NULL); 791 792 + if (panel_lockdown_is_forbidden_launcher (launcher)) 793 + return; 794 + 795 /* FIXME panel_ditem_launch() should be enough for this! */ 796 url = panel_key_file_get_string (launcher->key_file, "URL"); 797 798 @@ -136,6 +139,9 @@ launcher_launch (Launcher *launcher, 799 g_return_if_fail (launcher != NULL); 800 g_return_if_fail (launcher->key_file != NULL); 801 802 + if (panel_lockdown_is_forbidden_launcher (launcher)) 803 + return; 804 + 805 if (panel_global_config_get_enable_animations ()) 806 xstuff_zoom_animate (widget, 807 button_widget_get_pixbuf (BUTTON_WIDGET (widget)), 808 @@ -253,6 +259,8 @@ launcher_properties_destroy (Launcher *l 809 gtk_widget_destroy (dialog); 810 } 811 812 +static void panel_recheck_launcher (Launcher *launcher); 813 + 814 static void 815 free_launcher (gpointer data) 816 { 817 @@ -266,6 +274,8 @@ free_launcher (gpointer data) 818 g_free (launcher->location); 819 launcher->location = NULL; 820 821 + panel_lockdown_notify_remove (G_CALLBACK (panel_recheck_launcher), launcher); 822 + 823 g_free (launcher); 824 } 825 826 @@ -410,6 +416,19 @@ drag_data_get_cb (GtkWidget *widg 827 828 } 829 830 +static void 831 +panel_recheck_launcher (Launcher *launcher) 832 +{ 833 + if (!launcher || !launcher->button) 834 + return; 835 + 836 + if (panel_lockdown_is_forbidden_launcher (launcher)) { 837 + gtk_widget_hide (launcher->button); 838 + } else { 839 + gtk_widget_show (launcher->button); 840 + } 841 +} 842 + 843 static Launcher * 844 create_launcher (const char *location) 845 { 846 @@ -488,7 +507,11 @@ create_launcher (const char *location) 847 FALSE, 848 PANEL_ORIENTATION_TOP); 849 850 - gtk_widget_show (launcher->button); 851 + if (panel_lockdown_is_forbidden_launcher (launcher)) { 852 + gtk_widget_hide (launcher->button); 853 + } else { 854 + gtk_widget_show (launcher->button); 855 + } 856 857 /*gtk_drag_dest_set (GTK_WIDGET (launcher->button), 858 GTK_DEST_DEFAULT_ALL, 859 @@ -515,6 +538,8 @@ create_launcher (const char *location) 860 G_CALLBACK (destroy_launcher), 861 launcher); 862 863 + panel_lockdown_notify_add (G_CALLBACK (panel_recheck_launcher), launcher); 864 + 865 return launcher; 866 } 867 868 @@ -813,6 +838,12 @@ load_launcher_applet (const char * 869 /* setup button according to ditem */ 870 setup_button (launcher); 871 872 + if (panel_lockdown_is_forbidden_launcher (launcher)) { 873 + gtk_widget_hide (launcher->button); 874 + } else { 875 + gtk_widget_show (launcher->button); 876 + } 877 + 878 return launcher; 879 } 880 881 @@ -901,6 +932,10 @@ ask_about_launcher (const char *file, 882 if (file != NULL) 883 panel_key_file_set_string (key_file, "Exec", file); 884 panel_key_file_set_string (key_file, "Type", "Application"); 885 + 886 + if (panel_lockdown_is_forbidden_key_file (key_file)) 887 + return; /* Application being dragged is forbidden so just return */ 888 + 889 panel_ditem_editor_sync_display (PANEL_DITEM_EDITOR (dialog)); 890 891 panel_ditem_register_save_uri_func (PANEL_DITEM_EDITOR (dialog), 892 --- gnome-panel-2.27.92/gnome-panel/menu.c.ori 2009-09-09 10:13:23.778451017 +0100 893 +++ gnome-panel-2.27.92/gnome-panel/menu.c 2009-09-09 10:21:41.371983238 +0100 894 @@ -74,7 +74,8 @@ 895 static GSList *image_menu_items = NULL; 896 897 static GtkWidget *populate_menu_from_directory (GtkWidget *menu, 898 - GMenuTreeDirectory *directory); 899 + GMenuTreeDirectory *directory, 900 + gboolean *is_hidden); 901 902 static void panel_load_menu_image_deferred (GtkWidget *image_menu_item, 903 GtkIconSize icon_size, 904 @@ -1272,7 +1273,8 @@ 905 } 906 907 static void 908 -submenu_to_display (GtkWidget *menu) 909 +submenu_to_display (GtkWidget *menu, 910 + gboolean *is_hidden) 911 { 912 GMenuTree *tree; 913 GMenuTreeDirectory *directory; 914 @@ -1307,7 +1309,15 @@ 915 } 916 917 if (directory) 918 - populate_menu_from_directory (menu, directory); 919 + { /* It's possible that is_hidden is NULL if we end up here from the show 920 + signal, which could only happen for the top level menu. */ 921 + gboolean local_is_hidden = FALSE; 922 + 923 + populate_menu_from_directory (menu, directory, &local_is_hidden); 924 + if (is_hidden != NULL) { 925 + *is_hidden = local_is_hidden; 926 + } 927 + } 928 929 append_callback = g_object_get_data (G_OBJECT (menu), 930 "panel-menu-append-callback"); 931 @@ -1321,10 +1331,11 @@ 932 submenu_to_display_in_idle (gpointer data) 933 { 934 GtkWidget *menu = GTK_WIDGET (data); 935 + gboolean is_hidden = FALSE; 936 937 g_object_set_data (G_OBJECT (menu), "panel-menu-idle-id", NULL); 938 939 - submenu_to_display (menu); 940 + submenu_to_display (menu, &is_hidden); 941 942 return FALSE; 943 } 944 @@ -1419,19 +1430,25 @@ 945 static void 946 create_submenu (GtkWidget *menu, 947 GMenuTreeDirectory *directory, 948 - GMenuTreeDirectory *alias_directory) 949 + GMenuTreeDirectory *alias_directory, 950 + gboolean *is_hidden) 951 { 952 GtkWidget *menuitem; 953 GtkWidget *submenu; 954 gboolean force_categories_icon; 955 956 + submenu = create_fake_menu (directory); 957 + if (panel_lockdown_get_restrict_application_launching ()) { 958 + submenu_to_display (submenu, is_hidden); 959 + } else { 960 + *is_hidden = FALSE; 961 + } 962 + 963 if (alias_directory) 964 menuitem = create_submenu_entry (menu, alias_directory); 965 else 966 menuitem = create_submenu_entry (menu, directory); 967 968 - submenu = create_fake_menu (directory); 969 - 970 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu); 971 972 /* Keep the infor that we force (or not) the icons to be visible */ 973 @@ -1440,15 +1457,21 @@ 974 g_object_set_data (G_OBJECT (submenu), 975 "panel-menu-force-icon-for-categories", 976 GINT_TO_POINTER (force_categories_icon)); 977 + 978 + if (*is_hidden) { 979 + gtk_widget_hide (menuitem); 980 + } 981 } 982 983 static void 984 create_header (GtkWidget *menu, 985 - GMenuTreeHeader *header) 986 + GMenuTreeHeader *header, 987 + gboolean *is_hidden) 988 { 989 GMenuTreeDirectory *directory; 990 GtkWidget *menuitem; 991 992 + *is_hidden = FALSE; 993 directory = gmenu_tree_header_get_directory (header); 994 menuitem = create_submenu_entry (menu, directory); 995 gmenu_tree_item_unref (directory); 996 @@ -1465,10 +1488,12 @@ 997 static void 998 create_menuitem (GtkWidget *menu, 999 GMenuTreeEntry *entry, 1000 - GMenuTreeDirectory *alias_directory) 1001 + GMenuTreeDirectory *alias_directory, 1002 + gboolean *is_hidden) 1003 { 1004 GtkWidget *menuitem; 1005 1006 + *is_hidden = FALSE; 1007 menuitem = panel_image_menu_item_new (); 1008 1009 g_object_set_data_full (G_OBJECT (menuitem), 1010 @@ -1545,12 +1570,18 @@ 1011 g_signal_connect (menuitem, "activate", 1012 G_CALLBACK (activate_app_def), entry); 1013 1014 - gtk_widget_show (menuitem); 1015 + if (entry != NULL && !panel_lockdown_is_allowed_menu_entry (entry)) { 1016 + gtk_widget_hide (menuitem); 1017 + *is_hidden = TRUE; 1018 + } else { 1019 + gtk_widget_show (menuitem); 1020 + } 1021 } 1022 1023 static void 1024 create_menuitem_from_alias (GtkWidget *menu, 1025 - GMenuTreeAlias *alias) 1026 + GMenuTreeAlias *alias, 1027 + gboolean *is_hidden) 1028 { 1029 GMenuTreeItem *aliased_item; 1030 1031 @@ -1560,13 +1591,15 @@ 1032 case GMENU_TREE_ITEM_DIRECTORY: 1033 create_submenu (menu, 1034 GMENU_TREE_DIRECTORY (aliased_item), 1035 - gmenu_tree_alias_get_directory (alias)); 1036 + gmenu_tree_alias_get_directory (alias), 1037 + is_hidden); 1038 break; 1039 1040 case GMENU_TREE_ITEM_ENTRY: 1041 create_menuitem (menu, 1042 GMENU_TREE_ENTRY (aliased_item), 1043 - gmenu_tree_alias_get_directory (alias)); 1044 + gmenu_tree_alias_get_directory (alias), 1045 + is_hidden); 1046 break; 1047 1048 default: 1049 @@ -1673,18 +1706,21 @@ 1050 1051 static GtkWidget * 1052 populate_menu_from_directory (GtkWidget *menu, 1053 - GMenuTreeDirectory *directory) 1054 + GMenuTreeDirectory *directory, 1055 + gboolean *is_hidden) 1056 { 1057 GSList *l; 1058 GSList *items; 1059 gboolean add_separator; 1060 1061 + *is_hidden = TRUE; 1062 add_separator = (GTK_MENU_SHELL (menu)->children != NULL); 1063 1064 items = gmenu_tree_directory_get_contents (directory); 1065 1066 for (l = items; l; l = l->next) { 1067 GMenuTreeItem *item = l->data; 1068 + gboolean is_item_hidden = TRUE; 1069 1070 if (add_separator || 1071 gmenu_tree_item_get_type (item) == GMENU_TREE_ITEM_SEPARATOR) { 1072 @@ -1694,11 +1730,13 @@ 1073 1074 switch (gmenu_tree_item_get_type (item)) { 1075 case GMENU_TREE_ITEM_DIRECTORY: 1076 - create_submenu (menu, GMENU_TREE_DIRECTORY (item), NULL); 1077 + create_submenu (menu, GMENU_TREE_DIRECTORY (item), NULL, 1078 + &is_item_hidden); 1079 break; 1080 1081 case GMENU_TREE_ITEM_ENTRY: 1082 - create_menuitem (menu, GMENU_TREE_ENTRY (item), NULL); 1083 + create_menuitem (menu, GMENU_TREE_ENTRY (item), NULL, 1084 + &is_item_hidden); 1085 break; 1086 1087 case GMENU_TREE_ITEM_SEPARATOR : 1088 @@ -1706,11 +1744,13 @@ 1089 break; 1090 1091 case GMENU_TREE_ITEM_ALIAS: 1092 - create_menuitem_from_alias (menu, GMENU_TREE_ALIAS (item)); 1093 + create_menuitem_from_alias (menu, GMENU_TREE_ALIAS (item), 1094 + &is_item_hidden); 1095 break; 1096 1097 case GMENU_TREE_ITEM_HEADER: 1098 - create_header (menu, GMENU_TREE_HEADER (item)); 1099 + create_header (menu, GMENU_TREE_HEADER (item), 1100 + &is_item_hidden); 1101 break; 1102 1103 default: 1104 @@ -1718,6 +1758,10 @@ 1105 } 1106 1107 gmenu_tree_item_unref (item); 1108 + 1109 + if (!is_item_hidden) { 1110 + *is_hidden = FALSE; 1111 + } 1112 } 1113 1114 g_slist_free (items); 1115 diff -ruN gnome-panel-2.29.5.1.orig/gnome-panel/gnome-desktop-item-edit.c gnome-panel-2.29.5.1/gnome-panel/gnome-desktop-item-edit.c 1116 --- gnome-panel-2.29.5.1.orig/gnome-panel/gnome-desktop-item-edit.c 2010-01-18 09:05:11.250044366 +0000 1117 +++ gnome-panel-2.29.5.1/gnome-panel/gnome-desktop-item-edit.c 2010-01-18 09:06:41.525403508 +0000 1118 @@ -103,6 +103,8 @@ 1119 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); 1120 textdomain (GETTEXT_PACKAGE); 1121 1122 + panel_lockdown_init (); 1123 + 1124 if (!gtk_init_with_args (&argc, &argv, 1125 _("- Edit .desktop files"), 1126 options, 1127 @@ -220,5 +222,7 @@ 1128 if (dialogs > 0) 1129 gtk_main (); 1130 1131 + panel_lockdown_finalize (); 1132 + 1133 return 0; 1134 } 1135 diff -ruN gnome-panel-2.29.5.1.rig/gnome-panel/launcher.c gnome-panel-2.29.5.1/gnome-panel/launcher.c 1136 --- gnome-panel-2.29.5.1.rig/gnome-panel/launcher.c 2010-01-18 09:08:38.405535199 +0000 1137 +++ gnome-panel-2.29.5.1/gnome-panel/launcher.c 2010-01-18 09:09:52.117045808 +0000 1138 @@ -996,17 +996,18 @@ 1139 location = panel_make_unique_desktop_uri (NULL, exec_or_uri); 1140 1141 error = NULL; 1142 - if (panel_key_file_to_file (key_file, location, &error)) { 1143 - panel_launcher_create (toplevel, position, location); 1144 - } else { 1145 - panel_error_dialog (GTK_WINDOW (toplevel), 1146 - gtk_window_get_screen (GTK_WINDOW (toplevel)), 1147 - "cannot_save_launcher", TRUE, 1148 - _("Could not save launcher"), 1149 - error->message); 1150 - g_error_free (error); 1151 - } 1152 - 1153 + if (!panel_lockdown_is_forbidden_key_file (key_file)) { 1154 + if (panel_key_file_to_file (key_file, location, &error)) { 1155 + panel_launcher_create (toplevel, position, location); 1156 + } else { 1157 + panel_error_dialog (GTK_WINDOW (toplevel), 1158 + gtk_window_get_screen (GTK_WINDOW (toplevel)), 1159 + "cannot_save_launcher", TRUE, 1160 + _("Could not save launcher"), 1161 + error->message); 1162 + g_error_free (error); 1163 + } 1164 + } 1165 g_key_file_free (key_file); 1166 } 1167 1168