diff options
author | Alexander Larsson <alexl@redhat.com> | 2006-06-16 15:02:57 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2006-06-16 15:02:57 +0000 |
commit | 2f6ea5757cd326d1e898332cf40c87c2906a2a0a (patch) | |
tree | 0793f48b19826630db51aaed4a33ae706bc29263 | |
parent | 71b1be1b0b357d280bb9ad536129c154cdac4ca0 (diff) | |
download | nautilus-2f6ea5757cd326d1e898332cf40c87c2906a2a0a.tar.gz |
Add selinux context column
2006-06-16 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-column-utilities.c:
Add selinux context column
* libnautilus-private/nautilus-directory-async.c:
* libnautilus-private/nautilus-file-private.h:
* libnautilus-private/nautilus-file.[ch]:
Get selinux context for all files.
Add nautilus_file_can_get_selinux_context and nautilus_file_get_selinux_context
Add selinux_context string attribute.
* src/file-manager/fm-properties-window.c:
Display selinux context in permissions page.
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | libnautilus-private/nautilus-column-utilities.c | 8 | ||||
-rw-r--r-- | libnautilus-private/nautilus-directory-async.c | 12 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file-private.h | 6 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file.c | 55 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file.h | 2 | ||||
-rw-r--r-- | src/file-manager/fm-properties-window.c | 4 |
7 files changed, 85 insertions, 17 deletions
@@ -1,5 +1,20 @@ 2006-06-16 Alexander Larsson <alexl@redhat.com> + * libnautilus-private/nautilus-column-utilities.c: + Add selinux context column + + * libnautilus-private/nautilus-directory-async.c: + * libnautilus-private/nautilus-file-private.h: + * libnautilus-private/nautilus-file.[ch]: + Get selinux context for all files. + Add nautilus_file_can_get_selinux_context and nautilus_file_get_selinux_context + Add selinux_context string attribute. + + * src/file-manager/fm-properties-window.c: + Display selinux context in permissions page. + +2006-06-16 Alexander Larsson <alexl@redhat.com> + * libnautilus-private/nautilus-global-preferences.[ch]: * libnautilus-private/apps_nautilus_preferences.schemas.in: Add show_advanced_permissions setting diff --git a/libnautilus-private/nautilus-column-utilities.c b/libnautilus-private/nautilus-column-utilities.c index 642f99451..b467d952c 100644 --- a/libnautilus-private/nautilus-column-utilities.c +++ b/libnautilus-private/nautilus-column-utilities.c @@ -113,6 +113,14 @@ get_builtin_columns (void) "label", _("MIME Type"), "description", _("The mime type of the file."), NULL)); + columns = g_list_append (columns, + g_object_new (NAUTILUS_TYPE_COLUMN, + "name", "selinux_context", + "attribute", "selinux_context", + "label", _("SELinux Context"), + "description", _("The SELinux security context of the file."), + NULL)); + return columns; } diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c index d85be1eca..8290b8549 100644 --- a/libnautilus-private/nautilus-directory-async.c +++ b/libnautilus-private/nautilus-directory-async.c @@ -1492,9 +1492,7 @@ nautilus_directory_get_info_for_new_files (NautilusDirectory *directory, gnome_vfs_async_get_file_info (&handle, vfs_uri_list, - (GNOME_VFS_FILE_INFO_GET_MIME_TYPE - | GNOME_VFS_FILE_INFO_FOLLOW_LINKS - | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS), + NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS, GNOME_VFS_PRIORITY_DEFAULT, new_files_callback, directory); @@ -2034,9 +2032,7 @@ start_monitoring_file_list (NautilusDirectory *directory) gnome_vfs_async_load_directory (&directory->details->directory_load_in_progress, /* handle */ directory->details->uri, /* uri */ - (GNOME_VFS_FILE_INFO_GET_MIME_TYPE /* options */ - | GNOME_VFS_FILE_INFO_FOLLOW_LINKS - | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS), + NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS, DIRECTORY_LOAD_ITEMS_PER_CALLBACK, /* items_per_notification */ GNOME_VFS_PRIORITY_DEFAULT, directory_load_callback, /* callback */ @@ -2873,9 +2869,7 @@ file_info_start (NautilusDirectory *directory, fake_list.prev = NULL; fake_list.next = NULL; - options = GNOME_VFS_FILE_INFO_GET_MIME_TYPE - | GNOME_VFS_FILE_INFO_FOLLOW_LINKS - | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS; + options = NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS; if (need_slow_mime) { options |= GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE; } diff --git a/libnautilus-private/nautilus-file-private.h b/libnautilus-private/nautilus-file-private.h index 1d1c46254..c478d73f4 100644 --- a/libnautilus-private/nautilus-file-private.h +++ b/libnautilus-private/nautilus-file-private.h @@ -38,6 +38,12 @@ #define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_LINES 5 #define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_BYTES 1024 +#define NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS \ + (GNOME_VFS_FILE_INFO_FOLLOW_LINKS | \ + GNOME_VFS_FILE_INFO_GET_MIME_TYPE | \ + GNOME_VFS_FILE_INFO_GET_SELINUX_CONTEXT | \ + GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS) + /* These are in the typical sort order. Known things come first, then * things where we can't know, finally things where we don't yet know. */ diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index 773b6da64..4042df529 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -1206,8 +1206,7 @@ rename_guts (NautilusFile *file, op->is_rename = TRUE; op->use_slow_mime = file->details->got_slow_mime_type; - options = GNOME_VFS_FILE_INFO_GET_MIME_TYPE - | GNOME_VFS_FILE_INFO_FOLLOW_LINKS; + options = NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS; if (op->use_slow_mime) { options |= GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE; } @@ -3521,9 +3520,7 @@ nautilus_file_set_permissions (NautilusFile *file, op = operation_new (file, callback, callback_data); op->use_slow_mime = file->details->got_slow_mime_type; - options = GNOME_VFS_FILE_INFO_GET_MIME_TYPE - | GNOME_VFS_FILE_INFO_FOLLOW_LINKS - | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS; + options = NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS; if (op->use_slow_mime) { options |= GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE; } @@ -3541,6 +3538,46 @@ nautilus_file_set_permissions (NautilusFile *file, gnome_vfs_uri_unref (vfs_uri); } +/** + * nautilus_file_can_get_selinux_context: + * + * Check whether the selinux context for a file are determinable. + * This might not be the case for files on non-UNIX file systems, + * files without a context or systems that don't support selinux. + * + * @file: The file in question. + * + * Return value: TRUE if the permissions are valid. + */ +gboolean +nautilus_file_can_get_selinux_context (NautilusFile *file) +{ + return !nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SELINUX_CONTEXT); +} + + +/** + * nautilus_file_get_selinux_context: + * + * Get a user-displayable string representing a file's selinux + * context + * @file: NautilusFile representing the file in question. + * + * Returns: Newly allocated string ready to display to the user. + * + **/ +char * +nautilus_file_get_selinux_context (NautilusFile *file) +{ + g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL); + + if (!nautilus_file_can_get_selinux_context (file)) { + return NULL; + } + + return g_strdup (file->details->info->selinux_context); +} + static char * get_real_name (const char *name, const char *gecos) { @@ -3771,8 +3808,7 @@ set_owner_and_group (NautilusFile *file, op = operation_new (file, callback, callback_data); op->use_slow_mime = file->details->got_slow_mime_type; - options = GNOME_VFS_FILE_INFO_GET_MIME_TYPE - | GNOME_VFS_FILE_INFO_FOLLOW_LINKS; + options = NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS; if (op->use_slow_mime) { options |= GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE; } @@ -4495,7 +4531,7 @@ nautilus_file_get_deep_directory_count_as_string (NautilusFile *file) * set includes "name", "type", "mime_type", "size", "deep_size", "deep_directory_count", * "deep_file_count", "deep_total_count", "date_modified", "date_changed", "date_accessed", * "date_permissions", "owner", "group", "permissions", "octal_permissions", "uri", "where", - * "link_target", "volume", "free_space" + * "link_target", "volume", "free_space", "selinux_context" * * Returns: Newly allocated string ready to display to the user, or NULL * if the value is unknown or @attribute_name is not supported. @@ -4556,6 +4592,9 @@ nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_na if (strcmp (attribute_name, "permissions") == 0) { return nautilus_file_get_permissions_as_string (file); } + if (strcmp (attribute_name, "selinux_context") == 0) { + return nautilus_file_get_selinux_context (file); + } if (strcmp (attribute_name, "octal_permissions") == 0) { return nautilus_file_get_octal_permissions_as_string (file); } diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h index e80d94e6b..532d8c945 100644 --- a/libnautilus-private/nautilus-file.h +++ b/libnautilus-private/nautilus-file.h @@ -198,6 +198,8 @@ char * nautilus_file_get_group_name (Nautilu GList * nautilus_get_user_names (void); GList * nautilus_get_all_group_names (void); GList * nautilus_file_get_settable_group_names (NautilusFile *file); +gboolean nautilus_file_can_get_selinux_context (NautilusFile *file); +char * nautilus_file_get_selinux_context (NautilusFile *file); /* "Capabilities". */ gboolean nautilus_file_can_read (NautilusFile *file); diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 73f6982bd..e8dc606e8 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -3800,6 +3800,10 @@ create_permissions_page (FMPropertiesWindow *window) gtk_table_set_row_spacing (page_table, page_table->nrows - 1, 18); append_title_value_pair + (window, page_table, _("SELinux Context:"), + "selinux_context", _("--"), + FALSE); + append_title_value_pair (window, page_table, _("Last changed:"), "date_permissions", _("--"), FALSE); |