Sergei Datsenko | bcd8e46 | 2018-04-20 15:44:56 +1000 | [diff] [blame] | 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CROS_DISKS_SSHFS_HELPER_H_ |
| 6 | #define CROS_DISKS_SSHFS_HELPER_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
Sergei Datsenko | 71ba50a | 2020-11-27 14:33:39 +1100 | [diff] [blame] | 12 | #include "cros-disks/fuse_mounter.h" |
Sergei Datsenko | bcd8e46 | 2018-04-20 15:44:56 +1000 | [diff] [blame] | 13 | |
| 14 | namespace cros_disks { |
| 15 | |
| 16 | // Invokes sshfs to provide access to files over SFTP protocol. |
Sergei Datsenko | 71ba50a | 2020-11-27 14:33:39 +1100 | [diff] [blame] | 17 | class SshfsHelper : public FUSEMounterHelper { |
Sergei Datsenko | bcd8e46 | 2018-04-20 15:44:56 +1000 | [diff] [blame] | 18 | public: |
Sergei Datsenko | 71ba50a | 2020-11-27 14:33:39 +1100 | [diff] [blame] | 19 | SshfsHelper(const Platform* platform, |
| 20 | brillo::ProcessReaper* process_reaper, |
| 21 | base::FilePath working_dir); |
Qijiang Fan | 6bc59e1 | 2020-11-11 02:51:06 +0900 | [diff] [blame] | 22 | SshfsHelper(const SshfsHelper&) = delete; |
| 23 | SshfsHelper& operator=(const SshfsHelper&) = delete; |
| 24 | |
Sergei Datsenko | bcd8e46 | 2018-04-20 15:44:56 +1000 | [diff] [blame] | 25 | ~SshfsHelper() override; |
| 26 | |
Sergei Datsenko | 71ba50a | 2020-11-27 14:33:39 +1100 | [diff] [blame] | 27 | bool CanMount(const std::string& source, |
| 28 | const std::vector<std::string>& params, |
| 29 | base::FilePath* suggested_name) const override; |
| 30 | |
| 31 | protected: |
| 32 | MountErrorType ConfigureSandbox(const std::string& source, |
| 33 | const base::FilePath& target_path, |
| 34 | std::vector<std::string> params, |
| 35 | SandboxedProcess* sandbox) const override; |
Sergei Datsenko | bcd8e46 | 2018-04-20 15:44:56 +1000 | [diff] [blame] | 36 | |
| 37 | private: |
Sergei Datsenko | 71ba50a | 2020-11-27 14:33:39 +1100 | [diff] [blame] | 38 | const FUSESandboxedProcessFactory sandbox_factory_; |
| 39 | const base::FilePath working_dir_; |
| 40 | |
| 41 | friend class SshfsHelperTest; |
Sergei Datsenko | bcd8e46 | 2018-04-20 15:44:56 +1000 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | } // namespace cros_disks |
| 45 | |
| 46 | #endif // CROS_DISKS_SSHFS_HELPER_H_ |