-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from jsturtevant/windows-part1
Windows part 1
- Loading branch information
Showing
41 changed files
with
1,164 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
func isSocketAccessible(s string) error { | ||
abs, err := filepath.Abs(s) | ||
if err != nil { | ||
return err | ||
} | ||
// set AT_EACCESS to allow running nerdctl as a setuid binary | ||
return unix.Faccessat(-1, abs, unix.R_OK|unix.W_OK, unix.AT_EACCESS) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/Microsoft/go-winio" | ||
) | ||
|
||
func isSocketAccessible(s string) error { | ||
// test if we can access the pipe | ||
timeout := 2 * time.Second | ||
_, err := winio.DialPipe(s, &timeout) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/containerd/containerd/pkg/cap" | ||
"github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
func setExecCapabilities(pspec *specs.Process) error { | ||
if pspec.Capabilities == nil { | ||
pspec.Capabilities = &specs.LinuxCapabilities{} | ||
} | ||
allCaps, err := cap.Current() | ||
if err != nil { | ||
return err | ||
} | ||
pspec.Capabilities.Bounding = allCaps | ||
pspec.Capabilities.Permitted = pspec.Capabilities.Bounding | ||
pspec.Capabilities.Inheritable = pspec.Capabilities.Bounding | ||
pspec.Capabilities.Effective = pspec.Capabilities.Bounding | ||
|
||
// https://github.com/moby/moby/pull/36466/files | ||
// > `docker exec --privileged` does not currently disable AppArmor | ||
// > profiles. Privileged configuration of the container is inherited | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
func setExecCapabilities(pspec *specs.Process) error { | ||
//no op windows | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
|
||
"github.com/pkg/errors" | ||
"golang.org/x/term" | ||
) | ||
|
||
func readPassword() (string, error) { | ||
var fd int | ||
if term.IsTerminal(syscall.Stdin) { | ||
fd = syscall.Stdin | ||
} else { | ||
tty, err := os.Open("/dev/tty") | ||
if err != nil { | ||
return "", errors.Wrap(err, "error allocating terminal") | ||
} | ||
defer tty.Close() | ||
fd = int(tty.Fd()) | ||
} | ||
bytePassword, err := term.ReadPassword(fd) | ||
if err != nil { | ||
return "", errors.Wrap(err, "error reading password") | ||
} | ||
|
||
return string(bytePassword), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"syscall" | ||
|
||
"github.com/pkg/errors" | ||
"golang.org/x/term" | ||
) | ||
|
||
func readPassword() (string, error) { | ||
var fd int | ||
if term.IsTerminal(int(syscall.Stdin)) { | ||
fd = int(syscall.Stdin) | ||
} else { | ||
return "", fmt.Errorf("error allocating terminal") | ||
} | ||
bytePassword, err := term.ReadPassword(fd) | ||
if err != nil { | ||
return "", errors.Wrap(err, "error reading password") | ||
} | ||
|
||
return string(bytePassword), nil | ||
} |
Oops, something went wrong.