#ifndef _PWUPD_H_
#define _PWUPD_H_
#include <sys/param.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
#include <stdbool.h>
#include <stringlist.h>
struct pwf {
int _altdir;
void (*_setpwent)(void);
void (*_endpwent)(void);
struct passwd * (*_getpwent)(void);
struct passwd * (*_getpwuid)(uid_t uid);
struct passwd * (*_getpwnam)(const char * nam);
void (*_setgrent)(void);
void (*_endgrent)(void);
struct group * (*_getgrent)(void);
struct group * (*_getgrgid)(gid_t gid);
struct group * (*_getgrnam)(const char * nam);
};
struct userconf {
int default_password;
int reuse_uids;
int reuse_gids;
char *nispasswd;
char *dotdir;
char *newmail;
char *logfile;
char *home;
mode_t homemode;
char *shelldir;
char **shells;
char *shell_default;
char *default_group;
StringList *groups;
char *default_class;
uid_t min_uid, max_uid;
gid_t min_gid, max_gid;
time_t expire_days;
time_t password_days;
};
struct pwconf {
char rootdir[MAXPATHLEN];
char etcpath[MAXPATHLEN];
FILE *metalog;
int fd;
int rootfd;
bool altroot;
bool checkduplicate;
};
extern struct pwf PWF;
extern struct pwf VPWF;
extern struct pwconf conf;
#define SETPWENT() PWF._setpwent()
#define ENDPWENT() PWF._endpwent()
#define GETPWENT() PWF._getpwent()
#define GETPWUID(uid) PWF._getpwuid(uid)
#define GETPWNAM(nam) PWF._getpwnam(nam)
#define SETGRENT() PWF._setgrent()
#define ENDGRENT() PWF._endgrent()
#define GETGRENT() PWF._getgrent()
#define GETGRGID(gid) PWF._getgrgid(gid)
#define GETGRNAM(nam) PWF._getgrnam(nam)
#define PWF_REGULAR 0
#define PWF_ALT 1
#define PWF_ROOTDIR 2
#define PWALTDIR() PWF._altdir
#ifndef _PATH_PWD
#define _PATH_PWD "/etc"
#endif
#ifndef _GROUP
#define _GROUP "group"
#endif
#ifndef _MASTERPASSWD
#define _MASTERPASSWD "master.passwd"
#endif
__BEGIN_DECLS
int addpwent(struct passwd * pwd);
int delpwent(struct passwd * pwd);
int chgpwent(char const * login, struct passwd * pwd);
char * getpwpath(char const * file);
int addgrent(struct group * grp);
int delgrent(struct group * grp);
int chggrent(char const * name, struct group * grp);
char * getgrpath(const char *file);
void vsetpwent(void);
void vendpwent(void);
struct passwd * vgetpwent(void);
struct passwd * vgetpwuid(uid_t uid);
struct passwd * vgetpwnam(const char * nam);
struct group * vgetgrent(void);
struct group * vgetgrgid(gid_t gid);
struct group * vgetgrnam(const char * nam);
void vsetgrent(void);
void vendgrent(void);
void copymkdir(int rootfd, char const * dir, int skelfd, mode_t mode, uid_t uid,
gid_t gid, int flags);
bool rm_r(int rootfd, char const * dir, uid_t uid);
__END_DECLS
#endif