Subject: su -m in postresql rc script causes problems on Mac OS X (patch)
To: None <tech-pkg@NetBSD.org>
From: Louis Guillaume <lguillaume@berklee.edu>
List: tech-pkg
Date: 12/15/2007 13:05:55
Hi,

Using pkgsrc-2007Q3, databases/postgresql82-server, OS X (Intel)

On Mac OS X the pgsql rc script has trouble after the initial startup. 
Like this...

# /etc/rc.d/pgsql stop
Stopping pgsql.
shell-init: could not get current directory: getcwd: cannot access 
parent directories: Permission denied
could not identify current directory: Permission denied
server stopped
# /etc/rc.d/pgsql start
Starting pgsql.
shell-init: could not get current directory: getcwd: cannot access 
parent directories: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by pg_ctl but was not found in the
same directory as "pg_ctl".
Check your installation.
#


The patch below seems to fix the problem on OS X and, while NetBSD 
doesn't have this problem, the patch does not appear to affect NetBSD. 
Haven't tried other OSes.

Basically do a `su -l' (or `su -') instead of `su -m'. Should I send-pr 
with this fix?

Thanks,

Louis




--- files/pgsql.sh.orig 2007-12-15 12:56:44.000000000 -0500
+++ files/pgsql.sh      2007-12-15 12:58:02.000000000 -0500
@@ -80,7 +80,7 @@
                 common_args_without_m=$(echo "${common_args}" |\
                     sed -e 's/-m [a-z]*//')
                 eval doit_command=\"${initdb} ${common_args_without_m} 
${flags}\"
-               doit="@SU@ -m ${pgsql_user} -c '${doit_command}'"
+               doit="@SU@ -l ${pgsql_user} -c '${doit_command}'"
                 eval $doit
         fi
  }
@@ -115,7 +115,7 @@
         esac

         eval doit_command=\"${ctl_command} ${action} ${command_args}\"
-       doit="@SU@ -m ${pgsql_user} -c '${doit_command}'"
+       doit="@SU@ -l ${pgsql_user} -c '${doit_command}'"
         eval $doit
  }