about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2014-02-28 17:15:51 -0800
committerPaul Pluzhnikov <ppluzhnikov@google.com>2014-02-28 17:15:51 -0800
commit4e73acc04aa8671dcace0200de2f748d093334d7 (patch)
tree4d923b9a0aa35116acfab3b91749856e9bd93927
parent3fae2a38f853f386c25faf532dd12fc9044aab9d (diff)
downloadglibc-4e73acc04aa8671dcace0200de2f748d093334d7.tar.gz
glibc-4e73acc04aa8671dcace0200de2f748d093334d7.tar.xz
glibc-4e73acc04aa8671dcace0200de2f748d093334d7.zip
For b/2723095, allow grantpt() to succeed even if it can't chgrp the slave pty to the "tty" group.
-rw-r--r--README.google6
-rw-r--r--sysdeps/unix/grantpt.c14
2 files changed, 20 insertions, 0 deletions
diff --git a/README.google b/README.google
index 300cab9cd2..8cd55809ec 100644
--- a/README.google
+++ b/README.google
@@ -126,3 +126,9 @@ locale/programs/locarchive.c
   Forward-ported from cl/51331729 (from cl/39296-p2).
   (cgd, google-local)
 
+sysdeps/unix/grantpt.c
+  For b/2723095, allow grantpt() to succeed even if it can't chgrp
+  the slave pty to the "tty" group.
+  Forward-ported from cl/51332316 (from cl/41538-p2).
+  (ppluzhnikov, google-local)
+
diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c
index 602dfb623a..f0ceeda26b 100644
--- a/sysdeps/unix/grantpt.c
+++ b/sysdeps/unix/grantpt.c
@@ -31,6 +31,9 @@
 
 #include "pty-private.h"
 
+/* Needed for Google local fix for b/2723095.  */
+#include <sys/statfs.h>
+#include <linux/magic.h>
 
 /* Return the result of ptsname_r in the buffer pointed to by PTS,
    which should be of length BUF_LEN.  If it is too long to fit in
@@ -158,6 +161,17 @@ grantpt (int fd)
   /* Make sure the group of the device is that special group.  */
   if (st.st_gid != gid)
     {
+      /* Google local fix for b/2723095: if the device is on
+         a /dev/pts filesystem, don't fail when st_gid != gid (which may
+         be caused by the FS being mounted without gid=5 option, where
+         5 is the gid of the "tty" group).  */
+      struct statfs fsbuf;
+      if (__statfs (buf, &fsbuf) == 0 && fsbuf.f_type == DEVPTS_SUPER_MAGIC)
+	{
+	  retval = 0;
+	  goto cleanup;
+	}
+
       if (__chown (buf, uid, gid) < 0)
 	goto helper;
     }