nautilus r15059 - in trunk: . libnautilus-private
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r15059 - in trunk: . libnautilus-private
- Date: Thu, 5 Mar 2009 19:22:45 +0000 (UTC)
Author: alexl
Date: Thu Mar 5 19:22:45 2009
New Revision: 15059
URL: http://svn.gnome.org/viewvc/nautilus?rev=15059&view=rev
Log:
2009-03-05 Alexander Larsson <alexl redhat com>
Bug 449397 â misinterpreted uid over ssh
* libnautilus-private/nautilus-file-private.h:
* libnautilus-private/nautilus-file.c:
Use the gvfs reported owner/group names instead of the local
uid/gui mapping. This allows remote shares to report the correct
names.
Modified:
trunk/ChangeLog
trunk/libnautilus-private/nautilus-file-private.h
trunk/libnautilus-private/nautilus-file.c
Modified: trunk/libnautilus-private/nautilus-file-private.h
==============================================================================
--- trunk/libnautilus-private/nautilus-file-private.h (original)
+++ trunk/libnautilus-private/nautilus-file-private.h Thu Mar 5 19:22:45 2009
@@ -39,12 +39,6 @@
#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)
-
#define NAUTILUS_FILE_DEFAULT_ATTRIBUTES \
"standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*,id::filesystem,trash::orig-path"
@@ -81,6 +75,10 @@
guint32 permissions;
int uid; /* -1 is none */
int gid; /* -1 is none */
+
+ eel_ref_str owner;
+ eel_ref_str owner_real;
+ eel_ref_str group;
time_t atime; /* 0 is unknown */
time_t mtime; /* 0 is unknown */
Modified: trunk/libnautilus-private/nautilus-file.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file.c (original)
+++ trunk/libnautilus-private/nautilus-file.c Thu Mar 5 19:22:45 2009
@@ -326,6 +326,12 @@
file->details->selinux_context = NULL;
g_free (file->details->description);
file->details->description = NULL;
+ eel_ref_str_unref (file->details->owner);
+ file->details->owner = NULL;
+ eel_ref_str_unref (file->details->owner_real);
+ file->details->owner_real = NULL;
+ eel_ref_str_unref (file->details->group);
+ file->details->group = NULL;
eel_ref_str_unref (file->details->filesystem_id);
file->details->filesystem_id = NULL;
@@ -636,6 +642,9 @@
g_free (file->details->thumbnail_path);
g_free (file->details->symlink_name);
eel_ref_str_unref (file->details->mime_type);
+ eel_ref_str_unref (file->details->owner);
+ eel_ref_str_unref (file->details->owner_real);
+ eel_ref_str_unref (file->details->group);
g_free (file->details->selinux_context);
g_free (file->details->description);
g_free (file->details->top_left_text);
@@ -1550,6 +1559,8 @@
const char *description;
const char *filesystem_id;
const char *trash_orig_path;
+ const char *group, *owner, *owner_real;
+ gboolean free_owner, free_group;
if (file->details->is_gone) {
return FALSE;
@@ -1711,13 +1722,27 @@
file->details->can_unmount = can_unmount;
file->details->can_eject = can_eject;
+ free_owner = FALSE;
+ owner = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_USER);
+ owner_real = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_USER_REAL);
+ free_group = FALSE;
+ group = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_GROUP);
+
uid = -1;
gid = -1;
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_UID)) {
uid = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID);
+ if (owner == NULL) {
+ free_owner = TRUE;
+ owner = g_strdup_printf ("%d", uid);
+ }
}
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_GID)) {
gid = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_GID);
+ if (group == NULL) {
+ free_group = TRUE;
+ group = g_strdup_printf ("%d", gid);
+ }
}
if (file->details->uid != uid ||
file->details->gid != gid) {
@@ -1725,6 +1750,31 @@
}
file->details->uid = uid;
file->details->gid = gid;
+
+ if (eel_strcmp (eel_ref_str_peek (file->details->owner), owner) != 0) {
+ changed = TRUE;
+ eel_ref_str_unref (file->details->owner);
+ file->details->owner = eel_ref_str_get_unique (owner);
+ }
+
+ if (eel_strcmp (eel_ref_str_peek (file->details->owner_real), owner_real) != 0) {
+ changed = TRUE;
+ eel_ref_str_unref (file->details->owner_real);
+ file->details->owner_real = eel_ref_str_get_unique (owner_real);
+ }
+
+ if (eel_strcmp (eel_ref_str_peek (file->details->group), group) != 0) {
+ changed = TRUE;
+ eel_ref_str_unref (file->details->group);
+ file->details->group = eel_ref_str_get_unique (group);
+ }
+
+ if (free_owner) {
+ g_free ((char *)owner);
+ }
+ if (free_group) {
+ g_free ((char *)group);
+ }
size = -1;
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE)) {
@@ -4480,29 +4530,6 @@
return real_name;
}
-static char *
-get_user_and_real_name_from_id (uid_t uid)
-{
- char *name, *gecos;
- char *real_name, *user_and_real_name;
-
- name = nautilus_users_cache_get_name (uid);
- gecos = nautilus_users_cache_get_gecos (uid);
-
- real_name = get_real_name (name, gecos);
- if (real_name != NULL) {
- user_and_real_name = g_strdup_printf ("%s - %s", name, real_name);
- } else {
- user_and_real_name = g_strdup (name);
- }
- g_free (real_name);
-
- g_free (name);
- g_free (gecos);
-
- return user_and_real_name;
-}
-
static gboolean
get_group_id_from_group_name (const char *group_name, uid_t *gid)
{
@@ -4767,22 +4794,7 @@
char *
nautilus_file_get_group_name (NautilusFile *file)
{
- char *group_name;
-
- /* Before we have info on a file, the owner is unknown. */
- if (file->details->gid == -1) {
- return NULL;
- }
-
- group_name = nautilus_groups_cache_get_name ((gid_t) file->details->gid);
- if (group_name == NULL) {
- /* In the oddball case that the group name has been set to an id for which
- * there is no defined group, return the id in string form.
- */
- group_name = g_strdup_printf ("%d", file->details->gid);
- }
-
- return group_name;
+ return g_strdup (eel_ref_str_peek (file->details->group));
}
/**
@@ -5076,21 +5088,22 @@
char *user_name;
/* Before we have info on a file, the owner is unknown. */
- if (file->details->uid == -1) {
+ if (file->details->owner == NULL &&
+ file->details->owner_real == NULL) {
return NULL;
}
- if (include_real_name) {
- user_name = get_user_and_real_name_from_id (file->details->uid);
+ if (file->details->owner_real == NULL) {
+ user_name = g_strdup (eel_ref_str_peek (file->details->owner));
+ } else if (file->details->owner == NULL) {
+ user_name = g_strdup (eel_ref_str_peek (file->details->owner_real));
+ } else if (include_real_name &&
+ strcmp (eel_ref_str_peek (file->details->owner), eel_ref_str_peek (file->details->owner_real)) != 0) {
+ user_name = g_strdup_printf ("%s - %s",
+ eel_ref_str_peek (file->details->owner),
+ eel_ref_str_peek (file->details->owner_real));
} else {
- user_name = nautilus_users_cache_get_name (file->details->uid);
- }
-
- if (user_name == NULL) {
- /* In the oddball case that the user name has been set to an id for which
- * there is no defined user, return the id in string form.
- */
- user_name = g_strdup_printf ("%d", file->details->uid);
+ user_name = g_strdup (eel_ref_str_peek (file->details->owner));
}
return user_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]