it takes a new argument allowing to specify the endianness of the database
to generate
Differential Revision: https://reviews.freebsd.org/D2730
Reviewed by: ian
+#define PWDB_NATIVE 0
+#define PWDB_LE 1
+#define PWDB_BE 2
int pw_copy(int _ffd, int _tfd, const struct passwd *_pw,
struct passwd *_old_pw);
struct passwd
int pw_copy(int _ffd, int _tfd, const struct passwd *_pw,
struct passwd *_old_pw);
struct passwd
char *pw_make(const struct passwd *_pw);
char *pw_make_v7(const struct passwd *_pw);
int pw_mkdb(const char *_user);
char *pw_make(const struct passwd *_pw);
char *pw_make_v7(const struct passwd *_pw);
int pw_mkdb(const char *_user);
+int pw_mkdb2(const char *_user, int endian);
int pw_lock(void);
struct passwd *
pw_scan(const char *_line, int _flags);
int pw_lock(void);
struct passwd *
pw_scan(const char *_line, int _flags);
+int
+pw_mkdb(const char *user)
+{
+
+ return (pw_mkdb2(user, PWDB_NATIVE));
+}
+
/*
* Regenerate the password database.
*/
int
/*
* Regenerate the password database.
*/
int
-pw_mkdb(const char *user)
+pw_mkdb2(const char *user, int endian)
+ const char *arg;
+
+ switch (endian) {
+ case PWDB_NATIVE:
+ arg = "-p";
+ break;
+ case PWDB_LE:
+ arg = "-pL";
+ break;
+ case PWDB_BE:
+ arg = "-pB";
+ break;
+ default:
+ return (-1);
+ }
(void)fflush(stderr);
switch ((pid = fork())) {
(void)fflush(stderr);
switch ((pid = fork())) {
case 0:
/* child */
if (user == NULL)
case 0:
/* child */
if (user == NULL)
- execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p",
+ execl(_PATH_PWD_MKDB, "pwd_mkdb", arg,
"-d", passwd_dir, tempname, (char *)NULL);
else
"-d", passwd_dir, tempname, (char *)NULL);
else
- execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p",
+ execl(_PATH_PWD_MKDB, "pwd_mkdb", arg,
"-d", passwd_dir, "-u", user, tempname,
(char *)NULL);
_exit(1);
"-d", passwd_dir, "-u", user, tempname,
(char *)NULL);
_exit(1);