[gvfs] afp: retreive and store the user id for the logged in user
- From: Christian Kellner <gicmo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] afp: retreive and store the user id for the logged in user
- Date: Thu, 25 Aug 2011 19:26:09 +0000 (UTC)
commit 4cd5d1e70139aed969ce433fb86f4887d7fa68c6
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Tue Jul 19 13:22:14 2011 +0200
afp: retreive and store the user id for the logged in user
daemon/gvfsafpconnection.h | 11 +++++++++
daemon/gvfsafpserver.c | 9 +++++-
daemon/gvfsafpserver.h | 1 +
daemon/gvfsbackendafp.c | 51 ++++++++++++++++++++++++++++++++++++-----
daemon/gvfsbackendafpbrowse.c | 2 +-
5 files changed, 65 insertions(+), 9 deletions(-)
---
diff --git a/daemon/gvfsafpconnection.h b/daemon/gvfsafpconnection.h
index 364dc3d..efb39b0 100644
--- a/daemon/gvfsafpconnection.h
+++ b/daemon/gvfsafpconnection.h
@@ -27,6 +27,16 @@
G_BEGIN_DECLS
+enum
+{
+ AFP_MAP_NAME_FUNCTION_NAME_TO_USER_ID = 1,
+ AFP_MAP_NAME_FUNCTION_NAME_TO_GROUP_ID = 2,
+ AFP_MAP_NAME_FUNCTION_UTF8_NAME_TO_USER_ID = 3,
+ AFP_MAP_NAME_FUNCTION_UTF8_NAME_TO_GROUP_ID = 4,
+ AFP_MAP_NAME_FUNCTION_UTF8_NAME_TO_USER_UUID = 5,
+ AFP_MAP_NAME_FUNCTION_UTF8_NAME_TO_GROUP_UUID = 6
+};
+
typedef enum
{
AFP_PATH_TYPE_SHORT_NAME = 1,
@@ -173,6 +183,7 @@ typedef enum
AFP_COMMAND_GET_VOL_PARMS = 17,
AFP_COMMAND_LOGIN = 18,
AFP_COMMAND_LOGIN_CONT = 19,
+ AFP_COMMAND_MAP_NAME = 22,
AFP_COMMAND_OPEN_VOL = 24,
AFP_COMMAND_OPEN_FORK = 26,
AFP_COMMAND_RENAME = 28,
diff --git a/daemon/gvfsafpserver.c b/daemon/gvfsafpserver.c
index 4e03023..35dc552 100644
--- a/daemon/gvfsafpserver.c
+++ b/daemon/gvfsafpserver.c
@@ -828,6 +828,7 @@ gboolean
g_vfs_afp_server_login (GVfsAfpServer *afp_serv,
const char *initial_user,
GMountSource *mount_source,
+ char **logged_in_user,
GCancellable *cancellable,
GError **error)
{
@@ -984,7 +985,11 @@ try_login:
g_free (prompt);
}
- g_free (user);
+ if (logged_in_user)
+ *logged_in_user = user;
+ else
+ g_free (user);
+
g_free (password);
return TRUE;
@@ -1020,7 +1025,7 @@ static void
g_vfs_afp_server_finalize (GObject *object)
{
GVfsAfpServer *afp_serv = G_VFS_AFP_SERVER (object);
-
+
g_free (afp_serv->machine_type);
g_free (afp_serv->server_name);
g_free (afp_serv->utf8_server_name);
diff --git a/daemon/gvfsafpserver.h b/daemon/gvfsafpserver.h
index 2ec5325..5c624a6 100644
--- a/daemon/gvfsafpserver.h
+++ b/daemon/gvfsafpserver.h
@@ -72,6 +72,7 @@ struct _GVfsAfpServer
gboolean g_vfs_afp_server_login (GVfsAfpServer *afp_serv,
const char *initial_user,
GMountSource *mount_source,
+ char **logged_in_user,
GCancellable *cancellable,
GError **error);
diff --git a/daemon/gvfsbackendafp.c b/daemon/gvfsbackendafp.c
index c650ca1..feea6b4 100644
--- a/daemon/gvfsbackendafp.c
+++ b/daemon/gvfsbackendafp.c
@@ -70,6 +70,9 @@ struct _GVfsBackendAfp
GVfsAfpServer *server;
+ char *logged_in_user;
+ gint32 logged_in_user_id;
+
gint32 time_diff;
guint16 volume_id;
};
@@ -2314,10 +2317,9 @@ do_mount (GVfsBackend *backend,
GError *err = NULL;
GVfsAfpCommand *comm;
- guint16 vol_bitmap;
-
GVfsAfpReply *reply;
AfpResultCode res_code;
+
gint32 server_time;
GMountSpec *afp_mount_spec;
@@ -2327,10 +2329,45 @@ do_mount (GVfsBackend *backend,
afp_backend->server = g_vfs_afp_server_new (afp_backend->addr);
res = g_vfs_afp_server_login (afp_backend->server, afp_backend->user, mount_source,
+ &afp_backend->logged_in_user,
G_VFS_JOB (job)->cancellable, &err);
if (!res)
goto error;
+ /* Get UserID */
+ if (afp_backend->logged_in_user)
+ {
+ comm = g_vfs_afp_command_new (AFP_COMMAND_MAP_NAME);
+ /* SubFunction */
+ g_vfs_afp_command_put_byte (comm, AFP_MAP_NAME_FUNCTION_NAME_TO_USER_ID);
+ /* Name */
+ g_vfs_afp_command_put_pascal (comm, afp_backend->logged_in_user);
+
+ res = g_vfs_afp_connection_send_command_sync (afp_backend->server->conn,
+ comm, G_VFS_JOB (job)->cancellable,
+ &err);
+ g_object_unref (comm);
+ if (!res)
+ goto error;
+
+ reply = g_vfs_afp_connection_read_reply_sync (afp_backend->server->conn,
+ G_VFS_JOB (job)->cancellable,
+ &err);
+ if (!reply)
+ goto error;
+
+ res_code = g_vfs_afp_reply_get_result_code (reply);
+ if (res_code != AFP_RESULT_NO_ERROR)
+ {
+ g_object_unref (reply);
+ goto generic_error;
+ }
+
+ g_vfs_afp_reply_read_int32 (reply, &afp_backend->logged_in_user_id);
+ g_object_unref (reply);
+ }
+
+
/* Get Server Parameters */
comm = g_vfs_afp_command_new (AFP_COMMAND_GET_SRVR_PARMS);
/* pad byte */
@@ -2352,7 +2389,7 @@ do_mount (GVfsBackend *backend,
if (res_code != AFP_RESULT_NO_ERROR)
{
g_object_unref (reply);
- goto error;
+ goto generic_error;
}
/* server time */
@@ -2366,10 +2403,8 @@ do_mount (GVfsBackend *backend,
comm = g_vfs_afp_command_new (AFP_COMMAND_OPEN_VOL);
/* pad byte */
g_vfs_afp_command_put_byte (comm, 0);
-
/* Volume Bitmap */
- vol_bitmap = AFP_VOLUME_BITMAP_VOL_ID_BIT;
- g_vfs_afp_command_put_uint16 (comm, vol_bitmap);
+ g_vfs_afp_command_put_uint16 (comm, AFP_VOLUME_BITMAP_VOL_ID_BIT);
/* VolumeName */
g_vfs_afp_command_put_pascal (comm, afp_backend->volume);
@@ -2500,6 +2535,8 @@ g_vfs_backend_afp_init (GVfsBackendAfp *object)
afp_backend->volume = NULL;
afp_backend->user = NULL;
+ afp_backend->logged_in_user = NULL;
+
afp_backend->addr = NULL;
}
@@ -2511,6 +2548,8 @@ g_vfs_backend_afp_finalize (GObject *object)
g_free (afp_backend->volume);
g_free (afp_backend->user);
+ g_free (afp_backend->logged_in_user);
+
if (afp_backend->addr)
g_object_unref (afp_backend->addr);
diff --git a/daemon/gvfsbackendafpbrowse.c b/daemon/gvfsbackendafpbrowse.c
index 37e6236..549424e 100644
--- a/daemon/gvfsbackendafpbrowse.c
+++ b/daemon/gvfsbackendafpbrowse.c
@@ -455,7 +455,7 @@ do_mount (GVfsBackend *backend,
afp_backend->server = g_vfs_afp_server_new (afp_backend->addr);
res = g_vfs_afp_server_login (afp_backend->server, afp_backend->user, mount_source,
- G_VFS_JOB (job)->cancellable, &err);
+ NULL, G_VFS_JOB (job)->cancellable, &err);
if (!res)
goto error;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]