From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 25 17:30:29 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 27CC216A4CE for ; Tue, 25 Nov 2003 17:30:29 -0800 (PST) Received: from dust.freshx.de (freshx.de [80.190.100.215]) by mx1.FreeBSD.org (Postfix) with ESMTP id 008B243FBF for ; Tue, 25 Nov 2003 17:30:27 -0800 (PST) (envelope-from kai@freshx.de) Received: from localhost (localhost.freshx.de [127.0.0.1]) by dust.freshx.de (Postfix) with ESMTP id A1DFF15E2C8 for ; Wed, 26 Nov 2003 02:30:11 +0100 (CET) Received: from localhost (localhost.freshx.de [127.0.0.1]) by dust.freshx.de (Postfix) with ESMTP id F062C15E2AE for ; Wed, 26 Nov 2003 02:30:10 +0100 (CET) Received: from 127.0.0.1 ( [127.0.0.1]) as user dust0005@localhost by localhost with HTTP; Wed, 26 Nov 2003 02:30:10 +0100 Message-ID: <1069810210.3fc40222e2bca@localhost> Date: Wed, 26 Nov 2003 02:30:10 +0100 From: "sapdb@komadev.de" To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.0 X-Virus-Scanned: by AMaViS 0.3.12 Subject: getpwnam with md5 encrypted passwds X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list 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 01:30:29 -0000 Hi, i am trying to validate a given user password against my local passwd-file with this piece of code : if (!( pwd = getpwnam ( user ))) { log(ERROR,"User %s not known",user); stat=NOUSER; } if (!strcmp( crypt(pass,pwd->pw_name), pwd->pw_passwd) ) { log(DEBUG|MISC,"HURRAY : %s authenticated\n", user); stat = AUTHED; } The problem is, that my passwords are encrypted in md5-format, so the strcmp fails always. Now i did not find any usable information on how to work this out on FreeBSD, and how to be independent from the settings in the login-conf ? (that i dont have to check whether its using crypt,md5 or blowfish) The code should be running on 4.x and 5.x Any ideas ? Kind regards Kai