diff options
-rw-r--r-- | ChangeLog.txt | 2 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | pseudo.c | 17 | ||||
-rw-r--r-- | pseudo.h | 27 | ||||
-rw-r--r-- | pseudo_client.c | 96 | ||||
-rw-r--r-- | pseudo_client.h | 3 | ||||
-rw-r--r-- | pseudo_db.c | 4 | ||||
-rw-r--r-- | pseudo_server.c | 12 | ||||
-rw-r--r-- | pseudo_util.c | 172 | ||||
-rw-r--r-- | pseudo_wrappers.c | 24 | ||||
-rw-r--r-- | pseudolog.c | 15 | ||||
-rwxr-xr-x | run_tests.sh | 1 |
12 files changed, 270 insertions, 105 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index b9c2654..9b7ce22 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,8 @@ 2010-08-03: * (mhatle) Fix parallel build problem * (mhatle) allow both environment CFLAGS and internals CFLAGS + * (mhatle) add PSEUDO_BINDIR, PSEUDO_LIBDIR, PSEUDO_LOCALSTATEDIR + to allow specific overrides above and beyond PSEUDO_PREFIX 2010-07-30: * (kscherer) added .gitignore file diff --git a/Makefile.in b/Makefile.in index d616fd4..1093aea 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,7 +34,7 @@ LOCALSTATEDIR=$(PREFIX)/$(LOCALSTATE) CFLAGS_BASE=-pipe -std=gnu99 -Wall -W -Wextra CFLAGS_CODE=-fPIC -D_LARGEFILE64_SOURCE -D_ATFILE_SOURCE -m$(BITS) -CFLAGS_DEFS=-DPSEUDO_PREFIX='"$(PREFIX)"' -DPSEUDO_SUFFIX='"$(SUFFIX)"' -DPSEUDO_VERSION='"$(VERSION)"' +CFLAGS_DEFS=-DPSEUDO_PREFIX='"$(PREFIX)"' -DPSEUDO_SUFFIX='"$(SUFFIX)"' -DPSEUDO_BINDIR='"$(BIN)"' -DPSEUDO_LIBDIR='"$(LIB)"' -DPSEUDO_LOCALSTATEDIR='"$(LOCALSTATE)"' -DPSEUDO_VERSION='"$(VERSION)"' CFLAGS_DEBUG=-O2 -g CFLAGS_SQL=-L$(SQLITE)/lib -I$(SQLITE)/include CFLAGS_PSEUDO=$(CFLAGS_BASE) $(CFLAGS_CODE) $(CFLAGS_DEFS) \ @@ -184,6 +184,21 @@ main(int argc, char *argv[]) { exit(EXIT_FAILURE); } + if (!pseudo_get_bindir()) { + pseudo_diag("Can't figure out bindir. Set PSEUDO_BINDIR.\n"); + exit(EXIT_FAILURE); + } + + if (!pseudo_get_libdir()) { + pseudo_diag("Can't figure out libdir. Set PSEUDO_LIBDIR.\n"); + exit(EXIT_FAILURE); + } + + if (!pseudo_get_localstatedir()) { + pseudo_diag("Can't figure out localstatedir. Set PSEUDO_LOCALSTATEDIR.\n"); + exit(EXIT_FAILURE); + } + if (opt_C) { return pseudo_db_check(); } @@ -272,7 +287,7 @@ main(int argc, char *argv[]) { pseudo_new_pid(); pseudo_debug(3, "opening lock.\n"); - lockname = pseudo_prefix_path(PSEUDO_LOCKFILE); + lockname = pseudo_localstatedir_path(PSEUDO_LOCKFILE); if (!lockname) { pseudo_diag("Couldn't allocate a file path.\n"); exit(EXIT_FAILURE); @@ -124,7 +124,13 @@ extern char *pseudo_fix_path(const char *, const char *, size_t, size_t, size_t extern char **pseudo_dropenv(char * const *); extern char **pseudo_setupenv(char * const *, char *); extern char *pseudo_prefix_path(char *); +extern char *pseudo_bindir_path(char *); +extern char *pseudo_libdir_path(char *); +extern char *pseudo_localstatedir_path(char *); extern char *pseudo_get_prefix(char *); +extern char *pseudo_get_bindir(); +extern char *pseudo_get_libdir(); +extern char *pseudo_get_localstatedir(); extern int pseudo_logfile(char *defname); extern ssize_t pseudo_sys_path_max(void); extern ssize_t pseudo_path_max(void); @@ -134,11 +140,22 @@ extern int pseudo_etc_file(const char *filename, char *realname, int flags, char extern char *pseudo_version; -#define PSEUDO_DATA "var/pseudo/" -#define PSEUDO_LOCKFILE PSEUDO_DATA "pseudo.lock" -#define PSEUDO_LOGFILE PSEUDO_DATA "pseudo.log" -#define PSEUDO_PIDFILE PSEUDO_DATA "pseudo.pid" -#define PSEUDO_SOCKET PSEUDO_DATA "pseudo.socket" +#ifndef PSEUDO_BINDIR + #define PSEUDO_BINDIR "bin" +#endif + +#ifndef PSEUDO_LIBDIR + #define PSEUDO_LIBDIR "lib" +#endif + +#ifndef PSEUDO_LOCALSTATEDIR + #define PSEUDO_LOCALSTATEDIR "var/pseudo" +#endif + +#define PSEUDO_LOCKFILE "pseudo.lock" +#define PSEUDO_LOGFILE "pseudo.log" +#define PSEUDO_PIDFILE "pseudo.pid" +#define PSEUDO_SOCKET "pseudo.socket" /* some systems might not have *at(). We like to define operations in * terms of each other, and for instance, open(...) is the same as diff --git a/pseudo_client.c b/pseudo_client.c index f58d633..4c8cee0 100644 --- a/pseudo_client.c +++ b/pseudo_client.c @@ -44,7 +44,8 @@ static char *base_path(int dirfd, const char *path, int leave_last); static int connect_fd = -1; static int server_pid = 0; -int pseudo_dir_fd = -1; +int pseudo_prefix_dir_fd = -1; +int pseudo_localstate_dir_fd = -1; int pseudo_pwd_fd = -1; int pseudo_pwd_lck_fd = -1; char *pseudo_pwd_lck_name = NULL; @@ -358,7 +359,7 @@ client_spawn_server(void) { int status; FILE *fp; extern char **environ; - int cwd_fd; + char * pseudo_pidfile; if ((server_pid = fork()) != 0) { if (server_pid == -1) { @@ -371,24 +372,8 @@ client_spawn_server(void) { */ waitpid(server_pid, &status, 0); server_pid = -2; - cwd_fd = open(".", O_RDONLY); - if (cwd_fd == -1) { - pseudo_diag("Couldn't stash directory before opening pidfile: %s", - strerror(errno)); - close(connect_fd); - connect_fd = -1; - return 1; - } - if (fchdir(pseudo_dir_fd)) { - pseudo_diag("Couldn't change to server dir [%d]: %s\n", - pseudo_dir_fd, strerror(errno)); - } - fp = fopen(PSEUDO_PIDFILE, "r"); - if (fchdir(cwd_fd) == -1) { - pseudo_diag("return to previous directory failed: %s\n", - strerror(errno)); - } - close(cwd_fd); + pseudo_pidfile = pseudo_localstatedir_path(PSEUDO_PIDFILE); + fp = fopen(pseudo_pidfile, "r"); if (fp) { if (fscanf(fp, "%d", &server_pid) != 1) { pseudo_debug(1, "Opened server PID file, but didn't get a pid.\n"); @@ -396,9 +381,10 @@ client_spawn_server(void) { fclose(fp); } else { pseudo_diag("no pid file (%s): %s\n", - PSEUDO_PIDFILE, strerror(errno)); + pseudo_pidfile, strerror(errno)); } pseudo_debug(2, "read new pid file: %d\n", server_pid); + free(pseudo_pidfile); /* at this point, we should have a new server_pid */ return 0; } else { @@ -409,7 +395,7 @@ client_spawn_server(void) { int fd; pseudo_new_pid(); - base_args[0] = "bin/pseudo"; + base_args[0] = pseudo_bindir_path("pseudo"); base_args[1] = "-d"; if (getenv("PSEUDO_OPTS")) { char *option_string = strdup(getenv("PSEUDO_OPTS")); @@ -439,10 +425,6 @@ client_spawn_server(void) { } else { argv = base_args; } - if (fchdir(pseudo_dir_fd)) { - pseudo_diag("Couldn't change to server dir [%d]: %s\n", - pseudo_dir_fd, strerror(errno)); - } /* close any higher-numbered fds which might be open, * such as sockets. We don't have to worry about 0 and 1; * the server closes them already, and more importantly, @@ -542,7 +524,7 @@ client_connect(void) { connect_fd = socket(PF_UNIX, SOCK_STREAM, 0); connect_fd = pseudo_fd(connect_fd, MOVE_FD); if (connect_fd == -1) { - pseudo_diag("can't create socket: %s\n", strerror(errno)); + pseudo_diag("can't create socket: %s (%s)\n", sun.sun_path, strerror(errno)); return 1; } @@ -555,9 +537,9 @@ client_connect(void) { connect_fd = -1; return 1; } - if (fchdir(pseudo_dir_fd) == -1) { + if (fchdir(pseudo_localstate_dir_fd) == -1) { pseudo_diag("Couldn't chdir to server directory [%d]: %s\n", - pseudo_dir_fd, strerror(errno)); + pseudo_localstate_dir_fd, strerror(errno)); close(connect_fd); close(cwd_fd); connect_fd = -1; @@ -585,6 +567,7 @@ client_connect(void) { static int pseudo_client_setup(void) { + char * pseudo_pidfile; FILE *fp; server_pid = 0; int cwd_fd; @@ -595,25 +578,8 @@ pseudo_client_setup(void) { connect_fd = -1; } - cwd_fd = open(".", O_RDONLY); - if (cwd_fd == -1) { - pseudo_diag("Couldn't stash directory before opening pidfile: %s", - strerror(errno)); - close(connect_fd); - connect_fd = -1; - return 1; - } - if (fchdir(pseudo_dir_fd) != 1) { - fp = fopen(PSEUDO_PIDFILE, "r"); - if (fchdir(cwd_fd) == -1) { - pseudo_diag("return to previous directory failed: %s\n", - strerror(errno)); - } - } else { - fp = NULL; - pseudo_diag("couldn't change to pseudo working directory for pid file.\n"); - } - close(cwd_fd); + pseudo_pidfile = pseudo_localstatedir_path(PSEUDO_PIDFILE); + fp = fopen(pseudo_pidfile, "r"); if (fp) { if (fscanf(fp, "%d", &server_pid) != 1) { pseudo_debug(1, "Opened server PID file, but didn't get a pid.\n"); @@ -711,17 +677,35 @@ pseudo_client_shutdown(void) { char *pseudo_path; pseudo_path = pseudo_prefix_path(NULL); - if (pseudo_dir_fd == -1) { + if (pseudo_prefix_dir_fd == -1) { + if (pseudo_path) { + pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY); + pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, COPY_FD); + free(pseudo_path); + } else { + pseudo_diag("No prefix available to to find server.\n"); + exit(1); + } + if (pseudo_prefix_dir_fd == -1) { + pseudo_diag("Can't open prefix path (%s) for server. (%s)\n", + pseudo_prefix_path(NULL), + strerror(errno)); + exit(1); + } + } + pseudo_path = pseudo_localstatedir_path(NULL); + if (pseudo_localstate_dir_fd == -1) { if (pseudo_path) { - pseudo_dir_fd = open(pseudo_path, O_RDONLY); - pseudo_dir_fd = pseudo_fd(pseudo_dir_fd, COPY_FD); + pseudo_localstate_dir_fd = open(pseudo_path, O_RDONLY); + pseudo_localstate_dir_fd = pseudo_fd(pseudo_localstate_dir_fd, COPY_FD); free(pseudo_path); } else { pseudo_diag("No prefix available to to find server.\n"); exit(1); } - if (pseudo_dir_fd == -1) { - pseudo_diag("Can't open prefix path (%s) for server.\n", + if (pseudo_localstate_dir_fd == -1) { + pseudo_diag("Can't open prefix path (%s) for server. (%s)\n", + pseudo_localstatedir_path(NULL), strerror(errno)); exit(1); } @@ -934,8 +918,10 @@ pseudo_client_op(op_id_t op, int access, int fd, int dirfd, const char *path, co } } else if (fd == pseudo_util_debug_fd) { pseudo_util_debug_fd = pseudo_fd(fd, COPY_FD); - } else if (fd == pseudo_dir_fd) { - pseudo_dir_fd = pseudo_fd(fd, COPY_FD); + } else if (fd == pseudo_prefix_dir_fd) { + pseudo_prefix_dir_fd = pseudo_fd(fd, COPY_FD); + } else if (fd == pseudo_localstate_dir_fd) { + pseudo_localstate_dir_fd = pseudo_fd(fd, COPY_FD); } else if (fd == pseudo_pwd_fd) { pseudo_pwd_fd = pseudo_fd(fd, COPY_FD); /* since we have a FILE * on it, we close that... */ diff --git a/pseudo_client.h b/pseudo_client.h index 5b2a7f9..6bb334e 100644 --- a/pseudo_client.h +++ b/pseudo_client.h @@ -39,7 +39,8 @@ extern gid_t pseudo_egid; extern gid_t pseudo_sgid; extern gid_t pseudo_rgid; extern gid_t pseudo_fgid; -extern int pseudo_dir_fd; +extern int pseudo_prefix_dir_fd; +extern int pseudo_localstate_dir_fd; extern FILE *pseudo_pwd_open(void); extern FILE *pseudo_grp_open(void); extern void pseudo_pwd_close(void); diff --git a/pseudo_db.c b/pseudo_db.c index c024287..8e3b9b4 100644 --- a/pseudo_db.c +++ b/pseudo_db.c @@ -471,11 +471,11 @@ get_db(sqlite3 **db) { if (*db) return 0; if (db == &file_db) { - dbfile = pseudo_prefix_path(PSEUDO_DATA "files.db"); + dbfile = pseudo_localstatedir_path("files.db"); rc = sqlite3_open(dbfile, db); free(dbfile); } else { - dbfile = pseudo_prefix_path(PSEUDO_DATA "logs.db"); + dbfile = pseudo_localstatedir_path("logs.db"); rc = sqlite3_open(dbfile, db); free(dbfile); } diff --git a/pseudo_server.c b/pseudo_server.c index b8c754b..071614c 100644 --- a/pseudo_server.c +++ b/pseudo_server.c @@ -83,7 +83,7 @@ static void pseudo_server_loop(void); int pseudo_server_start(int daemonize) { - struct sockaddr_un sun = { AF_UNIX, "pseudo.socket" }; + struct sockaddr_un sun = { AF_UNIX, PSEUDO_SOCKET }; char *pseudo_path; int rc, newfd; FILE *fp; @@ -107,12 +107,8 @@ pseudo_server_start(int daemonize) { } /* cd to the data directory */ - pseudo_path = pseudo_prefix_path(PSEUDO_DATA); - if (!pseudo_path) { - pseudo_diag("can't find prefix/%s directory.\n", PSEUDO_DATA); - return 1; - } - if (chdir(pseudo_path) == -1) { + pseudo_path = pseudo_localstatedir_path(NULL); + if (!pseudo_path || chdir(pseudo_path) == -1) { pseudo_diag("can't get to '%s': %s\n", pseudo_path, strerror(errno)); return 1; @@ -138,7 +134,7 @@ pseudo_server_start(int daemonize) { return 0; } setsid(); - pseudo_path = pseudo_prefix_path(PSEUDO_PIDFILE); + pseudo_path = pseudo_localstatedir_path(PSEUDO_PIDFILE); if (!pseudo_path) { pseudo_diag("Couldn't get path for prefix/%s\n", PSEUDO_PIDFILE); return 1; diff --git a/pseudo_util.c b/pseudo_util.c index 48cf20d..0408a56 100644 --- a/pseudo_util.c +++ b/pseudo_util.c @@ -521,18 +521,16 @@ pseudo_setupenv(char * const *environ, char *opts) { } new_environ[j++] = newenv; } else if (!memcmp(environ[i], "LD_LIBRARY_PATH=", 16)) { - if (!strstr(environ[i], PSEUDO_PREFIX)) { - char *e1, *e2; - e1 = pseudo_prefix_path("lib"); - e2 = pseudo_prefix_path("lib64"); - len = strlen(environ[i]) + strlen(e1) + strlen(e2) + 3; + if (!strstr(environ[i], pseudo_libdir_path(NULL))) { + char *e1; + e1 = pseudo_libdir_path(NULL); + len = strlen(environ[i]) + strlen(e1) + (strlen(e1) + 2) + 3; newenv = malloc(len); if (!newenv) { pseudo_diag("fatal: can't allocate new environment variable.\n"); } - snprintf(newenv, len, "%s:%s:%s", environ[i], e1, e2); + snprintf(newenv, len, "%s:%s:%s64", environ[i], e1, e1); free(e1); - free(e2); new_environ[j++] = newenv; } else { new_environ[j++] = environ[i]; @@ -542,15 +540,14 @@ pseudo_setupenv(char * const *environ, char *opts) { } } if (!found_libpath) { - char *e1, *e2; - e1 = pseudo_prefix_path("lib"); - e2 = pseudo_prefix_path("lib64"); - len = 16 + strlen(e1) + strlen(e2) + 2; + char *e1; + e1 = pseudo_libdir_path(NULL); + len = 16 + strlen(e1) + (strlen(e1) + 2) + 2; newenv = malloc(len); if (!newenv) { pseudo_diag("fatal: can't allocate new environment variable.\n"); } - snprintf(newenv, len, "LD_LIBRARY_PATH=%s:%s", e1, e2); + snprintf(newenv, len, "LD_LIBRARY_PATH=%s:%s64", e1, e1); new_environ[j++] = newenv; } if (!found_preload) { @@ -578,23 +575,11 @@ pseudo_setupenv(char * const *environ, char *opts) { return new_environ; } -/* get the full path to a file under $PSEUDO_PREFIX. Other ways of - * setting the prefix all set it in the environment. - */ +/* Append the file value to the prefix value. */ char * -pseudo_prefix_path(char *file) { - static char *prefix = NULL; - static size_t prefix_len; +pseudo_append_path(const char * prefix, size_t prefix_len, char *file) { char *path; - if (!prefix) { - prefix = getenv("PSEUDO_PREFIX"); - if (!prefix) { - pseudo_diag("You must set the PSEUDO_PREFIX environment variable to run pseudo.\n"); - exit(1); - } - prefix_len = strlen(prefix); - } if (!file) { return strdup(prefix); } else { @@ -621,6 +606,81 @@ pseudo_prefix_path(char *file) { } } + +/* get the full path to a file under $PSEUDO_PREFIX. Other ways of + * setting the prefix all set it in the environment. + */ +char * +pseudo_prefix_path(char *file) { + static char *prefix = NULL; + static size_t prefix_len; + + if (!prefix) { + prefix = getenv("PSEUDO_PREFIX"); + if (!prefix) { + pseudo_diag("You must set the PSEUDO_PREFIX environment variable to run pseudo.\n"); + exit(1); + } + prefix_len = strlen(prefix); + } + + return pseudo_append_path(prefix, prefix_len, file); +} + +/* get the full path to a file under $PSEUDO_BINDIR. */ +char * +pseudo_bindir_path(char *file) { + static char *bindir = NULL; + static size_t bindir_len; + + if (!bindir) { + bindir = pseudo_get_bindir(); + if (!bindir) { + pseudo_diag("You must set the PSEUDO_BINDIR environment variable to run pseudo.\n"); + exit(1); + } + bindir_len = strlen(bindir); + } + + return pseudo_append_path(bindir, bindir_len, file); +} + +/* get the full path to a file under $PSEUDO_LIBDIR. */ +char * +pseudo_libdir_path(char *file) { + static char *libdir = NULL; + static size_t libdir_len; + + if (!libdir) { + libdir = pseudo_get_libdir(); + if (!libdir) { + pseudo_diag("You must set the PSEUDO_LIBDIR environment variable to run pseudo.\n"); + exit(1); + } + libdir_len = strlen(libdir); + } + + return pseudo_append_path(libdir, libdir_len, file); +} + +/* get the full path to a file under $PSEUDO_LOCALSTATEDIR. */ +char * +pseudo_localstatedir_path(char *file) { + static char *localstatedir = NULL; + static size_t localstatedir_len; + + if (!localstatedir) { + localstatedir = pseudo_get_localstatedir(); + if (!localstatedir) { + pseudo_diag("You must set the PSEUDO_LOCALSTATEDIR environment variable to run pseudo.\n"); + exit(1); + } + localstatedir_len = strlen(localstatedir); + } + + return pseudo_append_path(localstatedir, localstatedir_len, file); +} + char * pseudo_get_prefix(char *pathname) { char *s; @@ -676,6 +736,64 @@ pseudo_get_prefix(char *pathname) { return s; } +char * +pseudo_get_bindir() { + char *s; + s = getenv("PSEUDO_BINDIR"); + if (!s) { + char *pseudo_bindir; + pseudo_bindir = pseudo_prefix_path(PSEUDO_BINDIR); + if (pseudo_bindir) { + setenv("PSEUDO_BINDIR", pseudo_bindir, 1); + s = getenv("PSEUDO_BINDIR"); + } + } + return s; +} + +char * +pseudo_get_libdir() { + char *s; + s = getenv("PSEUDO_LIBDIR"); + if (!s) { + char *pseudo_libdir; + pseudo_libdir = pseudo_prefix_path(PSEUDO_LIBDIR); + if (pseudo_libdir) { + setenv("PSEUDO_LIBDIR", pseudo_libdir, 1); + s = getenv("PSEUDO_LIBDIR"); + } + } + /* If we somehow got lib64 in there, clean it down to just lib... */ + if (s) { + size_t len = strlen(s); + if (s[len-2] == '6' && s[len-1] == '4') { + char mypath[pseudo_path_max()]; + snprintf(mypath, pseudo_path_max(), "%s", s); + s = mypath + (strlen(mypath) - 2); + s[0] = '\0'; + setenv("PSEUDO_LIBDIR", mypath, 1); + s = getenv("PSEUDO_LIBDIR"); + } + } + + return s; +} + +char * +pseudo_get_localstatedir() { + char *s; + s = getenv("PSEUDO_LOCALSTATEDIR"); + if (!s) { + char *pseudo_localstatedir; + pseudo_localstatedir = pseudo_prefix_path(PSEUDO_LOCALSTATEDIR); + if (pseudo_localstatedir) { + setenv("PSEUDO_LOCALSTATEDIR", pseudo_localstatedir, 1); + s = getenv("PSEUDO_LOCALSTATEDIR"); + } + } + return s; +} + /* these functions define the sizes pseudo will try to use * when trying to allocate space, or guess how much space * other people will have allocated; see the GNU man page @@ -840,7 +958,7 @@ pseudo_logfile(char *defname) { pseudo_debug(3, "no special log file requested, using stderr.\n"); return -1; } - pseudo_path = pseudo_prefix_path(defname); + pseudo_path = pseudo_localstatedir_path(defname); if (!pseudo_path) { pseudo_diag("can't get path for prefix/%s\n", PSEUDO_LOGFILE); return -1; diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c index fd51e9a..4e98efa 100644 --- a/pseudo_wrappers.c +++ b/pseudo_wrappers.c @@ -181,16 +181,32 @@ pseudo_populate_wrappers(void) { */ pseudo_client_reset(); pseudo_path = pseudo_prefix_path(NULL); - if (pseudo_dir_fd == -1) { + if (pseudo_prefix_dir_fd == -1) { if (pseudo_path) { - pseudo_dir_fd = open(pseudo_path, O_RDONLY); - pseudo_dir_fd = pseudo_fd(pseudo_dir_fd, MOVE_FD); + pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY); + pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, MOVE_FD); free(pseudo_path); } else { pseudo_diag("No prefix available to to find server.\n"); exit(1); } - if (pseudo_dir_fd == -1) { + if (pseudo_prefix_dir_fd == -1) { + pseudo_diag("Can't open prefix path (%s) for server.\n", + strerror(errno)); + exit(1); + } + } + pseudo_path = pseudo_localstatedir_path(NULL); + if (pseudo_localstate_dir_fd == -1) { + if (pseudo_path) { + pseudo_localstate_dir_fd = open(pseudo_path, O_RDONLY); + pseudo_localstate_dir_fd = pseudo_fd(pseudo_localstate_dir_fd, MOVE_FD); + free(pseudo_path); + } else { + pseudo_diag("No prefix available to to find server.\n"); + exit(1); + } + if (pseudo_localstate_dir_fd == -1) { pseudo_diag("Can't open prefix path (%s) for server.\n", strerror(errno)); exit(1); diff --git a/pseudolog.c b/pseudolog.c index 1316b9d..e2161c4 100644 --- a/pseudolog.c +++ b/pseudolog.c @@ -619,6 +619,21 @@ main(int argc, char **argv) { exit(EXIT_FAILURE); } + if (!pseudo_get_bindir()) { + pseudo_diag("Can't figure out bindir. Set PSEUDO_BINDIR.\n"); + exit(EXIT_FAILURE); + } + + if (!pseudo_get_libdir()) { + pseudo_diag("Can't figure out libdir. Set PSEUDO_LIBDIR.\n"); + exit(EXIT_FAILURE); + } + + if (!pseudo_get_localstatedir()) { + pseudo_diag("Can't figure out localstatedir. Set PSEUDO_LOCALSTATEDIR.\n"); + exit(EXIT_FAILURE); + } + if (opt_l) { pdb_log_traits(traits); } else { diff --git a/run_tests.sh b/run_tests.sh index 9915d3b..9228668 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -24,7 +24,6 @@ done #The tests will be run on the build dir, not the installed versions #This requires to following be set properly. export PSEUDO_PREFIX=${PWD} -export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" num_tests=0 num_passed_tests=0 |