Some more portability updates

-Erik
This commit is contained in:
Erik Andersen 2000-05-17 05:24:24 +00:00
parent 499f65fb98
commit 5b46d792f1
5 changed files with 25 additions and 25 deletions

View File

@ -32,8 +32,8 @@
#include <pwd.h>
static uid_t uid = -1;
static gid_t gid = -1;
static unsigned long uid = -1;
static unsigned long gid = -1;
static int whichApp;
static char *invocationName = NULL;
static char *theMode = NULL;

View File

@ -43,7 +43,7 @@ extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
char *cp, *user, *group;
gid_t gid;
unsigned long gid;
cp = user = group = NULL;
@ -82,10 +82,10 @@ extern int id_main(int argc, char **argv)
my_getgrgid(group, gid);
}
if (no_group) printf("%u\n", my_getpwnam(user));
else if (no_user) printf("%u\n", my_getgrnam(group));
if (no_group) printf("%lu\n", my_getpwnam(user));
else if (no_user) printf("%lu\n", my_getgrnam(group));
else
printf("uid=%u(%s) gid=%u(%s)\n",
printf("uid=%lu(%s) gid=%lu(%s)\n",
my_getpwnam(user), user, my_getgrnam(group), group);

8
id.c
View File

@ -43,7 +43,7 @@ extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
char *cp, *user, *group;
gid_t gid;
unsigned long gid;
cp = user = group = NULL;
@ -82,10 +82,10 @@ extern int id_main(int argc, char **argv)
my_getgrgid(group, gid);
}
if (no_group) printf("%u\n", my_getpwnam(user));
else if (no_user) printf("%u\n", my_getgrnam(group));
if (no_group) printf("%lu\n", my_getpwnam(user));
else if (no_user) printf("%lu\n", my_getgrnam(group));
else
printf("uid=%u(%s) gid=%u(%s)\n",
printf("uid=%lu(%s) gid=%lu(%s)\n",
my_getpwnam(user), user, my_getgrnam(group), group);

View File

@ -257,11 +257,11 @@ extern char *cstring_lineFromFile(FILE *f);
/* These parse entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox since we want to avoid using the glibc NSS stuff, which
* increases target size and is often not needed embedded systems. */
extern uid_t my_getpwnam(char *name);
extern gid_t my_getgrnam(char *name);
extern void my_getpwuid(char *name, uid_t uid);
extern void my_getgrgid(char *group, gid_t gid);
extern gid_t my_getpwnamegid(char *name);
extern unsigned long my_getpwnam(char *name);
extern unsigned long my_getgrnam(char *name);
extern void my_getpwuid(char *name, unsigned long uid);
extern void my_getgrgid(char *group, unsigned long gid);
extern unsigned long my_getpwnamegid(char *name);
#if defined BB_INIT || defined BB_SYSLOGD

View File

@ -797,12 +797,12 @@ extern int parse_mode(const char *s, mode_t * theMode)
* This uses buf as storage to hold things.
*
*/
uid_t my_getid(const char *filename, char *name, uid_t id, gid_t *gid)
unsigned long my_getid(const char *filename, char *name, unsigned long id, unsigned long *gid)
{
FILE *file;
char *rname, *start, *end, buf[128];
id_t rid;
gid_t rgid = 0;
unsigned long rgid = 0;
file = fopen(filename, "r");
if (file == NULL) {
@ -830,13 +830,13 @@ uid_t my_getid(const char *filename, char *name, uid_t id, gid_t *gid)
/* uid in passwd, gid in group */
start = end + 1;
rid = (uid_t) strtol(start, &end, 10);
rid = (unsigned long) strtol(start, &end, 10);
if (end == start)
continue;
/* gid in passwd */
start = end + 1;
rgid = (gid_t) strtol(start, &end, 10);
rgid = (unsigned long) strtol(start, &end, 10);
if (name) {
if (0 == strcmp(rname, name)) {
@ -857,33 +857,33 @@ uid_t my_getid(const char *filename, char *name, uid_t id, gid_t *gid)
}
/* returns a uid given a username */
uid_t my_getpwnam(char *name)
unsigned long my_getpwnam(char *name)
{
return my_getid("/etc/passwd", name, -1, NULL);
}
/* returns a gid given a group name */
gid_t my_getgrnam(char *name)
unsigned long my_getgrnam(char *name)
{
return my_getid("/etc/group", name, -1, NULL);
}
/* gets a username given a uid */
void my_getpwuid(char *name, uid_t uid)
void my_getpwuid(char *name, unsigned long uid)
{
my_getid("/etc/passwd", name, uid, NULL);
}
/* gets a groupname given a gid */
void my_getgrgid(char *group, gid_t gid)
void my_getgrgid(char *group, unsigned long gid)
{
my_getid("/etc/group", group, gid, NULL);
}
/* gets a gid given a user name */
gid_t my_getpwnamegid(char *name)
unsigned long my_getpwnamegid(char *name)
{
gid_t gid;
unsigned long gid;
my_getid("/etc/passwd", name, -1, &gid);
return gid;
}