]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/pw_group.c
Partially revert r367756 (chpass(1) synopsis changes)
[pw-darwin.git] / pw / pw_group.c
index dd650625fde32429132de1fc4460d90cc0379957..a294d4ecbb5c49cc12c61da609b441a1cff3d02d 100644 (file)
@@ -66,13 +66,18 @@ grp_set_passwd(struct group *grp, bool update, int fd, bool precrypted)
        }
        
        if ((istty = isatty(fd))) {
-               n = t;
-               /* Disable echo */
-               n.c_lflag &= ~(ECHO);
-               tcsetattr(fd, TCSANOW, &n);
-               printf("%sassword for group %s:", update ? "New p" : "P",
-                   grp->gr_name);
-               fflush(stdout);
+               if (tcgetattr(fd, &t) == -1)
+                       istty = 0;
+               else {
+                       n = t;
+                       /* Disable echo */
+                       n.c_lflag &= ~(ECHO);
+                       tcsetattr(fd, TCSANOW, &n);
+                       printf("%sassword for group %s:",
+                           update ? "New p" : "P",
+                           grp->gr_name);
+                       fflush(stdout);
+               }
        }
        b = read(fd, line, sizeof(line) - 1);
        if (istty) {    /* Restore state */