$NetBSD$

--- src/main.c.orig	2011-09-23 20:31:32.000000000 +0000
+++ src/main.c
@@ -72,7 +72,7 @@
 #  define _POSIX_SOURCE 1               /* Solaris needs this */
 #endif
 
-extern char origbotname[], userfile[], botnetnick[];
+extern char origbotname[], userfile[], botnetnick[], tempdir[];
 extern int dcc_total, conmask, cache_hit, cache_miss, max_logs, quick_logs,
            quiet_save;
 extern struct dcc_t *dcc;
@@ -108,7 +108,7 @@ int con_chan = 0;       /* Foreground: c
 int term_z = 0;         /* Foreground: use the terminal as a partyline?  */
 int use_stderr = 1;     /* Send stuff to stderr instead of logfiles?     */
 
-char configfile[121] = "eggdrop.conf";  /* Default config file name */
+char configfile[121] = __PKG_SYSCONFDIR__ "/eggdrop.conf";  /* Default config file name */
 char pid_file[120];                     /* Name of the pid file     */
 char helpdir[121] = "help/";            /* Directory of help files  */
 char textdir[121] = "text/";            /* Directory for text files */
@@ -963,6 +963,8 @@ int main(int arg_c, char **arg_v)
   setrlimit(RLIMIT_CORE, &cdlim);
 #endif
 
+  chdir(__PREFIX__ "/share/eggdrop");
+
 #ifdef DEBUG_CONTEXT
   /* Initialise context list */
   for (i = 0; i < 16; i++)
@@ -1075,7 +1077,8 @@ int main(int arg_c, char **arg_v)
   cache_miss = 0;
   cache_hit = 0;
   if (!pid_file[0])
-    egg_snprintf(pid_file, sizeof pid_file, "pid.%s", botnetnick);
+    egg_snprintf(pid_file, sizeof pid_file, "%.100s/pid.%.32s",
+                 tempdir, botnetnick);
 
   /* Check for pre-existing eggdrop! */
   f = fopen(pid_file, "r");
