auths.c revision 49a66a682b5ea524222294a1268bb1a9e7ac3af5
/*
* 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
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
#include <string.h>
#include <deflt.h>
#include <libintl.h>
#include <locale.h>
#include <user_attr.h>
#include <prof_attr.h>
#include <auth_attr.h>
#define ALL_AUTHS "All"
#define ALL_SUN_AUTHS "solaris.*"
#define EXIT_OK 0
#define EXIT_FATAL 1
#define EXIT_NON_FATAL 2
#ifndef TEXT_DOMAIN /* Should be defined by cc -D */
#define TEXT_DOMAIN "SYS_TEST"
#endif
#define PROFLIST_SEP ","
#define AUTH_SEP ","
#define MAXAUTHS 4096
static int show_auths(char *, char **, int, int);
static int list_auths(userattr_t *, char **, int *);
static void get_default_auths(char *, char **, int *);
static void getProfiles(char *, char **, int *, char **, int *);
static void add_auths(char *, char **, int *);
static void free_auths(char **, int *);
static char *progname = "auths";
int
{
int defauth_cnt = 0;
(void) textdomain(TEXT_DOMAIN);
switch (argc) {
case 1:
break;
case 2:
break;
default:
while (*++argv) {
if (status == EXIT_FATAL) {
break;
}
/* free memory allocated for default authorizations */
(void) printf("\n");
}
break;
}
/* free memory allocated for default authorizations */
return (status);
}
static int
{
int userauth_cnt = 0, old_userauth_cnt;
int i, j, have_allauths, duplicate;
return (status);
}
return (status);
}
have_allauths = 0;
/* if ALL_AUTHS is default, don't need to look at other auths */
for (i = 0; i < defauth_cnt; i++) {
have_allauths = 1;
break;
}
}
if (have_allauths) {
/* check if any profiles have ALL_AUTHS */
for (i = 0; i < userauth_cnt; i++) {
have_allauths = 1;
break;
}
}
}
if ((defauth_cnt + userauth_cnt) == 0) {
}
}
if (status == EXIT_NON_FATAL) {
} else {
if (print_name) {
}
if (have_allauths) {
} else {
/*
* combine the user auths and default auths,
* and eliminate duplicates from the two
*/
for (i = 0; i < defauth_cnt; i++) {
duplicate = 0;
for (j = 0; j < old_userauth_cnt; j++) {
0) {
duplicate = 1;
break;
}
}
if (!duplicate) {
userauth_cnt++;
}
}
/* print out the auths */
for (i = 0; i < (userauth_cnt - 1); i++) {
}
/* print out the last entry, without the comma */
}
}
/* free memory allocated for authorizations */
return (status);
}
static int
{
int profcnt = 0;
}
if (authcnt == 0) {
}
} else {
}
if (authcnt == 0) {
}
return (status);
}
static void
{
int profcnt = 0;
}
}
}
/* get authorizations from default profiles */
}
}
}
void
{
int i;
} else {
}
/* check to see if authorization is already in list */
for (i = 0; i < *authcnt; i++) {
break; /* already in list */
}
}
/* not in list, add it in */
if (i == *authcnt) {
*authcnt = i + 1;
}
}
}
static void
{
int i;
for (i = 0; i < *auth_cnt; i++) {
}
*auth_cnt = 0;
}
static void
{
char *prof;
char *lasts;
profattr_t *pa;
char *auths;
int i;
}
/* get authorizations from list of profiles */
for (i = 0; i < *profcnt; i++) {
/*
* this should never happen.
* unless the database has an undefined profile
*/
continue;
}
/* get auths this profile */
}
}
}