[BB#115] Drop supplementary groups
Supplementary groups are inherited from the calling process. Drop all
supplementary groups if the "Group" configuration directive is set to
change to a different user. Otherwise the process may have more rights
than expected.
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit c8b8247f70)
			
			
This commit is contained in:
		
							parent
							
								
									a747617c05
								
							
						
					
					
						commit
						8963739e4b
					
				@ -203,7 +203,7 @@ AC_FUNC_REALLOC
 | 
			
		||||
AC_CHECK_FUNCS([gethostname inet_ntoa memchr memset select socket strcasecmp \
 | 
			
		||||
                strchr strdup strerror strncasecmp strpbrk strstr strtol])
 | 
			
		||||
AC_CHECK_FUNCS([isascii memcpy setrlimit ftruncate regcomp regexec])
 | 
			
		||||
AC_CHECK_FUNCS([strlcpy strlcat])
 | 
			
		||||
AC_CHECK_FUNCS([strlcpy strlcat setgroups])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
dnl Enable extra warnings
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.c
									
									
									
									
									
								
							@ -277,6 +277,16 @@ change_user (const char *program)
 | 
			
		||||
                        exit (EX_NOPERM);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_SETGROUPS
 | 
			
		||||
                /* Drop all supplementary groups, otherwise these are inherited from the calling process */
 | 
			
		||||
                if (setgroups (0, NULL) < 0) {
 | 
			
		||||
                        fprintf (stderr,
 | 
			
		||||
                                 "%s: Unable to drop supplementary groups.\n",
 | 
			
		||||
                                 program);
 | 
			
		||||
                        exit (EX_NOPERM);
 | 
			
		||||
                }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                log_message (LOG_INFO, "Now running as group \"%s\".",
 | 
			
		||||
                             config.group);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user