mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	Move check for SUID into the caps functions.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1119 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									8d2dc9c4d1
								
							
						
					
					
						commit
						57d8a315ea
					
				
					 2 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
					@ -27,6 +27,7 @@
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_SYS_CAPABILITY_H
 | 
					#ifdef HAVE_SYS_CAPABILITY_H
 | 
				
			||||||
#include <sys/capability.h>
 | 
					#include <sys/capability.h>
 | 
				
			||||||
| 
						 | 
					@ -80,6 +81,10 @@ int pa_limit_caps(void) {
 | 
				
			||||||
    cap_t caps;
 | 
					    cap_t caps;
 | 
				
			||||||
    cap_value_t nice_cap = CAP_SYS_NICE;
 | 
					    cap_value_t nice_cap = CAP_SYS_NICE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Only drop caps when called SUID */
 | 
				
			||||||
 | 
					    if (getuid() != 0)
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    caps = cap_init();
 | 
					    caps = cap_init();
 | 
				
			||||||
    assert(caps);
 | 
					    assert(caps);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -106,6 +111,10 @@ int pa_drop_caps(void) {
 | 
				
			||||||
    cap_t caps;
 | 
					    cap_t caps;
 | 
				
			||||||
    int r = -1;
 | 
					    int r = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Only drop caps when called SUID */
 | 
				
			||||||
 | 
					    if (getuid() != 0)
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    caps = cap_init();
 | 
					    caps = cap_init();
 | 
				
			||||||
    assert(caps);
 | 
					    assert(caps);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -328,7 +328,6 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setlocale(LC_ALL, "");
 | 
					    setlocale(LC_ALL, "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (getuid() != 0)
 | 
					 | 
				
			||||||
    pa_limit_caps();
 | 
					    pa_limit_caps();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_GETUID
 | 
					#ifdef HAVE_GETUID
 | 
				
			||||||
| 
						 | 
					@ -377,7 +376,6 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
    if (conf->high_priority && conf->cmd == PA_CMD_DAEMON)
 | 
					    if (conf->high_priority && conf->cmd == PA_CMD_DAEMON)
 | 
				
			||||||
        pa_raise_priority();
 | 
					        pa_raise_priority();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (getuid() != 0)
 | 
					 | 
				
			||||||
    pa_drop_caps();
 | 
					    pa_drop_caps();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (suid_root)
 | 
					    if (suid_root)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue