diff --git a/test/images/BUILD b/test/images/BUILD index 4cb04ad2302..40a9c7db390 100644 --- a/test/images/BUILD +++ b/test/images/BUILD @@ -31,6 +31,7 @@ filegroup( "//test/images/nettest:all-srcs", "//test/images/no-snat-test:all-srcs", "//test/images/no-snat-test-proxy:all-srcs", + "//test/images/nonewprivs:all-srcs", "//test/images/port-forward-tester:all-srcs", "//test/images/porter:all-srcs", "//test/images/resource-consumer:all-srcs", diff --git a/test/images/nonewprivs/BASEIMAGE b/test/images/nonewprivs/BASEIMAGE new file mode 100644 index 00000000000..114844f395e --- /dev/null +++ b/test/images/nonewprivs/BASEIMAGE @@ -0,0 +1,4 @@ +amd64=alpine:3.6 +arm=arm32v6/alpine:3.6 +arm64=arm64v8/alpine:3.6 +ppc64le=ppc64le/alpine:3.6 diff --git a/test/images/nonewprivs/BUILD b/test/images/nonewprivs/BUILD new file mode 100644 index 00000000000..83b38d5c558 --- /dev/null +++ b/test/images/nonewprivs/BUILD @@ -0,0 +1,34 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +go_binary( + name = "nonewprivs", + library = ":go_default_library", + tags = ["automanaged"], +) + +go_library( + name = "go_default_library", + srcs = ["nnp.go"], + tags = ["automanaged"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/test/images/nonewprivs/Dockerfile b/test/images/nonewprivs/Dockerfile index fede04af313..47e49f8d530 100644 --- a/test/images/nonewprivs/Dockerfile +++ b/test/images/nonewprivs/Dockerfile @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM alpine:latest +FROM BASEIMAGE + +CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/ COPY nnp /usr/local/bin/nnp RUN chmod +s /usr/local/bin/nnp diff --git a/test/images/nonewprivs/Makefile b/test/images/nonewprivs/Makefile index 05d78ba46e8..660b2f2f7ec 100644 --- a/test/images/nonewprivs/Makefile +++ b/test/images/nonewprivs/Makefile @@ -12,22 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -.PHONY: all image push clean +SRCS = nnp +ARCH ?= amd64 +TARGET ?= $(CURDIR) +GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export -TAG = 1.2 -PREFIX = gcr.io/google_containers +bin: + ../image-util.sh bin $(SRCS) - -all: push - -nnp: nnp.c - gcc -static -o $@ $@.c - -image: nnp - docker build --pull -t $(PREFIX)/nonewprivs:$(TAG) . - -push: image - gcloud docker -- push $(PREFIX)/nonewprivs:$(TAG) - -clean: - rm -f nnp +.PHONY: bin diff --git a/test/images/nonewprivs/VERSION b/test/images/nonewprivs/VERSION new file mode 100644 index 00000000000..d3827e75a5c --- /dev/null +++ b/test/images/nonewprivs/VERSION @@ -0,0 +1 @@ +1.0 diff --git a/test/images/nonewprivs/nnp.c b/test/images/nonewprivs/nnp.c deleted file mode 100644 index 324bd42e974..00000000000 --- a/test/images/nonewprivs/nnp.c +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Kubernetes 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. - -#include -#include -#include - -int main(int argc, char *argv[]){ - printf("Effective uid: %d\n", geteuid()); - return 0; -} diff --git a/test/images/nonewprivs/nnp.go b/test/images/nonewprivs/nnp.go new file mode 100644 index 00000000000..cdfe087ff9f --- /dev/null +++ b/test/images/nonewprivs/nnp.go @@ -0,0 +1,26 @@ +/* +Copyright 2017 The Kubernetes 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" + "os" +) + +func main() { + fmt.Printf("Effective uid: %d\n", os.Geteuid()) +}