aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Klaus <philipp.klaus@gmail.com>2011-06-21 17:12:21 +0200
committerPhilipp Klaus <philipp.klaus@gmail.com>2011-06-21 17:12:21 +0200
commit468a1f0c5bd165b6d0647b184885eb2040d7ddf4 (patch)
tree8b8116449edf5447bb3c86900007e805aac312df
parent6fe4e7f082beca523e237db60807e2d3535fee45 (diff)
downloadpwgen-468a1f0c5bd165b6d0647b184885eb2040d7ddf4.zip
automatic commit for pwgen-2.02
-rw-r--r--ChangeLog34
-rw-r--r--Makefile.in7
-rw-r--r--pw_phonemes.c9
-rw-r--r--pw_rand.c5
-rw-r--r--pwgen.14
-rw-r--r--pwgen.c22
-rw-r--r--pwgen.h12
-rw-r--r--randnum.c10
8 files changed, 75 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fb394b..1d44a3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2002-07-15 Theodore Ts'o <tytso@mit.edu>
+
+ * Release of pwgen 2.02
+
+ * pwgen.c (main): If the number of characters is less than 5,
+ force the use of the fully random generator, since the
+ quality of phonetic generator is really bad if the lengths
+ are small --- and if the length is less than or equal to
+ 2, pwgen will loop forever. (Addresses Debian bug #117137)
+
+ * pw_rand.c: Add most punctuation characters to the "bad
+ characters list", so that the random passwords are much
+ more usable.
+
+ * pwgen.1: Fix e-mail address in man page. (Addresses Debian bug
+ #150579)
+
+ * Makefile.in (WALL_OPTS): Add gcc options to do lots of nit-picky
+ checking.
+
+ * pwgen.c, pw_phonemes.c, pw_rand.c, pwgen.c, pwgen.h, randnum.c:
+ Add const declarations and other code cleanups for
+ avoidining -Wall warnings.
+
+ * pwgen.c, pw_rand.c: #include the appropriate header files to
+ avoid -Wall warnings. (Addresses Debian bug #126774).
+
+ * pwgen.c (main): Fix floating point exception errors if the
+ password is longer than terminal width. Addresses Debian
+ bug #113571.
+
+ * pwgen.c (main): Return an exit value of 0 when pwgen on
+ success. (Addresses Debian bugs #118181 and #102063).
+
2001-06-19 Theodore Tso <tytso@valinux.com>
* Release of pwgen 2.01
diff --git a/Makefile.in b/Makefile.in
index 21cf0c3..2ed04ed 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-PWGEN_VERSION=2.01
+PWGEN_VERSION=2.02
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -11,9 +11,12 @@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
+WALL_OPTS = -Wall -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes \
+ -Wshadow -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align \
+ -Wtraditional
CC = @CC@
DEFS = @DEFS@
-CFLAGS = @CFLAGS@
+CFLAGS = @CFLAGS@ $(WALL_OPTS)
CPPFLAGS = @CPPFLAGS@
ALL_CFLAGS = $(CPPFLAGS) $(DEFS) $(USE_WFLAGS) $(CFLAGS) $(XTRA_CFLAGS)
LDFLAGS = @LDFLAGS@
diff --git a/pw_phonemes.c b/pw_phonemes.c
index 91c8b55..1eaa311 100644
--- a/pw_phonemes.c
+++ b/pw_phonemes.c
@@ -1,12 +1,13 @@
/*
* pw_phonemes.c --- generate secure passwords using phoneme rules
*
- * Copyright (C) 2001 by Theodore Ts'o
+ * Copyright (C) 2001,2002 by Theodore Ts'o
*
* This file may be distributed under the terms of the GNU Public
* License.
*/
+#include <ctype.h>
#include "pwgen.h"
struct pw_element elements[] = {
@@ -56,9 +57,9 @@ struct pw_element elements[] = {
void pw_phonemes(char *buf, int size, int pw_flags)
{
- int c, i, len, flags, feature_flags;
- int prev, should_be, first;
- char *str;
+ int c, i, len, flags, feature_flags;
+ int prev, should_be, first;
+ const char *str;
try_again:
feature_flags = pw_flags;
diff --git a/pw_rand.c b/pw_rand.c
index e42a656..e49ff76 100644
--- a/pw_rand.c
+++ b/pw_rand.c
@@ -2,18 +2,19 @@
* pw_rand.c --- generate completely random (and hard to remember)
* passwords
*
- * Copyright (C) 2001 by Theodore Ts'o
+ * Copyright (C) 2001,2002 by Theodore Ts'o
*
* This file may be distributed under the terms of the GNU Public
* License.
*/
+#include <string.h>
#include "pwgen.h"
#define FIRST_CHAR '!'
#define LAST_CHAR '~'
-static char bad_chars[] = "'\\\"";
+static char bad_chars[] = "'\\\"!@#$%^&*()+=_-{}[]<>`~?:;,/.|";
void pw_rand(char *buf, int size, int pw_flags)
{
diff --git a/pwgen.1 b/pwgen.1
index fb952c3..4cfbff2 100644
--- a/pwgen.1
+++ b/pwgen.1
@@ -1,4 +1,4 @@
-.TH PWGEN 1 "June 2001" "pwgen version 2.01"
+.TH PWGEN 1 "July 2002" "pwgen version 2.02"
.SH NAME
pwgen \- generate pronounceable passwords
.SH SYNOPSIS
@@ -79,7 +79,7 @@ Print the generated passwords one per line.
.SH AUTHOR
This version of
.B pwgen
-was written by Theodore Ts'o <tytso@alummit.edu>.
+was written by Theodore Ts'o <tytso@alum.mit.edu>.
It is modelled after a program
originally written by Brandon S. Allbery, and then
later extensively modified by Olaf Titz, Jim Lynch, and others.
diff --git a/pwgen.c b/pwgen.c
index 590bacf..a563929 100644
--- a/pwgen.c
+++ b/pwgen.c
@@ -1,7 +1,7 @@
/*
* pwgen.c --- generate secure passwords
*
- * Copyright (C) 2001 by Theodore Ts'o
+ * Copyright (C) 2001,2002 by Theodore Ts'o
*
* This file may be distributed under the terms of the GNU Public
* License.
@@ -10,6 +10,8 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
@@ -61,10 +63,9 @@ const char *usage_msg =
" -1\n\tDon't print the generated passwords in columns\n"
;
-void usage(void)
+static void usage(void)
{
fprintf(stderr, usage_msg);
-
exit(1);
}
@@ -72,9 +73,10 @@ void usage(void)
int main(int argc, char **argv)
{
int term_width = 80;
- int c, i, num_cols;
+ int c, i;
+ int num_cols = -1;
char *buf, *tmp;
- void (*pwgen)(char *buf, int size, int pw_flags);
+ void (*pwgen)(char *inbuf, int size, int pw_flags);
pwgen = pw_phonemes;
if (isatty(1)) {
@@ -126,6 +128,8 @@ int main(int argc, char **argv)
}
if (optind < argc) {
pw_length = strtol(argv[optind], &tmp, 0);
+ if (pw_length < 5)
+ pwgen = pw_rand;
if (*tmp) {
fprintf(stderr, "Invalid password length: %s\n",
argv[optind]);
@@ -143,8 +147,11 @@ int main(int argc, char **argv)
}
}
- if (do_columns)
+ if (do_columns) {
num_cols = term_width / (pw_length+1);
+ if (num_cols == 0)
+ num_cols = 1;
+ }
if (num_pw < 0)
num_pw = do_columns ? num_cols * 20 : 1;
@@ -160,7 +167,8 @@ int main(int argc, char **argv)
else
printf("%s ", buf);
}
- if ((i % num_cols) != 0 && (num_cols > 1))
+ if ((num_cols > 1) && ((i % num_cols) != 0))
fputc('\n', stdout);
free(buf);
+ return 0;
}
diff --git a/pwgen.h b/pwgen.h
index 1d66da7..e28ac95 100644
--- a/pwgen.h
+++ b/pwgen.h
@@ -1,15 +1,15 @@
/*
* pwgen.h --- header file for password generator
*
- * Copyright (C) 2001 by Theodore Ts'o
+ * Copyright (C) 2001,2002 by Theodore Ts'o
*
* This file may be distributed under the terms of the GNU Public
* License.
*/
struct pw_element {
- char *str;
- int flags;
+ const char *str;
+ int flags;
};
/*
@@ -27,9 +27,9 @@ struct pw_element {
#define PW_ONE_CASE 0x0002
struct pwgen_func {
- char *name;
- void (*func)(char *buf, int size, int pw_flags);
- int flags;
+ const char *name;
+ void (*func)(char *buf, int size, int pw_flags);
+ int flags;
};
/* Function prototypes */
diff --git a/randnum.c b/randnum.c
index 3f22cfe..6afa191 100644
--- a/randnum.c
+++ b/randnum.c
@@ -1,7 +1,7 @@
/*
* randnum.c -- generate (good) randum numbers.
*
- * Copyright (C) 2001 by Theodore Ts'o
+ * Copyright (C) 2001,2002 by Theodore Ts'o
*
* This file may be distributed under the terms of the GNU Public
* License.
@@ -18,7 +18,7 @@
#include "pwgen.h"
#ifdef HAVE_DRAND48
-extern double drand48();
+extern double drand48(void);
#endif
/* Borrowed/adapted from e2fsprogs's UUID generation code */
@@ -60,8 +60,8 @@ int pw_random_number(int max_num)
{
int i, fd = get_random_fd();
int lose_counter = 0, nbytes=4;
- unsigned int rand;
- char *cp = (char *) &rand;
+ unsigned int rand_num;
+ char *cp = (char *) &rand_num;
if (fd >= 0) {
while (nbytes > 0) {
@@ -80,7 +80,7 @@ int pw_random_number(int max_num)
}
}
if (nbytes == 0)
- return (rand % max_num);
+ return (rand_num % max_num);
/* OK, we weren't able to use /dev/random, fall back to rand/rand48 */