Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
27bc865c
Commit
27bc865c
authored
Jul 03, 2018
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix smb mount security issue
parent
d5803e59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
mount_windows.go
pkg/util/mount/mount_windows.go
+12
-6
No files found.
pkg/util/mount/mount_windows.go
View file @
27bc865c
...
...
@@ -83,14 +83,20 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
return
fmt
.
Errorf
(
"azureMount: only cifs mount is supported now, fstype: %q, mounting source (%q), target (%q), with options (%q)"
,
fstype
,
source
,
target
,
options
)
}
cmdLine
:=
fmt
.
Sprintf
(
`$User = "%s";$PWord = ConvertTo-SecureString -String "%s" -AsPlainText -Force;`
+
`$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord`
,
options
[
0
],
options
[
1
])
bindSource
=
source
cmdLine
+=
fmt
.
Sprintf
(
";New-SmbGlobalMapping -RemotePath %s -Credential $Credential"
,
source
)
if
output
,
err
:=
exec
.
Command
(
"powershell"
,
"/c"
,
cmdLine
)
.
CombinedOutput
();
err
!=
nil
{
// use PowerShell Environment Variables to store user input string to prevent command line injection
// https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-5.1
cmdLine
:=
fmt
.
Sprintf
(
`$PWord = ConvertTo-SecureString -String $Env:smbpassword -AsPlainText -Force`
+
`;$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Env:smbuser, $PWord`
+
`;New-SmbGlobalMapping -RemotePath $Env:smbremotepath -Credential $Credential`
)
cmd
:=
exec
.
Command
(
"powershell"
,
"/c"
,
cmdLine
)
cmd
.
Env
=
append
(
os
.
Environ
(),
fmt
.
Sprintf
(
"smbuser=%s"
,
options
[
0
]),
fmt
.
Sprintf
(
"smbpassword=%s"
,
options
[
1
]),
fmt
.
Sprintf
(
"smbremotepath=%s"
,
source
))
if
output
,
err
:=
cmd
.
CombinedOutput
();
err
!=
nil
{
return
fmt
.
Errorf
(
"azureMount: SmbGlobalMapping failed: %v, only SMB mount is supported now, output: %q"
,
err
,
string
(
output
))
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment