You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix: escape backslashes and control chars in PostgreSQL config values (#10515)
Values written into custom.conf were only escaped for single quotes.
Backslashes and control characters (LF, CR, TAB, BS, FF) passed through
unescaped, which either corrupted the configuration (e.g. a
user-supplied recovery_target_name containing ' or a newline) or
silently mangled the runtime value (a \ in log_line_prefix stripped by
PostgreSQL's config lexer).
Introduce configfile.RenderPostgresConfiguration as the single canonical
helper that emits a postgresql.conf-style fragment from a
map[string]string, with values escaped according to the guc-file.l rules
(\, ', \n, \r, \t, \b, \f). Migrate every config-file-emitting site to
it: pkg/configfile.UpdateConfigurationContents (replacing
pq.QuoteLiteral, which emits an E'...' SQL-style literal that the config
lexer rejects when the value contains a backslash),
pkg/postgres.CreatePostgresqlConfFile,
api/v1.(*RecoveryTarget).BuildPostgresOptions (previously did no
escaping at all for recovery_target_name/_xid/_lsn/_timeline/_time), and
pkg/management/postgres.getRestoreWalConfig and RestoreSnapshot's
restore_command construction. After this change the inner
escapePostgresConfLiteral is private to pkg/configfile.
Upgrade impact: clusters whose PostgreSQL parameters contain \ or a
control character (most commonly a literal tab in log_line_prefix) will
see one pg_reload_conf() on the first reconcile after upgrade because
the config-file SHA256 changes. No restart, no connection drops.
Clusters with only default or quote-only special values are unaffected.
Related #10518Closes#10506
Reported-by: Koda Reef <kodareef5@users.noreply.github.com>
Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Co-authored-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
0 commit comments