[gnome-initial-setup] copy-worker: Use getpwnam_r() rather than iterating over pwent
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] copy-worker: Use getpwnam_r() rather than iterating over pwent
- Date: Fri, 18 Jan 2013 02:18:50 +0000 (UTC)
commit b782bb922507aa167fcbf566e9b4b87439019d40
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Jan 17 20:26:17 2013 -0500
copy-worker: Use getpwnam_r() rather than iterating over pwent
.../gnome-initial-setup-copy-worker.c | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/gnome-initial-setup/gnome-initial-setup-copy-worker.c b/gnome-initial-setup/gnome-initial-setup-copy-worker.c
index 05208e0..1863695 100644
--- a/gnome-initial-setup/gnome-initial-setup-copy-worker.c
+++ b/gnome-initial-setup/gnome-initial-setup-copy-worker.c
@@ -14,16 +14,11 @@ get_gnome_initial_setup_home_dir (void)
struct passwd pw, *pwp;
char buf[4096];
- setpwent();
- while (TRUE) {
- if (getpwent_r (&pw, buf, sizeof (buf), &pwp))
- break;
-
- if (strcmp (pwp->pw_name, "gnome-initial-setup") == 0)
- return g_strdup (pwp->pw_dir);
- }
-
- return NULL;
+ getpwnam_r ("gnome-initial-setup", &pw, buf, sizeof (buf), &pwp);
+ if (pwp != NULL)
+ return g_strdup (pwp->pw_dir);
+ else
+ return NULL;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]