@@ -20,6 +20,7 @@ import (
2020 "github.com/docker/docker-agent/pkg/cli"
2121 "github.com/docker/docker-agent/pkg/config"
2222 "github.com/docker/docker-agent/pkg/paths"
23+ "github.com/docker/docker-agent/pkg/permissions"
2324 "github.com/docker/docker-agent/pkg/profiling"
2425 "github.com/docker/docker-agent/pkg/runtime"
2526 "github.com/docker/docker-agent/pkg/session"
@@ -59,6 +60,10 @@ type runExecFlags struct {
5960
6061 // Run only
6162 hideToolResults bool
63+
64+ // globalPermissions holds the user-level global permission checker built
65+ // from user config settings. Nil when no global permissions are configured.
66+ globalPermissions * permissions.Checker
6267}
6368
6469func newRunCmd () * cobra.Command {
@@ -187,6 +192,11 @@ func (f *runExecFlags) runOrExec(ctx context.Context, out *cli.Printer, args []s
187192 }
188193 }
189194
195+ // Build global permissions checker from user config settings.
196+ if userSettings .Permissions != nil {
197+ f .globalPermissions = permissions .NewChecker (userSettings .Permissions )
198+ }
199+
190200 // Start fake proxy if --fake is specified
191201 fakeCleanup , err := setupFakeProxy (f .fakeResponses , f .fakeStreamDelay , & f .runConfig )
192202 if err != nil {
@@ -308,6 +318,12 @@ func (f *runExecFlags) createRemoteRuntimeAndSession(ctx context.Context, origin
308318func (f * runExecFlags ) createLocalRuntimeAndSession (ctx context.Context , loadResult * teamloader.LoadResult ) (runtime.Runtime , * session.Session , error ) {
309319 t := loadResult .Team
310320
321+ // Merge user-level global permissions into the team's checker so the
322+ // runtime receives a single, already-merged permission set.
323+ if f .globalPermissions != nil && ! f .globalPermissions .IsEmpty () {
324+ t .SetPermissions (permissions .Merge (t .Permissions (), f .globalPermissions ))
325+ }
326+
311327 agt , err := t .Agent (f .agentName )
312328 if err != nil {
313329 return nil , nil , err
@@ -505,6 +521,11 @@ func (f *runExecFlags) createSessionSpawner(agentSource config.Source, sessStore
505521 AgentDefaultModels : loadResult .AgentDefaultModels ,
506522 }
507523
524+ // Merge global permissions into the team's checker
525+ if f .globalPermissions != nil && ! f .globalPermissions .IsEmpty () {
526+ team .SetPermissions (permissions .Merge (team .Permissions (), f .globalPermissions ))
527+ }
528+
508529 // Create the local runtime
509530 localRt , err := runtime .New (team ,
510531 runtime .WithSessionStore (sessStore ),
0 commit comments