]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix permission of slave device on devpts if necessary.
authorUlrich Drepper <drepper@redhat.com>
Tue, 16 Jun 2009 05:56:51 +0000 (22:56 -0700)
committerPetr Baudis <pasky@suse.cz>
Tue, 16 Jun 2009 10:24:54 +0000 (12:24 +0200)
If devptr is misconfigured the slave device permission after grantpt
might not be 0620.  BZ #10166
(cherry picked from commit 292e3abebff9f94ca47c1a725a691cb6ed6cff5f)

ChangeLog
sysdeps/unix/sysv/linux/grantpt.c

index b1ba1459f8d7b32dab3e1fb394bf5b71a209981b..7bec39af0903b3642d3abfbf16c38cc0c579810e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
 
index b894b8b63138e2ed6071116f675518ca72df7485..c858f89c8bb5aed9b7e63adc8999adef8db087c1 100644 (file)
@@ -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
@@ -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);
 }