refactor for pkexec

This commit is contained in:
itwrx
2023-07-14 18:02:17 -05:00
parent b183de6a93
commit 959bb7305f
4 changed files with 19 additions and 43 deletions

View File

@@ -57,14 +57,11 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
#handle permission denied error.
if rsyncRun.exitCode == 23:
rsyncRun.exitCode = 0
if getAskPassPath() == "":
let err = "No ssh-askpass binary found. Please install an ssh-askpass package for your distro, and let us know if EZ-Bkup still can't detect it's location."
rsyncErrors.add(err)
else:
rsyncRunCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -aq " & source & " " & destination
rsyncRun = execCmdEx(rsyncRunCmd)
if rsyncRun.exitCode != 0:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
#rsyncRunCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -aq " & source & " " & destination
rsyncRunCmd = "pkexec rsync -aq " & source & " " & destination
rsyncRun = execCmdEx(rsyncRunCmd)
if rsyncRun.exitCode != 0:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
#handle non-perms related error.
else:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination)
@@ -75,15 +72,12 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
if rsyncCheckRun.exitCode != 0:
#handle permission denied error.
if rsyncCheckRun.exitCode == 23:
rsyncCheckRun.exitCode = 0
if getAskPassPath() == "":
let err = "No ssh-askpass binary found. Please install an ssh-askpass package for your distro, and let us know if EZ-Bkup still can't detect it's location."
rsyncErrors.add(err)
else:
rsyncCheckCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -rn " & source & " " & destination
rsyncCheckRun = execCmdEx(rsyncCheckCmd)
if rsyncCheckRun.exitCode != 0:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
rsyncCheckRun.exitCode = 0
#rsyncCheckCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -rn " & source & " " & destination
rsyncCheckCmd = "pkexec rsync -rn " & source & " " & destination
rsyncCheckRun = execCmdEx(rsyncCheckCmd)
if rsyncCheckRun.exitCode != 0:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
#handle non-perms related error.
else:
rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination)
@@ -101,7 +95,7 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
method view(list: RoutineListState): Widget =
result = gui:
ScrolledWindow:
ScrolledWindow:
Box:
orient = OrientY
if list.routineModel.routineSeq().len() > 0: