File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,24 @@ ErrorOr<void> Process::execute_file_actions(ReadonlyBytes file_actions_data)
125125 });
126126 break ;
127127 }
128+ case SpawnFileActionType::Fchdir: {
129+ if (header->record_length < sizeof (SpawnFileActionFchdir))
130+ return EINVAL;
131+
132+ auto const * action = reinterpret_cast <SpawnFileActionFchdir const *>(header);
133+ auto description = TRY (open_file_description (action->fd ));
134+ if (!description->is_directory ())
135+ return ENOTDIR;
136+
137+ // Check for search (+x) permission on the directory
138+ if (!description->metadata ().may_execute (credentials ()))
139+ return EACCES;
140+
141+ m_current_directory.with ([&](auto & current_directory) {
142+ current_directory = description->custody ();
143+ });
144+ break ;
145+ }
128146 default :
129147 return EINVAL;
130148 }
@@ -157,7 +175,7 @@ ErrorOr<FlatPtr> Process::sys$posix_spawn(Userspace<Syscall::SC_posix_spawn_para
157175 OwnPtr<KBuffer> file_actions_buffer;
158176 if (params.serialized_file_actions_data .ptr () != 0 && params.serialized_file_actions_data_size != 0 ) {
159177 // Check for unsupported file actions
160- constexpr u8 SUPPORTED_SPAWN_ACTIONS = (1 << static_cast <u8 >(SpawnFileActionType::Dup2)) | (1 << static_cast <u8 >(SpawnFileActionType::Close)) | (1 << static_cast <u8 >(SpawnFileActionType::Open)) | (1 << static_cast <u8 >(SpawnFileActionType::Chdir));
178+ constexpr u8 SUPPORTED_SPAWN_ACTIONS = (1 << static_cast <u8 >(SpawnFileActionType::Dup2)) | (1 << static_cast <u8 >(SpawnFileActionType::Close)) | (1 << static_cast <u8 >(SpawnFileActionType::Open)) | (1 << static_cast <u8 >(SpawnFileActionType::Chdir)) | ( 1 << static_cast < u8 >(SpawnFileActionType::Fchdir)) ;
161179 if (params.file_action_types_present & ~SUPPORTED_SPAWN_ACTIONS)
162180 return ENOTSUP;
163181
You can’t perform that action at this time.
0 commit comments