#ifndef _PASSWDUTIL_H
#define _PASSWDUTIL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <shadow.h>
#include <crypt.h>
#ifdef _LP64
#include <sys/types32.h>
#define DAY_NOW_32 ((time32_t)DAY_NOW)
#else
#define DAY_NOW_32 ((time_t)DAY_NOW)
#endif
typedef enum {
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,
ATTR_LSTCHG = 0x200,
ATTR_MIN = 0x400,
ATTR_MAX = 0x800,
ATTR_WARN = 0x1000,
ATTR_INACT = 0x2000,
ATTR_EXPIRE = 0x4000,
ATTR_FLAG = 0x8000,
ATTR_LOCK_ACCOUNT = 0x10000,
ATTR_EXPIRE_PASSWORD = 0x20000,
ATTR_NOLOGIN_ACCOUNT = 0x40000,
ATTR_UNLOCK_ACCOUNT = 0x80000,
ATTR_REP_NAME = 0x100000,
ATTR_PASSWD_SERVER_POLICY = 0x200000,
ATTR_HISTORY = 0x400000,
ATTR_FAILED_LOGINS = 0x800000,
ATTR_INCR_FAILED_LOGINS = 0x1000000,
ATTR_RST_FAILED_LOGINS = 0x2000000
} attrtype;
typedef struct attrlist_s {
attrtype type;
union {
char *val_s;
int val_i;
} data;
struct attrlist_s *next;
} attrlist;
typedef struct {
char *type;
void *scope;
size_t scope_len;
} pwu_repository_t;
#define PWU_DEFAULT_REP (pwu_repository_t *)NULL
#define REP_NOREP 0
#define REP_FILES 0x0001
#define REP_NIS 0x0002
#define REP_LDAP 0x0004
#define REP_NSS 0x0008
#define REP_LAST REP_NSS
#define REP_ERANGE 0x8000
#define REP_COMPAT_NIS 0x1000
#define REP_COMPAT_LDAP 0x2000
#undef IS_FILES
#undef IS_NIS
#undef IS_LDAP
#define IS_FILES(r) (r.type != NULL && strcmp(r.type, "files") == 0)
#define IS_NIS(r) (r.type != NULL && strcmp(r.type, "nis") == 0)
#define IS_LDAP(r) (r.type != NULL && strcmp(r.type, "ldap") == 0)
#define MINWEEKS -1
#define MAXWEEKS -1
#define WARNWEEKS -1
typedef struct repops {
int (*checkhistory)(const char *, const char *, pwu_repository_t *);
int (*getattr)(const char *, attrlist *, pwu_repository_t *);
int (*getpwnam)(const char *, attrlist *, pwu_repository_t *, void **);
int (*update)(attrlist *, pwu_repository_t *, void *);
int (*putpwnam)(const char *, const char *, pwu_repository_t *, void *);
int (*user_to_authenticate)(const char *, pwu_repository_t *, char **,
int *);
int (*lock)(void);
int (*unlock)(void);
} repops_t;
extern repops_t files_repops, nis_repops, ldap_repops, nss_repops;
extern repops_t *rops[];
void turn_on_default_aging(struct spwd *);
int def_getint(char *name, int defvalue);
void debug_init(void);
void debug(char *, ...);
#define PWU_READ 0
#define PWU_WRITE 1
int get_ns(pwu_repository_t *, int);
struct passwd *getpwnam_from(const char *, pwu_repository_t *, int);
struct passwd *getpwuid_from(uid_t, pwu_repository_t *, int);
struct spwd *getspnam_from(const char *, pwu_repository_t *, int);
int name_to_int(char *);
int __set_authtoken_attr(const char *, const char *, pwu_repository_t *,
attrlist *, int *);
int __get_authtoken_attr(const char *, pwu_repository_t *, attrlist *);
int __user_to_authenticate(const char *, pwu_repository_t *, char **, int *);
#define DEFHISTORY 0
#define MAXHISTORY 26
int __check_history(const char *, const char *, pwu_repository_t *);
int __incr_failed_count(const char *, char *, int);
int __rst_failed_count(const char *, char *);
#define PWU_SUCCESS 0
#define PWU_BUSY -1
#define PWU_STAT_FAILED -2
#define PWU_OPEN_FAILED -3
#define PWU_WRITE_FAILED -4
#define PWU_CLOSE_FAILED -5
#define PWU_NOT_FOUND -6
#define PWU_UPDATE_FAILED -7
#define PWU_NOMEM -8
#define PWU_SERVER_ERROR -9
#define PWU_SYSTEM_ERROR -10
#define PWU_DENIED -11
#define PWU_NO_CHANGE -12
#define PWU_REPOSITORY_ERROR -13
#define PWU_AGING_DISABLED -14
#define PWU_PWD_TOO_SHORT -15
#define PWU_PWD_INVALID -16
#define PWU_PWD_IN_HISTORY -17
#define PWU_CHANGE_NOT_ALLOWED -18
#define PWU_WITHIN_MIN_AGE -19
#define PWU_ACCOUNT_LOCKED -20
#ifdef __cplusplus
}
#endif
#endif