]> 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 834160fd5191fbf92a199ad5e5b980c371f24664..a294d4ecbb5c49cc12c61da609b441a1cff3d02d 100644 (file)
@@ -1,4 +1,6 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (C) 1996
  *     David L. Nugent.  All rights reserved.
  *
@@ -64,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 */
@@ -282,7 +289,7 @@ int
 pw_group_show(int argc, char **argv, char *arg1)
 {
        struct group *grp = NULL;
-       char *name;
+       char *name = NULL;
        intmax_t id = -1;
        int ch;
        bool all, force, quiet, pretty;