From b76f48320c5b5f6d44afab6e67b2da6c8f77c08b Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 29 May 2015 10:07:20 +0000 Subject: Remove dead declaration PR: 195928 MFC after: 2 days --- pw/pwupd.h | 1 - 1 file changed, 1 deletion(-) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index d6e39ce..1d13511 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -93,7 +93,6 @@ char * getpwpath(char const * file); int addgrent(struct group * grp); int delgrent(struct group * grp); int chggrent(char const * name, struct group * grp); -int editgroups(char *name, char **groups); int setgrdir(const char * dir); char * getgrpath(const char *file); -- cgit v1.2.3 From f1cacd691c6b62757f4a0168eded3d8672a06b13 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 3 Jun 2015 19:08:25 +0000 Subject: New pw -R rootdir option This allows to set an alternate root directory in which the users/groups will be manipulated Requested by: gjb, ian Tested by: gjb --- pw/pwupd.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index 1d13511..f936483 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -71,6 +71,10 @@ extern struct pwf VPWF; #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" -- cgit v1.2.3 From 39d77815028ba1a72509c07e0a8583493f6ec0a8 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 14:34:38 +0000 Subject: Add a new global struct pwconf to store etcpath, rootdir and struct userconf Do not add anymore -R and -V to arglist Add an error message if both -V and -R are set in arguments --- pw/pwupd.h | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index f936483..a17dacf 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -29,6 +29,7 @@ #ifndef _PWUPD_H_ #define _PWUPD_H_ +#include #include #include #include @@ -41,8 +42,7 @@ #define RET_SETGRENT void #endif -struct pwf -{ +struct pwf { int _altdir; void (*_setpwent)(void); void (*_endpwent)(void); @@ -56,8 +56,38 @@ struct pwf struct group * (*_getgrnam)(const char * nam); }; +struct userconf { + int default_password; /* Default password for new users? */ + int reuse_uids; /* Reuse uids? */ + int reuse_gids; /* Reuse gids? */ + char *nispasswd; /* Path to NIS version of the passwd file */ + char *dotdir; /* Where to obtain skeleton files */ + char *newmail; /* Mail to send to new accounts */ + char *logfile; /* Where to log changes */ + char *home; /* Where to create home directory */ + mode_t homemode; /* Home directory permissions */ + char *shelldir; /* Where shells are located */ + char **shells; /* List of shells */ + char *shell_default; /* Default shell */ + char *default_group; /* Default group number */ + char **groups; /* Default (additional) groups */ + char *default_class; /* Default user class */ + uid_t min_uid, max_uid; /* Allowed range of uids */ + gid_t min_gid, max_gid; /* Allowed range of gids */ + int expire_days; /* Days to expiry */ + int password_days; /* Days to password expiry */ + int numgroups; /* (internal) size of default_group array */ +}; + +struct pwconf { + char rootdir[MAXPATHLEN]; + char etcpath[MAXPATHLEN]; + struct userconf *userconf; +}; + extern struct pwf PWF; extern struct pwf VPWF; +extern struct pwconf conf; #define SETPWENT() PWF._setpwent() #define ENDPWENT() PWF._endpwent() @@ -91,14 +121,12 @@ int addpwent(struct passwd * pwd); int delpwent(struct passwd * pwd); int chgpwent(char const * login, struct passwd * pwd); -int setpwdir(const char * dir); char * getpwpath(char const * file); int addgrent(struct group * grp); int delgrent(struct group * grp); int chggrent(char const * name, struct group * grp); -int setgrdir(const char * dir); char * getgrpath(const char *file); void vsetpwent(void); -- cgit v1.2.3 From e6c20d74e9c630e7116f84d3712c178369b10c96 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 14:57:16 +0000 Subject: Sort headers --- pw/pwupd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index a17dacf..a5d6c27 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -29,13 +29,13 @@ #ifndef _PWUPD_H_ #define _PWUPD_H_ +#include #include #include + #include #include -#include - #if defined(__FreeBSD__) #define RET_SETGRENT int #else -- cgit v1.2.3 From 577824cadb88a52417c8a551d1aa6b70b2224b22 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 15:09:53 +0000 Subject: Handle dryrun (-N) via global pwconf --- pw/pwupd.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index a5d6c27..ec9ac30 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -35,6 +35,7 @@ #include #include +#include #if defined(__FreeBSD__) #define RET_SETGRENT int @@ -82,6 +83,7 @@ struct userconf { struct pwconf { char rootdir[MAXPATHLEN]; char etcpath[MAXPATHLEN]; + bool dryrun; struct userconf *userconf; }; -- cgit v1.2.3 From fec3dfc01be2e26eb5df5998a06066e2064e0a4b Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 15:27:17 +0000 Subject: Handle pretty print (-P) via global pwconf --- pw/pwupd.h | 1 + 1 file changed, 1 insertion(+) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index ec9ac30..63aaa64 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -84,6 +84,7 @@ struct pwconf { char rootdir[MAXPATHLEN]; char etcpath[MAXPATHLEN]; bool dryrun; + bool pretty; struct userconf *userconf; }; -- cgit v1.2.3 From 8b4eba30cac45e27a97d4e86a8e8506b0e8dc318 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 15:33:08 +0000 Subject: Handle -7 via gloval pwconf --- pw/pwupd.h | 1 + 1 file changed, 1 insertion(+) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index 63aaa64..573e063 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -85,6 +85,7 @@ struct pwconf { char etcpath[MAXPATHLEN]; bool dryrun; bool pretty; + bool v7; struct userconf *userconf; }; -- cgit v1.2.3 From 34211cbde959d55fb8e6b818365341d0193e7253 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 19:33:25 +0000 Subject: In case of rename validate the length of the new name Check early that the new name fits MAXLOGNAME and store it in pwconf --- pw/pwupd.h | 1 + 1 file changed, 1 insertion(+) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index 573e063..ebf78dc 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -83,6 +83,7 @@ struct userconf { struct pwconf { char rootdir[MAXPATHLEN]; char etcpath[MAXPATHLEN]; + char *newname; bool dryrun; bool pretty; bool v7; -- cgit v1.2.3 From 068c2f64c08c71d084c16d066a0fb3802e26b7a9 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 19:59:01 +0000 Subject: Fix duplicate checking --- pw/pwupd.h | 1 + 1 file changed, 1 insertion(+) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index ebf78dc..a67e6db 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -87,6 +87,7 @@ struct pwconf { bool dryrun; bool pretty; bool v7; + bool checkduplicate; struct userconf *userconf; }; -- cgit v1.2.3 From 5b291029a9ed6f6ac19b03b29501179559dc07c3 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 7 Jun 2015 20:44:06 +0000 Subject: Fix generating configuration file --- pw/pwupd.h | 1 + 1 file changed, 1 insertion(+) (limited to 'pw/pwupd.h') diff --git a/pw/pwupd.h b/pw/pwupd.h index a67e6db..8f46e7d 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -84,6 +84,7 @@ struct pwconf { char rootdir[MAXPATHLEN]; char etcpath[MAXPATHLEN]; char *newname; + char *config; bool dryrun; bool pretty; bool v7; -- cgit v1.2.3