Re: [HACKERS] DB-shell connect

From: <geek+(at)cmu(dot)edu>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] DB-shell connect
Date: 1998-07-01 15:48:21
Message-ID: emacs-smtp-1155-13722-23109-914195@export.andrew.cmu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

-----BEGIN PGP SIGNED MESSAGE-----

> Can an SQL database (PostgreSQL) be connected to shell in a way that if
> a directory is changed on shell it will update the database with the
> changes? If so how?
> A prompt reply would be appreciated.

On most *nix systems, this feature is called "auditing." You may not
realize this, Greg, but what you *really* want to do is:
1) Turn on auditing (if auditing is not available, try new OS).
2) Write a script which grovels through the audit log periodically
and inserts the appropriate rows in your database.

Actually, there *is* another alternative:
1) Make everybody's shell /bin/bash (or translate the following)
2) Create the following alias in /etc/profile
alias cd="\cd $1;psql database -c \"insert into cdtable values (\'$PWD\');\\g\""
3) Hope your users don't unalias that.

BTW, the alternative offered above is BAD:
1) Every cd invokes psql == suckful performance.
2) Can be trivially broken by users.
3) Will not notice chdir()'s in shell-scripts and executables.

An improvement can be attained by grabbing the source to bash, and
modifying both the init code (attach to database) and the "cd" code
(insert row, COMMIT). However, this shell should *never* be used by
root (never futz with the root shell) or PostgreSQL superuser
(chicken-and-egg).

- --
=====================================================================
| JAVA must have been developed in the wilds of West Virginia. |
| After all, why else would it support only single inheritance?? |
=====================================================================
| Finger geek(at)andrew(dot)cmu(dot)edu for my public key. |
=====================================================================

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQBVAwUBNZpaRYdzVnzma+gdAQFASQH+NaiN0JnlDGxd5mP7gjmQ/7mXqS8bvds9
GiYHmTuOZ1gTJeW1zWiz60nc4xHQYz6jTNE/JqLaIBqP44NKHwQiUA==
=gWRI
-----END PGP SIGNATURE-----

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1998-07-01 16:40:24 Re: [HACKERS] DB-shell connect
Previous Message Bruce Momjian 1998-07-01 15:30:25 Re: [HACKERS] DB-shell connect