~ubuntu-branches/ubuntu/hardy/autoconf-archive/hardy

« back to all changes in this revision

Viewing changes to htmldoc/ms_pgsql_priv_root.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin A. Godisch
  • Date: 2004-06-26 09:43:57 UTC
  • Revision ID: james.westby@ubuntu.com-20040626094357-3be3jwcz1vcdhpe8
Tags: upstream-20040616
ImportĀ upstreamĀ versionĀ 20040616

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
 
2
"http://www.w3.org/TR/html4/strict.dtd">
 
3
 
 
4
<html lang="en">
 
5
<head>
 
6
  <title>Autoconf Macro: ms_pgsql_priv_root</title>
 
7
  <link rel="stylesheet" type="text/css" href="ac-archive.css">
 
8
</head>
 
9
 
 
10
<body>
 
11
  <table summary="web navigation" style="width:100%;">
 
12
    <tbody>
 
13
      <tr>
 
14
        <td style="width:50%;" align="center">[<a href="index.html">Macro Index
 
15
        Page</a>]</td>
 
16
 
 
17
        <td style="width:50%;" align="center">[<a href=
 
18
        "../m4source/ms_pgsql_priv_root.m4">Download M4 Source</a>]</td>
 
19
      </tr>
 
20
    </tbody>
 
21
  </table>
 
22
  <hr>
 
23
 
 
24
  <h1>ms_pgsql_priv_root</h1>
 
25
 
 
26
  <h2>Synopsis</h2>
 
27
 
 
28
  <div class="indent">
 
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>
 
32
  </div>
 
33
 
 
34
  <h2>Description</h2>
 
35
 
 
36
  <div class="indent">
 
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>
 
41
 
 
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>
 
44
    <pre>
 
45
    AC_SUBST(pgclient_root_call)
 
46
</pre>
 
47
 
 
48
    <p>after having called MS_CHECK_PGSQL_PRIV_ROOT. You can then do something
 
49
    like the following in your Makefile.am:</p>
 
50
    <pre>
 
51
    @pgclient_root_call@ -f file.sql
 
52
</pre>
 
53
 
 
54
    <p>If you want the user to set the data, you should support something like
 
55
    these configure options:</p>
 
56
    <pre>
 
57
    AC_ARG_WITH(pgsql-host,
 
58
            [  --with-pgsql-host=HOST               server is running on HOST @&lt;:@local socket@:&gt;@],
 
59
            [pg_host=$withval], [pg_host=])
 
60
</pre>
 
61
    <pre>
 
62
    AC_ARG_WITH(pgsql-db,
 
63
            [  --with-pgsql-db=DBNAME               use database DBNAME @&lt;:@test@:&gt;@],
 
64
            [pg_db=$withval], [pg_db=test])
 
65
</pre>
 
66
    <pre>
 
67
    AC_ARG_WITH(pgsql-root-user,
 
68
            [  --with-pgsql-root-user=USER          use user USER, must have root (all) privileges @&lt;:@postgres@:&gt;@],
 
69
            [pg_root_user=$withval], [pg_root_user=postgres])
 
70
</pre>
 
71
    <pre>
 
72
    AC_ARG_WITH(pgsql-password,
 
73
            [  --with-pgsql-password=PASSWORD       use password PASSWORD @&lt;:@none@:&gt;@],
 
74
            [pg_password=$withval], [pg_password=""])
 
75
</pre>
 
76
 
 
77
    <p>You can then call the macro like this:</p>
 
78
    <pre>
 
79
    MS_CHECK_PGSQL_PRIV_ROOT([$pg_db], [$pg_root_user], [$pg_host], [$pg_password], [AC_MSG_ERROR([We need root privileges on database!])])
 
80
</pre>
 
81
  </div>
 
82
 
 
83
  <h2>Version</h2>
 
84
 
 
85
  <div class="indent">
 
86
    <p>1.1 (last modified: 2002-09-25)</p>
 
87
  </div>
 
88
 
 
89
  <h2>Author</h2>
 
90
 
 
91
  <div class="indent">
 
92
    <p>Moritz Sinn &lt;moritz@freesources.org&gt;</p>
 
93
  </div>
 
94
 
 
95
  <h2>M4 Source Code</h2>
 
96
 
 
97
  <div class="indent">
 
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])
 
103
 
 
104
pgclient_root_call="$pgclient"
 
105
 
 
106
if test "x$1" != "x"; then
 
107
        pgclient_root_call="$pgclient_root_call dbname=$1";
 
108
fi
 
109
if test "x$2" != "x"; then
 
110
        pgclient_root_call="$pgclient_root_call user=$2";
 
111
fi
 
112
if test "x$3" != "x"; then
 
113
        pgclient_root_call="$pgclient_root_call host=$3";
 
114
fi
 
115
if test "x$4" != "x"; then
 
116
        pgclient_root_call="$pgclient_root_call password=$4";
 
117
fi
 
118
 
 
119
testdb="test`date +%s`"
 
120
echo "CREATE DATABASE $testdb; DROP DATABASE $testdb;" | $pgclient_root_call  &gt; /dev/null 2&gt;&amp;1
 
121
if test "x$?" = "x0"; then
 
122
        AC_MSG_RESULT([yes])
 
123
        $6
 
124
else
 
125
        AC_MSG_RESULT([no])
 
126
        $5
 
127
fi;
 
128
])dnl
 
129
</pre>
 
130
  </div>
 
131
 
 
132
  <h2>Copyright</h2>
 
133
 
 
134
  <div class="indent">
 
135
    <a href="COPYING.html">GNU General Public License</a> with this special
 
136
    <a href="COPYING-Exception.html">exception</a>.
 
137
  </div>
 
138
</body>
 
139
</html>