postgresql password manager release 1.0.0

From: joseph speigle <joe(dot)speigle(at)jklh(dot)us>
To: pgsql-novice(at)postgresql(dot)org
Subject: postgresql password manager release 1.0.0
Date: 2003-12-18 21:31:02
Message-ID: 20031218213102.GA19470@www.sirfsup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

novices!

I have succeeded in making accessing my www passwords easy from the shell. I store the passwords in a postgresql table, and use the bash shell; for anybody who has these and uses the net a lot and use different passwords this may come in handy for them too. It is also my first sql function. The pieces are a password table, a data type (for the function), the sql-function, and two bash functions to call the sql function and insert values into the table. The source for the pieces in that order are:

============================================
psql commands
-------------
create sequence passwd_id_seq start 1 increment 1

CREATE TABLE passwd ( "id" int4 default nextval('passwd_id_seq') not null, "uname" varchar(30) NOT NULL default '', "pass" varchar(30) NOT NULL default '', "location" varchar(255) default NULL, "email" varchar(30) default NULL, "category" varchar(25) default NULL, "notes" varchar(255) default NULL, PRIMARY KEY (id));

create type getpass_type as
(
username character varying(30),
password character varying(30),
location character varying(255)
);

CREATE or replace FUNCTION getpass(text)
returns setof getpass_type AS
-- retrieves user and pass by matching against a partial location
'
SELECT uname,pass,location FROM passwd WHERE location like ''%'' || $1 || ''%''
' LANGUAGE 'sql';

============================================
.bashrc
-------
function getpass ()
{
psql -d database_name -c "select * from getpass('$1');"
}
function setpass ()
{
psql -d database_name -c "insert into passwd (uname,pass,location) values ('$1','$2','$3');"
}

the function was overkill, but a good lesson. I wish I could do the same for the setpass function.
============================================

use like this:
# setpass yahoo_user yahoo_pass mail.yahoo.com
# getpass yahoo

(you may need to change database_name above to your database where you put the passwd table)
--
joe speigle

Browse pgsql-novice by date

  From Date Subject
Next Message Matthew Rudolph 2003-12-19 00:44:33 INDEX and NULL
Previous Message Tom Lane 2003-12-18 20:03:11 Re: Can't create lock file /tmp/.s.PGSQL.5432.lock