refactor for pkexec
This commit is contained in:
		
							parent
							
								
									b183de6a93
								
							
						
					
					
						commit
						959bb7305f
					
				| @ -1,10 +1,11 @@ | |||||||
| # Changelog | # Changelog | ||||||
| 
 | 
 | ||||||
| ## 0.9.9 - 7-5-23 | ## 0.9.9 - 7-14-23 | ||||||
| ### Added | ### Added | ||||||
| - Added /usr/lib/ssh/x11-ssh-askpass path. (ITwrx) | - Added org.itwrx.EZ-Bkup.png for window/workspace icon. (ITwrx) | ||||||
| ### Changed | ### Changed | ||||||
| - remove path to non-functional gnome-ssh-askpass. (ITwrx) | - refactored to use pkexec instead of ssh-askpass. (ITwrx) | ||||||
|  | - Updated EZ-Bkup version in app_menu_button.nim. (ITwrx) | ||||||
| 
 | 
 | ||||||
| ## 0.9.8 - 7-5-23 | ## 0.9.8 - 7-5-23 | ||||||
| ### Added | ### Added | ||||||
| @ -12,7 +13,7 @@ | |||||||
| ### Changed | ### Changed | ||||||
| - Made some file names more uniform. (ITwrx) | - Made some file names more uniform. (ITwrx) | ||||||
| - Re-added selectedPreload proc accidentally removed from Routine.nim in last release. (ITwrx) | - Re-added selectedPreload proc accidentally removed from Routine.nim in last release. (ITwrx) | ||||||
| - Updated EZ-Bkup version in app_menu_button.nim and ez_bkup.desktop (included with installer in the funded release). (ITwrx) | - Updated EZ-Bkup version in app_menu_button.nim. (ITwrx) | ||||||
| 
 | 
 | ||||||
| ## 0.9.7 - 7-1-23 | ## 0.9.7 - 7-1-23 | ||||||
| ### Added | ### Added | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ method view(app: AppState): Widget = | |||||||
|     Window: |     Window: | ||||||
|       title = APP_NAME |       title = APP_NAME | ||||||
|       defaultSize = (1024, 768) |       defaultSize = (1024, 768) | ||||||
|  |       iconName = "org.itwrx.EZ-Bkup" | ||||||
|       HeaderBar {.addTitlebar.}: |       HeaderBar {.addTitlebar.}: | ||||||
|         Icon {.addLeft.}: |         Icon {.addLeft.}: | ||||||
|           name = "ez_bkup" |           name = "ez_bkup" | ||||||
|  | |||||||
							
								
								
									
										20
									
								
								shared.nim
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								shared.nim
									
									
									
									
									
								
							| @ -4,7 +4,6 @@ EZ-Bkup is released under the General Public License 3.0. | |||||||
| See COPYING or <https://www.gnu.org/licenses/> for details.]# | See COPYING or <https://www.gnu.org/licenses/> for details.]# | ||||||
| 
 | 
 | ||||||
| import logging, times, os | import logging, times, os | ||||||
| #import "models/routine" |  | ||||||
| 
 | 
 | ||||||
| let appPath* = getHomeDir() & ".ez-bkup" | let appPath* = getHomeDir() & ".ez-bkup" | ||||||
| let databasePath* = appPath & "/ez-bkup.sqlite" | let databasePath* = appPath & "/ez-bkup.sqlite" | ||||||
| @ -15,7 +14,6 @@ if not dirExists(appPath): | |||||||
| var logger = newFileLogger(appPath & "/errors.log") | var logger = newFileLogger(appPath & "/errors.log") | ||||||
| let dt = now() | let dt = now() | ||||||
| let nowDT* = dt.format("M-d-YYYY h:mm:ss tt") | let nowDT* = dt.format("M-d-YYYY h:mm:ss tt") | ||||||
| #var logMsg: string |  | ||||||
| 
 | 
 | ||||||
| proc writeErrorToLog*(logMsg: string) = | proc writeErrorToLog*(logMsg: string) = | ||||||
|   logger.log(lvlError, logMsg) |   logger.log(lvlError, logMsg) | ||||||
| @ -25,21 +23,3 @@ proc writeInfoToLog*(logMsg: string) = | |||||||
| 
 | 
 | ||||||
| proc hasCommas*(filename: string):bool = | proc hasCommas*(filename: string):bool = | ||||||
|   ',' in filename        |   ',' in filename        | ||||||
| 
 |  | ||||||
| proc getAskPassPath*(): string = |  | ||||||
|   var askPassPath: string |  | ||||||
|    |  | ||||||
|   if fileExists("/usr/libexec/openssh/ssh-askpass"): |  | ||||||
|     askPassPath = "/usr/libexec/openssh/ssh-askpass" |  | ||||||
|   elif fileExists("/usr/lib/ssh/x11-ssh-askpass"): |  | ||||||
|     askPassPath = "/usr/lib/ssh/x11-ssh-askpass" |  | ||||||
|   elif fileExists("/usr/lib/ssh/gtk-ssh-askpass"): |  | ||||||
|     askPassPath = "/usr/lib/ssh/gtk-ssh-askpass" |  | ||||||
|   elif fileExists("/usr/lib/ssh/ssh-askpass"): |  | ||||||
|     askPassPath = "/usr/lib/ssh/ssh-askpass" |  | ||||||
|   else: |  | ||||||
|     askPassPath = "" |  | ||||||
|    |  | ||||||
|   return askPassPath |  | ||||||
| 
 |  | ||||||
|      |  | ||||||
|  | |||||||
| @ -57,11 +57,8 @@ proc rsyncThread(list: RoutineListState) {.thread.} = | |||||||
|               #handle permission denied error. |               #handle permission denied error. | ||||||
|               if rsyncRun.exitCode == 23: |               if rsyncRun.exitCode == 23: | ||||||
|                 rsyncRun.exitCode = 0 |                 rsyncRun.exitCode = 0 | ||||||
|                 if getAskPassPath() == "": |                 #rsyncRunCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -aq " & source & " " & destination  | ||||||
|                   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." |                 rsyncRunCmd = "pkexec rsync -aq " & source & " " & destination                  | ||||||
|                   rsyncErrors.add(err) |  | ||||||
|                 else: |  | ||||||
|                   rsyncRunCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -aq " & source & " " & destination                   |  | ||||||
|                 rsyncRun = execCmdEx(rsyncRunCmd) |                 rsyncRun = execCmdEx(rsyncRunCmd) | ||||||
|                 if rsyncRun.exitCode != 0: |                 if rsyncRun.exitCode != 0: | ||||||
|                   rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination) |                   rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to back up " & source & " to " & destination) | ||||||
| @ -76,11 +73,8 @@ proc rsyncThread(list: RoutineListState) {.thread.} = | |||||||
|               #handle permission denied error. |               #handle permission denied error. | ||||||
|               if rsyncCheckRun.exitCode == 23: |               if rsyncCheckRun.exitCode == 23: | ||||||
|                 rsyncCheckRun.exitCode = 0                                 |                 rsyncCheckRun.exitCode = 0                                 | ||||||
|                 if getAskPassPath() == "": |                 #rsyncCheckCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -rn " & source & " " & destination   | ||||||
|                   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." |                 rsyncCheckCmd = "pkexec rsync -rn " & source & " " & destination                  | ||||||
|                   rsyncErrors.add(err) |  | ||||||
|                 else:                   |  | ||||||
|                   rsyncCheckCmd = "SUDO_ASKPASS=" & getAskPassPath() & " sudo -A rsync -rn " & source & " " & destination                   |  | ||||||
|                 rsyncCheckRun = execCmdEx(rsyncCheckCmd) |                 rsyncCheckRun = execCmdEx(rsyncCheckCmd) | ||||||
|                 if rsyncCheckRun.exitCode != 0: |                 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) |                   rsyncErrors.add("EZ-Bkup's rsync process(es) returned error (" & $rsyncRun.output & ") while attempting to verify that " & source & " got backed up to " & destination) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user