pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lonnie Cumberland <lonnie_cumberland@yahoo.com>
To: Brendan Guenther <guenthe8@msu.edu>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Re: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff
Date: Fri, 20 Apr 2001 06:12:02 -0700 (PDT)
Message-ID: <20010420131202.44750.qmail@web12503.mail.yahoo.com> (raw)
In-Reply-To: <3AE01970.EC523C59@msu.edu>

Hello Brendan,

I too was having this problem, but now think that I am getting a very good
handle on these interfaces.

Being that you are trying to hash the standard unix crypt function to look over
the password file, I think that this solution might help you.

I have a simple an efficient C++ solution to this problem:

My "unixcrypt" functions now looks like this
                                         
---------------------------------------------------------------
text *unix_encrypt(text *inarg, text *inpass)
{
        char temp[25];
        int temp_len;
 
        // Take the "text" variables directly to the "strings"
        string instr(VARDATA(inarg),0,VARSIZE(inarg)-VARHDRSZ);
        string passPhrase(VARDATA(inpass),0,VARSIZE(inpass)-VARHDRSZ);
 
        strcpy(temp,crypt(instr.c_str(),passPhrase.c_str()));
        temp_len=strlen(temp);
 
        string outstr(temp,0,temp_len);
         
        // Set up the outgoing DB "text" variable
        int32      new_text_size = outstr.size()+4;
        text       *new_text = (text *) palloc(new_text_size);
        memset((void *) new_text, 0, new_text_size);
        VARATT_SIZEP(new_text) = new_text_size;
 
        // Move the variable over from the string
        strncpy(VARDATA(new_text),outstr.c_str(),outstr.size());
 
        return new_text;
}
----------------------------------------------------------------------------

Be sure to include the header:

#include <unistd.h>             // for unix crypt function  

---------------------------------------------------------------------------

hope that this helps,

Lonnie

--- Brendan Guenther <guenthe8@msu.edu> wrote:
> 
> 
> Peter Eisentraut wrote:
> 
> > The best things might be not to mess with this but call textin() and
> > textout() to convert your data to C strings.
> 
> I can't seem to find documentation for textin() and textout() can somebody
> point
> me in the right direction for this or provide an example.  I'm having similar
> problems that Lonnie is having with VARDATA and I think this might help.  I'm
> trying to link in a C function that makes use of OpenSSL's libcrypto
> functions.
> 
> Basically I just need to hash and verify passwords in the database, so as an
> alternate question, if I'm missing something and there is a better way to do
> password storage let me know.
> 
> Thanks,
> --
> Brendan Guenther
> guenthe8@msu.edu
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://www.postgresql.org/search.mpl


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



view thread (5+ messages)  latest in thread

Message-ID: <20010420131202.44750.qmail@web12503.mail.yahoo.com>
Permalink:  ../20010420131202.44750.qmail@web12503.mail.yahoo.com/
Also on:    postgresql.org/message-id/20010420131202.44750.qmail@web12503.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: lonnie_cumberland@yahoo.com, guenthe8@msu.edu
  Subject: Re: Re: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff
  In-Reply-To: <20010420131202.44750.qmail@web12503.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox