diff -Nru pwgen-2.07/configure pwgen-2.08/configure --- pwgen-2.07/configure 2014-10-28 03:39:41.000000000 +0000 +++ pwgen-2.08/configure 2017-08-07 04:56:30.000000000 +0000 @@ -657,6 +657,7 @@ docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -727,6 +728,7 @@ sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' @@ -979,6 +981,15 @@ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1116,7 +1127,7 @@ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1269,6 +1280,7 @@ --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] diff -Nru pwgen-2.07/configure.ac pwgen-2.08/configure.ac --- pwgen-2.07/configure.ac 1970-01-01 00:00:00.000000000 +0000 +++ pwgen-2.08/configure.ac 2017-08-07 04:36:54.000000000 +0000 @@ -0,0 +1,11 @@ +AC_INIT(pwgen.c) +AC_PREREQ(2.50) +AC_PROG_CC +AC_PROG_INSTALL +AC_PATH_PROG(MV, mv, mv) +AC_PATH_PROG(RM, rm, rm) +AC_PATH_PROG(SED, sed, sed) +AC_PATH_PROG(PERL, perl, perl) +AC_CHECK_FUNCS(getopt_long) +AC_CHECK_HEADERS(getopt.h) +AC_OUTPUT(Makefile) diff -Nru pwgen-2.07/configure.in pwgen-2.08/configure.in --- pwgen-2.07/configure.in 2014-10-28 03:39:37.000000000 +0000 +++ pwgen-2.08/configure.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -AC_INIT(pwgen.c) -AC_PREREQ(2.50) -AC_PROG_CC -AC_PROG_INSTALL -AC_PATH_PROG(MV, mv, mv) -AC_PATH_PROG(RM, rm, rm) -AC_PATH_PROG(SED, sed, sed) -AC_PATH_PROG(PERL, perl, perl) -AC_CHECK_FUNCS(getopt_long) -AC_CHECK_HEADERS(getopt.h) -AC_OUTPUT(Makefile) diff -Nru pwgen-2.07/debian/changelog pwgen-2.08/debian/changelog --- pwgen-2.07/debian/changelog 2015-11-14 14:16:35.000000000 +0000 +++ pwgen-2.08/debian/changelog 2017-08-07 04:51:45.000000000 +0000 @@ -1,29 +1,29 @@ -pwgen (2.07-1.1ubuntu1) xenial; urgency=medium +pwgen (2.08-1) unstable; urgency=medium - * Resynchronise with Debian. Remaining changes: - - Use correct compiler when cross-building. + * New upstream version + * Suppress trailing space after the last password (Closes: #794635) + * Make pwgen -s more "secure" for 1 and 2 character passwords + (Closes: #666725) + * Fix option parsing of "pwgen --no-capitalize --no-vowels" (Closes: #791908) + * Add new option --remove-chars which removes chars from the set of + characters used to generate passwords (Closes: #836334) + * Add cross-compilation to debian/rules (Closes: #695148) + * Update control and copyright files to point at pwgen at github for + the home directory and primary git repository + (Closes: #454500, #855495, #846517) + * Update Debian policy compliance to 4.0.0 - -- Colin Watson Sat, 14 Nov 2015 14:15:59 +0000 + -- Theodore Y. Ts'o Mon, 07 Aug 2017 00:51:45 -0400 pwgen (2.07-1.1) unstable; urgency=medium * Non-maintainer upload. * Add multiarch metadata (Closes: #693964) * Fix manpage typo (Closes: #579178) - * Stop -s from overwriting other flags (Closes: 436912) + * Stop -s from overwriting other flags (Closes: #436912) -- Wookey Thu, 22 Oct 2015 22:14:04 +0100 -pwgen (2.07-1ubuntu1) vivid; urgency=medium - - * Resynchronise with Debian (LP: #1183213, #638418, #1349863). Remaining - changes: - - Fix pwgen -s so it works after other options. - - Use correct compiler when cross-building. - - Mark pwgen Multi-Arch: foreign. - - -- Colin Watson Tue, 11 Nov 2014 13:11:19 +0000 - pwgen (2.07-1) unstable; urgency=high * New upstream version @@ -41,39 +41,6 @@ -- Theodore Y. Ts'o Mon, 27 Oct 2014 23:30:52 -0400 -pwgen (2.06-1ubuntu4) raring; urgency=low - - * Use correct compiler when cross-building. - * Mark pwgen Multi-Arch: foreign (closes: #693964). - - -- Colin Watson Tue, 04 Dec 2012 16:09:42 +0000 - -pwgen (2.06-1ubuntu3) quantal; urgency=low - - * Rebuild for new armel compiler default of ARMv5t. - - -- Colin Watson Mon, 08 Oct 2012 16:52:52 +0100 - -pwgen (2.06-1ubuntu2) lucid; urgency=low - - * rebuild rest of main for armel armv7/thumb2 optimization; - UbuntuSpec:mobile-lucid-arm-gcc-v7-thumb2 - - -- Alexander Sack Sun, 07 Mar 2010 01:02:06 +0100 - -pwgen (2.06-1ubuntu1) karmic; urgency=low - - * Fix pwgen -s so it works after other options (Closes: #436912, - LP: #297470) - - -- Brian Murray Wed, 05 Aug 2009 01:07:13 -0700 - -pwgen (2.06-1build1) karmic; urgency=low - - * No-change rebuild to gain FORTIFY defaults. - - -- Kees Cook Mon, 11 May 2009 12:07:50 -0700 - pwgen (2.06-1) unstable; urgency=low * New upstream version diff -Nru pwgen-2.07/debian/compat pwgen-2.08/debian/compat --- pwgen-2.07/debian/compat 2014-10-28 03:11:30.000000000 +0000 +++ pwgen-2.08/debian/compat 2017-08-07 04:36:54.000000000 +0000 @@ -1 +1 @@ -8 +10 diff -Nru pwgen-2.07/debian/control pwgen-2.08/debian/control --- pwgen-2.07/debian/control 2015-11-14 14:14:34.000000000 +0000 +++ pwgen-2.08/debian/control 2017-08-07 04:36:54.000000000 +0000 @@ -1,10 +1,12 @@ Source: pwgen Section: admin Priority: optional -Build-Depends: debhelper (>= 8) -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Theodore Y. Ts'o -Standards-Version: 3.9.6.0 +Build-Depends: debhelper (>= 10) +Maintainer: Theodore Y. Ts'o +Standards-Version: 4.0.0 +Homepage: https://github.com/tytso/pwgen +Vcs-Browser: https://github.com/tytso/pwgen +Vcs-Git: https://github.com/tytso/pwgen.git Package: pwgen Architecture: any diff -Nru pwgen-2.07/debian/copyright pwgen-2.08/debian/copyright --- pwgen-2.07/debian/copyright 2014-10-28 03:12:04.000000000 +0000 +++ pwgen-2.08/debian/copyright 2017-08-07 04:36:54.000000000 +0000 @@ -1,7 +1,7 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: pwgen Upstream-Contact: tytso@mit.edu -Source: http://sourceforge.net/projects/pwgen/files/pwgen/ +Source: https://github.com/tytso/pwgen Files: * Copyright: 2001, 2002, 2005, 2006, 2014 Theodore Ts'o diff -Nru pwgen-2.07/debian/patches/bug-436912-fix.patch pwgen-2.08/debian/patches/bug-436912-fix.patch --- pwgen-2.07/debian/patches/bug-436912-fix.patch 2015-10-22 21:41:01.000000000 +0000 +++ pwgen-2.08/debian/patches/bug-436912-fix.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -Description: Stop -s flag overwriting others - Specifying -s overwrites other flags without this fix - (i.e. -s -y not the same as -y -s) -Author: Andreas Sundstrom -Bug-Debian: https://bugs.debian.org/436912 - ---- pwgen-2.07.orig/pwgen.c -+++ pwgen-2.07/pwgen.c -@@ -137,7 +137,7 @@ int main(int argc, char **argv) - break; - case 's': - pwgen = pw_rand; -- pwgen_flags = PW_DIGITS | PW_UPPERS; -+ pwgen_flags |= PW_DIGITS | PW_UPPERS; - break; - case 'C': - do_columns = 1; diff -Nru pwgen-2.07/debian/patches/bug-436912-fix.patch.backup pwgen-2.08/debian/patches/bug-436912-fix.patch.backup --- pwgen-2.07/debian/patches/bug-436912-fix.patch.backup 2015-10-22 21:41:01.000000000 +0000 +++ pwgen-2.08/debian/patches/bug-436912-fix.patch.backup 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -Description: Stop -s flag overwriting others - Specifying -s overwrites other flags without this fix - (i.e. -s -y not the same as -y -s) -Author: Andreas Sundstrom -Bug-Debian: https://bugs.debian.org/436912 - ---- pwgen-2.07.orig/pwgen.c -+++ pwgen-2.07/pwgen.c -@@ -137,7 +137,7 @@ int main(int argc, char **argv) - break; - case 's': - pwgen = pw_rand; -- pwgen_flags = PW_DIGITS | PW_UPPERS; -+ pwgen_flags |= PW_DIGITS | PW_UPPERS; - break; - case 'C': - do_columns = 1; diff -Nru pwgen-2.07/debian/patches/bug-579178-fix.patch pwgen-2.08/debian/patches/bug-579178-fix.patch --- pwgen-2.07/debian/patches/bug-579178-fix.patch 2015-10-22 21:40:36.000000000 +0000 +++ pwgen-2.08/debian/patches/bug-579178-fix.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Description: Fix manpage error and update version/date -Author: Lars Wirzenius -Bug-Debian: https://bugs.debian.org/579178 - ---- pwgen-2.07.orig/pwgen.1 -+++ pwgen-2.07/pwgen.1 -@@ -1,4 +1,4 @@ --.TH PWGEN 1 "January 2006" "pwgen version 2.05" -+.TH PWGEN 1 "October 2014" "pwgen version 2.07" - .SH NAME - pwgen \- generate pronounceable passwords - .SH SYNOPSIS -@@ -78,7 +78,7 @@ standard output is a tty device. - Generate - .I num - passwords. This defaults to a screenful if passwords are --printed by columns, and one password. -+printed by columns, and one password otherwise. - .TP - .B \-n, --numerals - Include at least one number in the password. This is the default diff -Nru pwgen-2.07/debian/patches/bug-579178-fix.patch.backup pwgen-2.08/debian/patches/bug-579178-fix.patch.backup --- pwgen-2.07/debian/patches/bug-579178-fix.patch.backup 2015-10-22 21:40:36.000000000 +0000 +++ pwgen-2.08/debian/patches/bug-579178-fix.patch.backup 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Description: Fix manpage error and update version/date -Author: Lars Wirzenius -Bug-Debian: https://bugs.debian.org/579178 - ---- pwgen-2.07.orig/pwgen.1 -+++ pwgen-2.07/pwgen.1 -@@ -1,4 +1,4 @@ --.TH PWGEN 1 "January 2006" "pwgen version 2.05" -+.TH PWGEN 1 "October 2014" "pwgen version 2.07" - .SH NAME - pwgen \- generate pronounceable passwords - .SH SYNOPSIS -@@ -78,7 +78,7 @@ standard output is a tty device. - Generate - .I num - passwords. This defaults to a screenful if passwords are --printed by columns, and one password. -+printed by columns, and one password otherwise. - .TP - .B \-n, --numerals - Include at least one number in the password. This is the default diff -Nru pwgen-2.07/debian/patches/series pwgen-2.08/debian/patches/series --- pwgen-2.07/debian/patches/series 2015-10-22 21:38:20.000000000 +0000 +++ pwgen-2.08/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -bug-436912-fix.patch -bug-579178-fix.patch diff -Nru pwgen-2.07/debian/rules pwgen-2.08/debian/rules --- pwgen-2.07/debian/rules 2015-11-14 14:14:34.000000000 +0000 +++ pwgen-2.08/debian/rules 2017-08-07 04:36:54.000000000 +0000 @@ -2,20 +2,13 @@ # Made with the aid of debmake, by Christoph Lameter, # based on the sample debian/rules file for GNU hello by Ian Jackson. +DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) - -ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) - CROSS := -else - CROSS := CC=$(DEB_HOST_GNU_TYPE)-gcc -endif - package=pwgen build: build-arch build-indep @@ -24,8 +17,9 @@ build-stamp: dh_testdir - ./configure --prefix=/usr --mandir=/usr/share/man - $(MAKE) CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(CROSS) + ./configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \ + --prefix=/usr --mandir=/usr/share/man + $(MAKE) CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" touch build-stamp clean: diff -Nru pwgen-2.07/.gitignore pwgen-2.08/.gitignore --- pwgen-2.07/.gitignore 2007-07-04 23:14:26.000000000 +0000 +++ pwgen-2.08/.gitignore 2017-08-07 04:36:54.000000000 +0000 @@ -4,4 +4,6 @@ config.status configure pwgen +build +autom4te.cache *.o diff -Nru pwgen-2.07/Makefile.in pwgen-2.08/Makefile.in --- pwgen-2.07/Makefile.in 2014-10-28 03:41:47.000000000 +0000 +++ pwgen-2.08/Makefile.in 2017-08-07 04:52:36.000000000 +0000 @@ -1,4 +1,4 @@ -PWGEN_VERSION=2.07 +PWGEN_VERSION=2.08 srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -32,9 +32,19 @@ .c.o: $(CC) -c $(ALL_CFLAGS) $< -o $@ -OBJS= pwgen.o pw_phonemes.o pw_rand.o randnum.o sha1.o sha1num.o - -SRCS= pwgen.c pw_phonemes.c pw_rand.c randnum.c sha1.c sha1num.c +OBJS= pwgen.o \ + pw_phonemes.o \ + pw_rand.o \ + randnum.o \ + sha1.o \ + sha1num.o + +SRCS= $(srcdir)/pwgen.c \ + $(srcdir)/pw_phonemes.c \ + $(srcdir)/pw_rand.c \ + $(srcdir)/randnum.c \ + $(srcdir)/sha1.c \ + $(srcdir)/sha1num.c pwgen: $(OBJS) @@ -66,6 +76,7 @@ -o -name TAGS -o -name \*.old -o -name \*.gmo \ -o -name config.log -o -name config.cache \ -o -name config.status -o -name Makefile \ + -o -name build -o -name autom4te.cache \ -o -name changed-files -o -name .#\* \) \ -print) | sed -e "s/^./$$a/" > $(srcdir)/.exclude-file echo "$(SRCROOT)/.exclude-file" >> $(srcdir)/.exclude-file @@ -87,7 +98,7 @@ Makefile: $(srcdir)/Makefile.in $(DEP_MAKEFILE) $(top_builddir)/config.status cd $(top_builddir); CONFIG_FILES=$(my_dir)/Makefile ./config.status -$(top_srcdir)/configure: $(top_srcdir)/configure.in +$(top_srcdir)/configure: $(top_srcdir)/configure.ac cd $(top_srcdir) && autoconf # @@ -123,9 +134,9 @@ # Makefile dependencies follow. This must be the last section in # the Makefile.in file # -pwgen.o: pwgen.c pwgen.h -pw_phonemes.o: pw_phonemes.c pwgen.h -pw_rand.o: pw_rand.c pwgen.h -randnum.o: randnum.c pwgen.h -sha1.o: sha1.c sha1.h -sha1num.o: sha1num.c sha1.h pwgen.h +pwgen.o: $(srcdir)/pwgen.c $(srcdir)/pwgen.h +pw_phonemes.o: $(srcdir)/pw_phonemes.c $(srcdir)/pwgen.h +pw_rand.o: $(srcdir)/pw_rand.c $(srcdir)/pwgen.h +randnum.o: $(srcdir)/randnum.c $(srcdir)/pwgen.h +sha1.o: $(srcdir)/sha1.c $(srcdir)/sha1.h +sha1num.o: $(srcdir)/sha1num.c $(srcdir)/pwgen.h $(srcdir)/sha1.h diff -Nru pwgen-2.07/pwgen.1 pwgen-2.08/pwgen.1 --- pwgen-2.07/pwgen.1 2014-10-28 01:00:39.000000000 +0000 +++ pwgen-2.08/pwgen.1 2017-08-07 04:53:04.000000000 +0000 @@ -1,4 +1,4 @@ -.TH PWGEN 1 "January 2006" "pwgen version 2.05" +.TH PWGEN 1 "August 2017" "pwgen version 2.08" .SH NAME pwgen \- generate pronounceable passwords .SH SYNOPSIS @@ -78,7 +78,7 @@ Generate .I num passwords. This defaults to a screenful if passwords are -printed by columns, and one password. +printed by columns, and one password otherwise. .TP .B \-n, --numerals Include at least one number in the password. This is the default @@ -101,6 +101,11 @@ .B \-h, --help Print a help message. .TP +.B \-r \fIchars\fR, \fB--remove-chars=\fIchars +Don't use the specified characters in password. This option will +disable the phomeme-based generator and uses the random password +generator. +.TP .B \-s, --secure Generate completely random, hard-to-memorize passwords. These should only be used for machine passwords, since otherwise it's almost diff -Nru pwgen-2.07/pwgen.c pwgen-2.08/pwgen.c --- pwgen-2.07/pwgen.c 2014-10-28 01:00:39.000000000 +0000 +++ pwgen-2.08/pwgen.c 2017-08-07 04:36:54.000000000 +0000 @@ -35,6 +35,7 @@ { "numerals", no_argument, 0, 'n'}, { "symbols", no_argument, 0, 'y'}, { "num-passwords", required_argument, 0, 'N'}, + { "remove-chars", required_argument, 0, 'r' }, { "secure", no_argument, 0, 's' }, { "help", no_argument, 0, 'h'}, { "no-numerals", no_argument, 0, '0' }, @@ -46,7 +47,7 @@ }; #endif -const char *pw_options = "01AaBCcnN:shH:vy"; +const char *pw_options = "01AaBCcnN:sr:hH:vy"; static void usage(void) { @@ -66,6 +67,9 @@ fputs(" -y or --symbols\n", stderr); fputs("\tInclude at least one special symbol in the password\n", stderr); + fputs(" -r or --remove-chars=\n", stderr); + fputs("\tRemove characters from the set of characters to " + "generate passwords\n", stderr); fputs(" -s or --secure\n", stderr); fputs("\tGenerate completely random passwords\n", stderr); fputs(" -B or --ambiguous\n", stderr); @@ -92,7 +96,8 @@ int c, i; int num_cols = -1; char *buf, *tmp; - void (*pwgen)(char *inbuf, int size, int pw_flags); + char *remove=NULL; + void (*pwgen)(char *inbuf, int size, int pw_flags, char *remove); pwgen = pw_phonemes; pw_number = pw_random_number; @@ -137,7 +142,6 @@ break; case 's': pwgen = pw_rand; - pwgen_flags = PW_DIGITS | PW_UPPERS; break; case 'C': do_columns = 1; @@ -154,7 +158,11 @@ break; case 'v': pwgen = pw_rand; - pwgen_flags |= PW_NO_VOWELS | PW_DIGITS | PW_UPPERS; + pwgen_flags |= PW_NO_VOWELS; + break; + case 'r': + remove = strdup(optarg); + pwgen = pw_rand; break; case 'h': case '?': @@ -166,10 +174,12 @@ pw_length = strtol(argv[optind], &tmp, 0); if (pw_length < 5) pwgen = pw_rand; - if (pw_length <= 2) - pwgen_flags &= ~PW_UPPERS; - if (pw_length <= 1) - pwgen_flags &= ~PW_DIGITS; + if (pwgen != pw_rand) { + if (pw_length <= 2) + pwgen_flags &= ~PW_UPPERS; + if (pw_length <= 1) + pwgen_flags &= ~PW_DIGITS; + } if (*tmp) { fprintf(stderr, "Invalid password length: %s\n", argv[optind]); @@ -201,14 +211,13 @@ exit(1); } for (i=0; i < num_pw; i++) { - pwgen(buf, pw_length, pwgen_flags); - if (!do_columns || ((i % num_cols) == (num_cols-1))) + pwgen(buf, pw_length, pwgen_flags, remove); + if (!do_columns || ((i % num_cols) == (num_cols-1)) || + (i == (num_pw - 1))) printf("%s\n", buf); else printf("%s ", buf); } - if ((num_cols > 1) && ((i % num_cols) != 0)) - fputc('\n', stdout); free(buf); return 0; } diff -Nru pwgen-2.07/pwgen.h pwgen-2.08/pwgen.h --- pwgen-2.07/pwgen.h 2007-07-04 23:14:26.000000000 +0000 +++ pwgen-2.08/pwgen.h 2017-08-07 04:36:54.000000000 +0000 @@ -38,10 +38,10 @@ /* Function prototypes */ /* pw_phonemes.c */ -extern void pw_phonemes(char *buf, int size, int pw_flags); +extern void pw_phonemes(char *buf, int size, int pw_flags, char *remove); /* pw_rand.c */ -extern void pw_rand(char *buf, int size, int pw_flags); +extern void pw_rand(char *buf, int size, int pw_flags, char *remove); /* randnum.c */ extern int pw_random_number(int max_num); diff -Nru pwgen-2.07/pw_phonemes.c pwgen-2.08/pw_phonemes.c --- pwgen-2.07/pw_phonemes.c 2014-10-28 01:45:54.000000000 +0000 +++ pwgen-2.08/pw_phonemes.c 2017-08-07 04:36:54.000000000 +0000 @@ -56,7 +56,7 @@ #define NUM_ELEMENTS (sizeof(elements) / sizeof (struct pw_element)) -void pw_phonemes(char *buf, int size, int pw_flags) +void pw_phonemes(char *buf, int size, int pw_flags, char *remove) { int c, i, len, flags, feature_flags; int prev, should_be, first; diff -Nru pwgen-2.07/pw_rand.c pwgen-2.08/pw_rand.c --- pwgen-2.07/pw_rand.c 2007-07-04 23:14:26.000000000 +0000 +++ pwgen-2.08/pw_rand.c 2017-08-07 04:36:54.000000000 +0000 @@ -20,7 +20,32 @@ const char *pw_ambiguous = "B8G6I1l0OQDS5Z2"; const char *pw_vowels = "01aeiouyAEIOUY"; -void pw_rand(char *buf, int size, int pw_flags) +static void remove_chars(char *buf, const char *remove) +{ + const char *cp; + + if (!remove) + return; + for (cp = remove; *cp; cp++) { + char *r = strchr(buf, *cp); + + if (r == NULL) + continue; + memmove(r, r+1, strlen(r)); + } +} + +static int find_chars(char *buf, const char *set) +{ + const char *cp; + + for (cp = set; *cp; cp++) + if (strchr(buf, *cp)) + return 1; + return 0; +} + +void pw_rand(char *buf, int size, int pw_flags, char *remove) { char ch, *chars, *wchars; int i, len, feature_flags; @@ -55,9 +80,40 @@ if (pw_flags & PW_SYMBOLS) { strcpy(wchars, pw_symbols); } -try_again: + if (remove) { + if (pw_flags & PW_AMBIGUOUS) + remove_chars(chars, pw_ambiguous); + if (pw_flags & PW_NO_VOWELS) + remove_chars(chars, pw_vowels); + remove_chars(chars, remove); + if ((pw_flags & PW_DIGITS) && + !find_chars(chars, pw_digits)) { + fprintf(stderr, + "Error: No digits left in the valid set\n"); + exit(1); + } + if ((pw_flags & PW_UPPERS) && + !find_chars(chars, pw_uppers)) { + fprintf(stderr, + "Error: No upper case letters left in " + "the valid set\n"); + exit(1); + } + if ((pw_flags & PW_SYMBOLS) && + !find_chars(chars, pw_symbols)) { + fprintf(stderr, + "Error: No symbols left in the valid set\n"); + exit(1); + } + if (chars[0] == '\0') { + fprintf(stderr, + "Error: No characters left in the valid set\n"); + exit(1); + } + } len = strlen(chars); - feature_flags = pw_flags; +try_again: + feature_flags = (size > 2) ? pw_flags : 0; i = 0; while (i < size) { ch = chars[pw_number(len)]; @@ -66,11 +122,14 @@ if ((pw_flags & PW_NO_VOWELS) && strchr(pw_vowels, ch)) continue; buf[i++] = ch; - if (strchr(pw_digits, ch)) + if ((feature_flags & PW_DIGITS) && + strchr(pw_digits, ch)) feature_flags &= ~PW_DIGITS; - if (strchr(pw_uppers, ch)) + if ((feature_flags & PW_UPPERS) && + strchr(pw_uppers, ch)) feature_flags &= ~PW_UPPERS; - if (strchr(pw_symbols, ch)) + if ((feature_flags & PW_SYMBOLS) && + strchr(pw_symbols, ch)) feature_flags &= ~PW_SYMBOLS; } if (feature_flags & (PW_UPPERS | PW_DIGITS | PW_SYMBOLS)) diff -Nru pwgen-2.07/randnum.c pwgen-2.08/randnum.c --- pwgen-2.07/randnum.c 2014-10-28 01:55:43.000000000 +0000 +++ pwgen-2.08/randnum.c 2017-08-07 04:36:54.000000000 +0000 @@ -46,13 +46,12 @@ int pw_random_number(max_num) int max_num; { - int i, fd = get_random_fd(); - int lose_counter = 0, nbytes; unsigned int rand_num; + int i, fd = get_random_fd(); + int lose_counter = 0, nbytes = sizeof(rand_num); char *cp = (char *) &rand_num; if (fd >= 0) { - nbytes = sizeof(rand_num); while (nbytes > 0) { i = read(fd, cp, nbytes); if ((i < 0) && diff -Nru pwgen-2.07/sha1num.c pwgen-2.08/sha1num.c --- pwgen-2.07/sha1num.c 2007-07-04 21:39:35.000000000 +0000 +++ pwgen-2.08/sha1num.c 2017-08-07 04:36:29.000000000 +0000 @@ -54,6 +54,8 @@ sha1_update( &sha1_ctx, buf, i ); } + fclose(f); + return; } diff -Nru pwgen-2.07/wordwrap.pl pwgen-2.08/wordwrap.pl --- pwgen-2.07/wordwrap.pl 2007-07-04 21:39:35.000000000 +0000 +++ pwgen-2.08/wordwrap.pl 2017-08-07 04:36:54.000000000 +0000 @@ -9,8 +9,8 @@ } next if (/^$/); # skip blank lines $linelen = 0; - split; - while (defined($word = shift @_)) { + @words = split; + while (defined($word = shift @words)) { $word =~ s#\$\(srcdir\)/\.\./version.h#\$\(top_srcdir\)/version.h#; $word =~ s#\$\(srcdir\)/.\.\/\.\./version.h#\$\(top_srcdir\)/version.h#; $word =~ s#\$\(srcdir\)/.\.\/et/com_err.h#\$\(top_srcdir\)/lib/et/com_err.h#;