Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validation: add hostname validation #72

Merged

Conversation

Mashimiao
Copy link

Signed-off-by: Ma Shimiao mashimiao.fnst@cn.fujitsu.com

@@ -163,9 +165,15 @@ func checkLinux(spec rspec.Linux, rootfs string) {
for index := 0; index < len(spec.Namespaces); index++ {
if !namespaceValid(spec.Namespaces[index]) {
logrus.Fatalf("Namespace %s is invalid.", spec.Namespaces[index])
} else if spec.Namespces[index].Type == spec.UTSNamespace {
utsExist = true
Copy link
Member

@liangchenye liangchenye May 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/spec.UTS/rspec.UTS

I think we don't need this variable, we can just popup an error here if hostname is empty.

@Mashimiao Mashimiao force-pushed the add-hostname-bundle-validation branch 4 times, most recently from f32459e to 82ba2b0 Compare May 19, 2016 09:59
@@ -163,6 +163,8 @@ func checkLinux(spec rspec.Linux, rootfs string) {
for index := 0; index < len(spec.Namespaces); index++ {
if !namespaceValid(spec.Namespaces[index]) {
logrus.Fatalf("Namespace %s is invalid.", spec.Namespaces[index])
} else if spec.Namespaces[index].Type == rspec.UTSNamespace && rspec.Spec.Hostname != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs the whole rspec.Spec, not its current rspec.Linux. Then you can check spec.Hostname and spec.Linux.Namespaces. With cross-platform options like ‘hostname’ depending on platform-specific options like UTS namespaces, this kind of cross-cutting is unavoidable.

@Mashimiao Mashimiao force-pushed the add-hostname-bundle-validation branch from 82ba2b0 to 9fe6309 Compare May 20, 2016 01:18
@@ -163,6 +163,8 @@ func checkLinux(spec rspec.Linux, rootfs string) {
for index := 0; index < len(spec.Namespaces); index++ {
if !namespaceValid(spec.Namespaces[index]) {
logrus.Fatalf("Namespace %s is invalid.", spec.Namespaces[index])
} else if spec.Namespaces[index].Type == rspec.UTSNamespace && hostname != "" {
Copy link
Member

@liangchenye liangchenye May 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mashimiao sorry, your first commit is right.

 On Linux, you can only set this if your bundle creates a new UTS namespace.

So host name could be empty even a config file has a UTS namespace.
We should get an error when hostname is empty and no UTS namespace is created.

Copy link
Contributor

@wking wking May 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Thu, May 19, 2016 at 08:30:00PM -0700, 梁辰晔 (Liang Chenye) wrote:

So host name could be empty even a config file has a UTS namespace.

Correct. Maybe the UTS namespace is for a NIS domain name.

We should get an error when hostname is empty and no UTS namespace
is created

I think you mean, when the hostname is not empty and no UTS
namespace is created. All other combinations (UTS and no hostname,
neither UTS nor hostname, both UTS and hostname) are valid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, when hostname is not empty.
@Mashimiao 's first commit did the right thing and I mislead him to squash code lines.

@liangchenye liangchenye mentioned this pull request May 20, 2016
76 tasks
@liangchenye
Copy link
Member

add a WIP link in #66

@Mashimiao Mashimiao force-pushed the add-hostname-bundle-validation branch from 9fe6309 to b62e1cc Compare May 20, 2016 06:25
@Mashimiao
Copy link
Author

@liangchenye @wking fixed.

@wking
Copy link
Contributor

wking commented May 20, 2016 via email

@liangchenye
Copy link
Member

LGTM

@@ -152,7 +152,9 @@ func checkProcess(process rspec.Process, rootfs string) {
}

//Linux only
func checkLinux(spec rspec.Linux, rootfs string) {
func checkLinux(spec rspec.Linux, hostname string, rootfs string) {
utsExist := false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: utsExist --> utsExists

Copy link
Author

@Mashimiao Mashimiao May 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrunalp fixed

@Mashimiao Mashimiao force-pushed the add-hostname-bundle-validation branch from b62e1cc to b625601 Compare May 23, 2016 02:41
}
}

if !utsExists && hostname != "" {
logrus.Fatalf("New UTS namespace should to be created.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"hostname requires a new UTS namespace to be specified as well"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrunalp fixed.

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
@Mashimiao Mashimiao force-pushed the add-hostname-bundle-validation branch from b625601 to 124c7ff Compare May 24, 2016 01:17
@mrunalp
Copy link
Contributor

mrunalp commented May 24, 2016

LGTM

@mrunalp mrunalp merged commit dcd628f into opencontainers:master May 24, 2016
@Mashimiao Mashimiao deleted the add-hostname-bundle-validation branch November 14, 2016 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants