2005-11-03 Jeff Johnston <jjohnstn@redhat.com>
* libc/unix/getcwd.c: Don't use non-reentrant syscall names.
        * libc/unix/getlogin.c: Ditto.
        * libc/unix/getpass.c: Ditto.
        * libc/unix/getut.c: Ditto.
        * libc/unix/ttyname.c: Ditto.
			
			
This commit is contained in:
		| @@ -1,3 +1,11 @@ | |||||||
|  | 2005-11-03  Jeff Johnston  <jjohnstn@redhat.com> | ||||||
|  |  | ||||||
|  | 	* libc/unix/getcwd.c: Don't use non-reentrant syscall names. | ||||||
|  | 	* libc/unix/getlogin.c: Ditto. | ||||||
|  | 	* libc/unix/getpass.c: Ditto. | ||||||
|  | 	* libc/unix/getut.c: Ditto. | ||||||
|  | 	* libc/unix/ttyname.c: Ditto. | ||||||
|  |  | ||||||
| 2005-11-03  Shaun Jackman  <sjackman@gmail.com> | 2005-11-03  Shaun Jackman  <sjackman@gmail.com> | ||||||
|  |  | ||||||
| 	* libc/include/sys/unistd.h (readlink, symlink): Provide these | 	* libc/include/sys/unistd.h (readlink, symlink): Provide these | ||||||
|   | |||||||
| @@ -124,7 +124,7 @@ getcwd (pt, size) | |||||||
|   for (first = 1;; first = 0) |   for (first = 1;; first = 0) | ||||||
|     { |     { | ||||||
|       /* Stat the current level. */ |       /* Stat the current level. */ | ||||||
|       if (_stat (up, &s)) |       if (stat (up, &s)) | ||||||
| 	goto err; | 	goto err; | ||||||
|  |  | ||||||
|       /* Save current node values. */ |       /* Save current node values. */ | ||||||
| @@ -165,7 +165,7 @@ getcwd (pt, size) | |||||||
|       *bup = '\0'; |       *bup = '\0'; | ||||||
|  |  | ||||||
|       /* Open and stat parent directory. */ |       /* Open and stat parent directory. */ | ||||||
|       if (!(dir = _opendir (up)) || _fstat (__dirfd (dir), &s)) |       if (!(dir = opendir (up)) || fstat (__dirfd (dir), &s)) | ||||||
| 	goto err; | 	goto err; | ||||||
|  |  | ||||||
|       /* Add trailing slash for next directory. */ |       /* Add trailing slash for next directory. */ | ||||||
| @@ -182,7 +182,7 @@ getcwd (pt, size) | |||||||
| 	{ | 	{ | ||||||
| 	  for (;;) | 	  for (;;) | ||||||
| 	    { | 	    { | ||||||
| 	      if (!(dp = _readdir (dir))) | 	      if (!(dp = readdir (dir))) | ||||||
| 		goto notfound; | 		goto notfound; | ||||||
| 	      if (dp->d_ino == ino) | 	      if (dp->d_ino == ino) | ||||||
| 		break; | 		break; | ||||||
| @@ -191,7 +191,7 @@ getcwd (pt, size) | |||||||
|       else |       else | ||||||
| 	for (;;) | 	for (;;) | ||||||
| 	  { | 	  { | ||||||
| 	    if (!(dp = _readdir (dir))) | 	    if (!(dp = readdir (dir))) | ||||||
| 	      goto notfound; | 	      goto notfound; | ||||||
| 	    if (ISDOT (dp)) | 	    if (ISDOT (dp)) | ||||||
| 	      continue; | 	      continue; | ||||||
| @@ -238,7 +238,7 @@ getcwd (pt, size) | |||||||
| 	*--bpt = '/'; | 	*--bpt = '/'; | ||||||
|       bpt -= strlen (dp->d_name); |       bpt -= strlen (dp->d_name); | ||||||
|       bcopy (dp->d_name, bpt, strlen (dp->d_name)); |       bcopy (dp->d_name, bpt, strlen (dp->d_name)); | ||||||
|       (void) _closedir (dir); |       (void) closedir (dir); | ||||||
|  |  | ||||||
|       /* Truncate any file name. */ |       /* Truncate any file name. */ | ||||||
|       *bup = '\0'; |       *bup = '\0'; | ||||||
|   | |||||||
| @@ -19,24 +19,24 @@ getlogin () | |||||||
|       || ((tty = ttyname (2)) == 0)) |       || ((tty = ttyname (2)) == 0)) | ||||||
|     return 0; |     return 0; | ||||||
|  |  | ||||||
|   if ((utmp_fd = _open (UTMP_FILE, O_RDONLY)) == -1) |   if ((utmp_fd = open (UTMP_FILE, O_RDONLY)) == -1) | ||||||
|     return 0; |     return 0; | ||||||
|  |  | ||||||
|   if (!strncmp (tty, "/dev/", 5)) |   if (!strncmp (tty, "/dev/", 5)) | ||||||
|     tty += 5; |     tty += 5; | ||||||
|  |  | ||||||
|   while (_read (utmp_fd, &utmp_buf, sizeof (utmp_buf)) == sizeof (utmp_buf)) |   while (read (utmp_fd, &utmp_buf, sizeof (utmp_buf)) == sizeof (utmp_buf)) | ||||||
|     { |     { | ||||||
|       if (!strncmp (tty, utmp_buf.ut_line, sizeof (utmp_buf.ut_line)) |       if (!strncmp (tty, utmp_buf.ut_line, sizeof (utmp_buf.ut_line)) | ||||||
| 	  && utmp_buf.ut_type == USER_PROCESS) | 	  && utmp_buf.ut_type == USER_PROCESS) | ||||||
| 	{ | 	{ | ||||||
| 	  _close (utmp_fd); | 	  close (utmp_fd); | ||||||
| 	  memset (buf, 0, sizeof (buf)); | 	  memset (buf, 0, sizeof (buf)); | ||||||
| 	  strncpy (buf, utmp_buf.ut_user, sizeof (utmp_buf.ut_user)); | 	  strncpy (buf, utmp_buf.ut_user, sizeof (utmp_buf.ut_user)); | ||||||
| 	  return buf; | 	  return buf; | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   _close (utmp_fd); |   close (utmp_fd); | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -90,7 +90,7 @@ getpass (prompt) | |||||||
|     if (p < buf + _PASSWORD_LEN) |     if (p < buf + _PASSWORD_LEN) | ||||||
|       *p++ = ch; |       *p++ = ch; | ||||||
|   *p = '\0'; |   *p = '\0'; | ||||||
|   (void) _write (fileno (outfp), "\n", 1); |   (void) write (fileno (outfp), "\n", 1); | ||||||
|   if (echo) |   if (echo) | ||||||
|     { |     { | ||||||
|       term.c_lflag |= ECHO; |       term.c_lflag |= ECHO; | ||||||
|   | |||||||
| @@ -16,15 +16,15 @@ setutent () | |||||||
| { | { | ||||||
|   if (utmp_fd == -2) |   if (utmp_fd == -2) | ||||||
|     { |     { | ||||||
|       utmp_fd = _open (utmp_file, O_RDONLY); |       utmp_fd = open (utmp_file, O_RDONLY); | ||||||
|     } |     } | ||||||
|   _lseek (utmp_fd, 0, SEEK_SET); |   lseek (utmp_fd, 0, SEEK_SET); | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| endutent () | endutent () | ||||||
| { | { | ||||||
|   _close (utmp_fd); |   close (utmp_fd); | ||||||
|   utmp_fd = -2; |   utmp_fd = -2; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -39,7 +39,7 @@ getutent () | |||||||
| { | { | ||||||
|   if (utmp_fd == -2) |   if (utmp_fd == -2) | ||||||
|     setutent (); |     setutent (); | ||||||
|   if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data)) |   if (read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data)) | ||||||
|     return 0; |     return 0; | ||||||
|   return &utmp_data; |   return &utmp_data; | ||||||
| } | } | ||||||
| @@ -47,7 +47,7 @@ getutent () | |||||||
| struct utmp * | struct utmp * | ||||||
| getutid (struct utmp *id) | getutid (struct utmp *id) | ||||||
| { | { | ||||||
|   while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data)) |   while (read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data)) | ||||||
|     { |     { | ||||||
|       switch (id->ut_type) |       switch (id->ut_type) | ||||||
| 	{ | 	{ | ||||||
| @@ -73,7 +73,7 @@ getutid (struct utmp *id) | |||||||
| struct utmp * | struct utmp * | ||||||
| getutline (struct utmp *line) | getutline (struct utmp *line) | ||||||
| { | { | ||||||
|   while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data)) |   while (read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data)) | ||||||
|     { |     { | ||||||
|       if ((utmp_data.ut_type == LOGIN_PROCESS || |       if ((utmp_data.ut_type == LOGIN_PROCESS || | ||||||
| 	   utmp_data.ut_type == USER_PROCESS) && | 	   utmp_data.ut_type == USER_PROCESS) && | ||||||
|   | |||||||
| @@ -62,13 +62,13 @@ ttyname (fd) | |||||||
|     return NULL; |     return NULL; | ||||||
|  |  | ||||||
|   /* Must be a character device. */ |   /* Must be a character device. */ | ||||||
|   if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode)) |   if (fstat (fd, &sb) || !S_ISCHR (sb.st_mode)) | ||||||
|     return NULL; |     return NULL; | ||||||
|  |  | ||||||
|   if ((dp = _opendir (_PATH_DEV)) == NULL) |   if ((dp = opendir (_PATH_DEV)) == NULL) | ||||||
|     return NULL; |     return NULL; | ||||||
|  |  | ||||||
|   while ((dirp = _readdir (dp)) != NULL) |   while ((dirp = readdir (dp)) != NULL) | ||||||
|     { |     { | ||||||
|       if (dirp->d_ino != sb.st_ino) |       if (dirp->d_ino != sb.st_ino) | ||||||
| 	continue; | 	continue; | ||||||
| @@ -76,9 +76,9 @@ ttyname (fd) | |||||||
|       if (stat (buf, &dsb) || sb.st_dev != dsb.st_dev || |       if (stat (buf, &dsb) || sb.st_dev != dsb.st_dev || | ||||||
| 	  sb.st_ino != dsb.st_ino) | 	  sb.st_ino != dsb.st_ino) | ||||||
| 	continue; | 	continue; | ||||||
|       (void) _closedir (dp); |       (void) closedir (dp); | ||||||
|       return buf; |       return buf; | ||||||
|     } |     } | ||||||
|   (void) _closedir (dp); |   (void) closedir (dp); | ||||||
|   return NULL; |   return NULL; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user