makelocalcred.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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.
*
* 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
*/
/*
*
* Copyright (c) 1988-1992 Sun Microsystems Inc
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* Make a "local" credential. The local credential is used to map from
* a UID in the nis_local_directory() to a principal name in some other
* NIS+ directory. Needless to say the principal name is required and
* this function must be run as the NIS+ administrator.
*/
#include <stdio.h>
#include <pwd.h>
#include <limits.h>
#include "nisaddcred.h"
/*
* _getgroupsbymember(uname, gid_array, maxgids, numgids):
* This function can be found in libc/port/gen/getgrnam_r.c.
* It's a private interface mainly for initgroups(). It returns the
* group ids of groups of which the specified user is a member.
*/
extern int _getgroupsbymember(const char *, gid_t[], int, int);
struct cback_info {
char *username;
int gidcnt;
int maxgids;
};
static
int
struct cback_info *info;
{
int i;
return (1); /* don't insert dup, but not error */
}
return (0); /* no room */
return (1);
}
int
void *udata;
{
int len;
char *p;
char *members;
char *gid;
char *gname;
int gidval;
while (*members) {
members++;
if (*members == '\0')
break;
p = members;
members++;
return (1); /* no more room */
}
}
if (*members == ',')
members++;
}
return (0);
}
/*
* Get groups from an NIS+ domain. If that doesn't yield any
* groups and the domain was not specified on the command line,
* then we try the local routines for getting group ids.
*/
static
int
char *domain;
char *username;
int maxgids;
{
struct cback_info info;
char name[1024];
#ifdef USE_LOCAL_INFO
/*
* If no domain was specified on the command line and we didn't get
* any extra gids from NIS+, then try getting them locally.
*/
else
/* if getgroups failed, put basegid back in list */
}
}
#endif /* USE_LOCAL_INFO */
}
int
char *nisprinc;
char *uidstr;
char *domain;
char *flavor; /* Ignored. */
{
int i, gidlen;
struct passwd *domain_getpwuid();
"%s: invalid local principal '%s' (must be number)\n",
return (0);
}
if (uid == 0) {
return (0);
}
if (!pw)
return (0);
if (nisprinc == 0)
else
/* Another principal owns same credentials? (exits if that happens) */
/* build up list of group ids */
return (0);
}
pdata[0] = '\0';
for (i = 0; i < gidlen; i++) {
if ((i + 1) < gidlen)
else
}
if (addition) {
/* owner: rmcd, group: rmcd */
} else {
/* columns that could have changed */
}
return (status);
}
/*
* Return a string representation of the "LOCAL" authentication name.
* In this case it is easy, its our uid.
*/
char *
char *domain; /* ignored for local case */
char *flavor; /* ignored */
{
return (myname);
}