Skip to content

Allow relabeling of files/directories under /usr prefix#180

Merged
rhatdan merged 1 commit intoopencontainers:mainfrom
rhatdan:relabel1
Sep 26, 2022
Merged

Allow relabeling of files/directories under /usr prefix#180
rhatdan merged 1 commit intoopencontainers:mainfrom
rhatdan:relabel1

Conversation

@rhatdan
Copy link
Copy Markdown
Collaborator

@rhatdan rhatdan commented Sep 23, 2022

We already check to make sure users do not accidentily relabel these excluded paths:

exclude_paths := map[string]bool{
	"/":           true,
	"/bin":        true,
	"/boot":       true,
	"/dev":        true,
	"/etc":        true,
	"/etc/passwd": true,
	"/etc/pki":    true,
	"/etc/shadow": true,
	"/home":       true,
	"/lib":        true,
	"/lib64":      true,
	"/media":      true,
	"/opt":        true,
	"/proc":       true,
	"/root":       true,
	"/run":        true,
	"/sbin":       true,
	"/srv":        true,
	"/sys":        true,
	"/tmp":        true,
	"/usr":        true,
	"/var":        true,
	"/var/lib":    true,
	"/var/log":    true,
}

But some users put homedirectories under /usr, and I see no reason to block them from relabeling.

At a certain point if users do something dumb with relableing we can not stop them.

Signed-off-by: Daniel J Walsh [email protected]

We already check to make sure users do not accidentily relabel these
excluded paths:

	exclude_paths := map[string]bool{
		"/":           true,
		"/bin":        true,
		"/boot":       true,
		"/dev":        true,
		"/etc":        true,
		"/etc/passwd": true,
		"/etc/pki":    true,
		"/etc/shadow": true,
		"/home":       true,
		"/lib":        true,
		"/lib64":      true,
		"/media":      true,
		"/opt":        true,
		"/proc":       true,
		"/root":       true,
		"/run":        true,
		"/sbin":       true,
		"/srv":        true,
		"/sys":        true,
		"/tmp":        true,
		"/usr":        true,
		"/var":        true,
		"/var/lib":    true,
		"/var/log":    true,
	}

But some users put homedirectories under /usr, and I see no
reason to block them from relabeling.

At a certain point if users do something dumb with relableing we
can not stop them.

Signed-off-by: Daniel J Walsh <[email protected]>
@rhatdan
Copy link
Copy Markdown
Collaborator Author

rhatdan commented Sep 23, 2022

@rhatdan
Copy link
Copy Markdown
Collaborator Author

rhatdan commented Sep 23, 2022

Copy link
Copy Markdown
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Copy Markdown
Member

We already check to make sure users do not accidentily relabel these excluded paths

Double-checking; it looks like exclude_paths is only used by label.Relabel(); selinux.Chcon() is not checking for any of these; should it ?

@rhatdan
Copy link
Copy Markdown
Collaborator Author

rhatdan commented Sep 26, 2022

We could move it into that function instead of label.Relabel. Where we use this in Podman and Buildah is always throught lable.Relabel.

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