xkb: check permissions on XKM_OUTPUT_DIR
Checking just for root is insufficient since that does not guarantee write/read permissions in XKM_OUTPUT_DIR (for example with sandbox). Check if we can write a file, as well as read it later. Otherwise, invoke the fallback to /tmp Signed-off-by: Nirbheek Chauhan <nirbheek@gentoo.org> Signed-off-by: Rémi Cardona <remi@gentoo.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
		
							parent
							
								
									622fc98fd0
								
							
						
					
					
						commit
						9bc7cbf9c0
					
				| 
						 | 
					@ -158,10 +158,9 @@ OutputDirectory(
 | 
				
			||||||
    size_t size)
 | 
					    size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#ifndef WIN32
 | 
					#ifndef WIN32
 | 
				
			||||||
    if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size))
 | 
					    /* Can we write an xkm and then open it too? */
 | 
				
			||||||
 | 
					    if (access(XKM_OUTPUT_DIR, W_OK | X_OK) == 0 && (strlen(XKM_OUTPUT_DIR) < size))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
	/* if server running as root it *may* be able to write */
 | 
					 | 
				
			||||||
	/* FIXME: check whether directory is writable at all */
 | 
					 | 
				
			||||||
	(void) strcpy (outdir, XKM_OUTPUT_DIR);
 | 
						(void) strcpy (outdir, XKM_OUTPUT_DIR);
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue