소스 검색

- When supervisord starts up as root, if the ``-c`` flag was not provided, a
warning is now emitted to the console. Rationale: supervisord looks in the
current working directory for a ``supervisord.conf`` file; someone might
trick the root user into starting supervisord while cd'ed into a directory
that has a rogue ``supervisord.conf``.

- A warning was added to the documentation about the security implications of
starting supervisord without the ``-c`` flag.

Chris McDonough 13 년 전
부모
커밋
16eb90929d
3개의 변경된 파일32개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      CHANGES.txt
  2. 11 0
      docs/running.rst
  3. 12 0
      supervisor/options.py

+ 9 - 0
CHANGES.txt

@@ -1,6 +1,15 @@
 Next release
 Next release
 ------------
 ------------
 
 
+- When supervisord starts up as root, if the ``-c`` flag was not provided, a
+  warning is now emitted to the console.  Rationale: supervisord looks in the
+  current working directory for a ``supervisord.conf`` file; someone might
+  trick the root user into starting supervisord while cd'ed into a directory
+  that has a rogue ``supervisord.conf``.
+
+- A warning was added to the documentation about the security implications of
+  starting supervisord without the ``-c`` flag.
+
 - Add a boolean program option ``stopasgroup``, defaulting to false.
 - Add a boolean program option ``stopasgroup``, defaulting to false.
   When true, the flag causes supervisor to send the stop signal to the
   When true, the flag causes supervisor to send the stop signal to the
   whole process group.  This is useful for programs, such as Flask in debug
   whole process group.  This is useful for programs, such as Flask in debug

+ 11 - 0
docs/running.rst

@@ -48,6 +48,17 @@ You may start the :command:`supervisord` executable in the foreground
 by passing the ``-n`` flag on its command line.  This is useful to
 by passing the ``-n`` flag on its command line.  This is useful to
 debug startup problems.
 debug startup problems.
 
 
+.. warning::
+
+   When :program:`supervisord` starts up, it will search for its
+   configuration file in default locations *including the current working
+   directory*.  If you are security-conscious you will probably want to
+   specify a "-c" argument after the :program:`supervisord` command
+   specifying an absolute path to a configuration file to ensure that someone
+   doesn't trick you into running supervisor from within a directory that
+   contains a rogue ``supervisord.conf`` file.  A warning is emitted when
+   supervisor is started as root without this ``-c`` argument.
+
 To change the set of programs controlled by :program:`supervisord`,
 To change the set of programs controlled by :program:`supervisord`,
 edit the :file:`supervisord.conf` file and ``kill -HUP`` or otherwise
 edit the :file:`supervisord.conf` file and ``kill -HUP`` or otherwise
 restart the :program:`supervisord` process.  This file has several
 restart the :program:`supervisord` process.  This file has several

+ 12 - 0
supervisor/options.py

@@ -16,6 +16,7 @@ import pkg_resources
 import select
 import select
 import glob
 import glob
 import platform
 import platform
+import warnings
 
 
 from fcntl import fcntl
 from fcntl import fcntl
 from fcntl import F_SETFL, F_GETFL
 from fcntl import F_SETFL, F_GETFL
@@ -64,6 +65,7 @@ class Options:
     stderr = sys.stderr
     stderr = sys.stderr
     stdout = sys.stdout
     stdout = sys.stdout
     exit = sys.exit
     exit = sys.exit
+    warnings = warnings
 
 
     uid = gid = None
     uid = gid = None
 
 
@@ -279,6 +281,16 @@ class Options:
                     self._set(name, value, 1)
                     self._set(name, value, 1)
 
 
         if self.configfile is None:
         if self.configfile is None:
+            if os.getuid() == 0: # pragma: no cover
+                self.warnings.warn(
+                    'Supervisord is running as root and it is searching '
+                    'for its configuration file in default locations '
+                    '(including its current working directory); you '
+                    'probably want to specify a "-c" argument specifying an '
+                    'absolute path to a configuration file for improved '
+                    'security.'
+                    )
+
             self.configfile = self.default_configfile()
             self.configfile = self.default_configfile()
 
 
         self.process_config_file()
         self.process_config_file()