From 513d57f66bbe34e4bd45c6ab5f61b2951f10d011 Mon Sep 17 00:00:00 2001 From: hualongzhong Date: Fri, 24 Mar 2023 12:00:25 +0800 Subject: [PATCH] sidecar: fix #770 change owener of plugin and xtraconf (#771) --- sidecar/init.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sidecar/init.go b/sidecar/init.go index 4ae83767..ff798158 100644 --- a/sidecar/init.go +++ b/sidecar/init.go @@ -283,12 +283,21 @@ func RunRequestBackup(cfg *Config, host string) error { // Save plugin.cnf and extra.cnf to specified path. func saveCnfTo(targetPath string, extraCnf *ini.File) error { + userId := 1001 + groupId := 1001 if err := copyFile(path.Join(mysqlCMPath, utils.PluginConfigs), path.Join(targetPath, utils.PluginConfigs)); err != nil { return fmt.Errorf("failed to copy plugin.cnf: %s", err) } + if err := os.Chown(path.Join(targetPath, utils.PluginConfigs), userId, groupId); err != nil { + return fmt.Errorf("failed to change owner of plugin.cnf: %s", err) + } if err := extraCnf.SaveTo(path.Join(targetPath, "extra.cnf")); err != nil { return fmt.Errorf("failed to save extra.cnf: %s", err) } + if err := os.Chown(path.Join(targetPath, "extra.cnf"), userId, groupId); err != nil { + return fmt.Errorf("failed to change owner of plugin.cnf: %s", err) + } + return nil }