[accounts-dialog] Add a method to get a user by uid
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [accounts-dialog] Add a method to get a user by uid
- Date: Wed, 20 Jan 2010 19:19:35 +0000 (UTC)
commit 556757645a475f19fb1647c07fe74890badda6b2
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jan 20 13:35:15 2010 -0500
Add a method to get a user by uid
src/um-user-manager.c | 15 +++++++++++++++
src/um-user-manager.h | 2 ++
2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/um-user-manager.c b/src/um-user-manager.c
index 4f45eff..7e54487 100644
--- a/src/um-user-manager.c
+++ b/src/um-user-manager.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <pwd.h>
#ifdef HAVE_PATHS_H
#include <paths.h>
@@ -306,6 +307,20 @@ um_user_manager_get_user (UmUserManager *manager,
return g_hash_table_lookup (manager->user_by_name, name);
}
+UmUser *
+um_user_manager_get_user_by_id (UmUserManager *manager,
+ uid_t uid)
+{
+ struct passwd *pwent;
+
+ pwent = getpwuid (uid);
+ if (!pwent) {
+ return NULL;
+ }
+
+ return um_user_manager_get_user (manager, pwent->pw_name);
+}
+
gboolean
um_user_manager_no_service (UmUserManager *manager)
{
diff --git a/src/um-user-manager.h b/src/um-user-manager.h
index 0c263ef..3c117af 100644
--- a/src/um-user-manager.h
+++ b/src/um-user-manager.h
@@ -71,6 +71,8 @@ gboolean um_user_manager_no_service (UmUserManager *manager
GSList * um_user_manager_list_users (UmUserManager *manager);
UmUser * um_user_manager_get_user (UmUserManager *manager,
const char *user_name);
+UmUser * um_user_manager_get_user_by_id (UmUserManager *manager,
+ uid_t uid);
void um_user_manager_create_user (UmUserManager *manager,
const char *user_name,
const char *real_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]