1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
6
<title>Autoconf Macro: ms_pgsql_priv_root</title>
7
<link rel="stylesheet" type="text/css" href="ac-archive.css">
11
<table summary="web navigation" style="width:100%;">
14
<td style="width:50%;" align="center">[<a href="index.html">Macro Index
17
<td style="width:50%;" align="center">[<a href=
18
"../m4source/ms_pgsql_priv_root.m4">Download M4 Source</a>]</td>
24
<h1>ms_pgsql_priv_root</h1>
29
<p style="text-align:left; white-space:nowrap;">
30
<code>MS_PGSQL_PRIV_ROOT(DB, USER, [HOST], [PASSWORD], [ACTION_IF_FAILED],
31
[ACTION_IF_OK])</code></p>
37
<p>This macro checks wether the given PostgreSQL user has root privileges
38
(can create and drop databases) It is recommended to first call
39
MS_CHECK_PGSQL_DB, this makes it easier to locate the cause of error. The
40
macro MS_PROG_PGCLIENT is required by this one.</p>
42
<p>The variable $pgclient_root_call is set for later use in Makefiles, if
43
you'd like to make use of this, you must do</p>
45
AC_SUBST(pgclient_root_call)
48
<p>after having called MS_CHECK_PGSQL_PRIV_ROOT. You can then do something
49
like the following in your Makefile.am:</p>
51
@pgclient_root_call@ -f file.sql
54
<p>If you want the user to set the data, you should support something like
55
these configure options:</p>
57
AC_ARG_WITH(pgsql-host,
58
[ --with-pgsql-host=HOST server is running on HOST @<:@local socket@:>@],
59
[pg_host=$withval], [pg_host=])
63
[ --with-pgsql-db=DBNAME use database DBNAME @<:@test@:>@],
64
[pg_db=$withval], [pg_db=test])
67
AC_ARG_WITH(pgsql-root-user,
68
[ --with-pgsql-root-user=USER use user USER, must have root (all) privileges @<:@postgres@:>@],
69
[pg_root_user=$withval], [pg_root_user=postgres])
72
AC_ARG_WITH(pgsql-password,
73
[ --with-pgsql-password=PASSWORD use password PASSWORD @<:@none@:>@],
74
[pg_password=$withval], [pg_password=""])
77
<p>You can then call the macro like this:</p>
79
MS_CHECK_PGSQL_PRIV_ROOT([$pg_db], [$pg_root_user], [$pg_host], [$pg_password], [AC_MSG_ERROR([We need root privileges on database!])])
86
<p>1.1 (last modified: 2002-09-25)</p>
92
<p>Moritz Sinn <moritz@freesources.org></p>
95
<h2>M4 Source Code</h2>
98
<pre class="m4source">
99
AC_DEFUN([MS_CHECK_PGSQL_PRIV_ROOT], [
100
AC_REQUIRE([MS_PROG_PGCLIENT])dnl
101
AC_REQUIRE([MS_CHECK_PGSQL_DB])dnl
102
AC_MSG_CHECKING([if PostgreSQL user $2 has root privileges])
104
pgclient_root_call="$pgclient"
106
if test "x$1" != "x"; then
107
pgclient_root_call="$pgclient_root_call dbname=$1";
109
if test "x$2" != "x"; then
110
pgclient_root_call="$pgclient_root_call user=$2";
112
if test "x$3" != "x"; then
113
pgclient_root_call="$pgclient_root_call host=$3";
115
if test "x$4" != "x"; then
116
pgclient_root_call="$pgclient_root_call password=$4";
119
testdb="test`date +%s`"
120
echo "CREATE DATABASE $testdb; DROP DATABASE $testdb;" | $pgclient_root_call > /dev/null 2>&1
121
if test "x$?" = "x0"; then
135
<a href="COPYING.html">GNU General Public License</a> with this special
136
<a href="COPYING-Exception.html">exception</a>.