Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8ee599c

Browse files
committed
fix: Apply environment variables to startup script (#2099)
This was stopping `coder` from being in the path, and allowedapplications started in the script to bypass injected environmnetvariables like `GIT_SSH_COMMAND`.
1 parentc26f8c7 commit8ee599c

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

‎agent/agent.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,10 @@ func (a *agent) run(ctx context.Context) {
155155
}
156156
}
157157

158-
func (*agent)runStartupScript(ctx context.Context,scriptstring)error {
158+
func (a*agent)runStartupScript(ctx context.Context,scriptstring)error {
159159
ifscript=="" {
160160
returnnil
161161
}
162-
currentUser,err:=user.Current()
163-
iferr!=nil {
164-
returnxerrors.Errorf("get current user: %w",err)
165-
}
166-
username:=currentUser.Username
167-
168-
shell,err:=usershell.Get(username)
169-
iferr!=nil {
170-
returnxerrors.Errorf("get user shell: %w",err)
171-
}
172162

173163
writer,err:=os.OpenFile(filepath.Join(os.TempDir(),"coder-startup-script.log"),os.O_CREATE|os.O_RDWR,0600)
174164
iferr!=nil {
@@ -178,12 +168,10 @@ func (*agent) runStartupScript(ctx context.Context, script string) error {
178168
_=writer.Close()
179169
}()
180170

181-
caller:="-c"
182-
ifruntime.GOOS=="windows" {
183-
caller="/c"
171+
cmd,err:=a.createCommand(ctx,script,nil)
172+
iferr!=nil {
173+
returnxerrors.Errorf("create command: %w",err)
184174
}
185-
186-
cmd:=exec.CommandContext(ctx,shell,caller,script)
187175
cmd.Stdout=writer
188176
cmd.Stderr=writer
189177
err=cmd.Run()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp