mirror of git://sourceware.org/git/glibc.git
Optimize pt_chown.
Don't call chown and chmod if not necessary.
This commit is contained in:
parent
292e3abebf
commit
837dea7cf5
|
@ -1,5 +1,8 @@
|
||||||
2009-06-15 Ulrich Drepper <drepper@redhat.com>
|
2009-06-15 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/grantpt.c (grantpt): Only call chown and
|
||||||
|
chmod if it is necessary.
|
||||||
|
|
||||||
[BZ #10166]
|
[BZ #10166]
|
||||||
* sysdeps/unix/sysv/linux/grantpt.c: If slave device is on devpts or
|
* sysdeps/unix/sysv/linux/grantpt.c: If slave device is on devpts or
|
||||||
devfs, the mode might not be correct. Check it and return only if it
|
devfs, the mode might not be correct. Check it and return only if it
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* pt_chmod - helper program for `grantpt'.
|
/* pt_chmod - helper program for `grantpt'.
|
||||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2009 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by C. Scott Ananian <cananian@alumni.princeton.edu>, 1998.
|
Contributed by C. Scott Ananian <cananian@alumni.princeton.edu>, 1998.
|
||||||
|
|
||||||
|
@ -119,12 +119,13 @@ do_pt_chown (void)
|
||||||
|
|
||||||
/* Set the owner to the real user ID, and the group to that special
|
/* Set the owner to the real user ID, and the group to that special
|
||||||
group ID. */
|
group ID. */
|
||||||
if (chown (pty, getuid (), gid) < 0)
|
if (st.st_gid != gid && chown (pty, getuid (), gid) < 0)
|
||||||
return FAIL_EACCES;
|
return FAIL_EACCES;
|
||||||
|
|
||||||
/* Set the permission mode to readable and writable by the owner,
|
/* Set the permission mode to readable and writable by the owner,
|
||||||
and writable by the group. */
|
and writable by the group. */
|
||||||
if (chmod (pty, S_IRUSR|S_IWUSR|S_IWGRP) < 0)
|
if ((st.st_mode & ACCESSPERMS) != (S_IRUSR|S_IWUSR|S_IWGRP)
|
||||||
|
&& chmod (pty, S_IRUSR|S_IWUSR|S_IWGRP) < 0)
|
||||||
return FAIL_EACCES;
|
return FAIL_EACCES;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue