Article View: es.comp.os.linux.programacion
Article #16117Re: Funcion crypt
From: J.A. Gutierrez
Date: Mon, 08 May 2000 00:00
Date: Mon, 08 May 2000 00:00
76 lines
2817 bytes
2817 bytes
"Jordi Fern�ndez" <sarabia@larural.es> wrote:
: �Que semilla debo utilizar para poder obtener el password encriptado
: correcto?
#ifdef _USE_SHADOW_
# include <shadow.h>
struct spwd *spasswd;
#endif
#ifdef _BSD_
extern char *sys_errlist[];
# define raise(s) kill(getpid(),(s))
# define strerror(e) sys_errlist[(e)]
extern char *crypt( char *key, char *salt);
extern char *getpass( char *prompt);
#else
#include <crypt.h>
#endif
[...]
int main(int argc, char **argv, char **envp)
{
int i;
int error;
char s[256];
char user[256];
char *pass;
struct passwd *pwd;
if ( NULL == ( pwd = getpwuid ( getuid () )))
{
output("getpwuid failed for %s (%s)",
getuid(), strerror(errno) );
error = errno;
}
else
{
sprintf(s, "%s's password? ", pwd->pw_name);
if ( NULL == (pass = getpass(s)))
{
output( "getpass failed for %s (%s)",
pwd->pw_name, strerror(errno));
error = errno;
}
else
{
#ifdef _USE_SHADOW_
if ( NULL == ( spasswd = getspnam(pwd->pw_name) ))
{
output( "getspnam failed for %s (%s)\n",
pwd->pw_name, strerror(errno));
exit(errno);
}
if (strcmp(spasswd->sp_pwdp, crypt(pass, spasswd->sp_pwdp)))
#else
if (strcmp(pwd->pw_passwd, crypt(pass, pwd->pw_passwd)))
#endif
{
output( "incorrect password for %s\n",
pwd->pw_name);
}
else
{
[...]
--
PGP and other useless info at \ Oh, show us the way
http://www.cps.unizar.es/~spd/ \ to the next whisky bar
finger://daphne.cps.unizar.es/spd \ Weill/Bretch
es doloroso ser sabio y descubrir la sopa de ajo (Pla)
Technical Details
Message-ID:
<8f6bq5$r5i$1@news.unizar.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8f10jt$o6i$1@talia.mad.ttd.net> <8bg4f8.ir2.ln@simpsons4ever> <8f4tjs$r1j$1@talia.mad.ttd.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f86c8,ab0cc78e9d0b9708
X-Google-Attributes: gidf86c8,public
From: "J.A. Gutierrez" <spd@daphne.cps.unizar.es>
Subject: Re: Funcion crypt
Date: 2000/05/08
Message-ID: <8f6bq5$r5i$1@news.unizar.es>
X-Deja-AN: 620890945
Content-Transfer-Encoding: 8bit
References: <8f10jt$o6i$1@talia.mad.ttd.net> <8bg4f8.ir2.ln@simpsons4ever> <8f4tjs$r1j$1@talia.mad.ttd.net>
Content-Type: text/plain; charset=ISO-8859-1
X-Complaints-To: usenet@news.unizar.es
X-Trace: news.unizar.es 957788805 27826 155.210.152.20 (8 May 2000 12:26:45 GMT)
Organization: Rank
Mime-Version: 1.0
User-Agent: tin/1.4.1-19991201 ("Polish") (UNIX) (IRIX/6.2 (IP22))
NNTP-Posting-Date: 8 May 2000 12:26:45 GMT
Newsgroups: es.comp.os.linux.programacion