/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* 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
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <user_attr.h>
#include <pwd.h>
#include <grp.h>
#include <userdefs.h>
#include <project.h>
#include <memory.h>
#include <nss_dbdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NORMAL_PROJECT 0
int _str2project(const char *, int, void *, char *, int);
static DEFINE_NSS_DB_ROOT(db_root);
static DEFINE_NSS_GETENT(context);
void
{
p->name = NSS_DBNAM_PROJECT;
}
void
_setprojent(void)
{
}
void
_endprojent(void)
{
}
struct project *
{
}
struct project *
{
_nss_XbyY_fgets(f, &arg);
}
struct project *
{
}
struct project *
{
}
/*
* The following routine checks if user specified by the second argument
* is allowed to join the project specified as project structure in first
* argument. Information about user's default group and whether or not
* the project specified in the first argument is user's default project
* (i.e., user_attr, "default", "user.username", or "group.groupname"
* should also be provided. If is_default is set to DEFAULT_PROJECT,
* then this function returns 1 (true), unless specified user explicitly
* excluded with "!user", or "!group" wildcards.
*/
static int
{
int group_ok = 0;
char **u, **g;
char *member;
group_ok = 1;
}
/*
* Scan project's user list.
*/
member = *u;
if (member[0] == '!' &&
return (0);
res = 1;
}
/*
* Scan project's group list.
*/
member = *g;
/*
* Check if user's default group is included here.
*/
if (group_ok) {
if (member[0] == '!' &&
return (0);
res = 1;
}
/*
* Check if user is a member of one of project's groups.
*/
res = 1;
}
}
return (res);
}
struct project *
{
struct passwd p;
struct group g;
char *attrproj;
/*
* Need user's default group ID for ismember() calls later
*/
return (NULL);
/*
* Check user_attr database first
*/
return (result);
}
}
}
/*
* Check user.{username} and group.{groupname} projects
*/
return (result);
return (result);
}
return (result);
return (NULL);
}
int
{
char *attrproj;
/*
* 0. Sanity checks.
*/
return (0); /* user does not exist */
return (0); /* project does not exist */
/*
* 1. Check for special "default" project.
*/
/*
* 2. Check user_attr database.
*/
}
}
}
/*
* 3. Check if this is a special "user.username" project.
*
* User "username" is considered to be a member of project
* "user.username" even if project's user lists do not
* include "username".
*/
/*
* 4. Check if this is a special "group.groupname" project.
*
* User "username" with default group "groupname" is considered
* to be a member of project "group.groupname" even if project's
* group list does not include "groupname".
*/
}
/*
* 5. Handle all other (non-default) projects.
*/
}
/*
* Just a quick wrapper around getprojbyname so that the caller does not
* need to allocate the buffer.
*/
{
else
return ((projid_t)-1);
}
static char *
{
char *p = *nextpp;
char *q = p;
char c;
if (p == NULL)
return (NULL);
while ((c = *q) != '\0' && c != sep)
q++;
if (c == '\0')
*nextpp = 0;
else {
*q++ = '\0';
*nextpp = q;
}
return (p);
}
/*
* Return values: 0 = success, 1 = parse error, 2 = erange ...
* The structure pointer passed in is a structure in the caller's space
* wherein the field pointers would be set to areas in the buffer if
* need be. instring and buffer should be separate areas.
*/
int
{
char *p, *next;
char **uglist;
char **limit;
return (NSS_STR_PARSE_ERANGE);
/*
* We copy the input string into the output buffer and
* operate on it in place.
*/
/*
* Parsers for passwd and group have always been pretty rigid;
* we wouldn't want to buck a Unix tradition
*/
/*
* empty or very long project names are not allowed
*/
return (NSS_STR_PARSE_ERANGE);
}
if (p == NULL || *p == '\0') {
/*
* projid field shouldn't be empty
*/
return (NSS_STR_PARSE_PARSE);
}
/*
* projids should be positive number
*/
return (NSS_STR_PARSE_PARSE);
}
if (p == NULL) {
/*
* comment field can be empty but should not be last field
*/
return (NSS_STR_PARSE_PARSE);
}
project->pj_comment = p;
/*
* users field should not be last field
*/
return (NSS_STR_PARSE_PARSE);
}
/*
* groups field should not be last field
*/
return (NSS_STR_PARSE_PARSE);
}
/*
* attributes field should be last
*/
return (NSS_STR_PARSE_PARSE);
}
if (p == NULL || *p == '\0') {
*uglist = 0;
break;
}
*uglist++ = p;
}
return (NSS_STR_PARSE_ERANGE);
uglist++;
if (p == NULL || *p == '\0') {
*uglist = 0;
break;
}
*uglist++ = p;
}
return (NSS_STR_PARSE_ERANGE);
return (NSS_STR_PARSE_SUCCESS);
}