Merge ~athos-ribeiro/ubuntu/+source/postgresql-common:fix-set-conffile-regex into ubuntu/+source/postgresql-common:ubuntu/devel

Proposed by Athos Ribeiro
Status: Merged
Approved by: git-ubuntu bot
Approved revision: not available
Merged at revision: 3d35c67d042aafca58fc481f31c61200fb668624
Proposed branch: ~athos-ribeiro/ubuntu/+source/postgresql-common:fix-set-conffile-regex
Merge into: ubuntu/+source/postgresql-common:ubuntu/devel
Diff against target: 121 lines (+28/-3)
4 files modified
PgCommon.pm (+2/-2)
debian/changelog (+6/-0)
debian/control (+2/-1)
t/005_PgCommon.t (+18/-0)
Reviewer Review Type Date Requested Status
git-ubuntu bot Approve
Sergio Durigan Junior (community) Approve
Canonical Server Reporter Pending
Review via email: mp+438630@code.launchpad.net

Description of the change

pg_conftool mistakes regular comments starting with a configuration option for actual commented configuration options.

While the issue does not impact any software features or its usability, it may lead to the deletion of useful comments or documentation in configuration files.

See LP: #2007794 for further reference.

PPA: https://launchpad.net/~athos-ribeiro/+archive/ubuntu/pg-fix-config-regex/+packages

Local autopkgtest results:

autopkgtest [14:40:00]: @@@@@@@@@@@@@@@@@@@@ summary
default-psql PASS
run-testsuite PASS

To post a comment you must log in.
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks, Athos.

LGTM. I verified that the new package fixes the issue. Also, I'm happy that Myon accepted your fix into Debian already.

+1

review: Approve
Revision history for this message
git-ubuntu bot (git-ubuntu-bot) wrote :

Approvers: athos-ribeiro, sergiodj
Uploaders: athos-ribeiro, sergiodj
MP auto-approved

review: Approve
Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

Thanks, Sergio!

Uploaded

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading postgresql-common_247ubuntu1.dsc: done.
  Uploading postgresql-common_247ubuntu1.tar.xz: done.
  Uploading postgresql-common_247ubuntu1_source.buildinfo: done.
  Uploading postgresql-common_247ubuntu1_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/PgCommon.pm b/PgCommon.pm
2index 783aa4c..e51d89e 100644
3--- a/PgCommon.pm
4+++ b/PgCommon.pm
5@@ -340,8 +340,8 @@ sub set_conffile_value {
6 # of appending
7 if (!$found) {
8 for (my $i=0; $i <= $#lines; ++$i) {
9- if ($lines[$i] =~ /^\s*#\s*($key)(\s*(?:=|\s)\s*)\w+\b((?:\s*#.*)?)/i or
10- $lines[$i] =~ /^\s*#\s*($key)(\s*(?:=|\s)\s*)'[^']*'((?:\s*#.*)?)/i) {
11+ if ($lines[$i] =~ /^\s*#\s*($key)(\s*(?:=|\s)\s*)\w+\b((?:\s*#.*)?)$/i or
12+ $lines[$i] =~ /^\s*#\s*($key)(\s*(?:=|\s)\s*)'[^']*'((?:\s*#.*)?)$/i) {
13 $lines[$i] = "$1$2$value$3\n";
14 $found = 1;
15 last;
16diff --git a/debian/changelog b/debian/changelog
17index dbdbe2c..2e74f93 100644
18--- a/debian/changelog
19+++ b/debian/changelog
20@@ -1,3 +1,9 @@
21+postgresql-common (247ubuntu1) lunar; urgency=medium
22+
23+ * Fix set_conffile_value comment parsing regular expression. (LP: #2007794)
24+
25+ -- Athos Ribeiro <athos.ribeiro@canonical.com> Thu, 09 Mar 2023 11:44:03 -0300
26+
27 postgresql-common (247) unstable; urgency=medium
28
29 [ Christoph Berg ]
30diff --git a/debian/control b/debian/control
31index 1497395..29cc456 100644
32--- a/debian/control
33+++ b/debian/control
34@@ -1,7 +1,8 @@
35 Source: postgresql-common
36 Section: database
37 Priority: optional
38-Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>
39+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
40+XSBC-Original-Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>
41 Uploaders:
42 Martin Pitt <mpitt@debian.org>,
43 Christoph Berg <myon@debian.org>,
44diff --git a/t/005_PgCommon.t b/t/005_PgCommon.t
45index 22dcca8..e1bc337 100644
46--- a/t/005_PgCommon.t
47+++ b/t/005_PgCommon.t
48@@ -102,6 +102,9 @@ print F <<EOF;
49
50 # Commented_Int = 12
51 # commented_str='foobar'
52+# commented_bool off
53+# commented_bool2 off # comment
54+# commented_bool3 just a comment
55
56 #intval = 1
57 Intval = 42
58@@ -194,6 +197,9 @@ is_deeply (\%conf, {
59 # test set_conf_value()
60 PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'commented_int', '24';
61 PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'commented_str', 'new foo';
62+PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'commented_bool', 'on';
63+PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'commented_bool2', 'on';
64+PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'commented_bool3', 'on';
65 PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'intval', '39';
66 PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'cintval', '5';
67 PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'strval', 'Howdy';
68@@ -210,6 +216,9 @@ is ($conf, <<EOF, 'set_conf_value');
69
70 Commented_Int = 24
71 commented_str='new foo'
72+commented_bool on
73+commented_bool2 on # comment
74+# commented_bool3 just a comment
75
76 #intval = 1
77 Intval = 39
78@@ -223,6 +232,7 @@ cemptystr = '' # moo!
79 #testpath = '/bin/bad'
80 testpath = '/bin/new'
81 QuoteStr = 'test ! -f \\'/tmp/%f\\' && echo \\'yes\\''
82+commented_bool3 = on
83 newval = 'NEW!'
84 include_dir = 'conf.d'
85 EOF
86@@ -241,6 +251,9 @@ is ($conf, <<EOF, 'disable_conf_value');
87
88 Commented_Int = 24
89 commented_str='new foo'
90+commented_bool on
91+commented_bool2 on # comment
92+# commented_bool3 just a comment
93
94 #intval = 1
95 #Intval = 39 #ints are out of fashion
96@@ -254,6 +267,7 @@ cemptystr = '' # moo!
97 #testpath = '/bin/bad'
98 #testpath = '/bin/new' #now 2 comments
99 QuoteStr = 'test ! -f \\'/tmp/%f\\' && echo \\'yes\\''
100+commented_bool3 = on
101 newval = 'NEW!'
102 include_dir = 'conf.d'
103 EOF
104@@ -272,6 +286,9 @@ is ($conf, <<EOF, 'replace_conf_value');
105
106 Commented_Int = 24
107 commented_str='new foo'
108+commented_bool on
109+commented_bool2 on # comment
110+# commented_bool3 just a comment
111
112 #intval = 1
113 #Intval = 39 #ints are out of fashion
114@@ -286,6 +303,7 @@ cemptystr = '' # moo!
115 #testpath = '/bin/bad'
116 #testpath = '/bin/new' #now 2 comments
117 QuoteStr = 'test ! -f \\'/tmp/%f\\' && echo \\'yes\\''
118+commented_bool3 = on
119 newval = 'NEW!'
120 include_dir = 'conf.d'
121 EOF

Subscribers

People subscribed via source and target branches