blob: c290dcbf0a8784841b51e0aa6e3e4283008adb61 [file] [log] [blame]
Sergei Datsenkobcd8e462018-04-20 15:44:56 +10001// 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 Datsenko71ba50a2020-11-27 14:33:39 +110012#include "cros-disks/fuse_mounter.h"
Sergei Datsenkobcd8e462018-04-20 15:44:56 +100013
14namespace cros_disks {
15
16// Invokes sshfs to provide access to files over SFTP protocol.
Sergei Datsenko71ba50a2020-11-27 14:33:39 +110017class SshfsHelper : public FUSEMounterHelper {
Sergei Datsenkobcd8e462018-04-20 15:44:56 +100018 public:
Sergei Datsenko71ba50a2020-11-27 14:33:39 +110019 SshfsHelper(const Platform* platform,
20 brillo::ProcessReaper* process_reaper,
21 base::FilePath working_dir);
Qijiang Fan6bc59e12020-11-11 02:51:06 +090022 SshfsHelper(const SshfsHelper&) = delete;
23 SshfsHelper& operator=(const SshfsHelper&) = delete;
24
Sergei Datsenkobcd8e462018-04-20 15:44:56 +100025 ~SshfsHelper() override;
26
Sergei Datsenko71ba50a2020-11-27 14:33:39 +110027 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 Datsenkobcd8e462018-04-20 15:44:56 +100036
37 private:
Sergei Datsenko71ba50a2020-11-27 14:33:39 +110038 const FUSESandboxedProcessFactory sandbox_factory_;
39 const base::FilePath working_dir_;
40
41 friend class SshfsHelperTest;
Sergei Datsenkobcd8e462018-04-20 15:44:56 +100042};
43
44} // namespace cros_disks
45
46#endif // CROS_DISKS_SSHFS_HELPER_H_