passwdutil.h 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _PASSWDUTIL_H
#define _PASSWDUTIL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <shadow.h>
#include <crypt.h> /* CRYPT_MAXCIPHERTEXTLEN max crypt length */
/* DAY_NOW_32 is a 32-bit value, independent of the architecture */
#ifdef _LP64
#else
#endif
typedef enum {
/* from plain passwd */
ATTR_NAME = 0x1,
ATTR_PASSWD = 0x2,
ATTR_UID = 0x4,
ATTR_GID = 0x8,
ATTR_AGE = 0x10,
ATTR_COMMENT = 0x20,
ATTR_GECOS = 0x40,
ATTR_HOMEDIR = 0x80,
ATTR_SHELL = 0x100,
/* from shadow */
ATTR_LSTCHG = 0x200,
ATTR_MIN = 0x400,
ATTR_MAX = 0x800,
ATTR_WARN = 0x1000,
ATTR_INACT = 0x2000,
ATTR_EXPIRE = 0x4000,
ATTR_FLAG = 0x8000,
/* special operations */
ATTR_LOCK_ACCOUNT = 0x10000,
ATTR_EXPIRE_PASSWORD = 0x20000,
ATTR_NOLOGIN_ACCOUNT = 0x40000,
ATTR_UNLOCK_ACCOUNT = 0x80000,
/* Query operations */
/* to obtain repository name that contained the info */
ATTR_REP_NAME = 0x100000,
/* special attribute */
/* to set password following server policy */
ATTR_PASSWD_SERVER_POLICY = 0x200000,
/* get history entry from supporting repositories */
ATTR_HISTORY = 0x400000,
/* Failed login bookkeeping */
} attrtype;
typedef struct attrlist_s {
union {
char *val_s;
int val_i;
} data;
struct attrlist_s *next;
} attrlist;
typedef struct {
char *type;
void *scope;
#define REP_NOREP 0 /* Can't find suitable repository */
#define REP_NIS 0x0002
#define REP_NISPLUS 0x0004
#define REP_LDAP 0x0008
#define REP_NSS 0x0010
#define REP_COMPAT_NIS 0x1000
#define REP_COMPAT_NISPLUS 0x2000
#define REP_COMPAT_LDAP 0x4000
/* For the time being, these are also defined in pam_*.h */
#define MINWEEKS -1
#define MAXWEEKS -1
#define WARNWEEKS -1
#define NISPLUS_LOOKUP 0
#define NISPLUS_UPDATE 1
typedef struct repops {
int (*checkhistory)(char *, char *, pwu_repository_t *);
int (*putpwnam)(char *, char *, char *, pwu_repository_t *, void *);
int (*user_to_authenticate)(char *, pwu_repository_t *, char **, int *);
int (*lock)(void);
int (*unlock)(void);
} repops_t;
/*
* utils.c
*/
void turn_on_default_aging(struct spwd *);
/*
* debug.c
*/
void debug_init(void);
void debug(char *, ...);
/*
*/
char *strsep(char **, const char *);
/*
*/
#define PWU_READ 0 /* Read access to the repository */
int get_ns(pwu_repository_t *, int);
/*
*/
int __set_authtoken_attr(char *, char *, char *, pwu_repository_t *,
attrlist *, int *);
/*
*/
/*
*/
int __user_to_authenticate(char *, pwu_repository_t *, char **, int *);
/*
*/
int __verify_rpc_passwd(char *, char *, pwu_repository_t *);
/*
* Password history definitions
*/
#define DEFHISTORY 0 /* default history depth */
/*
* __check_history.c
*/
int __check_history(char *, char *, pwu_repository_t *);
int __incr_failed_count(char *, char *, int);
int __rst_failed_count(char *, char *);
/*
* Error codes
*/
#define PWU_SUCCESS 0 /* update succeeded */
/* NISPLUS specific errors */
/* More errors, not NISPLUS specific */
#ifdef __cplusplus
}
#endif
#endif /* _PASSWDUTIL_H */