aboutsummaryrefslogtreecommitdiff
path: root/loginutils/adduser.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
committerRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
commitd921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch)
treee4a2769349867c441cf2983d83097bb66701a733 /loginutils/adduser.c
parent6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff)
downloadbusybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only had one user), clean up lots of #includes... General cleanup pass. What I've been doing for the last couple days. And it conflicts! I've removed httpd.c from this checkin due to somebody else touching that file. It builds for me. I have to catch a bus. (Now you know why I'm looking forward to Mercurial.)
Diffstat (limited to 'loginutils/adduser.c')
-rw-r--r--loginutils/adduser.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index a640ece3b..0133d8288 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -8,14 +8,6 @@
8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
9 */ 9 */
10 10
11#include <stdio.h>
12#include <sys/types.h>
13#include <string.h>
14#include <unistd.h>
15#include <time.h>
16#include <getopt.h>
17#include <sys/stat.h>
18
19#include "busybox.h" 11#include "busybox.h"
20 12
21#define DONT_SET_PASS (1 << 4) 13#define DONT_SET_PASS (1 << 4)
@@ -32,7 +24,7 @@ static int passwd_study(const char *filename, struct passwd *p)
32 const int min = 500; 24 const int min = 500;
33 const int max = 65000; 25 const int max = 65000;
34 26
35 passwd = bb_xfopen(filename, "r"); 27 passwd = xfopen(filename, "r");
36 28
37 /* EDR if uid is out of bounds, set to min */ 29 /* EDR if uid is out of bounds, set to min */
38 if ((p->pw_uid > max) || (p->pw_uid < min)) 30 if ((p->pw_uid > max) || (p->pw_uid < min))
@@ -78,7 +70,7 @@ static void addgroup_wrapper(struct passwd *p)
78{ 70{
79 char *cmd; 71 char *cmd;
80 72
81 cmd = bb_xasprintf("addgroup -g %d \"%s\"", p->pw_gid, p->pw_name); 73 cmd = xasprintf("addgroup -g %d \"%s\"", p->pw_gid, p->pw_name);
82 system(cmd); 74 system(cmd);
83 free(cmd); 75 free(cmd);
84} 76}
@@ -99,7 +91,7 @@ static int adduser(struct passwd *p, unsigned long flags)
99 int addgroup = !p->pw_gid; 91 int addgroup = !p->pw_gid;
100 92
101 /* make sure everything is kosher and setup uid && gid */ 93 /* make sure everything is kosher and setup uid && gid */
102 file = bb_xfopen(bb_path_passwd_file, "a"); 94 file = xfopen(bb_path_passwd_file, "a");
103 fseek(file, 0, SEEK_END); 95 fseek(file, 0, SEEK_END);
104 96
105 switch (passwd_study(bb_path_passwd_file, p)) { 97 switch (passwd_study(bb_path_passwd_file, p)) {
@@ -119,7 +111,7 @@ static int adduser(struct passwd *p, unsigned long flags)
119 111
120#if ENABLE_FEATURE_SHADOWPASSWDS 112#if ENABLE_FEATURE_SHADOWPASSWDS
121 /* add to shadow if necessary */ 113 /* add to shadow if necessary */
122 file = bb_xfopen(bb_path_shadow_file, "a"); 114 file = xfopen(bb_path_shadow_file, "a");
123 fseek(file, 0, SEEK_END); 115 fseek(file, 0, SEEK_END);
124 fprintf(file, "%s:!:%ld:%d:%d:%d:::\n", 116 fprintf(file, "%s:!:%ld:%d:%d:%d:::\n",
125 p->pw_name, /* username */ 117 p->pw_name, /* username */