Skip to content

Commit

Permalink
tweak(ecryptfs): better support
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Apr 12, 2023
1 parent 2176941 commit 7034976
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/me-keybindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"tr" #'read-only-mode
"tl" #'follow-mode
"tV" '(netextender-toggle :wk "NetExtender")
"te" '(ecryptfs-toggle-mount-private :wk "eCryptfs")
"tv" #'visible-mode

;; ====== Code ======
Expand Down
2 changes: 2 additions & 0 deletions core/me-loaddefs.el
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ CMD is the command to execute (interactively, `chown').

;;; Generated autoloads from ../elisp/ecryptfs.el

(autoload 'ecryptfs-toggle-mount-private "../elisp/ecryptfs" "\
Mount/Unmount eCryptfs' private directory." t)
(autoload 'ecryptfs-mount-private "../elisp/ecryptfs" "\
Mount eCryptfs' private directory." t)
(autoload 'ecryptfs-umount-private "../elisp/ecryptfs" "\
Expand Down
32 changes: 25 additions & 7 deletions elisp/ecryptfs.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@
"ecryptfs-insert-wrapped-passphrase-into-keyring %s '%s'"
"ecryptfs-unwrap-passphrase %s '%s' | ecryptfs-add-passphrase -"))

(defun ecryptfs-private-mounted-p ()
(let ((mount (shell-command-to-string "mount")))
(and (string-match-p (concat ".*" (expand-file-name ecryptfs-private-dir-name "~") ".*ecryptfs.*") mount)
t)))

;;;###autoload
(defun ecryptfs-toggle-mount-private ()
"Mount/Unmount eCryptfs' private directory."
(interactive)
(if (ecryptfs-private-mounted-p)
(ecryptfs-umount-private)
(ecryptfs-mount-private)))

;;;###autoload
(defun ecryptfs-mount-private ()
"Mount eCryptfs' private directory."
Expand All @@ -69,15 +82,20 @@
(message "Encrypted filenames mode [%s]" (if ecryptfs-encrypt-filenames-p "" ""))
(while (and ;; In the first iteration, we try to silently mount the ecryptfs private directory,
;; this would succeed if the key is available in the keyring.
(shell-command ecryptfs--mount-private-cmd
ecryptfs-buffer-name)
(and (shell-command ecryptfs--mount-private-cmd
ecryptfs-buffer-name)
(message "Successfully mounted private directory."))
try-again)
(setq try-again nil)
(shell-command
(format ecryptfs--command-format
ecryptfs-wrapped-passphrase-file
(funcall ecryptfs--passphrase))
ecryptfs-buffer-name)))))
(if (zerop
(shell-command
(format ecryptfs--command-format
ecryptfs-wrapped-passphrase-file
(funcall ecryptfs--passphrase))
ecryptfs-buffer-name))
(message "Successfully mounted private directory.")
(user-error "A problem occured while mounting the private directory, see %s"
ecryptfs-buffer-name))))))

;;;###autoload
(defun ecryptfs-umount-private ()
Expand Down

0 comments on commit 7034976

Please sign in to comment.