aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-08-03 15:41:12 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-08-03 15:41:12 +0000
commit5e2a5391f9142bca773aab4c829615895b69a6b7 (patch)
treee4a2769349867c441cf2983d83097bb66701a733 /loginutils
parente883e03918a0e26e390ea23996abdb8fc1925f88 (diff)
downloadbusybox-w32-5e2a5391f9142bca773aab4c829615895b69a6b7.tar.gz
busybox-w32-5e2a5391f9142bca773aab4c829615895b69a6b7.tar.bz2
busybox-w32-5e2a5391f9142bca773aab4c829615895b69a6b7.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.) git-svn-id: svn://busybox.net/trunk/busybox@15767 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/addgroup.c11
-rw-r--r--loginutils/adduser.c16
-rw-r--r--loginutils/getty.c17
-rw-r--r--loginutils/passwd.c16
-rw-r--r--loginutils/su.c6
-rw-r--r--loginutils/vlock.c14
6 files changed, 14 insertions, 66 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index f4962ffb9..f5a99b796 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -9,11 +9,6 @@
9 * 9 *
10 */ 10 */
11 11
12#include <stdio.h>
13#include <string.h>
14#include <sys/types.h>
15#include <unistd.h>
16
17#include "busybox.h" 12#include "busybox.h"
18 13
19/* make sure gr_name isn't taken, make sure gid is kosher 14/* make sure gr_name isn't taken, make sure gid is kosher
@@ -26,7 +21,7 @@ static int group_study(struct group *g)
26 struct group *grp; 21 struct group *grp;
27 const int max = 65000; 22 const int max = 65000;
28 23
29 etc_group = bb_xfopen(bb_path_group_file, "r"); 24 etc_group = xfopen(bb_path_group_file, "r");
30 25
31 /* make sure gr_name isn't taken, make sure gid is kosher */ 26 /* make sure gr_name isn't taken, make sure gid is kosher */
32 desired = g->gr_gid; 27 desired = g->gr_gid;
@@ -67,13 +62,13 @@ static int addgroup(char *group, gid_t gid, const char *user)
67 return 1; 62 return 1;
68 63
69 /* add entry to group */ 64 /* add entry to group */
70 file = bb_xfopen(bb_path_group_file, "a"); 65 file = xfopen(bb_path_group_file, "a");
71 /* group:passwd:gid:userlist */ 66 /* group:passwd:gid:userlist */
72 fprintf(file, "%s:%s:%d:%s\n", group, "x", gr.gr_gid, user); 67 fprintf(file, "%s:%s:%d:%s\n", group, "x", gr.gr_gid, user);
73 fclose(file); 68 fclose(file);
74 69
75#if ENABLE_FEATURE_SHADOWPASSWDS 70#if ENABLE_FEATURE_SHADOWPASSWDS
76 file = bb_xfopen(bb_path_gshadow_file, "a"); 71 file = xfopen(bb_path_gshadow_file, "a");
77 fprintf(file, "%s:!::\n", group); 72 fprintf(file, "%s:!::\n", group);
78 fclose(file); 73 fclose(file);
79#endif 74#endif
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 */
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 2d05d9a1c..ebb107d4b 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -16,19 +16,6 @@
16 * 16 *
17 */ 17 */
18 18
19#include <stdio.h>
20#include <stdlib.h>
21#include <unistd.h>
22#include <string.h>
23#include <sys/ioctl.h>
24#include <errno.h>
25#include <sys/stat.h>
26#include <signal.h>
27#include <fcntl.h>
28#include <stdarg.h>
29#include <ctype.h>
30#include <getopt.h>
31#include <termios.h>
32#include "busybox.h" 19#include "busybox.h"
33 20
34#ifdef CONFIG_FEATURE_UTMP 21#ifdef CONFIG_FEATURE_UTMP
@@ -324,7 +311,7 @@ static void parse_args(int argc, char **argv, struct options *op)
324 const char *p = op->initstring; 311 const char *p = op->initstring;
325 char *q; 312 char *q;
326 313
327 q = op->initstring = bb_xstrdup(op->initstring); 314 q = op->initstring = xstrdup(op->initstring);
328 /* copy optarg into op->initstring decoding \ddd 315 /* copy optarg into op->initstring decoding \ddd
329 octal codes into chars */ 316 octal codes into chars */
330 while (*p) { 317 while (*p) {
@@ -858,7 +845,7 @@ int getty_main(int argc, char **argv)
858 }; 845 };
859 846
860#ifdef DEBUGGING 847#ifdef DEBUGGING
861 dbf = bb_xfopen(DEBUGTERM, "w"); 848 dbf = xfopen(DEBUGTERM, "w");
862 849
863 { 850 {
864 int i; 851 int i;
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 7745444c0..aa75dd260 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -3,20 +3,8 @@
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
4 */ 4 */
5 5
6#include <fcntl.h>
7#include <stdio.h>
8#include <string.h>
9#include <signal.h>
10#include <sys/stat.h>
11#include <sys/types.h>
12#include <unistd.h>
13#include <utime.h>
14#include <syslog.h>
15#include <time.h>
16#include <sys/resource.h>
17#include <errno.h>
18
19#include "busybox.h" 6#include "busybox.h"
7#include <syslog.h>
20 8
21static char crypt_passwd[128]; 9static char crypt_passwd[128];
22 10
@@ -170,7 +158,7 @@ int passwd_main(int argc, char **argv)
170 bb_show_usage(); 158 bb_show_usage();
171 } 159 }
172 } 160 }
173 myname = (char *) bb_xstrdup(bb_getpwuid(NULL, getuid(), -1)); 161 myname = (char *) xstrdup(bb_getpwuid(NULL, getuid(), -1));
174 /* exits on error */ 162 /* exits on error */
175 if (optind < argc) { 163 if (optind < argc) {
176 name = argv[optind]; 164 name = argv[optind];
diff --git a/loginutils/su.c b/loginutils/su.c
index 660ec6f51..6410e748f 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -6,11 +6,7 @@
6 */ 6 */
7 7
8#include "busybox.h" 8#include "busybox.h"
9#include <signal.h>
10#include <syslog.h> 9#include <syslog.h>
11#include <sys/resource.h>
12#include <time.h>
13
14 10
15int su_main ( int argc, char **argv ) 11int su_main ( int argc, char **argv )
16{ 12{
@@ -43,7 +39,7 @@ int su_main ( int argc, char **argv )
43 the user, especially if someone su's from a su-shell. 39 the user, especially if someone su's from a su-shell.
44 But getlogin can fail -- usually due to lack of utmp entry. 40 But getlogin can fail -- usually due to lack of utmp entry.
45 in this case resort to getpwuid. */ 41 in this case resort to getpwuid. */
46 old_user = bb_xstrdup(USE_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : ""); 42 old_user = xstrdup(USE_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : "");
47 tty = ttyname(2) ? : "none"; 43 tty = ttyname(2) ? : "none";
48 openlog(bb_applet_name, 0, LOG_AUTH); 44 openlog(bb_applet_name, 0, LOG_AUTH);
49 } 45 }
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index a35f9e0ec..b4426ad41 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -16,18 +16,8 @@
16/* Fixed by Erik Andersen to do passwords the tinylogin way... 16/* Fixed by Erik Andersen to do passwords the tinylogin way...
17 * It now works with md5, sha1, etc passwords. */ 17 * It now works with md5, sha1, etc passwords. */
18 18
19#include <stdio.h>
20#include <stdlib.h>
21#include <sys/vt.h>
22#include <signal.h>
23#include <string.h>
24#include <unistd.h>
25#include <fcntl.h>
26#include <errno.h>
27#include <sys/ioctl.h>
28#include <termios.h>
29
30#include "busybox.h" 19#include "busybox.h"
20#include <sys/vt.h>
31 21
32static struct passwd *pw; 22static struct passwd *pw;
33static struct vt_mode ovtm; 23static struct vt_mode ovtm;
@@ -71,7 +61,7 @@ int vlock_main(int argc, char **argv)
71 bb_error_msg_and_die("Unknown uid %d", getuid()); 61 bb_error_msg_and_die("Unknown uid %d", getuid());
72 } 62 }
73 63
74 vfd = bb_xopen(CURRENT_TTY, O_RDWR); 64 vfd = xopen(CURRENT_TTY, O_RDWR);
75 65
76 if (ioctl(vfd, VT_GETMODE, &vtm) < 0) { 66 if (ioctl(vfd, VT_GETMODE, &vtm) < 0) {
77 bb_perror_msg_and_die("VT_GETMODE"); 67 bb_perror_msg_and_die("VT_GETMODE");