@@ -12,7 +12,7 @@ use anyhow::Error;
1212use async_trait:: async_trait;
1313use cm_config:: RuntimeConfig ;
1414use cm_rust:: FidlIntoNative ;
15- use cm_types:: { Name , OPEN_FLAGS_MAX_POSSIBLE_RIGHTS } ;
15+ use cm_types:: { Name , FLAGS_MAX_POSSIBLE_RIGHTS } ;
1616use errors:: OpenExposedDirError ;
1717use fidl:: endpoints:: { DiscoverableProtocolMarker , ServerEnd } ;
1818use futures:: prelude:: * ;
@@ -210,11 +210,8 @@ impl RealmCapabilityProvider {
210210 ) ;
211211 return fcomponent:: Error :: InstanceCannotResolve ;
212212 } ) ?;
213- // open_exposed does not have a rights input parameter, so this
214- // makes use of the POSIX_[WRITABLE|EXECUTABLE] flags to open
215- // a connection with those rights if available from the parent
216- // directory connection but without failing if not available.
217- let flags = OPEN_FLAGS_MAX_POSSIBLE_RIGHTS | fio:: OpenFlags :: DIRECTORY ;
213+ // We request the maximum possible rights from the parent directory connection.
214+ let flags = FLAGS_MAX_POSSIBLE_RIGHTS | fio:: Flags :: PROTOCOL_DIRECTORY ;
218215 let mut object_request = flags. to_object_request ( exposed_dir) ;
219216 child
220217 . open_exposed ( OpenRequest :: new (
@@ -1166,19 +1163,15 @@ mod tests {
11661163 . now_or_never ( ) ;
11671164 assert ! ( event. is_none( ) ) ;
11681165
1169- // Check flags on directory opened. These are not exactly the flags we
1170- // set in `open_exposed_dir`, because fuchsia.io transforms POSIX_*
1171- // flags into their respective {RIGHT_READABLE, RIGHT_WRITABLE,
1172- // RIGHT_EXECUTABLE} variants if and only if all intermediate nodes are
1173- // readable, writable, or executable. Additionally, we already know
1174- // this is a directory, and fuchsia.io does not propagate that flag.
1175- let ( status, flags) = dir_proxy. get_flags ( ) . await . expect ( "getting exposed dir flags" ) ;
1176- assert_matches ! ( zx:: Status :: ok( status) , Ok ( ( ) ) ) ;
1166+ // Check flags on directory opened. This should match the maximum set of rights for every
1167+ // directory connection along the open chain.
1168+ let flags = dir_proxy. get_flags2 ( ) . await . expect ( "FIDL error" ) . expect ( "GetFlags error" ) ;
11771169 assert_eq ! (
11781170 flags,
1179- fio:: OpenFlags :: RIGHT_READABLE
1180- | fio:: OpenFlags :: RIGHT_WRITABLE
1181- | fio:: OpenFlags :: RIGHT_EXECUTABLE
1171+ fio:: PERM_READABLE
1172+ | fio:: PERM_WRITABLE
1173+ | fio:: PERM_EXECUTABLE
1174+ | fio:: Flags :: PROTOCOL_DIRECTORY
11821175 ) ;
11831176
11841177 // Now that it was asserted that "system:0" has yet to start,
0 commit comments