~ubuntu-branches/debian/sid/pyro/sid

« back to all changes in this revision

Viewing changes to examples/tlstest/server.py

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Goretkin
  • Date: 2011-08-21 16:04:00 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110821160400-ugc9tghmf0ycxzwp
Tags: 1:3.14-1
* New upstream release
    - /usr/bin/pyro-rns was removed by upstream
* SECURITY UPDATE: arbitrary file overwriting via symlink (Closes: #631912,
  LP: #830742)
    - store pidfile in /var/run instead of /tmp
    - Pyro/ext/daemonizer.py changed default location to /var/run
    - Pyro/ext/daemonizer.py added command-line parameter (--pidfile=...) to
      override default pidfile location
    - default location for pidfile is tunable via /etc/default/pyro-nsd
    - CVE-2011-2765 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import threading
 
2
import sys, time
 
3
import Pyro.core
 
4
try:
 
5
    import win32com.client, pythoncom
 
6
    has_com=True
 
7
except ImportError:
 
8
    has_com=False
 
9
    
 
10
class TestServer(Pyro.core.ObjBase):
 
11
    def ping(self):
 
12
        threadid=threading.currentThread().ident
 
13
        tls=self.getLocalStorage()
 
14
        output="server: ping, tls=%s, threadid=%s, TLS threadid=%s\n" % (id(tls), threadid, tls.threadid)
 
15
        sys.stdout.write(output)
 
16
        sys.stdout.flush()
 
17
        if tls.threadid!=threadid:
 
18
            sys.stdout.write("!!!!! ERROR: threadids aren't identical !!!!!\n")
 
19
            sys.stdout.flush()
 
20
    def oneway(self):
 
21
        threadid=threading.currentThread().ident
 
22
        tls=self.getLocalStorage()
 
23
        output="server: oneway, tls=%s, threadid=%s, TLS threadid=%s\n" % (id(tls), threadid, tls.threadid)
 
24
        sys.stdout.write(output)
 
25
        sys.stdout.flush()
 
26
        if tls.threadid!=threadid:
 
27
            sys.stdout.write("!!!!! ERROR: threadids aren't identical !!!!!\n")
 
28
            sys.stdout.flush()
 
29
    def comcall(self):
 
30
        if not has_com:
 
31
            print "server: no com, doing nothing"
 
32
            return
 
33
        else:
 
34
            locator=win32com.client.Dispatch("WbemScripting.SwbemLocator")
 
35
            top = locator.ConnectServer(".", r"\\.\root\cimv2")
 
36
            users = top.InstancesOf("Win32_UserAccount")
 
37
            names=[]
 
38
            for u in users:
 
39
                names.append(u.name)
 
40
            return names
 
41
 
 
42
 
 
43
def initTLS(tls):
 
44
    threadid=threading.currentThread().ident
 
45
    if has_com:
 
46
        pythoncom.CoInitialize()   # initialize COM for this thread
 
47
    sys.stdout.write("server: initTLS, tls=%s, threadid=%s\n" % (id(tls),threadid))
 
48
    sys.stdout.flush()
 
49
    tls.threadid=threadid
 
50
 
 
51
daemon=Pyro.core.Daemon()
 
52
obj=TestServer()
 
53
uri=daemon.connect(obj)
 
54
daemon.setInitTLS(initTLS)
 
55
print "URI=",uri
 
56
print "server running"
 
57
daemon.requestLoop()