diff options
author | markm <markm@FreeBSD.org> | 1995-12-16 09:45:17 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 1995-12-16 09:45:17 +0000 |
commit | 2d2185e129a0b9591326cf6780f33103e6daf487 (patch) | |
tree | 7cda69034c3f75363c1c91fd1cdf9f6f9b2de853 /usr.bin/passwd/local_passwd.c | |
parent | c141a4f4bb83940bb7b6208d7605034c71eca2a2 (diff) | |
download | FreeBSD-src-2d2185e129a0b9591326cf6780f33103e6daf487.zip FreeBSD-src-2d2185e129a0b9591326cf6780f33103e6daf487.tar.gz |
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.
Diffstat (limited to 'usr.bin/passwd/local_passwd.c')
-rw-r--r-- | usr.bin/passwd/local_passwd.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c index b98bba3..aefd9af 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)); } |