diff options
author | Eric Andersen | 2002-06-23 04:24:25 +0000 |
---|---|---|
committer | Eric Andersen | 2002-06-23 04:24:25 +0000 |
commit | 27f64e1f4eb4354844f6553e37501deffde8373e (patch) | |
tree | 632fbb26b13ad67f6efa335c33a22551b2707930 /loginutils/adduser.c | |
parent | 0fbff134f400ea51540cfd6ef5eeaeab60f9a5de (diff) | |
download | busybox-27f64e1f4eb4354844f6553e37501deffde8373e.zip busybox-27f64e1f4eb4354844f6553e37501deffde8373e.tar.gz |
Port over the last of the tinylogin applets
-Erik
Diffstat (limited to 'loginutils/adduser.c')
-rw-r--r-- | loginutils/adduser.c | 56 |
1 files changed, 4 insertions, 52 deletions
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 66fcaa2..7aa7fcf 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c @@ -33,11 +33,7 @@ #include <sys/stat.h> #include <sys/types.h> #include "busybox.h" -#include "pwd.h" -#include "grp.h" -#define PASSWD_FILE "/etc/passwd" -#define SHADOW_FILE "/etc/shadow" /* structs __________________________ */ @@ -56,9 +52,6 @@ static const char default_home_prefix[] = "/home"; static const char default_shell[] = "/bin/sh"; #ifdef CONFIG_FEATURE_SHADOWPASSWDS - -#include "shadow.h" - /* shadow in use? */ static int shadow_enabled = 0; #endif @@ -138,47 +131,6 @@ static void passwd_wrapper(const char *login) error_msg_and_die("Failed to execute 'passwd', you must set the password for '%s' manually", login); } -#ifdef CONFIG_FEATURE_SHADOWPASSWDS -/* - * pwd_to_spwd - create entries for new spwd structure - * - * pwd_to_spwd() creates a new (struct spwd) containing the - * information in the pointed-to (struct passwd). - */ -#define DAY (24L*3600L) -#define WEEK (7*DAY) -#define SCALE DAY -static struct spwd *pwd_to_spwd(const struct passwd *pw) -{ - static struct spwd sp; - - /* - * Nice, easy parts first. The name and passwd map directly - * from the old password structure to the new one. - */ - sp.sp_namp = pw->pw_name; - sp.sp_pwdp = pw->pw_passwd; - - /* - * Defaults used if there is no pw_age information. - */ - sp.sp_min = 0; - sp.sp_max = (10000L * DAY) / SCALE; - sp.sp_lstchg = time((time_t *) 0) / SCALE; - - /* - * These fields have no corresponding information in the password - * file. They are set to uninitialized values. - */ - sp.sp_warn = -1; - sp.sp_expire = -1; - sp.sp_inact = -1; - sp.sp_flag = -1; - - return &sp; -} -#endif - /* putpwent(3) remix */ static int adduser(const char *filename, struct passwd *p) { @@ -222,7 +174,7 @@ static int adduser(const char *filename, struct passwd *p) #ifdef CONFIG_FEATURE_SHADOWPASSWDS /* add to shadow if necessary */ if (shadow_enabled) { - shadow = wfopen(SHADOW_FILE, "a"); + shadow = wfopen(shadow_file, "a"); if (shadow == NULL) { /* return -1; */ return 1; @@ -333,7 +285,7 @@ int adduser_main(int argc, char **argv) } #ifdef CONFIG_FEATURE_SHADOWPASSWDS /* is /etc/shadow in use? */ - shadow_enabled = (0 == access(SHADOW_FILE, F_OK)); + shadow_enabled = (0 == access(shadow_file, F_OK)); #endif /* create a passwd struct */ @@ -346,7 +298,7 @@ int adduser_main(int argc, char **argv) pw.pw_shell = (char *)shell; /* grand finale */ - return adduser(PASSWD_FILE, &pw); + return adduser(passwd_file, &pw); } -/* $Id: adduser.c,v 1.1 2002/06/04 20:45:05 sandman Exp $ */ +/* $Id: adduser.c,v 1.2 2002/06/23 04:24:24 andersen Exp $ */ |