[Pkg-shadow-commits] r632 - in trunk/debian: . patches
Alexander Gattin
xrgtn-guest at costa.debian.org
Mon Oct 31 21:24:41 UTC 2005
Author: xrgtn-guest
Date: 2005-10-31 21:24:40 +0000 (Mon, 31 Oct 2005)
New Revision: 632
Added:
trunk/debian/patches/366_fflush-prompt
Modified:
trunk/debian/changelog
Log:
fixing 333138
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2005-10-31 21:18:21 UTC (rev 631)
+++ trunk/debian/changelog 2005-10-31 21:24:40 UTC (rev 632)
@@ -7,6 +7,7 @@
* Upstream fixes which will reach next upstream version
- 467_usermod_longopts: add long options support to usermod.
Closes: #260149
+ - 366_fflush-prompt: fflush prompts to allow scripting. Closes: #333138
-- Christian Perrier <bubulle at debian.org> Mon, 31 Oct 2005 15:46:44 +0100
Added: trunk/debian/patches/366_fflush-prompt
===================================================================
--- trunk/debian/patches/366_fflush-prompt 2005-10-31 21:18:21 UTC (rev 631)
+++ trunk/debian/patches/366_fflush-prompt 2005-10-31 21:24:40 UTC (rev 632)
@@ -0,0 +1,305 @@
+Goal: Fflush all prompts supposedly presented to a user, because we may
+ conversate with a script (over pipe) instead. See bug #333138.
+
+Status wrt upstream: may appear in 4.0.14
+
+Index: shadow-cvs/libmisc/Makefile.am
+===================================================================
+--- shadow-cvs.orig/libmisc/Makefile.am 2005-10-31 21:52:57.000000000 +0200
++++ shadow-cvs/libmisc/Makefile.am 2005-10-31 22:51:12.000000000 +0200
+@@ -49,4 +49,5 @@
+ ulimit.c \
+ utmp.c \
+ valid.c \
+- xmalloc.c
++ xmalloc.c \
++ yesno.c
+Index: shadow-cvs/libmisc/fields.c
+===================================================================
+--- shadow-cvs.orig/libmisc/fields.c 2005-10-31 21:52:57.000000000 +0200
++++ shadow-cvs/libmisc/fields.c 2005-10-31 22:51:12.000000000 +0200
+@@ -71,6 +71,7 @@
+ maxsize = sizeof (newf);
+
+ printf ("\t%s [%s]: ", prompt, buf);
++ fflush (stdout);
+ if (fgets (newf, maxsize, stdin) != newf)
+ return;
+
+Index: shadow-cvs/libmisc/yesno.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ shadow-cvs/libmisc/yesno.c 2005-10-31 22:56:21.000000000 +0200
+@@ -0,0 +1,41 @@
++/*
++ * Common code for yes/no prompting
++ *
++ * Used by pwck.c and grpck.c
++ */
++
++#include <config.h> /* configuration parameters like e.g. ENABLE_NLS */
++
++#ident "$Id$"
++
++#include <stdio.h> /* printf(), fflush() & fgets() */
++#include "defines.h" /* _() macro */
++
++/*
++ * yes_or_no - get answer to question from the user
++ */
++int yes_or_no (int read_only)
++{
++ char buf[80];
++
++ /*
++ * In read-only mode all questions are answered "no".
++ */
++ if (read_only) {
++ printf (_("No\n"));
++ return 0;
++ }
++
++ /*
++ * Typically, there's a prompt on stdout, sometimes unflushed.
++ */
++ fflush (stdout);
++
++ /*
++ * Get a line and see what the first character is.
++ */
++ if (fgets (buf, sizeof buf, stdin))
++ return buf[0] == 'y' || buf[0] == 'Y';
++
++ return 0;
++}
+Index: shadow-cvs/src/grpck.c
+===================================================================
+--- shadow-cvs.orig/src/grpck.c 2005-10-31 22:46:18.000000000 +0200
++++ shadow-cvs/src/grpck.c 2005-10-31 22:52:11.000000000 +0200
+@@ -49,6 +49,8 @@
+ extern struct commonio_entry *__sgr_get_head (void);
+ #endif
+
++extern int yes_or_no (int);
++
+ /*
+ * Exit codes
+ */
+@@ -73,7 +75,6 @@
+
+ /* local function prototypes */
+ static void usage (void);
+-static int yes_or_no (void);
+ static void delete_member (char **, const char *);
+
+ /*
+@@ -90,30 +91,6 @@
+ }
+
+ /*
+- * yes_or_no - get answer to question from the user
+- */
+-static int yes_or_no (void)
+-{
+- char buf[80];
+-
+- /*
+- * In read-only mode all questions are answered "no".
+- */
+- if (read_only) {
+- printf (_("No\n"));
+- return 0;
+- }
+-
+- /*
+- * Get a line and see what the first character is.
+- */
+- if (fgets (buf, sizeof buf, stdin))
+- return buf[0] == 'y' || buf[0] == 'Y';
+-
+- return 0;
+-}
+-
+-/*
+ * delete_member - delete an entry in a list of members
+ */
+ static void delete_member (char **list, const char *member)
+@@ -300,7 +277,7 @@
+ * prompt the user to delete the entry or not
+ */
+ if (!prune) {
+- if (!yes_or_no ())
++ if (!yes_or_no (read_only))
+ continue;
+ } else {
+ puts (_("Yes"));
+@@ -360,7 +337,7 @@
+ /*
+ * prompt the user to delete the entry or not
+ */
+- if (yes_or_no ())
++ if (yes_or_no (read_only))
+ goto delete_gr;
+ }
+
+@@ -396,7 +373,7 @@
+ grp->gr_name, grp->gr_mem[i]);
+ printf (_("delete member `%s'? "), grp->gr_mem[i]);
+
+- if (!yes_or_no ())
++ if (!yes_or_no (read_only))
+ continue;
+
+ SYSLOG ((LOG_INFO, "delete member `%s' group `%s'",
+@@ -420,7 +397,7 @@
+ printf (_("add group `%s' in %s? "),
+ grp->gr_name, sgr_file);
+ errors++;
+- if (yes_or_no ())
++ if (yes_or_no (read_only))
+ {
+ struct sgrp sg;
+ struct group gr;
+@@ -502,7 +479,7 @@
+ /*
+ * prompt the user to delete the entry or not
+ */
+- if (!yes_or_no ())
++ if (!yes_or_no (read_only))
+ continue;
+
+ /*
+@@ -558,7 +535,7 @@
+ /*
+ * prompt the user to delete the entry or not
+ */
+- if (yes_or_no ())
++ if (yes_or_no (read_only))
+ goto delete_sg;
+ }
+
+@@ -570,7 +547,7 @@
+ printf (_("no matching group file entry in %s\n"), grp_file);
+ printf (_("delete line `%s'? "), sge->line);
+ errors++;
+- if (yes_or_no ())
++ if (yes_or_no (read_only))
+ goto delete_sg;
+ } else {
+ /**
+@@ -610,7 +587,7 @@
+ printf (_("delete administrative member `%s'? "),
+ sgr->sg_adm[i]);
+
+- if (!yes_or_no ())
++ if (!yes_or_no (read_only))
+ continue;
+
+ SYSLOG ((LOG_INFO,
+@@ -637,7 +614,7 @@
+ sgr->sg_name, sgr->sg_mem[i]);
+ printf (_("delete member `%s'? "), sgr->sg_mem[i]);
+
+- if (!yes_or_no ())
++ if (!yes_or_no (read_only))
+ continue;
+
+ SYSLOG ((LOG_INFO,
+Index: shadow-cvs/src/pwck.c
+===================================================================
+--- shadow-cvs.orig/src/pwck.c 2005-10-31 22:46:18.000000000 +0200
++++ shadow-cvs/src/pwck.c 2005-10-31 22:51:12.000000000 +0200
+@@ -48,6 +48,8 @@
+ extern void __spw_del_entry (const struct commonio_entry *);
+ extern struct commonio_entry *__spw_get_head (void);
+
++extern int yes_or_no (int);
++
+ /*
+ * Exit codes
+ */
+@@ -72,7 +74,6 @@
+
+ /* local function prototypes */
+ static void usage (void);
+-static int yes_or_no (void);
+
+ /*
+ * usage - print syntax message and exit
+@@ -85,31 +86,6 @@
+ }
+
+ /*
+- * yes_or_no - get answer to question from the user
+- */
+-static int yes_or_no (void)
+-{
+- char buf[80];
+-
+- /*
+- * In read-only mode all questions are answered "no".
+- */
+-
+- if (read_only) {
+- printf (_("No\n"));
+- return 0;
+- }
+-
+- /*
+- * Get a line and see what the first character is.
+- */
+- if (fgets (buf, sizeof buf, stdin))
+- return buf[0] == 'y' || buf[0] == 'Y';
+-
+- return 0;
+-}
+-
+-/*
+ * pwck - verify password file integrity
+ */
+ int main (int argc, char **argv)
+@@ -260,7 +236,7 @@
+ /*
+ * prompt the user to delete the entry or not
+ */
+- if (!yes_or_no ())
++ if (!yes_or_no (read_only))
+ continue;
+
+ /*
+@@ -315,7 +291,7 @@
+ /*
+ * prompt the user to delete the entry or not
+ */
+- if (yes_or_no ())
++ if (yes_or_no (read_only))
+ goto delete_pw;
+ }
+
+@@ -456,7 +432,7 @@
+ /*
+ * prompt the user to delete the entry or not
+ */
+- if (!yes_or_no ())
++ if (!yes_or_no (read_only))
+ continue;
+
+ /*
+@@ -511,7 +487,7 @@
+ /*
+ * prompt the user to delete the entry or not
+ */
+- if (yes_or_no ())
++ if (yes_or_no (read_only))
+ goto delete_spw;
+ }
+
+@@ -532,7 +508,7 @@
+ /*
+ * prompt the user to delete the entry or not
+ */
+- if (yes_or_no ())
++ if (yes_or_no (read_only))
+ goto delete_spw;
+ }
+
More information about the Pkg-shadow-commits
mailing list