restrict file permissions from "machines add" (#2648)
This commit is contained in:
parent
b1f85693c2
commit
84cbff16d4
6 changed files with 8 additions and 8 deletions
|
@ -106,7 +106,7 @@ func NewCapiRegisterCmd() *cobra.Command {
|
||||||
return fmt.Errorf("unable to marshal api credentials: %w", err)
|
return fmt.Errorf("unable to marshal api credentials: %w", err)
|
||||||
}
|
}
|
||||||
if dumpFile != "" {
|
if dumpFile != "" {
|
||||||
err = os.WriteFile(dumpFile, apiConfigDump, 0600)
|
err = os.WriteFile(dumpFile, apiConfigDump, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("write api credentials in '%s' failed: %w", dumpFile, err)
|
return fmt.Errorf("write api credentials in '%s' failed: %w", dumpFile, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ func backupHub(dirPath string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed marshaling upstream parsers : %s", err)
|
return fmt.Errorf("failed marshaling upstream parsers : %s", err)
|
||||||
}
|
}
|
||||||
err = os.WriteFile(upstreamParsersFname, upstreamParsersContent, 0644)
|
err = os.WriteFile(upstreamParsersFname, upstreamParsersContent, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to write to %s %s : %s", itemType, upstreamParsersFname, err)
|
return fmt.Errorf("unable to write to %s %s : %s", itemType, upstreamParsersFname, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ func dumpConsoleConfig(c *csconfig.LocalApiServerCfg) error {
|
||||||
log.Debugf("Empty console_path, defaulting to %s", c.ConsoleConfigPath)
|
log.Debugf("Empty console_path, defaulting to %s", c.ConsoleConfigPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(c.ConsoleConfigPath, out, 0600); err != nil {
|
if err := os.WriteFile(c.ConsoleConfigPath, out, 0o600); err != nil {
|
||||||
return fmt.Errorf("while dumping console config to %s: %w", c.ConsoleConfigPath, err)
|
return fmt.Errorf("while dumping console config to %s: %w", c.ConsoleConfigPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ func SetConsoleOpts(args []string, wanted bool) error {
|
||||||
return fmt.Errorf("cannot marshal credentials: %s", err)
|
return fmt.Errorf("cannot marshal credentials: %s", err)
|
||||||
}
|
}
|
||||||
log.Infof("Updating credentials file: %s", csConfig.API.Server.OnlineClient.CredentialsFilePath)
|
log.Infof("Updating credentials file: %s", csConfig.API.Server.OnlineClient.CredentialsFilePath)
|
||||||
err = os.WriteFile(csConfig.API.Server.OnlineClient.CredentialsFilePath, fileContent, 0600)
|
err = os.WriteFile(csConfig.API.Server.OnlineClient.CredentialsFilePath, fileContent, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot write credentials file: %s", err)
|
return fmt.Errorf("cannot write credentials file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,7 @@ func (cli cliMachines) add(cmd *cobra.Command, args []string) error {
|
||||||
return fmt.Errorf("unable to marshal api credentials: %s", err)
|
return fmt.Errorf("unable to marshal api credentials: %s", err)
|
||||||
}
|
}
|
||||||
if dumpFile != "" && dumpFile != "-" {
|
if dumpFile != "" && dumpFile != "-" {
|
||||||
err = os.WriteFile(dumpFile, apiConfigDump, 0644)
|
err = os.WriteFile(dumpFile, apiConfigDump, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("write api credentials in '%s' failed: %s", dumpFile, err)
|
return fmt.Errorf("write api credentials in '%s' failed: %s", dumpFile, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ func dumpSimulationFile() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to marshal simulation configuration: %s", err)
|
return fmt.Errorf("unable to marshal simulation configuration: %s", err)
|
||||||
}
|
}
|
||||||
err = os.WriteFile(csConfig.ConfigPaths.SimulationFilePath, newConfigSim, 0644)
|
err = os.WriteFile(csConfig.ConfigPaths.SimulationFilePath, newConfigSim, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("write simulation config in '%s' failed: %s", csConfig.ConfigPaths.SimulationFilePath, err)
|
return fmt.Errorf("write simulation config in '%s' failed: %s", csConfig.ConfigPaths.SimulationFilePath, err)
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ func disableGlobalSimulation() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to marshal new simulation configuration: %s", err)
|
return fmt.Errorf("unable to marshal new simulation configuration: %s", err)
|
||||||
}
|
}
|
||||||
err = os.WriteFile(csConfig.ConfigPaths.SimulationFilePath, newConfigSim, 0644)
|
err = os.WriteFile(csConfig.ConfigPaths.SimulationFilePath, newConfigSim, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to write new simulation config in '%s' : %s", csConfig.ConfigPaths.SimulationFilePath, err)
|
return fmt.Errorf("unable to write new simulation config in '%s' : %s", csConfig.ConfigPaths.SimulationFilePath, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -423,7 +423,7 @@ cscli support dump -f /tmp/crowdsec-support.zip
|
||||||
log.Fatalf("could not finalize zip file: %s", err)
|
log.Fatalf("could not finalize zip file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(outFile, w.Bytes(), 0600)
|
err = os.WriteFile(outFile, w.Bytes(), 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("could not write zip file to %s: %s", outFile, err)
|
log.Fatalf("could not write zip file to %s: %s", outFile, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue