mfm/src/filesystems/gocryptfs.cr

43 lines
1,010 B
Crystal
Raw Normal View History

2023-10-25 14:01:46 +02:00
# SPDX-License-Identifier: GPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
2023-10-24 12:50:01 +02:00
require "shellwords"
require "./abstract_filesystem"
require "./concerns/base"
2023-10-24 12:50:01 +02:00
2023-10-22 23:23:56 +02:00
module GX
module Filesystem
class GoCryptFS < AbstractFilesystem
getter name : String = ""
getter encrypted_path : String = ""
2023-10-22 23:23:56 +02:00
@[YAML::Field(key: "mount_dir", ignore: true)]
getter mount_dir : String = ""
2023-10-24 15:53:28 +02:00
include Concerns::Base
2023-10-24 15:53:28 +02:00
def mounted_prefix()
"#{encrypted_path}"
end
2023-10-22 23:23:56 +02:00
def mount
_mount_wrapper do
process = Process.new(
"gocryptfs",
["-idle", "15m", encrypted_path, mount_dir],
input: STDIN,
output: STDOUT,
error: STDERR
)
unless process.wait.success?
puts "Error mounting the vault".colorize(:red)
return
end
2023-10-24 12:50:01 +02:00
end
2023-10-22 23:23:56 +02:00
end
2023-10-24 12:50:01 +02:00
end
2023-10-22 23:23:56 +02:00
end
end