Source: tryton-server Version: 6.0.29-1 Severity: important Tags: patch Hi Matthias,
I noticed that tryton-server-uwsgi.postinst is quite fragile. When I tried to install it, I got this failure: | /var/lib/dpkg/info/tryton-server-uwsgi.postinst: 46: [: postgresql://tryton@/: unexpected operator | sed: -e expression #1, char 56: unterminated `s' command | dpkg: error processing package tryton-server-uwsgi (--configure): | installed tryton-server-uwsgi package post-installation script subprocess returned error exit status 1 | Processing triggers for man-db (2.9.4-2) ... | Processing triggers for libc-bin (2.31-13+deb11u5) ... | Errors were encountered while processing: | tryton-server-uwsgi | E: Sub-process /usr/bin/dpkg returned an error code (1) Admittedly, this was using 6.0.29-1~11bullseye+1, but it applies to unstable as well, so I'll report here. While investigating this in encountered multiple issues: * A general lack of quoting. It is much safer to quote shell variables to avoid unintentional word splitting. This actually seems to be causing the problem above. * Fragile parsing of trytond.conf, which is an ini file with sections. The uri that is being parsed can be found in multiple sections such as database and email. It would be good to use section-aware parsing. I'm attaching a patch that addresses all of the above and think that this should be fixed in bookworm and in the backports provided at https://debian.m9s.biz/debian. Thanks in advance Helmut
diff --minimal -Nru tryton-server-6.0.29/debian/changelog tryton-server-6.0.29/debian/changelog --- tryton-server-6.0.29/debian/changelog 2023-03-04 10:45:59.000000000 +0100 +++ tryton-server-6.0.29/debian/changelog 2023-03-16 12:34:42.000000000 +0100 @@ -1,3 +1,10 @@ +tryton-server (6.0.29-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Fix bugs in tryton-server-uwsgi.postinst. (Closes: #-1) + + -- Helmut Grohne <hel...@subdivi.de> Thu, 16 Mar 2023 12:34:42 +0100 + tryton-server (6.0.29-1) unstable; urgency=high * Merging upstream version 6.0.29. diff --minimal -Nru tryton-server-6.0.29/debian/tryton-server-uwsgi.postinst tryton-server-6.0.29/debian/tryton-server-uwsgi.postinst --- tryton-server-6.0.29/debian/tryton-server-uwsgi.postinst 2023-03-04 10:45:59.000000000 +0100 +++ tryton-server-6.0.29/debian/tryton-server-uwsgi.postinst 2023-03-16 12:34:41.000000000 +0100 @@ -36,14 +36,14 @@ create_config () { trap cleanup EXIT TRYTON_UWSGI_INI_NEW=$(mktemp) - cp -a "$TRYTON_UWSGI_INI_TEMPLATE" $TRYTON_UWSGI_INI_NEW + cp -a "$TRYTON_UWSGI_INI_TEMPLATE" "$TRYTON_UWSGI_INI_NEW" TRYTON_CONFNEW=$(mktemp) - cp -a "$TRYTON_CONFFILE" $TRYTON_CONFNEW + cp -a "$TRYTON_CONFFILE" "$TRYTON_CONFNEW" db_name="tryton" - db_uri="$(grep "^uri =" $TRYTON_CONFFILE|cut -d' ' -f3)" + db_uri="$(sed -n '/^\[database\]$/,/^\[.*\]$/s/^uri\s*=\s*//p' "$TRYTON_CONFFILE")" # if no uri is configured we use the default sqlite connection - if [ -z $db_uri ]; then + if [ -z "$db_uri" ]; then db_uri=sqlite:// fi @@ -52,7 +52,7 @@ . /etc/dbconfig-common/tryton-server-postgresql.conf fi - if [ ! -z $dbc_dbname ]; then + if [ ! -z "$dbc_dbname" ]; then db_name=$dbc_dbname fi @@ -109,7 +109,7 @@ . /etc/dbconfig-common/tryton-server-postgresql.conf fi - if [ ! -z $dbc_dbname ]; then + if [ ! -z "$dbc_dbname" ]; then db_name=$dbc_dbname fi