Mercurial > hg > toybox
diff toys/pending/useradd.c @ 1183:0752b2d58909 draft
Rename xmsprintf() to just xmprintf().
Partly because there's no supplied target string ala sprintf, and partly
because I can never remember what order the m and s go in.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 16 Jan 2014 09:26:50 -0600 |
parents | c4d4a6e7473f |
children | 85f297591693 |
line wrap: on
line diff
--- a/toys/pending/useradd.c Wed Jan 15 09:38:31 2014 -0600 +++ b/toys/pending/useradd.c Thu Jan 16 09:26:50 2014 -0600 @@ -90,7 +90,7 @@ args[0] = "chown"; args[1] = "-R"; - args[2] = xmsprintf("%u:%u", TT.uid, TT.gid); + args[2] = xmprintf("%u:%u", TT.uid, TT.gid); args[3] = hdir; //Change ownership to that of UID and GID of new user toys.exitval = exec_wait(args); @@ -118,7 +118,7 @@ if (toys.optflags & FLAG_g) pwd.pw_gecos = TT.gecos; else pwd.pw_gecos = "Linux User,"; if (toys.optflags & FLAG_h) pwd.pw_dir = TT.dir; - else pwd.pw_dir = xmsprintf("/home/%s", *toys.optargs); + else pwd.pw_dir = xmprintf("/home/%s", *toys.optargs); if (toys.optflags & FLAG_s) pwd.pw_shell = TT.shell; else pwd.pw_shell = get_shell(); @@ -168,7 +168,7 @@ //add group, invoke addgroup command args[0] = "groupadd"; args[1] = toys.optargs[0]; - args[2] = xmsprintf("-g%ld", pwd.pw_gid); + args[2] = xmprintf("-g%ld", pwd.pw_gid); args[3] = NULL; if (exec_wait(args)) error_msg("addgroup fail"); } @@ -180,15 +180,15 @@ */ // 1. add an entry to /etc/passwd and /etc/shadow file - entry = xmsprintf("%s:%s:%ld:%ld:%s:%s:%s", pwd.pw_name, pwd.pw_passwd, + entry = xmprintf("%s:%s:%ld:%ld:%s:%s:%s", pwd.pw_name, pwd.pw_passwd, pwd.pw_uid, pwd.pw_gid, pwd.pw_gecos, pwd.pw_dir, pwd.pw_shell); if (update_password("/etc/passwd", pwd.pw_name, entry)) error_exit("updating passwd file failed"); free(entry); if (toys.optflags & FLAG_S) - entry = xmsprintf("%s:!!:%u::::::", pwd.pw_name, + entry = xmprintf("%s:!!:%u::::::", pwd.pw_name, (unsigned)(time(NULL))/(24*60*60)); //passwd is not set initially - else entry = xmsprintf("%s:!!:%u:%ld:%ld:%ld:::", pwd.pw_name, + else entry = xmprintf("%s:!!:%u:%ld:%ld:%ld:::", pwd.pw_name, (unsigned)(time(NULL))/(24*60*60), 0, 99999, 7); //passwd is not set initially update_password("/etc/shadow", pwd.pw_name, entry); free(entry);