ADD cache for sudo
This commit is contained in:
parent
442dbafaba
commit
54651e2fe9
|
@ -732,9 +732,16 @@ runMountSudoMaybe' useSudo cmd args environ =
|
|||
-- runSudoMount rootpass cmd args stdin = runSudoMount' rootpass cmd args stdin []
|
||||
|
||||
runSudoMount' :: MonadIO m => T.Text -> T.Text -> [T.Text] -> [(T.Text, T.Text)] -> m MountResult
|
||||
runSudoMount' rootpass cmd args environ = runMount "sudo" args' rootpass
|
||||
runSudoMount' rootpass cmd args environ = do
|
||||
-- This needs Default timestamp_type=global in sudoers to have any effect
|
||||
-- since these are all separate shells
|
||||
isCached <- isJust <$> readCmdSuccess "sudo" ["-n", "true"] ""
|
||||
if isCached then run else do
|
||||
cacheSuccess <- isJust <$> readCmdSuccess "sudo" ["-S", "true"] rootpass
|
||||
if cacheSuccess then run else return $ MountError "Could not cache password"
|
||||
where
|
||||
args' = ["-S"] ++ environ' ++ [cmd] ++ args
|
||||
run = runMount "sudo" args' ""
|
||||
args' = ["-n"] ++ environ' ++ [cmd] ++ args
|
||||
environ' = fmap (\(k, v) -> T.concat [k, "=", v]) environ
|
||||
|
||||
eitherToMountResult :: Either (Int, T.Text, T.Text) T.Text -> MountResult
|
||||
|
|
|
@ -69,8 +69,8 @@ hotkeyMsg hs = ["-mesg", T.intercalate " | " $ fmap hotkeyMsg1 hs]
|
|||
|
||||
hotkeyArgs :: [Hotkey c] -> [T.Text]
|
||||
hotkeyArgs hks =
|
||||
(hotkeyMsg hks)
|
||||
++ (concatMap (uncurry hotkeyBinding) $ take 19 $ zip [1 ..] hks)
|
||||
hotkeyMsg hks
|
||||
++ concatMap (uncurry hotkeyBinding) (take 19 $ zip [1 ..] hks)
|
||||
|
||||
data RofiMenu c = RofiMenu
|
||||
{ groups :: ![RofiGroup c]
|
||||
|
@ -129,7 +129,7 @@ selectAction rm = do
|
|||
-- keybindings are labeled 1-19 and thus need to be explicitly
|
||||
-- indexed, and the program itself tells the world which key was
|
||||
-- pressed via return code (any possible integer)
|
||||
((V.fromList $ hotkeys rm) V.!? (n - 10))
|
||||
(V.fromList (hotkeys rm) V.!? (n - 10))
|
||||
|
||||
runRofi :: (MonadIO m, HasRofiConf c) => c -> RofiMenu c -> m ()
|
||||
runRofi c = runRIO c . selectAction
|
||||
|
@ -171,7 +171,7 @@ readCmdEither'
|
|||
-> m (Either (Int, T.Text, T.Text) T.Text)
|
||||
readCmdEither' cmd args input environ =
|
||||
resultToEither
|
||||
<$> (liftIO $ readCreateProcessWithExitCode p (T.unpack input))
|
||||
<$> liftIO (readCreateProcessWithExitCode p (T.unpack input))
|
||||
where
|
||||
e = case environ of
|
||||
[] -> Nothing
|
||||
|
|
|
@ -16,8 +16,8 @@ notify icon summary body =
|
|||
liftIO $
|
||||
void $
|
||||
spawnProcess "notify-send" $
|
||||
maybe args (\b -> args ++ [b]) $
|
||||
fmap T.unpack body
|
||||
maybe args ((\b -> args ++ [b]) . T.unpack)
|
||||
body
|
||||
where
|
||||
args = ["-i", show icon, T.unpack summary]
|
||||
|
||||
|
|
Loading…
Reference in New Issue