From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH 1/4] Use re-entrant variants of getpwnam and getgrnam
Date: Wed, 22 Oct 2008 14:13:08 +0000 [thread overview]
Message-ID: <48FF34F4.2030901@tuffmail.co.uk> (raw)
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
diff --git a/udev/udev-util.c b/udev/udev-util.c
index 76445bb..204c096 100644
--- a/udev/udev-util.c
+++ b/udev/udev-util.c
@@ -126,13 +126,16 @@ int util_unlink_secure(struct udev *udev, const char *filename)
uid_t util_lookup_user(struct udev *udev, const char *user)
{
+ int buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+ char buf[buflen];
+ struct passwd pwbuf;
struct passwd *pw;
uid_t uid = 0;
if (strcmp(user, "root") = 0)
return 0;
errno = 0;
- pw = getpwnam(user);
+ getpwnam_r(user, &pwbuf, buf, buflen, &pw);
if (pw = NULL) {
if (errno = 0 || errno = ENOENT || errno = ESRCH)
err(udev, "specified user '%s' unknown\n", user);
@@ -140,18 +143,22 @@ uid_t util_lookup_user(struct udev *udev, const char *user)
err(udev, "error resolving user '%s': %m\n", user);
} else
uid = pw->pw_uid;
+
return uid;
}
extern gid_t util_lookup_group(struct udev *udev, const char *group)
{
+ int buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
+ char buf[buflen];
+ struct group grbuf;
struct group *gr;
gid_t gid = 0;
if (strcmp(group, "root") = 0)
return 0;
errno = 0;
- gr = getgrnam(group);
+ getgrnam_r(group, &grbuf, buf, buflen, &gr);
if (gr = NULL) {
if (errno = 0 || errno = ENOENT || errno = ESRCH)
err(udev, "specified group '%s' unknown\n", group);
next reply other threads:[~2008-10-22 14:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-22 14:13 Alan Jenkins [this message]
2008-10-22 16:25 ` [PATCH 1/4] Use re-entrant variants of getpwnam and getgrnam Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48FF34F4.2030901@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.