Re: Securing PyDoc and CGIHTTPserver

Discussion in 'Python' started by Shane Hathaway, Jul 10, 2003.

  1. Jon Schull wrote:
    > The port number used by pydoc is currently set by the user at the
    > command line. Many people probably use the example given in the
    > python module documentation : "python -p 1234" However, if the port
    > were chosen at random and printed out, then only pydoc and the user
    > would know how to access the pydoc server.


    What about binding only to the local (loopback) interface? That way,
    the system won't even listen for external connections. It's like a
    built-in firewall.

    The change is a one-liner. The DocServer computes the hostname for the
    loopback interface but then binds to all interfaces. So change this line:

    self.address = ('', port)

    to:

    self.address = (host, port)

    Shane
     
    Shane Hathaway, Jul 10, 2003
    #1
    1. Advertising

  2. Irmen de Jong wrote:
    > Shane Hathaway wrote:
    >
    >> What about binding only to the local (loopback) interface? That way,
    >> the system won't even listen for external connections. It's like a
    >> built-in firewall.
    >>
    >> The change is a one-liner. The DocServer computes the hostname for
    >> the loopback interface but then binds to all interfaces. So change
    >> this line:
    >>
    >> self.address = ('', port)
    >>
    >> to:
    >>
    >> self.address = (host, port)
    >>

    >
    > I think Shane meant:
    >
    > self.address = ('localhost',port)


    No, actually the 'host' variable is computed on the line before it. :)
    It's either "127.0.0.1" or "localhost", depending on the platform.
    "localhost" is preferable for readability, but "127.0.0.1" is more reliable.

    Shane
     
    Shane Hathaway, Jul 11, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Hansen

    Re: Securing PyDoc and CGIHTTPserver

    Peter Hansen, Jul 10, 2003, in forum: Python
    Replies:
    7
    Views:
    454
    Peter Hansen
    Jul 15, 2003
  2. vincent delft

    CGIHTTPserver looze PYTHONPATH

    vincent delft, Jul 13, 2003, in forum: Python
    Replies:
    1
    Views:
    472
    vincent_delft
    Jul 13, 2003
  3. Michele Simionato

    Popularizing SimpleHTTPServer and CGIHTTPServer

    Michele Simionato, Feb 3, 2005, in forum: Python
    Replies:
    6
    Views:
    460
    Michael Spencer
    Feb 4, 2005
  4. Fuzzyman

    CGIHTTPServer, popen3, and windoze

    Fuzzyman, Sep 11, 2005, in forum: Python
    Replies:
    1
    Views:
    341
    Fuzzyman
    Sep 14, 2005
  5. BartlebyScrivener

    pydoc script.py vs. pydoc scriptpy

    BartlebyScrivener, Oct 20, 2007, in forum: Python
    Replies:
    1
    Views:
    687
    Stargaming
    Oct 22, 2007
Loading...

Share This Page