mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-11-03 19:15:58 +00:00 
			
		
		
		
	genpolicy: better parsing of mount path
Mount paths ending in '/' were not parsed correctly. Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
		
				
					committed by
					
						
						Fabiano Fidêncio
					
				
			
			
				
	
			
			
			
						parent
						
							ba792945ef
						
					
				
				
					commit
					6ab59453ff
				
			@@ -301,11 +301,12 @@ fn get_shared_bind_mount(
 | 
				
			|||||||
    propagation: &str,
 | 
					    propagation: &str,
 | 
				
			||||||
    access: &str,
 | 
					    access: &str,
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
    let mount_path = if let Some(byte_index) = str::rfind(&yaml_mount.mountPath, '/') {
 | 
					    // The Kata Shim filepath.Base() to extract the last element of this path, in
 | 
				
			||||||
        str::from_utf8(&yaml_mount.mountPath.as_bytes()[byte_index + 1..]).unwrap()
 | 
					    // https://github.com/kata-containers/kata-containers/blob/5e46f814dd79ab6b34588a83825260413839735a/src/runtime/virtcontainers/fs_share_linux.go#L305
 | 
				
			||||||
    } else {
 | 
					    // In Rust, Path::file_name() has a similar behavior.
 | 
				
			||||||
        &yaml_mount.mountPath
 | 
					    let path = Path::new(&yaml_mount.mountPath);
 | 
				
			||||||
    };
 | 
					    let mount_path = path.file_name().unwrap().to_str().unwrap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let source = format!("$(sfprefix){mount_path}$");
 | 
					    let source = format!("$(sfprefix){mount_path}$");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let dest = yaml_mount.mountPath.clone();
 | 
					    let dest = yaml_mount.mountPath.clone();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user