summaryrefslogtreecommitdiff
path: root/usr/src/lib/libsecdb
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libsecdb')
-rw-r--r--usr/src/lib/libsecdb/common/getexecattr.c137
-rw-r--r--usr/src/lib/libsecdb/common/getprofattr.c112
-rw-r--r--usr/src/lib/libsecdb/common/getuserattr.c109
3 files changed, 9 insertions, 349 deletions
diff --git a/usr/src/lib/libsecdb/common/getexecattr.c b/usr/src/lib/libsecdb/common/getexecattr.c
index 1f6782b84f..1e1ab20ffd 100644
--- a/usr/src/lib/libsecdb/common/getexecattr.c
+++ b/usr/src/lib/libsecdb/common/getexecattr.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -54,7 +53,6 @@ extern char *_strdup_null(char *);
static execattr_t *userprof(const char *, const char *, const char *, int);
static execattr_t *get_tail(execattr_t *);
static execattr_t *execstr2attr(execstr_t *);
-static execstr_t *process_getexec(execstr_t *, char *, int, nsc_data_t *);
execattr_t *
getexecattr()
@@ -73,26 +71,16 @@ getexecattr()
execattr_t *
getexecprof(const char *name, const char *type, const char *id, int search_flag)
{
- int len_unique;
int err = 0;
- int ndata = 0;
- int adata = 0;
char unique[NSS_BUFLEN_EXECATTR];
char buf[NSS_BUFLEN_EXECATTR];
execattr_t *head = (execattr_t *)NULL;
execattr_t *prev = (execattr_t *)NULL;
execstr_t exec;
execstr_t *tmp;
- execstr_t *resptr = (execstr_t *)NULL;
- nsc_data_t *sptr = (nsc_data_t *)NULL;
- union {
- nsc_data_t s_d;
- char s_b[NSS_BUFLEN_EXECATTR];
- } space;
(void) memset(unique, 0, NSS_BUFLEN_EXECATTR);
(void) memset(&exec, 0, sizeof (execstr_t));
- (void) memset(&space, 0, sizeof (space));
if ((search_flag != GET_ONE) && (search_flag != GET_ALL)) {
return ((execattr_t *)NULL);
@@ -120,55 +108,6 @@ getexecprof(const char *name, const char *type, const char *id, int search_flag)
return (head);
}
-#ifdef PIC
- /*
- * If the search criteria is completely specified
- * and we only want a single entry,
- * then attempt to look up the entry using the nscd.
- * Only commands are cached.
- */
- if (name && type && (strcmp(type, KV_COMMAND) == 0) && id &&
- (search_flag == GET_ONE)) {
- if (snprintf(unique, NSS_BUFLEN_EXECATTR, "%s:%s:%s",
- name, type, id) >= NSS_BUFLEN_EXECATTR) {
- errno = ERANGE;
- return ((execattr_t *)NULL);
- }
- len_unique = strlen(unique);
- if ((len_unique >= (sizeof (space) - sizeof (nsc_data_t)))) {
- errno = ERANGE;
- return ((execattr_t *)NULL);
- }
- ndata = sizeof (space);
- adata = len_unique + sizeof (nsc_call_t) + 1;
- space.s_d.nsc_call.nsc_callnumber = GETEXECID;
- (void) strcpy(space.s_d.nsc_call.nsc_u.name, unique);
- sptr = &space.s_d;
-
- switch (_nsc_trydoorcall(&sptr, &ndata, &adata)) {
- case SUCCESS: /* positive cache hit */
- break;
- case NOTFOUND: /* negative cache hit */
- return ((execattr_t *)NULL);
- default:
- resptr = _getexecprof(name, type, id, search_flag,
- &exec, buf, NSS_BUFLEN_EXECATTR, &err);
- return (execstr2attr(resptr));
- }
- resptr = process_getexec(&exec, buf, NSS_BUFLEN_EXECATTR,
- sptr);
-
- /*
- * check if doors reallocated the memory underneath us
- * if they did munmap it or suffer a memory leak
- */
- if (sptr != &space.s_d)
- (void) munmap((void *)sptr, ndata);
-
- return (execstr2attr(resptr));
- } /* end if (name && type && id && search_flag == GET_ONE) */
-#endif /* PIC */
-
tmp = _getexecprof(name,
type,
id,
@@ -427,76 +366,6 @@ execstr2attr(execstr_t *es)
return (newexec);
}
-
-static execstr_t *
-process_getexec(
- execstr_t *result,
- char *buffer,
- int buflen,
- nsc_data_t *sptr)
-{
- char *fixed;
-#ifdef _LP64
- execstr_t exec64;
-
- fixed = (char *)(((uintptr_t)buffer + 7) & ~7);
-#else
- fixed = (char *)(((uintptr_t)buffer + 3) & ~3);
-#endif
- buflen -= fixed - buffer;
- buffer = fixed;
-
- if (sptr->nsc_ret.nsc_return_code != SUCCESS)
- return ((execstr_t *)NULL);
-
-#ifdef _LP64
- if (sptr->nsc_ret.nsc_bufferbytesused - (int)sizeof (execstr32_t)
- > buflen)
-#else
- if (sptr->nsc_ret.nsc_bufferbytesused - (int)sizeof (execstr_t)
- > buflen)
-#endif
- {
- errno = ERANGE;
- return ((execstr_t *)NULL);
- }
-
-#ifdef _LP64
- (void) memcpy(buffer, (sptr->nsc_ret.nsc_u.buff + sizeof (execstr32_t)),
- (sptr->nsc_ret.nsc_bufferbytesused - sizeof (execstr32_t)));
- exec64.name = (char *)(sptr->nsc_ret.nsc_u.exec.name +
- (uintptr_t)buffer);
- exec64.type = (char *)(sptr->nsc_ret.nsc_u.exec.type +
- (uintptr_t)buffer);
- exec64.policy = (char *)(sptr->nsc_ret.nsc_u.exec.policy +
- (uintptr_t)buffer);
- exec64.res1 = (char *)(sptr->nsc_ret.nsc_u.exec.res1 +
- (uintptr_t)buffer);
- exec64.res2 = (char *)(sptr->nsc_ret.nsc_u.exec.res2 +
- (uintptr_t)buffer);
- exec64.id = (char *)(sptr->nsc_ret.nsc_u.exec.id +
- (uintptr_t)buffer);
- exec64.attr = (char *)(sptr->nsc_ret.nsc_u.exec.attr +
- (uintptr_t)buffer);
- exec64.next = (execstr_t *)NULL;
- *result = exec64;
-#else
- sptr->nsc_ret.nsc_u.exec.name += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.exec.type += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.exec.policy += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.exec.res1 += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.exec.res2 += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.exec.id += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.exec.attr += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.exec.next = (execstr_t *)NULL;
- *result = sptr->nsc_ret.nsc_u.exec;
- (void) memcpy(buffer, (sptr->nsc_ret.nsc_u.buff + sizeof (execstr_t)),
- (sptr->nsc_ret.nsc_bufferbytesused - sizeof (execstr_t)));
-#endif
- return (result);
-}
-
-
#ifdef DEBUG
void
print_execattr(execattr_t *exec)
diff --git a/usr/src/lib/libsecdb/common/getprofattr.c b/usr/src/lib/libsecdb/common/getprofattr.c
index ade2cdfcc8..bb3173672c 100644
--- a/usr/src/lib/libsecdb/common/getprofattr.c
+++ b/usr/src/lib/libsecdb/common/getprofattr.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -43,8 +42,6 @@ extern void _setprofattr(void);
extern void _endprofattr(void);
static profattr_t *profstr2attr(profstr_t *);
-static profstr_t *process_getprof(profstr_t *, char *, int, nsc_data_t *);
-
profattr_t *
getprofattr()
@@ -63,55 +60,13 @@ profattr_t *
getprofnam(const char *name)
{
int err = 0;
- int ndata = 0;
- int adata = 0;
char buf[NSS_BUFLEN_PROFATTR];
profstr_t prof;
- union {
- nsc_data_t s_d;
- char s_b[1024];
- } space;
- nsc_data_t *sptr = (nsc_data_t *)NULL;
profstr_t *resptr = (profstr_t *)NULL;
(void) memset(&prof, 0, sizeof (profstr_t));
-#ifdef PIC
- (void) memset(&space, 0, sizeof (space));
-
- if ((name == NULL) ||
- (strlen(name) >= (sizeof (space) - sizeof (nsc_data_t)))) {
- errno = ERANGE;
- return ((profattr_t *)NULL);
- }
- ndata = sizeof (space);
- adata = strlen(name) + sizeof (nsc_call_t) + 1;
- space.s_d.nsc_call.nsc_callnumber = GETPROFNAM;
- (void) strcpy(space.s_d.nsc_call.nsc_u.name, name);
- sptr = &space.s_d;
-
- switch (_nsc_trydoorcall(&sptr, &ndata, &adata)) {
- case SUCCESS: /* positive cache hit */
- break;
- case NOTFOUND: /* negative cache hit */
- return ((profattr_t *)NULL);
- default:
- (void) memset(&prof, 0, sizeof (profattr_t));
- resptr = _getprofnam(name, &prof, buf,
- NSS_BUFLEN_PROFATTR, &err);
- return (profstr2attr(resptr));
- }
- resptr = process_getprof(&prof, buf, NSS_BUFLEN_PROFATTR, sptr);
-
- /*
- * check if doors reallocated the memory underneath us
- * if they did munmap it or suffer a memory leak
- */
- if (sptr != &space.s_d)
- (void) munmap((void *)sptr, ndata);
-#else /* !PIC */
resptr = _getprofnam(name, &prof, buf, NSS_BUFLEN_PROFATTR, &err);
-#endif /* PIC */
return (profstr2attr(resptr));
@@ -166,67 +121,6 @@ profstr2attr(profstr_t *prof)
}
-static profstr_t *
-process_getprof(
- profstr_t *result,
- char *buffer,
- int buflen,
- nsc_data_t *sptr)
-{
- char *fixed;
-#ifdef _LP64
- profstr_t prof64;
-
- fixed = (char *)(((uintptr_t)buffer + 7) & ~7);
-#else
- fixed = (char *)(((uintptr_t)buffer + 3) & ~3);
-#endif
- buflen -= fixed - buffer;
- buffer = fixed;
-
- if (sptr->nsc_ret.nsc_return_code != SUCCESS)
- return ((profstr_t *)NULL);
-
-#ifdef _LP64
- if (sptr->nsc_ret.nsc_bufferbytesused - (int)sizeof (profstr32_t)
- > buflen)
-#else
- if (sptr->nsc_ret.nsc_bufferbytesused - (int)sizeof (profstr_t)
- > buflen)
-#endif
- {
- errno = ERANGE;
- return ((profstr_t *)NULL);
- }
-
-#ifdef _LP64
- (void) memcpy(buffer, (sptr->nsc_ret.nsc_u.buff + sizeof (profstr32_t)),
- (sptr->nsc_ret.nsc_bufferbytesused - sizeof (profstr32_t)));
- prof64.name = (char *)(sptr->nsc_ret.nsc_u.prof.name +
- (uintptr_t)buffer);
- prof64.res1 = (char *)(sptr->nsc_ret.nsc_u.prof.res1 +
- (uintptr_t)buffer);
- prof64.res2 = (char *)(sptr->nsc_ret.nsc_u.prof.res2 +
- (uintptr_t)buffer);
- prof64.desc = (char *)(sptr->nsc_ret.nsc_u.prof.desc +
- (uintptr_t)buffer);
- prof64.attr = (char *)(sptr->nsc_ret.nsc_u.prof.attr +
- (uintptr_t)buffer);
- *result = prof64;
-#else
- sptr->nsc_ret.nsc_u.prof.name += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.prof.res1 += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.prof.res2 += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.prof.desc += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.prof.attr += (uintptr_t)buffer;
- *result = sptr->nsc_ret.nsc_u.prof;
- (void) memcpy(buffer, (sptr->nsc_ret.nsc_u.buff + sizeof (profstr_t)),
- (sptr->nsc_ret.nsc_bufferbytesused - sizeof (profstr_t)));
-#endif
- return (result);
-}
-
-
/*
* Given a profile name, gets the list of profiles found from
* the whole hierarchy, using the given profile as root
diff --git a/usr/src/lib/libsecdb/common/getuserattr.c b/usr/src/lib/libsecdb/common/getuserattr.c
index 7c0c8b9ff8..dd0789b5dd 100644
--- a/usr/src/lib/libsecdb/common/getuserattr.c
+++ b/usr/src/lib/libsecdb/common/getuserattr.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -46,7 +45,6 @@ extern void _enduserattr(void);
static userattr_t *userstr2attr(userstr_t *);
-static userstr_t *process_getuser(userstr_t *, char *, int, nsc_data_t *);
userattr_t *
@@ -80,51 +78,11 @@ userattr_t *
getusernam(const char *name)
{
int err = 0;
- int ndata;
- int adata;
char buf[NSS_BUFLEN_USERATTR];
userstr_t user;
- union {
- nsc_data_t s_d;
- char s_b[1024];
- } space;
- nsc_data_t *sptr;
userstr_t *resptr = (userstr_t *)NULL;
-#ifdef PIC
- if ((name == NULL) ||
- (strlen(name) >= (sizeof (space) - sizeof (nsc_data_t)))) {
- errno = ERANGE;
- return ((userattr_t *)NULL);
- }
- ndata = sizeof (space);
- adata = strlen(name) + sizeof (nsc_call_t) + 1;
- space.s_d.nsc_call.nsc_callnumber = GETUSERNAM;
- (void) strcpy(space.s_d.nsc_call.nsc_u.name, name);
- sptr = &space.s_d;
-
- switch (_nsc_trydoorcall(&sptr, &ndata, &adata)) {
- case SUCCESS: /* positive cache hit */
- break;
- case NOTFOUND: /* negative cache hit */
- return ((userattr_t *)NULL);
- default:
- (void) memset(&user, 0, sizeof (userattr_t));
- resptr = _getusernam(name, &user, buf,
- NSS_BUFLEN_USERATTR, &err);
- return (userstr2attr(resptr));
- }
- resptr = process_getuser(&user, buf, NSS_BUFLEN_USERATTR, sptr);
-
- /*
- * check if doors reallocated the memory underneath us
- * if they did munmap it or suffer a memory leak
- */
- if (sptr != &space.s_d)
- (void) munmap((void *)sptr, ndata);
-#else /* !PIC */
resptr = _getusernam(name, &user, buf, NSS_BUFLEN_USERATTR, &err);
-#endif /* PIC */
return (userstr2attr(resptr));
@@ -191,67 +149,6 @@ userstr2attr(userstr_t *user)
}
-static userstr_t *
-process_getuser(
- userstr_t *result,
- char *buffer,
- int buflen,
- nsc_data_t *sptr)
-{
- char *fixed;
-#ifdef _LP64
- userstr_t user64;
-
- fixed = (char *)(((uintptr_t)buffer + 7) & ~7);
-#else
- fixed = (char *)(((uintptr_t)buffer + 3) & ~3);
-#endif
- buflen -= fixed - buffer;
- buffer = fixed;
-
- if (sptr->nsc_ret.nsc_return_code != SUCCESS)
- return ((userstr_t *)NULL);
-
-#ifdef _LP64
- if (sptr->nsc_ret.nsc_bufferbytesused - (int)sizeof (userstr32_t)
- > buflen)
-#else
- if (sptr->nsc_ret.nsc_bufferbytesused - (int)sizeof (userstr_t)
- > buflen)
-#endif
- {
- errno = ERANGE;
- return ((userstr_t *)NULL);
- }
-
-#ifdef _LP64
- (void) memcpy(buffer, (sptr->nsc_ret.nsc_u.buff + sizeof (userstr32_t)),
- (sptr->nsc_ret.nsc_bufferbytesused - sizeof (userstr32_t)));
- user64.name = (char *)(sptr->nsc_ret.nsc_u.user.name +
- (uintptr_t)buffer);
- user64.qualifier = (char *)(sptr->nsc_ret.nsc_u.user.qualifier +
- (uintptr_t)buffer);
- user64.res1 = (char *)(sptr->nsc_ret.nsc_u.user.res1 +
- (uintptr_t)buffer);
- user64.res2 = (char *)(sptr->nsc_ret.nsc_u.user.res2 +
- (uintptr_t)buffer);
- user64.attr = (char *)(sptr->nsc_ret.nsc_u.user.attr +
- (uintptr_t)buffer);
- *result = user64;
-#else
- sptr->nsc_ret.nsc_u.user.name += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.user.qualifier += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.user.res1 += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.user.res2 += (uintptr_t)buffer;
- sptr->nsc_ret.nsc_u.user.attr += (uintptr_t)buffer;
- *result = sptr->nsc_ret.nsc_u.user;
- (void) memcpy(buffer, (sptr->nsc_ret.nsc_u.buff + sizeof (userstr_t)),
- (sptr->nsc_ret.nsc_bufferbytesused - sizeof (userstr_t)));
-#endif
- return (result);
-}
-
-
#ifdef DEBUG
void
print_userattr(userattr_t *user)