File: pgsql-sudo-to-su-potential-problem-fix.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 (101 lines) | stat: -rw-r--r-- 2,924 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Hi Ola,

thanks a lot for your fast reaction and the honorable mention of my name
in the change log!

There is one small improvement that just came to my mind: If we turn
the line

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

into

    su $dbadmin -s /bin/sh -c "psql $hostopt $passopt $_psql_args"

then it will work even for those who have changed the login shell for
the postgres user to something weird (like csh or /bin/false). I don't
know if anybody does this, but still...

Best regards,
Arndt


On Thu, Sep 26, 2002 at 08:29:43AM +0200, Ola Lundqvist wrote:
> On Wed, Sep 25, 2002 at 05:03:34PM +0200, Arndt Schoenewald wrote:
> > Hi Ola,
> 
> Hi
> 
> > 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.
> 
> That is really great. You spent less time and solved it. :)
> 
> > 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:
> 
> That is the problem I was hit by too.
> 
> > pgsqlcmd()
> > {
> >     _psql_args=
> >     while [ $# -gt 0 ]
> >     do
> >         _psql_args="$_psql_args '`echo \"$1\" | sed -e \"s/'/'\\\\\\''/g\"`'"
> >         shift
> >     done
> 
> Ahh that one may do the trick.
> 
> >     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.
> 
> That is really great.
> 
> > Yes, this solution may look strange, but is perfectly normal and portable
> > Bourne shell programming. I have tested it with bash, ash, and pdksh.
> 
> I'll do this Linko:ping today so I hope that I can upload this today.
> 
> Thanks a lot for the patch. This is what is so great about open source!
> 
> Regards,
> 
> // Ola
> 
> > 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.
> 
> You can always file a minor one. :)

Yeah, sorry, this is of course not your business. This must go to the
maintainer of the phpgroupware package.

> Regards,
> 
> // Ola

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