summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/passwd/local_passwd.c22
-rw-r--r--usr.bin/passwd/passwd.c11
-rw-r--r--usr.bin/passwd/yp_passwd.c3
3 files changed, 26 insertions, 10 deletions
diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c
index b98bba3f30ff..aefd9afbede6 100644
--- a/usr.bin/passwd/local_passwd.c
+++ b/usr.bin/passwd/local_passwd.c
@@ -29,10 +29,12 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $Id$
*/
#ifndef lint
-static char sccsid[] = "@(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
+static const char sccsid[] = "@(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/types.h>
@@ -124,11 +126,21 @@ getnewpasswd(pw, nis)
salt[9] = '\0';
#else
/* Make a good size salt for algoritms that can use it. */
- to64(&salt[0], random(), 3);
gettimeofday(&tv,0);
- to64(&salt[3], tv.tv_usec, 3);
- to64(&salt[6], tv.tv_sec, 2);
- salt[8] = '\0';
+ if (strncmp(pw->pw_passwd, "$1$", 3)) {
+ /* DES Salt */
+ to64(&salt[0], random(), 3);
+ to64(&salt[3], tv.tv_usec, 3);
+ to64(&salt[6], tv.tv_sec, 2);
+ salt[8] = '\0';
+ }
+ else {
+ /* MD5 Salt */
+ strncpy(&salt[0], "$1$", 3);
+ to64(&salt[3], random(), 3);
+ to64(&salt[6], tv.tv_usec, 3);
+ salt[8] = '\0';
+ }
#endif
return (crypt(buf, salt));
}
diff --git a/usr.bin/passwd/passwd.c b/usr.bin/passwd/passwd.c
index 31e005d3572f..92dd895ea64c 100644
--- a/usr.bin/passwd/passwd.c
+++ b/usr.bin/passwd/passwd.c
@@ -29,18 +29,21 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $id$
+ *
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1988, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "From: @(#)passwd.c 8.3 (Berkeley) 4/2/94";
+static const char sccsid[] = "From: @(#)passwd.c 8.3 (Berkeley) 4/2/94";
static const char rcsid[] =
- "$Id: passwd.c,v 1.5 1995/08/13 16:07:35 wpaul Exp $";
+ "$Id$";
#endif /* not lint */
#include <err.h>
@@ -48,12 +51,14 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
#ifdef YP
#include <pwd.h>
#include <pw_yp.h>
char *prog_name;
int __use_yp = 0;
+int yp_passwd(char *user);
#endif
#ifdef KERBEROS
diff --git a/usr.bin/passwd/yp_passwd.c b/usr.bin/passwd/yp_passwd.c
index 86811e378f20..fc6b0e4cbad4 100644
--- a/usr.bin/passwd/yp_passwd.c
+++ b/usr.bin/passwd/yp_passwd.c
@@ -91,7 +91,7 @@ yp_passwd(char *user)
struct passwd *pw;
CLIENT *clnt;
char *master;
- int c, err, status;
+ int err, status;
char *s;
if ((master = getserver()) == NULL) {
@@ -136,7 +136,6 @@ yp_passwd(char *user)
/* Get old password */
if(pw->pw_passwd[0]) {
- char prompt[40];
s = getpass ("Old password: ");
if( strcmp(crypt(s, pw->pw_passwd), pw->pw_passwd)) {