add polkit for custom authentication && update build.rs
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
		
							parent
							
								
									64f5f3253c
								
							
						
					
					
						commit
						203d9e39a0
					
				
							
								
								
									
										18
									
								
								build.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								build.py
									
									
									
									
									
								
							| @ -71,7 +71,7 @@ def make_parser(): | |||||||
|     parser.add_argument( |     parser.add_argument( | ||||||
|         '--hwcodec', |         '--hwcodec', | ||||||
|         action='store_true', |         action='store_true', | ||||||
|         help='Enable feature hwcodec, windows only.' |         help='Enable feature hwcodec' | ||||||
|     ) |     ) | ||||||
|     return parser |     return parser | ||||||
| 
 | 
 | ||||||
| @ -124,26 +124,28 @@ def get_features(args): | |||||||
| 
 | 
 | ||||||
| def build_flutter_deb(version): | def build_flutter_deb(version): | ||||||
|     os.chdir('flutter') |     os.chdir('flutter') | ||||||
|  |     os.system('/bin/rm -rf tmpdeb/') | ||||||
|     os.system('dpkg-deb -R rustdesk.deb tmpdeb') |     os.system('dpkg-deb -R rustdesk.deb tmpdeb') | ||||||
|     # os.system('flutter build linux --release') |     os.system('flutter build linux --release') | ||||||
|     os.system('rm tmpdeb/usr/bin/rustdesk') |     os.system('rm tmpdeb/usr/bin/rustdesk') | ||||||
|     os.system('strip build/linux/x64/release/liblibrustdesk.so') |  | ||||||
|     os.system('mkdir -p tmpdeb/usr/lib/rustdesk') |     os.system('mkdir -p tmpdeb/usr/lib/rustdesk') | ||||||
|     os.system('mkdir -p tmpdeb/usr/share/rustdesk/files/systemd/') |     os.system('mkdir -p tmpdeb/usr/share/rustdesk/files/systemd/') | ||||||
|  |     os.system('mkdir -p tmpdeb/usr/share/polkit-1/actions') | ||||||
|     os.system( |     os.system( | ||||||
|         'cp -r build/linux/x64/release/bundle/* tmpdeb/usr/lib/rustdesk/') |         'cp -r build/linux/x64/release/bundle/* tmpdeb/usr/lib/rustdesk/') | ||||||
|     os.system( |     os.system( | ||||||
|         'pushd tmpdeb && ln -s /usr/lib/rustdesk/flutter_hbb usr/bin/rustdesk && popd') |         'pushd tmpdeb && ln -s /usr/lib/rustdesk/flutter_hbb usr/bin/rustdesk && popd') | ||||||
|     os.system( |     os.system( | ||||||
|         'cp build/linux/x64/release/liblibrustdesk.so tmpdeb/usr/lib/rustdesk/librustdesk.so') |         'cp ../rustdesk.service tmpdeb/usr/share/rustdesk/files/systemd/') | ||||||
|     os.system( |     os.system( | ||||||
|         'cp rustdesk.service tmpdeb/usr/share/rustdesk/files/systemd/') |         'cp ../rustdesk.service.user tmpdeb/usr/share/rustdesk/files/systemd/') | ||||||
|     os.system( |  | ||||||
|         'cp rustdesk.service.user tmpdeb/usr/share/rustdesk/files/systemd/') |  | ||||||
|     os.system( |     os.system( | ||||||
|         'cp ../128x128@2x.png tmpdeb/usr/share/rustdesk/files/rustdesk.png') |         'cp ../128x128@2x.png tmpdeb/usr/share/rustdesk/files/rustdesk.png') | ||||||
|     os.system( |     os.system( | ||||||
|         'cp rustdesk.desktop tmpdeb/usr/share/applications/rustdesk.desktop') |         'cp ../rustdesk.desktop tmpdeb/usr/share/applications/rustdesk.desktop') | ||||||
|  |     os.system( | ||||||
|  |         'cp ../com.rustdesk.RustDesk.policy tmpdeb/usr/share/polkit-1/actions/') | ||||||
|  |     os.system("echo \"#!/bin/sh\" >> tmpdeb/usr/share/rustdesk/files/polkit && chmod a+x tmpdeb/usr/share/rustdesk/files/polkit") | ||||||
|     os.system('mkdir -p tmpdeb/DEBIAN') |     os.system('mkdir -p tmpdeb/DEBIAN') | ||||||
|     os.system('cp -a ../DEBIAN/* tmpdeb/DEBIAN/') |     os.system('cp -a ../DEBIAN/* tmpdeb/DEBIAN/') | ||||||
|     md5_file('usr/share/rustdesk/files/systemd/rustdesk.service') |     md5_file('usr/share/rustdesk/files/systemd/rustdesk.service') | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								com.rustdesk.RustDesk.policy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								com.rustdesk.RustDesk.policy
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <!DOCTYPE policyconfig PUBLIC | ||||||
|  |  "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" | ||||||
|  |  "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd"> | ||||||
|  | <policyconfig> | ||||||
|  |   <vendor>RustDesk</vendor> | ||||||
|  |   <vendor_url>https://rustdesk.com/</vendor_url> | ||||||
|  |   <icon_name>rustdesk</icon_name> | ||||||
|  |   <action id="com.rustdesk.RustDesk.options"> | ||||||
|  |     <description>Change RustDesk options</description> | ||||||
|  |     <message>Authentication is required to change RustDesk options</message> | ||||||
|  |     <message xml:lang="zh_CN">要更改RustDesk选项, 需要您先通过身份验证</message> | ||||||
|  |     <message xml:lang="zh_TW">要變更RustDesk選項, 需要您先通過身份驗證</message> | ||||||
|  |     <annotate key="org.freedesktop.policykit.exec.path">/usr/share/rustdesk/files/polkit</annotate> | ||||||
|  |     <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> | ||||||
|  |     <defaults> | ||||||
|  |       <allow_any>auth_admin</allow_any> | ||||||
|  |       <allow_inactive>auth_admin</allow_inactive> | ||||||
|  |       <allow_active>auth_admin</allow_active> | ||||||
|  |     </defaults> | ||||||
|  |   </action> | ||||||
|  | </policyconfig> | ||||||
| @ -638,7 +638,13 @@ pub fn quit_gui() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn check_super_user_permission() -> ResultType<bool> { | pub fn check_super_user_permission() -> ResultType<bool> { | ||||||
|     // TODO: replace echo with a rustdesk's program, which is location-fixed and non-gui.
 |     let file = "/usr/share/rustdesk/files/polkit"; | ||||||
|     let status = std::process::Command::new("pkexec").arg("echo").status()?; |     let arg; | ||||||
|  |     if std::path::Path::new(file).is_file() { | ||||||
|  |         arg = file; | ||||||
|  |     } else { | ||||||
|  |         arg = "echo"; | ||||||
|  |     } | ||||||
|  |     let status = std::process::Command::new("pkexec").arg(arg).status()?; | ||||||
|     Ok(status.success() && status.code() == Some(0)) |     Ok(status.success() && status.code() == Some(0)) | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user