···139139 world: &mut world::World,
140140 entity: entity::Entity,
141141 object: session_core_user::SessionCoreUser,
142142+ management_access: &crate::Access,
142143) {
143144 if let Some(uid) = world.get::<ecs::Uid>(entity) {
144145 object.send_uid(uid.0);
···151152 }
152153 if let Some(state) = world.get::<ecs::UserState>(entity) {
153154 object.send_state(state.0);
155155+ }
156156+ if let Some(client) = object.client() {
157157+ let uid = world.get::<ecs::Uid>(entity).map_or(0, |uid| uid.0);
158158+ let can_modify =
159159+ management_access.allows(client.creds()) || uid == client.creds().uid.as_raw();
160160+ object.send_can_modify(u32::from(can_modify));
154161 }
155162 object.send_done();
156163
+25
protocols/session_core_v1.xml
···8080 <c2s name="destroy" destructor="true">
8181 <description summary="destroy this object"/>
8282 </c2s>
8383+ <s2c name="can_control_power">
8484+ <description summary="client may run power operations">
8585+ Non-zero if this client can reboot, power off, suspend, or hibernate
8686+ without first closing other users' sessions.
8787+ </description>
8888+ <arg name="can_control_power" type="uint" summary="non-zero if power operations are currently allowed"/>
8989+ </s2c>
8390 </object>
8491 <object name="session_core_session" version="1">
8592 <description summary="per-session information">
···155162 <c2s name="destroy" destructor="true">
156163 <description summary="destroy this object"/>
157164 </c2s>
165165+ <s2c name="can_modify">
166166+ <description summary="client may modify this session">
167167+ Non-zero if this client may lock, unlock, terminate, or kill this session.
168168+ </description>
169169+ <arg name="can_modify" type="uint" summary="non-zero if mutating requests are allowed"/>
170170+ </s2c>
158171 </object>
159172160173 <object name="session_core_seat" version="1">
···212225 <c2s name="destroy" destructor="true">
213226 <description summary="destroy this object"/>
214227 </c2s>
228228+ <s2c name="can_modify">
229229+ <description summary="client may modify this seat">
230230+ Non-zero if this client may terminate all sessions on this seat.
231231+ </description>
232232+ <arg name="can_modify" type="uint" summary="non-zero if mutating requests are allowed"/>
233233+ </s2c>
215234 </object>
216235217236 <object name="session_core_seat_client" version="1">
···355374 <c2s name="destroy" destructor="true">
356375 <description summary="destroy this object"/>
357376 </c2s>
377377+ <s2c name="can_modify">
378378+ <description summary="client may modify this user">
379379+ Non-zero if this client may terminate or kill this user's sessions.
380380+ </description>
381381+ <arg name="can_modify" type="uint" summary="non-zero if mutating requests are allowed"/>
382382+ </s2c>
358383 </object>
359384360385 <enum name="user_state">