diff options
author | Rob Landley | 2006-08-03 15:41:12 +0000 |
---|---|---|
committer | Rob Landley | 2006-08-03 15:41:12 +0000 |
commit | d921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch) | |
tree | e4a2769349867c441cf2983d83097bb66701a733 /loginutils | |
parent | 6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff) | |
download | busybox-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip busybox-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz |
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')
-rw-r--r-- | loginutils/addgroup.c | 11 | ||||
-rw-r--r-- | loginutils/adduser.c | 16 | ||||
-rw-r--r-- | loginutils/getty.c | 17 | ||||
-rw-r--r-- | loginutils/passwd.c | 16 | ||||
-rw-r--r-- | loginutils/su.c | 6 | ||||
-rw-r--r-- | loginutils/vlock.c | 14 |
6 files changed, 14 insertions, 66 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c index f4962ff..f5a99b7 100644 --- a/loginutils/addgroup.c +++ b/loginutils/addgroup.c @@ -9,11 +9,6 @@ * */ -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <unistd.h> - #include "busybox.h" /* make sure gr_name isn't taken, make sure gid is kosher @@ -26,7 +21,7 @@ static int group_study(struct group *g) struct group *grp; const int max = 65000; - etc_group = bb_xfopen(bb_path_group_file, "r"); + etc_group = xfopen(bb_path_group_file, "r"); /* make sure gr_name isn't taken, make sure gid is kosher */ desired = g->gr_gid; @@ -67,13 +62,13 @@ static int addgroup(char *group, gid_t gid, const char *user) return 1; /* add entry to group */ - file = bb_xfopen(bb_path_group_file, "a"); + file = xfopen(bb_path_group_file, "a"); /* group:passwd:gid:userlist */ fprintf(file, "%s:%s:%d:%s\n", group, "x", gr.gr_gid, user); fclose(file); #if ENABLE_FEATURE_SHADOWPASSWDS - file = bb_xfopen(bb_path_gshadow_file, "a"); + file = xfopen(bb_path_gshadow_file, "a"); fprintf(file, "%s:!::\n", group); fclose(file); #endif diff --git a/loginutils/adduser.c b/loginutils/adduser.c index a640ece..0133d82 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c @@ -8,14 +8,6 @@ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ -#include <stdio.h> -#include <sys/types.h> -#include <string.h> -#include <unistd.h> -#include <time.h> -#include <getopt.h> -#include <sys/stat.h> - #include "busybox.h" #define DONT_SET_PASS (1 << 4) @@ -32,7 +24,7 @@ static int passwd_study(const char *filename, struct passwd *p) const int min = 500; const int max = 65000; - passwd = bb_xfopen(filename, "r"); + passwd = xfopen(filename, "r"); /* EDR if uid is out of bounds, set to min */ if ((p->pw_uid > max) || (p->pw_uid < min)) @@ -78,7 +70,7 @@ static void addgroup_wrapper(struct passwd *p) { char *cmd; - cmd = bb_xasprintf("addgroup -g %d \"%s\"", p->pw_gid, p->pw_name); + cmd = xasprintf("addgroup -g %d \"%s\"", p->pw_gid, p->pw_name); system(cmd); free(cmd); } @@ -99,7 +91,7 @@ static int adduser(struct passwd *p, unsigned long flags) int addgroup = !p->pw_gid; /* make sure everything is kosher and setup uid && gid */ - file = bb_xfopen(bb_path_passwd_file, "a"); + file = xfopen(bb_path_passwd_file, "a"); fseek(file, 0, SEEK_END); switch (passwd_study(bb_path_passwd_file, p)) { @@ -119,7 +111,7 @@ static int adduser(struct passwd *p, unsigned long flags) #if ENABLE_FEATURE_SHADOWPASSWDS /* add to shadow if necessary */ - file = bb_xfopen(bb_path_shadow_file, "a"); + file = xfopen(bb_path_shadow_file, "a"); fseek(file, 0, SEEK_END); fprintf(file, "%s:!:%ld:%d:%d:%d:::\n", p->pw_name, /* username */ diff --git a/loginutils/getty.c b/loginutils/getty.c index 2d05d9a..ebb107d 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -16,19 +16,6 @@ * */ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <errno.h> -#include <sys/stat.h> -#include <signal.h> -#include <fcntl.h> -#include <stdarg.h> -#include <ctype.h> -#include <getopt.h> -#include <termios.h> #include "busybox.h" #ifdef CONFIG_FEATURE_UTMP @@ -324,7 +311,7 @@ static void parse_args(int argc, char **argv, struct options *op) const char *p = op->initstring; char *q; - q = op->initstring = bb_xstrdup(op->initstring); + q = op->initstring = xstrdup(op->initstring); /* copy optarg into op->initstring decoding \ddd octal codes into chars */ while (*p) { @@ -858,7 +845,7 @@ int getty_main(int argc, char **argv) }; #ifdef DEBUGGING - dbf = bb_xfopen(DEBUGTERM, "w"); + dbf = xfopen(DEBUGTERM, "w"); { int i; diff --git a/loginutils/passwd.c b/loginutils/passwd.c index 7745444..aa75dd2 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c @@ -3,20 +3,8 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <signal.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> -#include <utime.h> -#include <syslog.h> -#include <time.h> -#include <sys/resource.h> -#include <errno.h> - #include "busybox.h" +#include <syslog.h> static char crypt_passwd[128]; @@ -170,7 +158,7 @@ int passwd_main(int argc, char **argv) bb_show_usage(); } } - myname = (char *) bb_xstrdup(bb_getpwuid(NULL, getuid(), -1)); + myname = (char *) xstrdup(bb_getpwuid(NULL, getuid(), -1)); /* exits on error */ if (optind < argc) { name = argv[optind]; diff --git a/loginutils/su.c b/loginutils/su.c index 660ec6f..6410e74 100644 --- a/loginutils/su.c +++ b/loginutils/su.c @@ -6,11 +6,7 @@ */ #include "busybox.h" -#include <signal.h> #include <syslog.h> -#include <sys/resource.h> -#include <time.h> - int su_main ( int argc, char **argv ) { @@ -43,7 +39,7 @@ int su_main ( int argc, char **argv ) the user, especially if someone su's from a su-shell. But getlogin can fail -- usually due to lack of utmp entry. in this case resort to getpwuid. */ - old_user = bb_xstrdup(USE_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : ""); + old_user = xstrdup(USE_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : ""); tty = ttyname(2) ? : "none"; openlog(bb_applet_name, 0, LOG_AUTH); } diff --git a/loginutils/vlock.c b/loginutils/vlock.c index a35f9e0..b4426ad 100644 --- a/loginutils/vlock.c +++ b/loginutils/vlock.c @@ -16,18 +16,8 @@ /* Fixed by Erik Andersen to do passwords the tinylogin way... * It now works with md5, sha1, etc passwords. */ -#include <stdio.h> -#include <stdlib.h> -#include <sys/vt.h> -#include <signal.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <sys/ioctl.h> -#include <termios.h> - #include "busybox.h" +#include <sys/vt.h> static struct passwd *pw; static struct vt_mode ovtm; @@ -71,7 +61,7 @@ int vlock_main(int argc, char **argv) bb_error_msg_and_die("Unknown uid %d", getuid()); } - vfd = bb_xopen(CURRENT_TTY, O_RDWR); + vfd = xopen(CURRENT_TTY, O_RDWR); if (ioctl(vfd, VT_GETMODE, &vtm) < 0) { bb_perror_msg_and_die("VT_GETMODE"); |