Nikhil Sontakke 7e43f45ccb Ensure superuser perms during copy/move chunk
There is a security loophole in current core Postgres, due to which
it's possible for a non-superuser to gain superuser access by attaching
dependencies like expression indexes, triggers, etc. before logical
replication commences.

To avoid this, we now ensure that the chunk objects that get created
for the subscription are done so as a superuser. This avoids malicious
dependencies by regular users.
2023-03-23 13:26:47 +05:30
..
2022-11-25 17:42:26 +05:30
2023-03-03 18:34:05 +05:30
2022-02-23 16:44:19 +01:00
2021-06-01 20:21:06 +02:00
2021-12-17 16:12:57 +03:00
2022-10-27 16:06:58 +04:00
2022-01-24 16:58:09 -05:00
2022-05-16 08:37:34 +02:00
2023-02-01 07:54:03 +01:00

Submodule Licensing and Initialization

Loading and Activation

We link module loading and activation to the license GUC itself. We have a single GUC, the license, and load submodules based on what capabilities the license enables, i.e., an apache license-key does not load this module, while timescale key does. This ensures that the loader "does the right thing" with respect to the license, and a user cannot accidentally activate features they aren't licensed to use.

The actual loading and activation is done through check and assign hooks on the license GUC. On check we validate the license type and on assign we set the capabilities-struct in this module, if needed. The check and assign functions can be found in license_guc.c/h in the Apache-Licensed src.

Cross License Functions

To enable binaries which only contain Apache-Licensed code, we dynamically link in Timescale-Licensed code on license activation, and handle all function calls into the module via function pointers.

The registry in ts_cm_functions of type CrossModuleFunctions (declared in cross_module_fn.h and defined in cross_module_fn.c) stores all of the cross-module functions.

To add a new cross-module function you must:

  • Add a struct member CrossModuleFunctions.<function name>.
  • Add default function to ts_cm_functions_default that will be called from the Apache version, usually this function should just call error_no_default_fn. NOTE Due to function-pointer casting rules, the default function must have the exact same signature as the function pointer; you may not cast another function pointer of another type.
  • Add the overriding function to tsl_cm_functionsin init.c in this module.

To call a cross-module functions use ts_cm_functions-><function name>(args).