Merge pull request #24124 from mheon/validate_bind_propagation
Validate the bind-propagation option to `--mount`
This commit is contained in:
		
						commit
						e9e9f7e1ff
					
				| 
						 | 
				
			
			@ -272,6 +272,12 @@ func parseMountOptions(mountType string, args []string) (*spec.Mount, error) {
 | 
			
		|||
			if !hasValue {
 | 
			
		||||
				return nil, fmt.Errorf("%v: %w", name, errOptionArg)
 | 
			
		||||
			}
 | 
			
		||||
			switch value {
 | 
			
		||||
			case "shared", "rshared", "private", "rprivate", "slave", "rslave", "unbindable", "runbindable":
 | 
			
		||||
				// Do nothing, sane value
 | 
			
		||||
			default:
 | 
			
		||||
				return nil, fmt.Errorf("invalid value %q", arg)
 | 
			
		||||
			}
 | 
			
		||||
			mnt.Options = append(mnt.Options, value)
 | 
			
		||||
		case "consistency":
 | 
			
		||||
			// Often used on MACs and mistakenly on Linux platforms.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -122,6 +122,10 @@ var _ = Describe("Podman run with volumes", func() {
 | 
			
		|||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session).To(ExitWithError(125, `"notmpcopyup" option not supported for "bind" mount types`))
 | 
			
		||||
 | 
			
		||||
		session = podmanTest.Podman([]string{"run", "--rm", "--mount", "type=bind,src=/tmp,target=/tmp,bind-propagation=fake", ALPINE, "true"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session).To(ExitWithError(125, `invalid value "bind-propagation=fake"`))
 | 
			
		||||
 | 
			
		||||
		session = podmanTest.Podman([]string{"run", "--rm", "--mount", "type=tmpfs,target=/etc/ssl,notmpcopyup", ALPINE, "ls", "/etc/ssl"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session).Should(ExitCleanly())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue