]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
For b/2723095, allow grantpt() to succeed even if it can't chgrp the slave pty to...
authorPaul Pluzhnikov <ppluzhnikov@google.com>
Sat, 1 Mar 2014 01:15:51 +0000 (17:15 -0800)
committerPaul Pluzhnikov <ppluzhnikov@google.com>
Sat, 1 Mar 2014 01:15:51 +0000 (17:15 -0800)
README.google
sysdeps/unix/grantpt.c

index 300cab9cd2ef85c63560cea6d53fe609493c5339..8cd55809ec9a95f8db4347428802e799a75bded7 100644 (file)
@@ -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)
+
index 602dfb623ae91b7566209b4ebf88971b1f29cad5..f0ceeda26b59f0f1a428e1fe1f35a4785df3b3ee 100644 (file)
@@ -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;
     }