summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2005-09-20 21:08:10 +0000
committerBernhard Reutner-Fischer2005-09-20 21:08:10 +0000
commitf56b8e4b0067c9cd7cdf11f3aa9bfaa4e055a722 (patch)
tree1183359fc1238f1b425728d51bf6498c05b41ecc
parentd5bd137a247145afabfbc3a3c376ad8787381d8f (diff)
downloadbusybox-f56b8e4b0067c9cd7cdf11f3aa9bfaa4e055a722.zip
busybox-f56b8e4b0067c9cd7cdf11f3aa9bfaa4e055a722.tar.gz
- consolidated password helpers into bb_pwd.c
-rw-r--r--libbb/get_ug_id.c30
-rw-r--r--libbb/my_getgrgid.c57
-rw-r--r--libbb/my_getgrnam.c49
-rw-r--r--libbb/my_getpwnam.c49
-rw-r--r--libbb/my_getpwuid.c56
-rw-r--r--libbb/my_getug.c64
6 files changed, 0 insertions, 305 deletions
diff --git a/libbb/get_ug_id.c b/libbb/get_ug_id.c
deleted file mode 100644
index b0b9b2e..0000000
--- a/libbb/get_ug_id.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <stdlib.h>
-
-extern unsigned long get_ug_id(const char *s, long (*my_getxxnam)(const char *))
-{
- unsigned long r;
- char *p;
-
- r = strtoul(s, &p, 10);
- if (*p || (s == p)) {
- r = my_getxxnam(s);
- }
-
- return r;
-}
diff --git a/libbb/my_getgrgid.c b/libbb/my_getgrgid.c
deleted file mode 100644
index 9ac14a3..0000000
--- a/libbb/my_getgrgid.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more
- * flexible :
- *
- * if bufsize is > 0 char *group cannot be set to NULL.
- * On success groupname is written on static allocated buffer group
- * (and a pointer to it is returned).
- * On failure gid as string is written to static allocated buffer
- * group and NULL is returned.
- * if bufsize is = 0 char *group can be set to NULL.
- * On success groupname is returned.
- * On failure NULL is returned.
- * if bufsize is < 0 char *group can be set to NULL.
- * On success groupname is returned.
- * On failure an error message is printed and the program exits.
- */
-
-#include "libbb.h"
-#include "grp_.h"
-
-/* gets a groupname given a gid */
-char * my_getgrgid(char *group, long gid, int bufsize)
-{
- struct group *mygroup = getgrgid(gid);
-
- return my_getug(group, (mygroup) ? mygroup->gr_name : (char *)mygroup, gid, bufsize, 'g');
-}
-
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/
diff --git a/libbb/my_getgrnam.c b/libbb/my_getgrnam.c
deleted file mode 100644
index 22a617c..0000000
--- a/libbb/my_getgrnam.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "libbb.h"
-#include "pwd_.h"
-#include "grp_.h"
-
-
-/* returns a gid given a group name */
-long my_getgrnam(const char *name)
-{
- struct group *mygroup;
-
- mygroup = getgrnam(name);
- if (mygroup==NULL)
- bb_error_msg_and_die("unknown group name: %s", name);
-
- return (mygroup->gr_gid);
-}
-
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/
diff --git a/libbb/my_getpwnam.c b/libbb/my_getpwnam.c
deleted file mode 100644
index a9fd0cd..0000000
--- a/libbb/my_getpwnam.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "libbb.h"
-#include "pwd_.h"
-#include "grp_.h"
-
-
-/* returns a uid given a username */
-long my_getpwnam(const char *name)
-{
- struct passwd *myuser;
-
- myuser = getpwnam(name);
- if (myuser==NULL)
- bb_error_msg_and_die("unknown user name: %s", name);
-
- return myuser->pw_uid;
-}
-
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/
diff --git a/libbb/my_getpwuid.c b/libbb/my_getpwuid.c
deleted file mode 100644
index 7da360a..0000000
--- a/libbb/my_getpwuid.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more
- * flexible :
- *
- * if bufsize is > 0 char *name can not be set to NULL.
- * On success username is written on the static allocated buffer name
- * (and a pointer to it is returned).
- * On failure uid as string is written to the static allocated buffer name
- * and NULL is returned.
- * if bufsize is = 0 char *name can be set to NULL.
- * On success username is returned.
- * On failure NULL is returned.
- * if bufsize is < 0 char *name can be set to NULL
- * On success username is returned.
- * On failure an error message is printed and the program exits.
- */
-
-#include "libbb.h"
-#include "pwd_.h"
-
-/* gets a username given a uid */
-char * my_getpwuid(char *name, long uid, int bufsize)
-{
- struct passwd *myuser = getpwuid(uid);
-
- return my_getug(name, (myuser) ? myuser->pw_name : (char *)myuser , uid, bufsize, 'u');
-}
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/
diff --git a/libbb/my_getug.c b/libbb/my_getug.c
deleted file mode 100644
index 9b7292d..0000000
--- a/libbb/my_getug.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 2004 by Tito Ragusa <farmatito@tiscali.it>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- /*
- *
- * if bufsize is > 0 char *buffer can not be set to NULL.
- * If idname is not NULL it is written on the static allocated buffer
- * (and a pointer to it is returned).
- * if idname is NULL, id as string is written to the static allocated buffer
- * and NULL is returned.
- * if bufsize is = 0 char *buffer can be set to NULL.
- * If idname exists a pointer to it is returned,
- * else NULL is returned.
- * if bufsize is < 0 char *buffer can be set to NULL.
- * If idname exists a pointer to it is returned,
- * else an error message is printed and the program exits.
- */
-
-#include <stdio.h>
-#include <assert.h>
-#include "libbb.h"
-
-
-/* internal function for my_getpwuid and my_getgrgid */
-char * my_getug(char *buffer, char *idname, long id, int bufsize, char prefix)
-{
- if(bufsize > 0 ) {
- assert(buffer!=NULL);
- if(idname) {
- return safe_strncpy(buffer, idname, bufsize);
- }
- snprintf(buffer, bufsize, "%ld", id);
- } else if(bufsize < 0 && !idname) {
- bb_error_msg_and_die("unknown %cid %ld", prefix, id);
- }
- return idname;
-}
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/