]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Switch the user name on startup.
authorCameron Dale <camrdale@gmail.com>
Wed, 16 Apr 2008 19:50:14 +0000 (12:50 -0700)
committerCameron Dale <camrdale@gmail.com>
Wed, 16 Apr 2008 19:50:14 +0000 (12:50 -0700)
apt-p2p.conf
apt-p2p.py
apt_p2p/apt_p2p_conf.py
debian/apt-p2p.conf.sgml
debian/init.d
debian/postinst
debian/postrm
test.py

index eb5d0ca023232f11c933290b3339ddcdd4d55b65..65289351f5174dc5074b9ceabc0c0671ec31c598 100644 (file)
@@ -51,6 +51,9 @@ UNLOAD_PACKAGES_CACHE = 5m
 # This should be a time slightly less than the DHT's KEY_EXPIRE value.
 KEY_REFRESH = 57m
 
 # This should be a time slightly less than the DHT's KEY_EXPIRE value.
 KEY_REFRESH = 57m
 
+# The user name to try and run as (leave blank to run as current user)
+USERNAME = apt-p2p
+
 # Which DHT implementation to use.
 # It must be possible to do "from <DHT>.DHT import DHT" to get a class that
 # implements the IDHT interface. There should also be a similarly named
 # Which DHT implementation to use.
 # It must be possible to do "from <DHT>.DHT import DHT" to get a class that
 # implements the IDHT interface. There should also be a similarly named
@@ -70,6 +73,7 @@ DHT-ONLY = no
 
 # bootstrap nodes to contact to join the DHT
 BOOTSTRAP = www.camrdale.org:9977
 
 # bootstrap nodes to contact to join the DHT
 BOOTSTRAP = www.camrdale.org:9977
+            www.camrdale.org:9976
             steveholt.hopto.org:9976
 
 # whether this node is a bootstrap node
             steveholt.hopto.org:9976
 
 # whether this node is a bootstrap node
index c3d48ef4cb2c98841dc5a7c6fc7636ebf2afd981..adbc7bdd72e679c67d3140a756760a71b102217c 100644 (file)
@@ -53,9 +53,9 @@ if __name__ == '__main__':
 log.msg("Loading config files: '%s'" % "', '".join(DEFAULT_CONFIG_FILES + [config_file]))
 config_read = config.read(DEFAULT_CONFIG_FILES + [config_file])
 log.msg("Successfully loaded config files: '%s'" % "', '".join(config_read))
 log.msg("Loading config files: '%s'" % "', '".join(DEFAULT_CONFIG_FILES + [config_file]))
 config_read = config.read(DEFAULT_CONFIG_FILES + [config_file])
 log.msg("Successfully loaded config files: '%s'" % "', '".join(config_read))
-if config.has_option('DEFAULT', 'username') and config.get('DEFAULT', 'username'):
-    uid,gid = pwd.getpwnam(config.get('DEFAULT', 'username'))[2:4]
-else:
+try:
+    uid,gid = pwd.getpwnam(config.get('DEFAULT', 'USERNAME'))[2:4]
+except:
     uid,gid = None,None
 
 log.msg('Starting application')
     uid,gid = None,None
 
 log.msg('Starting application')
index e4f0bf9f7733efd94e6498e9789e924b319496cb..3f17473c9dbe46ce9c9c78ccf744fc9da111faad 100644 (file)
@@ -73,6 +73,9 @@ DEFAULTS = {
     # This should be a time slightly less than the DHT's KEY_EXPIRE value.
     'KEY_REFRESH': '57m',
 
     # This should be a time slightly less than the DHT's KEY_EXPIRE value.
     'KEY_REFRESH': '57m',
 
+    # The user name to try and run as (leave blank to run as current user)
+    'USERNAME': 'apt-p2p',
+    
     # Which DHT implementation to use.
     # It must be possible to do "from <DHT>.DHT import DHT" to get a class that
     # implements the IDHT interface.
     # Which DHT implementation to use.
     # It must be possible to do "from <DHT>.DHT import DHT" to get a class that
     # implements the IDHT interface.
index f73d85b0b3dde2b18b56ea4bc26ee8d9bc139be1..cd08a40bacbb4cad5a19e2a3cb6653b4e6c5cb7e 100644 (file)
                  (Default is 57 minutes.)</para>
            </listitem>
          </varlistentry>
                  (Default is 57 minutes.)</para>
            </listitem>
          </varlistentry>
+         <varlistentry>
+           <term><option>USERNAME = <replaceable>user</replaceable></option></term>
+            <listitem>
+             <para>The <replaceable>user</replaceable> name to try and run as.
+                 Leaving this blank will try to run as current user.
+                 (Default is 'apt-p2p'.)</para>
+           </listitem>
+         </varlistentry>
          <varlistentry>
            <term><option>DHT = <replaceable>string</replaceable></option></term>
             <listitem>
          <varlistentry>
            <term><option>DHT = <replaceable>string</replaceable></option></term>
             <listitem>
index 2faf531e9de4e09a03d968337b5f4c245a2854bd..a3a374f740d1bb0b3db3c33c2375280523ea4876 100755 (executable)
@@ -24,7 +24,7 @@ pidfile=$rundir/apt-p2p.pid
 logfile=/var/log/apt-p2p.log
 application=/usr/sbin/apt-p2p
 twistd=/usr/bin/twistd
 logfile=/var/log/apt-p2p.log
 application=/usr/sbin/apt-p2p
 twistd=/usr/bin/twistd
-user=aptp2p
+user=apt-p2p
 group=nogroup
 
 [ -r /etc/default/apt-p2p ] && . /etc/default/apt-p2p
 group=nogroup
 
 [ -r /etc/default/apt-p2p ] && . /etc/default/apt-p2p
index eb87fd291545b97e6c2cffbaf58a73c452f98869..24147f26f0839f87f74aa23642a9b5ec002c2033 100644 (file)
@@ -25,17 +25,17 @@ set -e
 
 case "$1" in
     configure)
 
 case "$1" in
     configure)
-               if ! getent passwd aptp2p >/dev/null; then
+               if ! getent passwd apt-p2p >/dev/null; then
                        adduser --quiet --system --no-create-home \
                                        --home /var/cache/apt-p2p --disabled-password \
                                        --disabled-login --shell /bin/false --ingroup nogroup \
                        adduser --quiet --system --no-create-home \
                                        --home /var/cache/apt-p2p --disabled-password \
                                        --disabled-login --shell /bin/false --ingroup nogroup \
-                                       aptp2p
+                                       apt-p2p
                fi
                
                touch /var/log/apt-p2p.log
                fi
                
                touch /var/log/apt-p2p.log
-               chown aptp2p:adm /var/log/apt-p2p.log
+               chown apt-p2p:adm /var/log/apt-p2p.log
                mkdir -p /var/cache/apt-p2p
                mkdir -p /var/cache/apt-p2p
-               chown -R aptp2p:adm /var/cache/apt-p2p
+               chown -R apt-p2p:adm /var/cache/apt-p2p
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
index b604ced74f69d09abe3a3c155ecbb94d267909c4..fa48524ea87df8c5cdb1d3e9a543826573024c17 100644 (file)
@@ -24,8 +24,8 @@ if test "$1" = "purge"; then
   echo Purging apt-p2p cache directory
   rm -rf /var/cache/apt-p2p
 
   echo Purging apt-p2p cache directory
   rm -rf /var/cache/apt-p2p
 
-  if id aptp2p >/dev/null; then
-    deluser aptp2p
+  if id apt-p2p >/dev/null; then
+    deluser apt-p2p
   fi
 fi
 
   fi
 fi
 
diff --git a/test.py b/test.py
index ec64de2e30a2a35a268a2da22018682c5ef5939f..150b5c2dbf5d4aec085c3880f0c42c5e7f6d7c8e 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -372,6 +372,9 @@ UNLOAD_PACKAGES_CACHE = 5m
 # This should be a time slightly less than the DHT's KEY_EXPIRE value.
 KEY_REFRESH = 57m
 
 # This should be a time slightly less than the DHT's KEY_EXPIRE value.
 KEY_REFRESH = 57m
 
+# The user name to try and run as (leave blank to run as current user)
+USERNAME = 
+
 # Which DHT implementation to use.
 # It must be possile to do "from <DHT>.DHT import DHT" to get a class that
 # implements the IDHT interface.
 # Which DHT implementation to use.
 # It must be possile to do "from <DHT>.DHT import DHT" to get a class that
 # implements the IDHT interface.