From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 26 11:21:28 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BE7D716A4CE for ; Wed, 26 Nov 2003 11:21:28 -0800 (PST) Received: from kientzle.com (h-66-166-149-50.SNVACAID.covad.net [66.166.149.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id C96E843F75 for ; Wed, 26 Nov 2003 11:21:27 -0800 (PST) (envelope-from kientzle@acm.org) Received: from acm.org ([66.166.149.54]) by kientzle.com (8.12.9/8.12.9) with ESMTP id hAQJLQkX057761; Wed, 26 Nov 2003 11:21:27 -0800 (PST) (envelope-from kientzle@acm.org) Message-ID: <3FC4FD34.2060807@acm.org> Date: Wed, 26 Nov 2003 11:21:24 -0800 From: Tim Kientzle User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031006 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "sapdb@komadev.de" References: <1069810210.3fc40222e2bca@localhost> In-Reply-To: <1069810210.3fc40222e2bca@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-hackers@freebsd.org Subject: Re: getpwnam with md5 encrypted passwds X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: kientzle@acm.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Nov 2003 19:21:28 -0000 sapdb@komadev.de wrote: > Hi, > > i am trying to validate a given user password against my local passwd-file with > this piece of code : > > if (!strcmp( crypt(pass,pwd->pw_name), pwd->pw_passwd) ) { The second argument to crypt here should be pwd->pw_passwd. Otherwise, this doesn't work even with DES-encrypted passwords. The first part of any encrypted password is the 'salt', which effectively indicates how that password is encrypted. You need to give the encrypted password to crypt so it knows which encryption to use for the plaintext. Tim Kientzle