Changeset c7304b2 for skype/skyped.py


Ignore:
Timestamp:
2008-01-12T20:07:10Z (16 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
55664fc
Parents:
e65ceaa
Message:

auth via ssl

  • move the config file to sysconfdir/skyped/skyped.conf as there will other config files there, too
  • autogenerate the ssl paths in skyped.conf.dist
  • skype plugin: connect via ssl
  • skyped: listen via ssl
File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skyped.py

    re65ceaa rc7304b2  
    3737import sha
    3838from ConfigParser import ConfigParser
     39from OpenSSL import SSL
    3940
    4041__version__ = "0.1.1"
     
    6768
    6869def server(host, port):
    69         sock = socket.socket()
     70        global options
     71
     72        ctx = SSL.Context(SSL.TLSv1_METHOD)
     73        ctx.use_privatekey_file(options.config.sslkey)
     74        ctx.use_certificate_file(options.config.sslcert)
     75        sock = SSL.Connection(ctx, socket.socket())
    7076        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    7177        sock.bind((host, port))
     
    7682        global options
    7783        options.conn, addr = sock.accept()
    78         lines = options.conn.recv(512).split('\n')
    7984        ret = 0
    80         nlines = []
    81         for i in lines:
    82                 if i.startswith("USERNAME") and i.split(' ')[1].strip() == options.config.username:
    83                         ret += 1
    84                 elif i.startswith("PASSWORD") and sha.sha(i.split(' ')[1].strip()).hexdigest() == options.config.password:
    85                         ret += 1
    86                 else:
    87                         nlines.append(i)
    88         del lines
     85        line = options.conn.recv(1024)
     86        if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username:
     87                ret += 1
     88        line = options.conn.recv(1024)
     89        if line.startswith("PASSWORD") and sha.sha(line.split(' ')[1].strip()).hexdigest() == options.config.password:
     90                ret += 1
    8991        if ret == 2:
    9092                dprint("Username and password OK.")
    91                 options.buf = nlines
    92                 input_handler(None, None)
     93                options.conn.send("PASSWORD OK\n")
    9394                gobject.io_add_watch(options.conn, gobject.IO_IN, input_handler)
    9495                return True
    9596        else:
    9697                dprint("Username and/or password WRONG.")
     98                options.conn.send("PASSWORD KO\n")
    9799                return False
    98100
     
    153155class Options:
    154156        def __init__(self):
    155                 self.cfgpath = "/etc/skyped.conf"
     157                self.cfgpath = "/usr/local/etc/skyped/skyped.conf"
    156158                self.daemon = True
    157159                self.debug = False
     
    217219        options.config.username = options.config.get('skyped', 'username').split('#')[0]
    218220        options.config.password = options.config.get('skyped', 'password').split('#')[0]
     221        options.config.sslkey = options.config.get('skyped', 'key').split('#')[0]
     222        options.config.sslcert = options.config.get('skyped', 'cert').split('#')[0]
    219223        dprint("Parsing config file '%s' done, username is '%s'." % (options.cfgpath, options.config.username))
    220224        if options.daemon:
Note: See TracChangeset for help on using the changeset viewer.