forked from Imagelibrary/rtems
2001-08-09 Fernando-Ruiz Casas <correo@fernando-ruiz.com>
* libc/getgrent.c, libc/getpwent.c: the 'ls' and more related command previous failed after a chroot(). (unknown user & group)
This commit is contained in:
@@ -21,6 +21,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
|
|
||||||
static struct group gr_group; /* password structure */
|
static struct group gr_group; /* password structure */
|
||||||
static FILE *group_fp;
|
static FILE *group_fp;
|
||||||
|
|
||||||
@@ -47,11 +50,14 @@ int getgrnam_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,11 +72,13 @@ int getgrnam_r(
|
|||||||
if (!strcmp (groupname, name)) {
|
if (!strcmp (groupname, name)) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = grp;
|
*result = grp;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,11 +104,15 @@ int getgrgid_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,11 +128,13 @@ int getgrgid_r(
|
|||||||
if (gid == gr_group.gr_gid) {
|
if (gid == gr_group.gr_gid) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = grp;
|
*result = grp;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,12 +174,15 @@ struct group *getgrent( void )
|
|||||||
void
|
void
|
||||||
setgrent ()
|
setgrent ()
|
||||||
{
|
{
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if (group_fp != NULL)
|
if (group_fp != NULL)
|
||||||
fclose (group_fp);
|
fclose (group_fp);
|
||||||
|
|
||||||
group_fp = fopen ("/etc/group", "r");
|
group_fp = fopen ("/etc/group", "r");
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
static struct passwd pw_passwd; /* password structure */
|
static struct passwd pw_passwd; /* password structure */
|
||||||
static FILE *passwd_fp;
|
static FILE *passwd_fp;
|
||||||
|
|
||||||
@@ -95,11 +97,14 @@ int getpwnam_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +123,13 @@ int getpwnam_r(
|
|||||||
if (!strcmp (logname, name)) {
|
if (!strcmp (logname, name)) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = pwd;
|
*result = pwd;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +155,14 @@ int getpwuid_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,11 +181,13 @@ int getpwuid_r(
|
|||||||
if (uid == pwd->pw_uid) {
|
if (uid == pwd->pw_uid) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = pwd;
|
*result = pwd;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,12 +230,15 @@ struct passwd *getpwent()
|
|||||||
|
|
||||||
void setpwent( void )
|
void setpwent( void )
|
||||||
{
|
{
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if (passwd_fp != NULL)
|
if (passwd_fp != NULL)
|
||||||
fclose (passwd_fp);
|
fclose (passwd_fp);
|
||||||
|
|
||||||
passwd_fp = fopen ("/etc/passwd", "r");
|
passwd_fp = fopen ("/etc/passwd", "r");
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
}
|
}
|
||||||
|
|
||||||
void endpwent( void )
|
void endpwent( void )
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
2001-08-09 Fernando-Ruiz Casas <correo@fernando-ruiz.com>
|
||||||
|
|
||||||
|
* libc/getgrent.c, libc/getpwent.c: the 'ls' and more related command
|
||||||
|
previous failed after a chroot(). (unknown user & group)
|
||||||
|
|
||||||
2001-08-03 Joel Sherrill <joel@OARcorp.com>
|
2001-08-03 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
* libc/libio_sockets.c (rtems_bsdnet_fdToSocket): Per bug
|
* libc/libio_sockets.c (rtems_bsdnet_fdToSocket): Per bug
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
|
|
||||||
static struct group gr_group; /* password structure */
|
static struct group gr_group; /* password structure */
|
||||||
static FILE *group_fp;
|
static FILE *group_fp;
|
||||||
|
|
||||||
@@ -47,11 +50,14 @@ int getgrnam_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,11 +72,13 @@ int getgrnam_r(
|
|||||||
if (!strcmp (groupname, name)) {
|
if (!strcmp (groupname, name)) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = grp;
|
*result = grp;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,11 +104,15 @@ int getgrgid_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,11 +128,13 @@ int getgrgid_r(
|
|||||||
if (gid == gr_group.gr_gid) {
|
if (gid == gr_group.gr_gid) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = grp;
|
*result = grp;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,12 +174,15 @@ struct group *getgrent( void )
|
|||||||
void
|
void
|
||||||
setgrent ()
|
setgrent ()
|
||||||
{
|
{
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if (group_fp != NULL)
|
if (group_fp != NULL)
|
||||||
fclose (group_fp);
|
fclose (group_fp);
|
||||||
|
|
||||||
group_fp = fopen ("/etc/group", "r");
|
group_fp = fopen ("/etc/group", "r");
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
static struct passwd pw_passwd; /* password structure */
|
static struct passwd pw_passwd; /* password structure */
|
||||||
static FILE *passwd_fp;
|
static FILE *passwd_fp;
|
||||||
|
|
||||||
@@ -95,11 +97,14 @@ int getpwnam_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +123,13 @@ int getpwnam_r(
|
|||||||
if (!strcmp (logname, name)) {
|
if (!strcmp (logname, name)) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = pwd;
|
*result = pwd;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +155,14 @@ int getpwuid_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,11 +181,13 @@ int getpwuid_r(
|
|||||||
if (uid == pwd->pw_uid) {
|
if (uid == pwd->pw_uid) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = pwd;
|
*result = pwd;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,12 +230,15 @@ struct passwd *getpwent()
|
|||||||
|
|
||||||
void setpwent( void )
|
void setpwent( void )
|
||||||
{
|
{
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if (passwd_fp != NULL)
|
if (passwd_fp != NULL)
|
||||||
fclose (passwd_fp);
|
fclose (passwd_fp);
|
||||||
|
|
||||||
passwd_fp = fopen ("/etc/passwd", "r");
|
passwd_fp = fopen ("/etc/passwd", "r");
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
}
|
}
|
||||||
|
|
||||||
void endpwent( void )
|
void endpwent( void )
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
|
|
||||||
static struct group gr_group; /* password structure */
|
static struct group gr_group; /* password structure */
|
||||||
static FILE *group_fp;
|
static FILE *group_fp;
|
||||||
|
|
||||||
@@ -47,11 +50,14 @@ int getgrnam_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,11 +72,13 @@ int getgrnam_r(
|
|||||||
if (!strcmp (groupname, name)) {
|
if (!strcmp (groupname, name)) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = grp;
|
*result = grp;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,11 +104,15 @@ int getgrgid_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
if ((fp = fopen ("/etc/group", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,11 +128,13 @@ int getgrgid_r(
|
|||||||
if (gid == gr_group.gr_gid) {
|
if (gid == gr_group.gr_gid) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = grp;
|
*result = grp;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,12 +174,15 @@ struct group *getgrent( void )
|
|||||||
void
|
void
|
||||||
setgrent ()
|
setgrent ()
|
||||||
{
|
{
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if (group_fp != NULL)
|
if (group_fp != NULL)
|
||||||
fclose (group_fp);
|
fclose (group_fp);
|
||||||
|
|
||||||
group_fp = fopen ("/etc/group", "r");
|
group_fp = fopen ("/etc/group", "r");
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
static struct passwd pw_passwd; /* password structure */
|
static struct passwd pw_passwd; /* password structure */
|
||||||
static FILE *passwd_fp;
|
static FILE *passwd_fp;
|
||||||
|
|
||||||
@@ -95,11 +97,14 @@ int getpwnam_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +123,13 @@ int getpwnam_r(
|
|||||||
if (!strcmp (logname, name)) {
|
if (!strcmp (logname, name)) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = pwd;
|
*result = pwd;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +155,14 @@ int getpwuid_r(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
|
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,11 +181,13 @@ int getpwuid_r(
|
|||||||
if (uid == pwd->pw_uid) {
|
if (uid == pwd->pw_uid) {
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
*result = pwd;
|
*result = pwd;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,12 +230,15 @@ struct passwd *getpwent()
|
|||||||
|
|
||||||
void setpwent( void )
|
void setpwent( void )
|
||||||
{
|
{
|
||||||
|
rtems_user_env_t * aux=rtems_current_user_env; /* save */
|
||||||
init_etc_passwd_group();
|
init_etc_passwd_group();
|
||||||
|
rtems_current_user_env=&rtems_global_user_env; /* set root */
|
||||||
|
|
||||||
if (passwd_fp != NULL)
|
if (passwd_fp != NULL)
|
||||||
fclose (passwd_fp);
|
fclose (passwd_fp);
|
||||||
|
|
||||||
passwd_fp = fopen ("/etc/passwd", "r");
|
passwd_fp = fopen ("/etc/passwd", "r");
|
||||||
|
rtems_current_user_env=aux; /* restore */
|
||||||
}
|
}
|
||||||
|
|
||||||
void endpwent( void )
|
void endpwent( void )
|
||||||
|
|||||||
Reference in New Issue
Block a user