mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-10 17:31:23 +00:00
merge of 'd51bb1b592f986d2e34036c3dad0c70f43f0150a'
and 'da71a89c98fc467cc01710a03c0654176bc8b0fe' Monotone-Parent: d51bb1b592f986d2e34036c3dad0c70f43f0150a Monotone-Parent: da71a89c98fc467cc01710a03c0654176bc8b0fe Monotone-Revision: 19d6588c4dfb7220f7b5d02e619c02259029cabb Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2011-06-29T17:43:38 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from config import hostname, port, username, password
|
||||
import sys, getopt
|
||||
import webdavlib
|
||||
import urllib
|
||||
import urllib2
|
||||
@@ -14,10 +15,9 @@ def getAuthCookie(hostname, port, username, password) :
|
||||
urllib2.install_opener(opener)
|
||||
|
||||
creds = urllib.urlencode([("userName",username), ("password", password)])
|
||||
req = urllib2.Request("http://%s/SOGo/connect" % hostname, creds)
|
||||
req = urllib2.Request("http://%s:%s/SOGo/connect" % (hostname, port), creds)
|
||||
|
||||
fd = urllib2.urlopen(req)
|
||||
#print fd.info()
|
||||
|
||||
for cookie in cjar :
|
||||
if cookie.name == "0xHIGHFLYxSOGo":
|
||||
@@ -25,5 +25,32 @@ def getAuthCookie(hostname, port, username, password) :
|
||||
break
|
||||
|
||||
return "0xHIGHFLYxSOGo="+authinfo
|
||||
|
||||
def usage() :
|
||||
msg ="""Usage:
|
||||
%s [-h] [-H | --host=hostname] [-p|--passwd=password] \
|
||||
[-P|--port=port] [-u|--user=username]\n""" % sys.argv[0]
|
||||
|
||||
sys.stderr.write(msg);
|
||||
|
||||
if __name__ == "__main__" :
|
||||
getAuthCookie()
|
||||
try:
|
||||
opts, args = getopt.getopt (sys.argv[1:], "hH:p:P:u:", \
|
||||
("host=", "passwd=", "port=", "user="));
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
exit(1)
|
||||
for o, v in opts :
|
||||
if o == "-h" :
|
||||
usage()
|
||||
exit(1)
|
||||
elif o == "-H" or o == "--host" :
|
||||
hostname = v
|
||||
elif o == "-p" or o == "--passwd" :
|
||||
password = v
|
||||
elif o == "-P" or o == "--port" :
|
||||
port = v
|
||||
elif o == "-u" or o == "--user" :
|
||||
username = v
|
||||
|
||||
print getAuthCookie(hostname, port, username, password)
|
||||
|
||||
Reference in New Issue
Block a user