Skip to content

Commit 1be5fba

Browse files
BreakthroughCQ Bot
authored andcommitted
[sys] Remove remaining usages of FLAG_POSIX_*
Test: fx test //src/sys/component_manager Bug: 378924259 Change-Id: I3b3bff70bf9b0ff880af09daa7d433967809b0e6 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1191813 Commit-Queue: Brandon Castellano <[email protected]> Reviewed-by: Claire Gonyeo <[email protected]>
1 parent 05bf2f3 commit 1be5fba

File tree

2 files changed

+10
-40
lines changed

2 files changed

+10
-40
lines changed

src/sys/component_manager/src/framework/realm.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use anyhow::Error;
1212
use async_trait::async_trait;
1313
use cm_config::RuntimeConfig;
1414
use cm_rust::FidlIntoNative;
15-
use cm_types::{Name, OPEN_FLAGS_MAX_POSSIBLE_RIGHTS};
15+
use cm_types::{Name, FLAGS_MAX_POSSIBLE_RIGHTS};
1616
use errors::OpenExposedDirError;
1717
use fidl::endpoints::{DiscoverableProtocolMarker, ServerEnd};
1818
use 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,

src/sys/lib/cm_types/src/lib.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,36 +108,13 @@ pub const MAX_LONG_NAME_LENGTH: usize = 1024;
108108
pub const MAX_PATH_LENGTH: usize = fio::MAX_PATH_LENGTH as usize;
109109
pub const MAX_URL_LENGTH: usize = 4096;
110110

111-
/// This asks for the maximum possible rights that the parent connection will allow; this will
112-
/// include the writable and executable rights if the parent connection has them, but won't fail if
113-
/// it doesn't.
114-
// TODO(https://fxbug.dev/324111518): Remove this once we migrate to using Open3.
115-
pub const OPEN_FLAGS_MAX_POSSIBLE_RIGHTS: fio::OpenFlags = fio::OpenFlags::RIGHT_READABLE
116-
.union(fio::OpenFlags::POSIX_WRITABLE)
117-
.union(fio::OpenFlags::POSIX_EXECUTABLE);
118-
119-
#[cfg(fuchsia_api_level_at_least = "HEAD")]
120111
/// This asks for the maximum possible rights that the parent connection will allow; this will
121112
/// include the writable and executable rights if the parent connection has them, but won't fail if
122113
/// it doesn't.
123114
pub const FLAGS_MAX_POSSIBLE_RIGHTS: fio::Flags = fio::PERM_READABLE
124115
.union(fio::Flags::PERM_INHERIT_WRITE)
125116
.union(fio::Flags::PERM_INHERIT_EXECUTE);
126117

127-
#[cfg(fuchsia_api_level_less_than = "HEAD")]
128-
/// This asks for the maximum possible rights that the parent connection will allow; this will
129-
/// include the writable and executable rights if the parent connection has them, but won't fail if
130-
/// it doesn't.
131-
// Note that when opening a node as readable, we expect the connection to have the following set of
132-
// permissions: `PERM_CONNECT | PERM_ENUMERATE | PERM_TRAVERSE | PERM_READ | PERM_GET_ATTRIBUTES`.
133-
pub const FLAGS_MAX_POSSIBLE_RIGHTS: fio::Flags = fio::Flags::PERM_READ
134-
.union(fio::Flags::PERM_CONNECT)
135-
.union(fio::Flags::PERM_ENUMERATE)
136-
.union(fio::Flags::PERM_TRAVERSE)
137-
.union(fio::Flags::PERM_GET_ATTRIBUTES)
138-
.union(fio::Flags::PERM_INHERIT_WRITE)
139-
.union(fio::Flags::PERM_INHERIT_EXECUTE);
140-
141118
/// A name that can refer to a component, collection, or other entity in the
142119
/// Component Manifest. Its length is bounded to `MAX_NAME_LENGTH`.
143120
pub type Name = BoundedName<MAX_NAME_LENGTH>;

0 commit comments

Comments
 (0)