Invidious is an alternative front-end to YouTube
Add checks for socket path and permissions
Caian Benedicto525dea1e2a2d
diff --git a/src/invidious/config.cr b/src/invidious/config.crindex b15cf832..6578709e 100644--- a/src/invidious/config.cr+++ b/src/invidious/config.cr@@ -145,7 +145,7 @@ class Configproperty port : Int32 = 3000# Host to bind (overridden by command line argument)property host_binding : String = "0.0.0.0"- # Path and permissions to make Invidious listen on a UNIX socket instead of a TCP port - Example: /tmp/invidious.sock,777+ # Path and permissions to make Invidious listen on a UNIX socket instead of a TCP portproperty socket_binding : SocketBindingConfig? = nil# Pool size for HTTP requests to youtube.com and ytimg.com (each domain has a separate pool of `pool_size`)property pool_size : Int32 = 100@@ -258,6 +258,25 @@ class Configendend+ # Check if the socket configuration is valid+ if config.socket_binding+ sb = config.socket_binding.not_nil!+ if sb.path.ends_with?("/") || File.directory?(sb.path)+ puts "Config: The socket path " + sb.path + " must not be a directory!"+ exit(1)+ end+ d = File.dirname(sb.path)+ if !File.directory?(d)+ puts "Config: Socket directory " + sb.path + " does not exist or is not a directory!"+ exit(1)+ end+ p = sb.permissions.to_i?(base: 8)+ if !p || p < 0 || p > 0o777+ puts "Config: Socket permissions must be an octal between 0 and 777!"+ exit(1)+ end+ end+return configendend