1) Fix local_passwd to co-operate with dual-personality crypt(3).
Changing a local passwd will now keep the encryption type that was originally used to encrypt the password, so folks adding DES to their systems will not be irritated/confused by having MD5'ed passwords in their master.passwd. Coming later is an option to allow the user to choose the encryption type. 2) Fix a bunch of compiler warnings announced by turning on -Wall. I did not get them all, that will come a bit later.
This commit is contained in:
parent
6b492ae46d
commit
e075ffc9a7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=12886
@ -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));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user