Skip to content

Commit 4f0386c

Browse files
author
r.inyakin
committed
start: insufficient permissions to directories
Fixed a bug where an error did not appear when access rights to the var directive were insufficient. Closes #1238
1 parent 9e90ba9 commit 4f0386c

4 files changed

Lines changed: 48 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313

1414
### Fixed
1515

16+
- `tt start`: fixed a bug where an error did not appear when access rights
17+
to the var directive were insufficient.
18+
1619
## [2.11.3] - 2026-02-25
1720

1821
The release updates the dependencies and fixes discovering of the available

cli/cmd/start.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"sync"
1111
"syscall"
1212

13+
"github.com/apex/log"
1314
"github.com/spf13/cobra"
1415
"github.com/tarantool/tt/cli/cmd/internal"
1516
"github.com/tarantool/tt/cli/cmdcontext"
@@ -92,9 +93,12 @@ func startInstancesInteractive(cmdCtx *cmdcontext.CmdCtx, instances []running.In
9293
prefix := running.GetAppInstanceName(instCtx) + " "
9394
wg.Add(1)
9495
go func(inst running.InstanceCtx) {
95-
running.RunInstance(ctx, cmdCtx, inst,
96+
err := running.RunInstance(ctx, cmdCtx, inst,
9697
running.NewColorizedPrefixWriter(os.Stdout, clr, prefix),
9798
running.NewColorizedPrefixWriter(os.Stderr, clr, prefix))
99+
if err != nil {
100+
log.Errorf("failed to run instance %q: %s", prefix, err)
101+
}
98102
wg.Done()
99103
}(instCtx)
100104
}

cli/running/running.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,16 @@ Cluster config path: %q`, tntVersion.Str, inst.ClusterConfigPath)
966966
func StartWatchdog(cmdCtx *cmdcontext.CmdCtx, ttExecutable string, instance InstanceCtx,
967967
args []string,
968968
) error {
969+
for _, dataDir := range [...]string{
970+
instance.WalDir, instance.VinylDir,
971+
instance.MemtxDir, instance.RunDir,
972+
} {
973+
if err := util.CreateDirectory(dataDir, defaultDirPerms); err != nil {
974+
return fmt.Errorf("failed to run instance %q: %s",
975+
GetAppInstanceName(instance)+" ", err)
976+
}
977+
}
978+
969979
appName := GetAppInstanceName(instance)
970980
// If an instance is already running don't try to start it again.
971981
// To restart an instance use tt restart command.

test/integration/start/test_start.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
import pytest
24
import tt_helper
35

@@ -109,3 +111,31 @@ def test_start_multi_inst(tt, tt_app, target):
109111
)
110112
def test_start_cluster(tt, tt_app, target):
111113
check_start(tt, tt_app, target)
114+
115+
116+
################################################################
117+
# Permission denied
118+
119+
120+
@pytest.mark.skipif(
121+
os.getuid() == 0,
122+
reason="Skipping the test, it shouldn't run as root",
123+
)
124+
@pytest.mark.tt_app(**tt_multi_inst_app)
125+
@pytest.mark.parametrize(
126+
"tt_running_targets",
127+
[
128+
pytest.param([], id="running:none"),
129+
],
130+
)
131+
def test_start_permission_denied(tt, tt_app):
132+
var_dir = tt_app.path("var")
133+
os.makedirs(var_dir, exist_ok=True)
134+
os.chmod(var_dir, 0o444)
135+
136+
try:
137+
rc, out = tt.exec("start", "app")
138+
assert rc != 0
139+
assert "permission denied" in out.lower()
140+
finally:
141+
os.chmod(var_dir, 0o755)

0 commit comments

Comments
 (0)