mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-06 00:39:40 -06:00
Bug fix: Testing for invalid global configuration dir permissions earlier, to prevent a panic
This commit is contained in:
@@ -510,6 +510,11 @@ func runMain() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
if dEnv.CfgLoadErr != nil {
|
||||
cli.PrintErrln(color.RedString("Failed to load the global config. %v", dEnv.CfgLoadErr))
|
||||
return 1
|
||||
}
|
||||
|
||||
strMetricsDisabled := dEnv.Config.GetStringOrDefault(config.MetricsDisabled, "false")
|
||||
var metricsEmitter events.Emitter
|
||||
metricsEmitter = events.NewFileEmitter(homeDir, dbfactory.DoltDir)
|
||||
@@ -520,10 +525,6 @@ func runMain() int {
|
||||
|
||||
events.SetGlobalCollector(events.NewCollector(doltversion.Version, metricsEmitter))
|
||||
|
||||
if dEnv.CfgLoadErr != nil {
|
||||
cli.PrintErrln(color.RedString("Failed to load the global config. %v", dEnv.CfgLoadErr))
|
||||
return 1
|
||||
}
|
||||
globalConfig, ok := dEnv.Config.GetConfig(env.GlobalConfig)
|
||||
if !ok {
|
||||
cli.PrintErrln(color.RedString("Failed to get global config"))
|
||||
|
||||
@@ -422,3 +422,46 @@ NOT_VALID_REPO_ERROR="The current directory is not a valid dolt repository."
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Unknown Command notarealcommand" ]] || false
|
||||
}
|
||||
|
||||
@test "no-repo: the global dolt directory is not accessible due to permissions" {
|
||||
noPermissionsDir=$(mktemp -d -t noPermissions-XXXX)
|
||||
chmod 000 $noPermissionsDir
|
||||
DOLT_ROOT_PATH=$noPermissionsDir
|
||||
|
||||
run dolt version
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Failed to load the global config" ]] || false
|
||||
[[ "$output" =~ "permission denied" ]] || false
|
||||
|
||||
run dolt sql
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Failed to load the global config" ]] || false
|
||||
[[ "$output" =~ "permission denied" ]] || false
|
||||
|
||||
run dolt sql-server
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Failed to load the global config" ]] || false
|
||||
[[ "$output" =~ "permission denied" ]] || false
|
||||
}
|
||||
|
||||
@test "no-repo: the global dolt directory is accessible, but not writable" {
|
||||
noPermissionsDir=$(mktemp -d -t noPermissions-XXXX)
|
||||
chmod 000 $noPermissionsDir
|
||||
chmod a+x $noPermissionsDir
|
||||
DOLT_ROOT_PATH=$noPermissionsDir
|
||||
|
||||
run dolt version
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Failed to load the global config" ]] || false
|
||||
[[ "$output" =~ "permission denied" ]] || false
|
||||
|
||||
run dolt sql
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Failed to load the global config" ]] || false
|
||||
[[ "$output" =~ "permission denied" ]] || false
|
||||
|
||||
run dolt sql-server
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Failed to load the global config" ]] || false
|
||||
[[ "$output" =~ "permission denied" ]] || false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user