Re: [HACKERS] Patch to psql.c to allow .psqlrc file
| От | Andrew Martin |
|---|---|
| Тема | Re: [HACKERS] Patch to psql.c to allow .psqlrc file |
| Дата | |
| Msg-id | 703b819127d3bce6361daceedd8a18d3 обсуждение исходный текст |
| Ответ на | [HACKERS] Patch to psql.c to allow .psqlrc file (Andrew Martin <martin@biochemistry.ucl.ac.uk>) |
| Список | pgsql-hackers |
> > > Kind of hard to CENTRALLY locate something if you are not root. I
> > > wouldn't worry about it.
> >
> > No, you actually missed the point.
> >
> > If I install pgsql as userid pgsql, I can also install a psqlrc
> > file into pgdata/psqlrc...but, as pgsql, I can't install the same thing in
> > /etc
> >
> > So, what we are saying, is that in order to *completely* install
> > PostgreSQL, you now have to have root access? Completely including the
> > psqlrc file...
>
> Makes sense. Maybe we should look in /etc, the PostgreSQL install
> directory, then the user's home directory.
>
> --
> Bruce Momjian
> maillist@candle.pha.pa.us
>
OK, here's a patch (to be applied after the previous one) which now checks
1. /etc/pgsqlrc
2. $(PGDATA)/pgsqlrc
3. $(HOME)/.pgsqlrc
Andrew
*** psql.c.new Tue Jun 24 13:54:34 1997
- --- psql.c Tue Jun 24 13:56:32 1997
***************
*** 1736,1741 ****
- --- 1736,1757 ----
*/
if(!access("/etc/psqlrc",R_OK))
HandleSlashCmds(&settings, "\\i /etc/psqlrc", "");
+ if((home = getenv("PGDATA"))!=NULL) {
+ char *psqlrc = NULL,
+ *line = NULL;
+
+ if((psqlrc = (char *)malloc(strlen(home) + 10))!=NULL) {
+ sprintf(psqlrc, "%s/psqlrc", home);
+ if(!access(psqlrc, R_OK)) {
+ if((line = (char *)malloc(strlen(psqlrc) + 5))!=NULL) {
+ sprintf(line, "\\i %s", psqlrc);
+ HandleSlashCmds(&settings, line, "");
+ free(line);
+ }
+ }
+ free(psqlrc);
+ }
+ }
if((home = getenv("HOME"))!=NULL) {
char *psqlrc = NULL,
*line = NULL;
- ----------------------------------------------------------------------------
Dr. Andrew C.R. Martin University College London
EMAIL: (Work) martin@biochem.ucl.ac.uk (Home) andrew@stagleys.demon.co.uk
URL: http://www.biochem.ucl.ac.uk/~martin
Tel: (Work) +44(0)171 419 3890 (Home) +44(0)1372 275775
------------------------------
В списке pgsql-hackers по дате отправления: