diff options
author | Bruce Momjian <bruce@momjian.us> | 2004-07-11 00:18:45 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2004-07-11 00:18:45 +0000 |
commit | 130f89e93f59cdb4b160cbc31e6929de25d13794 (patch) | |
tree | 7ac3acd73f01020a12fe37d9c6e89547dcae2f46 /src/backend/libpq/hba.c | |
parent | b4a98c5fcc6b418912dde8e8ce3a8a486cbe4c85 (diff) |
Allow configuration files to be placed outside the data directory.
Add new postgresql.conf variables to point to data, pg_hba.conf, and
pg_ident.conf files.
Needs more documentation.
Diffstat (limited to 'src/backend/libpq/hba.c')
-rw-r--r-- | src/backend/libpq/hba.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index d15e8f6aff4..4577aec4935 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.125 2004/05/30 23:40:26 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.126 2004/07/11 00:18:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,6 +35,7 @@ #include "miscadmin.h" #include "nodes/pg_list.h" #include "storage/fd.h" +#include "utils/guc.h" /* Max size of username ident server can return */ @@ -1029,17 +1030,22 @@ load_user(void) void load_hba(void) { - int bufsize; FILE *file; /* The config file we have to read */ char *conf_file; /* The name of the config file */ if (hba_lines || hba_line_nums) free_lines(&hba_lines, &hba_line_nums); - /* Put together the full pathname to the config file. */ - bufsize = (strlen(DataDir) + strlen(CONF_FILE) + 2) * sizeof(char); - conf_file = (char *) palloc(bufsize); - snprintf(conf_file, bufsize, "%s/%s", DataDir, CONF_FILE); + /* HBA filename in config file */ + if (guc_hbafile) + conf_file = pstrdup(guc_hbafile); + else + { + char *confloc = (user_pgconfig_is_dir) ? user_pgconfig : DataDir; + /* put together the full pathname to the config file */ + conf_file = palloc(strlen(confloc) + strlen(CONF_FILE) + 2); + sprintf(conf_file, "%s/%s", confloc, CONF_FILE); + } file = AllocateFile(conf_file, "r"); if (file == NULL) @@ -1178,16 +1184,20 @@ load_ident(void) FILE *file; /* The map file we have to read */ char *map_file; /* The name of the map file we have to * read */ - int bufsize; - if (ident_lines || ident_line_nums) free_lines(&ident_lines, &ident_line_nums); - /* put together the full pathname to the map file */ - bufsize = (strlen(DataDir) + strlen(USERMAP_FILE) + 2) * sizeof(char); - map_file = (char *) palloc(bufsize); - snprintf(map_file, bufsize, "%s/%s", DataDir, USERMAP_FILE); - + /* IDENT filename in config file */ + if (guc_identfile) + map_file = pstrdup(guc_identfile); + else + { + /* put together the full pathname to the map file */ + char *confloc = (user_pgconfig_is_dir) ? user_pgconfig : DataDir; + map_file = (char *) palloc(strlen(confloc) + strlen(USERMAP_FILE) + 2); + sprintf(map_file, "%s/%s", confloc, USERMAP_FILE); + } + file = AllocateFile(map_file, "r"); if (file == NULL) { |