DEVEL15-pt_util-database-path-20080630
authorRuss Allbery <rra@stanford.edu>
Tue, 1 Jul 2008 06:57:35 +0000 (06:57 +0000)
committerRuss Allbery <rra@stanford.edu>
Tue, 1 Jul 2008 06:57:35 +0000 (06:57 +0000)
LICENSE BSD

Use the dirpath functions to find the prdb database path in pt_util instead
of hard-coding the default Transarc path.

(cherry picked from commit 5e1459f431fc046dfd3b25aca87709193ccca211)

src/ptserver/pt_util.c

index 1b276b8..d34f441 100644 (file)
@@ -26,6 +26,7 @@ RCSID
     ("$Header$");
 
 #include <afs/cmd.h>           /*Command line parsing */
+#include <afs/afsutil.h>
 #include <errno.h>
 #include <lock.h>
 #include <netinet/in.h>
@@ -137,7 +138,9 @@ CommandProc(register struct cmd_syndesc *a_as, void *arock)
     struct prentry uentry, gentry;
     struct ubik_hdr *uh;
     char *dfile = 0;
-    char *pfile = "/usr/afs/db/prdb.DB0";
+    char *pbase = AFSDIR_SERVER_PRDB_FILEPATH;
+    char *pfile = NULL;
+    char pbuffer[1028];
     struct cmd_parmdesc *tparm;
 
     tparm = a_as->parms;
@@ -170,6 +173,10 @@ CommandProc(register struct cmd_syndesc *a_as, void *arock)
        dfile = tparm[8].items->data;
     }
 
+    if (pfile == NULL) {
+        afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0", pbase);
+        pfile = pbuffer;
+    }
     if ((dbase_fd = open(pfile, (wflag ? O_RDWR : O_RDONLY) | O_CREAT, 0600))
        < 0) {
        fprintf(stderr, "pt_util: cannot open %s: %s\n", pfile,