Commit 2f6ea575 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

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.
parent 71b1be1b
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]:
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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.
*/
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -3799,6 +3799,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", _("--"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment