Skip to content

Commit

Permalink
Fix permission of slave device on devpts if necessary.
Browse files Browse the repository at this point in the history
If devptr is misconfigured the slave device permission after grantpt
might not be 0620.  BZ #10166
  • Loading branch information
Ulrich Drepper committed Jun 16, 2009
1 parent 395a37e commit 292e3ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
2009-06-15 Ulrich Drepper <drepper@redhat.com>

[BZ #10166]
* 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
is correct.

[BZ #10183]
* posix/tst-cpucount.c: Don't try more than CPU_SETSIZE bits.

Expand Down
13 changes: 10 additions & 3 deletions sysdeps/unix/sysv/linux/grantpt.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
/* Copyright (C) 1998, 1999, 2001, 2002, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -70,9 +70,16 @@ grantpt (int fd)
return -1;

/* If the slave pseudo terminal lives on a `devpts' filesystem, the
ownership and access permission are already set. */
ownership is already set and the access permission might already
be set. */
if (fsbuf.f_type == DEVPTS_SUPER_MAGIC || fsbuf.f_type == DEVFS_SUPER_MAGIC)
return 0;
{
struct stat64 st;

if (fstat (fd, &st) == 0
&& (st.st_mode & ACCESSPERMS) == (S_IRUSR|S_IWUSR|S_IWGRP))
return 0;
}

return __unix_grantpt (fd);
}
Expand Down

0 comments on commit 292e3ab

Please sign in to comment.