dbTalk Databases Forums  

postgresql password manager release 1.0.0

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss postgresql password manager release 1.0.0 in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
joseph speigle
 
Posts: n/a

Default postgresql password manager release 1.0.0 - 12-18-2003 , 03:31 PM






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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.