Add patch that detects and corrects unsafe permissions on ~/.nut-monitor left over from old installations during NUT-Monitor startup. (Closes: #777706)
This commit is contained in:
		
							parent
							
								
									241119d464
								
							
						
					
					
						commit
						1563b485dc
					
				
					 4 changed files with 90 additions and 1 deletions
				
			
		
							
								
								
									
										69
									
								
								debian/patches/0009-fix-favorites-permissions.patch
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								debian/patches/0009-fix-favorites-permissions.patch
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,69 @@
 | 
			
		|||
If a ~/.nut-monitor directory is found with insecure permissions, change them to 0700.
 | 
			
		||||
--- a/scripts/python/app/NUT-Monitor
 | 
			
		||||
+++ b/scripts/python/app/NUT-Monitor
 | 
			
		||||
@@ -29,6 +29,7 @@
 | 
			
		||||
 import sys
 | 
			
		||||
 import base64
 | 
			
		||||
 import os, os.path
 | 
			
		||||
+import stat
 | 
			
		||||
 import platform
 | 
			
		||||
 import time
 | 
			
		||||
 import threading
 | 
			
		||||
@@ -44,21 +45,23 @@
 | 
			
		||||
 
 | 
			
		||||
 class interface :
 | 
			
		||||
 
 | 
			
		||||
-    __widgets                  = {}
 | 
			
		||||
-    __callbacks                = {}
 | 
			
		||||
-    __favorites                = {}
 | 
			
		||||
-    __favorites_file           = None
 | 
			
		||||
-    __favorites_path           = ""
 | 
			
		||||
-    __fav_menu_items           = list()
 | 
			
		||||
-    __window_visible           = True
 | 
			
		||||
-    __glade_file               = None
 | 
			
		||||
-    __connected                = False
 | 
			
		||||
-    __ups_handler              = None
 | 
			
		||||
-    __ups_commands             = None
 | 
			
		||||
-    __ups_vars                 = None
 | 
			
		||||
-    __ups_rw_vars              = None
 | 
			
		||||
-    __gui_thread               = None
 | 
			
		||||
-    __current_ups              = None
 | 
			
		||||
+    DESIRED_FAVORITES_DIRECTORY_MODE = 0700
 | 
			
		||||
+
 | 
			
		||||
+    __widgets                        = {}
 | 
			
		||||
+    __callbacks                      = {}
 | 
			
		||||
+    __favorites                      = {}
 | 
			
		||||
+    __favorites_file                 = None
 | 
			
		||||
+    __favorites_path                 = ""
 | 
			
		||||
+    __fav_menu_items                 = list()
 | 
			
		||||
+    __window_visible                 = True
 | 
			
		||||
+    __glade_file                     = None
 | 
			
		||||
+    __connected                      = False
 | 
			
		||||
+    __ups_handler                    = None
 | 
			
		||||
+    __ups_commands                   = None
 | 
			
		||||
+    __ups_vars                       = None
 | 
			
		||||
+    __ups_rw_vars                    = None
 | 
			
		||||
+    __gui_thread                     = None
 | 
			
		||||
+    __current_ups                    = None
 | 
			
		||||
 
 | 
			
		||||
     def __init__( self ) :
 | 
			
		||||
 
 | 
			
		||||
@@ -528,6 +531,9 @@
 | 
			
		||||
             return
 | 
			
		||||
 
 | 
			
		||||
         try :
 | 
			
		||||
+            if ( not stat.S_IMODE( os.stat( self.__favorites_path ).st_mode ) == self.DESIRED_FAVORITES_DIRECTORY_MODE ) : # unsafe pre-1.2 directory found
 | 
			
		||||
+                os.chmod( self.__favorites_path, self.DESIRED_FAVORITES_DIRECTORY_MODE )
 | 
			
		||||
+
 | 
			
		||||
             conf = ConfigParser.ConfigParser()
 | 
			
		||||
             conf.read( self.__favorites_file )
 | 
			
		||||
             for current in conf.sections() :
 | 
			
		||||
@@ -573,7 +579,7 @@
 | 
			
		||||
         # If path does not exists, try to create it
 | 
			
		||||
         if ( not os.path.exists( self.__favorites_file ) ) :
 | 
			
		||||
             try :
 | 
			
		||||
-                os.makedirs( self.__favorites_path, mode=0700 )
 | 
			
		||||
+                os.makedirs( self.__favorites_path, mode=self.DESIRED_FAVORITES_DIRECTORY_MODE )
 | 
			
		||||
             except :
 | 
			
		||||
                 self.gui_status_message( _("Error while creating configuration folder (%s)") % sys.exc_info()[1] )
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								debian/patches/series
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								debian/patches/series
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -4,3 +4,4 @@
 | 
			
		|||
0006-ups-conf-maxretry.patch
 | 
			
		||||
0007-killpower-path.patch
 | 
			
		||||
0008-drop-w3c-icons.patch
 | 
			
		||||
0009-fix-favorites-permissions.patch
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue