File: mm_ckpasswd

package info (click to toggle)
inn2 2.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,720 kB
  • ctags: 8,983
  • sloc: ansic: 92,499; sh: 13,509; perl: 12,921; makefile: 2,985; yacc: 842; python: 342; lex: 255
file content (83 lines) | stat: -rwxr-xr-x 2,260 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
# P@draigBrady.com
#
# This is a ckpasswd equivalent that verifies user passwords against the
# passwords stored in a Mailman list configuration file.  It allows users
# to access newsgroups with the same password as they use to access their
# Mailman configuration.
#
# To use this program, it needs to run as the Mailman user, and therefore
# may have to be run from a wrapper.  Other than that, use it like ckpasswd
# in a readers.conf file as an auth parameter, passing it the configuration
# file for the list as its only parameter.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


"""Reads username and password from stdin,
and database to use as first parameter.
and is meant to be used like ckpasswd is.
returns:
  0 success
  1 bad username &/or password
  2 other errors"""

import sys
import marshal
import string
import os
os.setgid(41)
try:
    filename = sys.argv[1]
except IndexError:
    sys.stderr.write("Usage: " + sys.argv[0] + " /path/to/config.db\n")
    sys.exit(2)

fp = open(filename)
d = marshal.load(fp)
passwords=d['passwords']
fp.close()

username=""
password=""

while 1:
    line=sys.stdin.readline()
    if line == '':
        break
    try:
        name, value = map(string.strip,line.split(':'))
        if name == "ClientAuthname":
            username=value
        if name == "ClientPassword":
            password=value
    except:
        pass

if not username or not password:
    sys.exit(2)

auth=0
try:
    if passwords[username] == password:
        auth=1
except:
    pass

if auth==1:
    print "User:%s" % username
    sys.exit(0)
else:
    sys.exit(1)