mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	terminate-psql-sessions: Fix shell and SQL quoting.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							c0792808e2
						
					
				
				
					commit
					981f09d950
				
			@@ -11,10 +11,11 @@ cd /
 | 
			
		||||
username=$1
 | 
			
		||||
 | 
			
		||||
shift
 | 
			
		||||
tables=$(echo "'$*'" | sed "s/ /','/g")
 | 
			
		||||
tables="$(printf "'%s'," "${@//\'/\'\'}")"
 | 
			
		||||
tables="${tables%,}"
 | 
			
		||||
 | 
			
		||||
if [ "$EUID" -eq 0 ]; then
 | 
			
		||||
    sudo -u "$DEFAULT_USER" sh -c "psql postgres '$DEFAULT_USER'" <<EOF
 | 
			
		||||
    sudo -u "$DEFAULT_USER" psql postgres "$DEFAULT_USER" <<EOF
 | 
			
		||||
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname IN ($tables);
 | 
			
		||||
EOF
 | 
			
		||||
else
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user