Selaa lähdekoodia

Log successful setuid.

Set a SUPERVISOR_ENABLED envvar (for Ian).
Chris McDonough 19 vuotta sitten
vanhempi
commit
a5cd52cdfc
3 muutettua tiedostoa jossa 7 lisäystä ja 19 poistoa
  1. 2 17
      TODO.txt
  2. 1 1
      sample.conf
  3. 4 1
      src/supervisor/supervisord.py

+ 2 - 17
TODO.txt

@@ -12,12 +12,12 @@
 
    - Error conditions when X-bit not set on command file.
 
+   - SUPERVISOR_ENABLED envvar.
+
 - Unit test the http_client package.
 
 - Unit tests for meld classes and ui server.
 
-- Create named process log files after we setuid.
-
 - Usage messages when we invoke supervisord/supervisorctl -h
 
 - Tail main log.
@@ -40,21 +40,6 @@
 
 - stop logging all RPC requests in info mode when we ship
 
-- Collector issue 76:
-
-  Adding -c to the shell script also drove me nuts for a while, since
-  I got an error about two -c's. Maybe instead it could set an
-  environmental variable in the shell script and read that for the
-  default?
-
-- Collector issue 84:
-
-  I'd like to make Paste detect when it is running under Supervisor,
-  mostly so it would know that it could safely die to be
-  restarted. Otherwise it starts its own monitoring process to handle
-  restarts.  I think always setting an environmental variable (e.g.,
-  "SUPERVISOR_ENABLED") would be sufficient.
-
  - Collector issue 152:
 
    I'd like supervisor to look after a number of postgres instances

+ 1 - 1
sample.conf

@@ -20,7 +20,7 @@ backofflimit=3              ; (child process restart seconds;default 3)
 ;http_username=user        ; (default is no username (open system))
 ;http_password=123         ; (default is no password (open system))
 ;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
-;user=nobody                 ; (default is current user, required if root)
+;user=chrism                 ; (default is current user, required if root)
 ;directory=/tmp              ; (default is not to cd during start)
 
 [supervisorctl]

+ 4 - 1
src/supervisor/supervisord.py

@@ -440,6 +440,7 @@ class Supervisor:
     stopping = False # set after we detect that we are handling a stop request
 
     def main(self, args=None, test=False, first=False):
+        os.environ['SUPERVISOR_ENABLED'] = '1'
         self.options = ServerOptions()
         self.options.realize(args)
         self.cleanup_fds()
@@ -582,7 +583,9 @@ class Supervisor:
                                    'user without a "user" setting in the '
                                    'configuration file')
             return
-        return dropPrivileges(self.options.uid)
+        msg = dropPrivileges(self.options.uid)
+        if msg is None:
+            return 'Set uid to user %s' % self.options.uid
 
     def set_rlimits(self):
         limits = []