ENH remove sudo prompts from veracrypt mounts
This commit is contained in:
parent
1ab10ed55b
commit
0fda1a55a3
|
@ -331,15 +331,15 @@ instance Mountable VeraCrypt where
|
||||||
mount (VeraCrypt Removable{ deviceSpec = s, label = l } m getPwd) False =
|
mount (VeraCrypt Removable{ deviceSpec = s, label = l } m getPwd) False =
|
||||||
bracketOnError_ (mkDirMaybe m) (rmDirMaybe m) mountMaybe
|
bracketOnError_ (mkDirMaybe m) (rmDirMaybe m) mountMaybe
|
||||||
where
|
where
|
||||||
mountMaybe = io $ maybe (runVeraCryptWith []) (runVeraCryptWithPwd =<<) getPwd
|
mountMaybe = io $ maybe (runVeraCryptWith "" []) (runVeraCryptWithPwd =<<) getPwd
|
||||||
runVeraCryptWithPwd = maybe notifyFail (\p -> runVeraCryptWith ["-p", p])
|
runVeraCryptWithPwd = maybe notifyFail (\p -> runVeraCryptWith p ["--stdin"])
|
||||||
runVeraCryptWith args = (\res -> notifyMounted (isRight res) False l)
|
runVeraCryptWith stdin args = (\res -> notifyMounted (isRight res) False l)
|
||||||
=<< runVeraCrypt ([s, m] ++ args)
|
=<< runVeraCrypt stdin ([s, m] ++ args)
|
||||||
notifyFail = notify "dialog-error-symbolic" $
|
notifyFail = notify "dialog-error-symbolic" $
|
||||||
printf "Failed to get volume password for %s" l
|
printf "Failed to get volume password for %s" l
|
||||||
|
|
||||||
mount (VeraCrypt Removable{ label = l } m _) True = io $ do
|
mount (VeraCrypt Removable{ label = l } m _) True = io $ do
|
||||||
res <- runVeraCrypt ["-d", m]
|
res <- runVeraCrypt "" ["-d", m]
|
||||||
notifyMounted (isRight res) True l
|
notifyMounted (isRight res) True l
|
||||||
|
|
||||||
allInstalled _ = io $ isJust <$> findExecutable "veracrypt"
|
allInstalled _ = io $ isJust <$> findExecutable "veracrypt"
|
||||||
|
@ -348,12 +348,13 @@ instance Mountable VeraCrypt where
|
||||||
|
|
||||||
fmtEntry (VeraCrypt r _ _) = fmtEntry r
|
fmtEntry (VeraCrypt r _ _) = fmtEntry r
|
||||||
|
|
||||||
runVeraCrypt :: [String] -> IO (Either (Int, String, String) String)
|
-- NOTE: the user is assumed to have added themselves to the sudoers file so
|
||||||
runVeraCrypt args = do
|
-- that this command will work
|
||||||
rootpass <- maybe "" (++ "\n") <$> readPassword' "Sudo Password"
|
runVeraCrypt :: String -> [String] -> IO (Either (Int, String, String) String)
|
||||||
readCmdEither "sudo" (defaultArgs ++ args) rootpass
|
runVeraCrypt stdin args = do
|
||||||
|
readCmdEither "sudo" (defaultArgs ++ args) stdin
|
||||||
where
|
where
|
||||||
defaultArgs = ["-S", "-E", "/usr/bin/veracrypt", "--text", "--non-interactive"]
|
defaultArgs = ["/usr/bin/veracrypt", "--text", "--non-interactive"]
|
||||||
|
|
||||||
getVeracryptDevices :: RofiIO MountConf [VeraCrypt]
|
getVeracryptDevices :: RofiIO MountConf [VeraCrypt]
|
||||||
getVeracryptDevices = mapM toDev =<< asks vcMounts
|
getVeracryptDevices = mapM toDev =<< asks vcMounts
|
||||||
|
|
Loading…
Reference in New Issue