makedescred.c revision 7d1e83948cb684521e72cab96020be241508f449
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* Make a "AUTH_DES" credential. This is the old secure rpc credentials from
* SunOS 4.0 and Vanilla System V release 4.0.
*/
#include <stdio.h>
#include <stdlib.h>
#include <pwd.h>
#include <shadow.h>
#include <string.h>
#include <ctype.h>
#include <nsswitch.h>
#include <netdb.h>
#include <rpcsvc/nispasswd.h>
#include <rpcsvc/nis_dhext.h>
#include <rpc/key_prot.h>
#include "nisaddcred.h"
#include <assert.h>
extern char *getpass();
extern char *crypt();
extern void __gen_dhkeys(char *, char *, char *);
extern int add_cred_obj(nis_object *, char *);
extern int check_switch_policy(char *, char *, struct __nsw_switchconfig *,
char *, char *);
extern nis_error cred_exists(char *, char *, char *);
extern char *get_password(uid_t, int, char *, char *);
extern int is_switch_policy(struct __nsw_switchconfig *, char *);
extern int make_dhext_cred(char *, char *, char *, char *);
extern int modify_cred_obj(nis_object *, char *);
extern int no_switch_policy(struct __nsw_switchconfig *);
extern int sanity_checks(char *, char *, char *, char *);
extern char *switch_policy_str(struct __nsw_switchconfig *);
extern int xencrypt(char *, char *);
static const char *OPSYS = "unix";
#define OPSYS_LEN 4
/* ************************ switch functions *************************** */
/* NSW_NOTSUCCESS NSW_NOTFOUND NSW_UNAVAIL NSW_TRYAGAIN */
/* ***************************** keylogin stuff *************************** */
int
{
struct key_netstarg netst;
netst.st_pub_key[0] = 0;
#ifdef NFS_AUTH
perror("Warning: NFS credentials not destroyed");
err = 1;
}
#endif /* NFS_AUTH */
/* do actual key login */
if (key_setnet(&netst) < 0) {
return (0);
}
return (1);
}
/*
* Definitions of the credential table.
*
* Column Name Contents
* ------ ---- --------
* 0 cname nis principal name
* 1 auth_type DES
* 2 auth_name netname
* 3 public_auth_data public key
* 4 private_auth_data encrypted secret key with checksum
*/
/*
* Function for building DES credentials.
*
* The domain may be the local domain or some remote domain.
* 'domain' should be the same as the domain found in netname,
* which should be the home domain of nis+ principal.
*/
int
{
char *pass;
int same_host = 0;
return (0);
uid = 0; /* root */
same_host = 1;
} else {
}
if (pass == 0)
return (0);
/* Get password with which to encrypt secret key. */
(void) printf("%s key pair for %s (%s).\n",
/* Encrypt secret key */
/* Now we have a key pair, build up the cred entry */
#ifdef OLD_MODE
#endif
if (addition) {
/* owner: r, group: rmcd */
NIS_DESTROY_ACC)<<8);
} else {
}
/* attempt keylogin if appropriate */
if (status) {
}
return (status);
}
int
{
int status = 0;
int i = 0;
while (mechlist[i]) {
if (!status)
return (status);
i++;
}
} else
return (status);
}
char *
char *domain;
char *flavor; /* Ignored. */
{
if (uid == 0)
else {
/* generate netname using uid and domain information. */
int len;
goto not_found;
}
status = 1;
}
if (status == 1) {
return (netname);
}
return (NULL);
}