summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port
diff options
context:
space:
mode:
authorBaban Kenkre <Baban.Kenkre@Sun.COM>2008-11-07 12:09:53 -0800
committerBaban Kenkre <Baban.Kenkre@Sun.COM>2008-11-07 12:09:53 -0800
commit2b4a78020b9c38d1b95e2f3fefa6d6e4be382d1f (patch)
treeb9f0bc817d950cefb1af4653dad8de547a17e061 /usr/src/lib/libc/port
parent0a2b1d27cac02f57e17b310f8baeb1dda082c83a (diff)
downloadillumos-joyent-2b4a78020b9c38d1b95e2f3fefa6d6e4be382d1f.tar.gz
PSARC/2008/441 Active Directory name service module (nss_ad)
6722476 name service switch module for AD (nss_ad) needed
Diffstat (limited to 'usr/src/lib/libc/port')
-rw-r--r--usr/src/lib/libc/port/gen/getgrnam_r.c12
-rw-r--r--usr/src/lib/libc/port/gen/getpwnam_r.c26
-rw-r--r--usr/src/lib/libc/port/gen/putpwent.c4
3 files changed, 24 insertions, 18 deletions
diff --git a/usr/src/lib/libc/port/gen/getgrnam_r.c b/usr/src/lib/libc/port/gen/getgrnam_r.c
index 52e1b6d0e7..7e610cd8f2 100644
--- a/usr/src/lib/libc/port/gen/getgrnam_r.c
+++ b/usr/src/lib/libc/port/gen/getgrnam_r.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include <mtlib.h>
#include <sys/types.h>
@@ -318,6 +316,7 @@ str2group(const char *instr, int lenstr, void *ent, char *buffer, int buflen)
char *p, *next;
int black_magic; /* "+" or "-" entry */
char **memlist, **limit;
+ ulong_t tmp;
if (lenstr + 1 > buflen)
return (NSS_STR_PARSE_ERANGE);
@@ -378,16 +377,15 @@ str2group(const char *instr, int lenstr, void *ent, char *buffer, int buflen)
return (NSS_STR_PARSE_PARSE);
}
if (!black_magic) {
- group->gr_gid = (gid_t)strtol(p, &next, 10);
+ tmp = strtoul(p, &next, 10);
if (next == p) {
/* gid field should be nonempty */
return (NSS_STR_PARSE_PARSE);
}
- /*
- * gids should be in the range 0 .. MAXUID
- */
- if (group->gr_gid > MAXUID)
+ if (group->gr_gid >= UINT32_MAX)
group->gr_gid = GID_NOBODY;
+ else
+ group->gr_gid = (gid_t)tmp;
}
if (*next++ != ':') {
/* Parse error, even for a '+' entry (which should have */
diff --git a/usr/src/lib/libc/port/gen/getpwnam_r.c b/usr/src/lib/libc/port/gen/getpwnam_r.c
index 7ff4d21f0d..7b7c417de5 100644
--- a/usr/src/lib/libc/port/gen/getpwnam_r.c
+++ b/usr/src/lib/libc/port/gen/getpwnam_r.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include <sys/types.h>
#include <pwd.h>
@@ -244,6 +242,7 @@ str2passwd(const char *instr, int lenstr, void *ent, char *buffer, int buflen)
struct passwd *passwd = (struct passwd *)ent;
char *p, *next;
int black_magic; /* "+" or "-" entry */
+ ulong_t tmp;
if (lenstr + 1 > buflen)
return (NSS_STR_PARSE_ERANGE);
@@ -310,7 +309,14 @@ str2passwd(const char *instr, int lenstr, void *ent, char *buffer, int buflen)
return (NSS_STR_PARSE_PARSE);
}
if (!black_magic) {
- passwd->pw_uid = (uid_t)strtol(p, &next, 10);
+ /*
+ * strtoul returns unsigned long which is
+ * 8 bytes on a 64-bit system. We don't want
+ * to assign it directly to passwd->pw_uid
+ * which is 4 bytes or else we will end up
+ * truncating the value.
+ */
+ tmp = strtoul(p, &next, 10);
if (next == p) {
/* uid field should be nonempty */
return (NSS_STR_PARSE_PARSE);
@@ -321,11 +327,13 @@ str2passwd(const char *instr, int lenstr, void *ent, char *buffer, int buflen)
* than 60001 (the rfs limit). If it met either of
* these conditions, the uid was translated to 60001.
*
- * Now we just check for negative uids; anything else
+ * Now we just check for -1 (UINT32_MAX); anything else
* is administrative policy
*/
- if (passwd->pw_uid > MAXUID)
+ if (tmp >= UINT32_MAX)
passwd->pw_uid = UID_NOBODY;
+ else
+ passwd->pw_uid = (uid_t)tmp;
}
if (*next++ != ':') {
if (black_magic)
@@ -341,17 +349,19 @@ str2passwd(const char *instr, int lenstr, void *ent, char *buffer, int buflen)
return (NSS_STR_PARSE_PARSE);
}
if (!black_magic) {
- passwd->pw_gid = (gid_t)strtol(p, &next, 10);
+ tmp = strtoul(p, &next, 10);
if (next == p) {
/* gid field should be nonempty */
return (NSS_STR_PARSE_PARSE);
}
/*
- * gid should be non-negative; anything else
+ * gid should not be -1; anything else
* is administrative policy.
*/
- if (passwd->pw_gid > MAXUID)
+ if (passwd->pw_gid >= UINT32_MAX)
passwd->pw_gid = GID_NOBODY;
+ else
+ passwd->pw_gid = (gid_t)tmp;
}
if (*next++ != ':') {
if (black_magic)
diff --git a/usr/src/lib/libc/port/gen/putpwent.c b/usr/src/lib/libc/port/gen/putpwent.c
index efc482c7f4..b4c1928902 100644
--- a/usr/src/lib/libc/port/gen/putpwent.c
+++ b/usr/src/lib/libc/port/gen/putpwent.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* format a password file entry
*/
@@ -55,7 +53,7 @@ putpwent(const struct passwd *p, FILE *f)
p->pw_dir ? p->pw_dir : "",
p->pw_shell ? p->pw_shell : "");
} else { /* "normal case" */
- (void) fprintf(f, ":%d:%d:%s:%s:%s",
+ (void) fprintf(f, ":%u:%u:%s:%s:%s",
p->pw_uid,
p->pw_gid,
p->pw_gecos,