File: pgsql-sudo-to-su.patchdescription

package info (click to toggle)
wwwconfig-common 0.3.0
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 488 kB
  • sloc: sh: 952; makefile: 5
file content (50 lines) | stat: -rw-r--r-- 1,571 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Hi Ola,

it is nice that you try to come up with the big and cool solution
(splitting packages), but people keep getting bitten by this problem
again and again, so we need a fix or workaround soon. I just spent two
hours figuring out why phpgroupware wouldn't work after installation.

It should be perfectly possible to use "su" instead of "sudo", just as

    su posgres -c "psql -d template1 -c ''"

works just as well as

    sudo -u posgres psql -d template1 -c ''

The problem is that "su" takes command and args as one single string,
which we must assemble while getting the quoting right. Here is how to
do it:

pgsqlcmd()
{
    _psql_args=
    while [ $# -gt 0 ]
    do
        _psql_args="$_psql_args '`echo \"$1\" | sed -e \"s/'/'\\\\\\''/g\"`'"
        shift
    done

    su $dbadmin -c "psql $hostopt $passopt $_psql_args"
}

pgsqlcmd=pgsqlcmd

Just replace the line 'pgsqlcmd="sudo -u $dbadmin psql $hostopt $passopt"'
with above code in /usr/share/wwwconfig-common/pgsql.get, and the problem
is solved, phpgroupware installs fine and database and user are created.

Yes, this solution may look strange, but is perfectly normal and portable
Bourne shell programming. I have tested it with bash, ash, and pdksh.

Best regards,
Arndt

PS: There is a small typo in /var/lib/dpkg/info/phpgroupware.config;
line 60 has "flase" instead of "false". I think this issue is too small
to file a full blown bug report for it.

-- 
Arndt Sch´┐Żnewald <arndt@lin02384n012.mc.schoenewald.de>, Software Developer
Quelltext AG (http://www.quelltext-ag.de), Dortmund, Germany