CVS: tmda-cgi configure,NONE,1.1 .cvsignore,1.1,1.2 ChangeLog,1.24,1.25 TODO,1.12,1.13 compile,1.17,NONE
Gre7g Luterman <[email protected]>
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tmda/tmda-cgi In directory sc8-pr-cvs1:/tmp/cvs-serv11363 Modified Files: .cvsignore ChangeLog TODO Added Files: configure Removed Files: compile Log Message: Replaced compile with new, improved configure. Makes better guesses about where TMDA is installed. A little more standard to use. --- NEW FILE --- #!/usr/bin/env python # # Copyright (C) 2002 Gre7g Luterman <[email protected]> # # This file is part of TMDA. # # TMDA 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. A copy of this license should # be included in the file COPYING. # # TMDA 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 TMDA; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # TODO: Perhaps a check should be put in for the various authentication schemes # that the arguments are valid. This is currently done at runtime within # "Authenticate.py", but it may be better to check at least some of the # values at compile-time anyway. """Configure tmda-cgi for compiling. Usage: %(Program)s [OPTIONS] Where: -b <path> --base-dir <path> Specify a path to TMDA. -c <file> --config-file <file> Specify a different configuration file other than ~/.tmda/config. -d <path> --display-dir <path> Specify a different directory for supplimental display files (icons and stylesheet). -e <seconds> --session-exp <seconds> Specify the number of seconds old a session may be before it risk get- ting "cleaned". -f <authfile> --file-auth <authfile> Specify a different authentication file than the default. - The default is either <config_directory>/tmda-cgi, ~/.tmda/tmda-cgi for the authenticating user, or /etc/tmda-cgi, whichever is found first. -h --help Print this help message and exit. -l <path> --virtual-lookup <path> Specify a stub and parameters for a virtual user lookup. - This is generally "<stub> <program> <params...>" where <stub> is the Python stub, <program> is the program that must be run to feed the stub, and <params...> are any parameters needed by <program>. Any parameter that is a ~ will be replaced by the login name. -m system-wide|single-user|no-su --mode system-wide|single-user|no-su Specify an operating mode. -n --no-su Compile a CGI to run in no-su mode. Forces option "-m no-su". -o <odds> --cleanup-odds Specify chance of cleaning up session files. -p <checkpassword> --program-auth <checkpassword> Specify checkpassword-style authentication - Must conform exactly to the checkpassword stardard http://cr.yp.to/checkpwd/interface.html - Any program that returns '0' (true) is acceptable as the command run by the checkpassword program upon successful authentication. - If "program" requires commandline switches, you must supply the command to be run upon successful authentication. If "program" does not, the default program (/usr)/bin/true is automatically appended if not specified. Examples: -p "/usr/sbin/checkpassword-pam -s id -- /bin/true" -p /home/vpopmail/bin/vchkpw (/usr/bin/true or /bin/true is automatically used) -r protocol[://host[:port]][/dn] --remote-auth protocol[://host[:port]][/dn] Host to connect to to check username and password. - Allowed protocols are: imap, imaps, apop, pop3, ldap - Host defaults to localhost - Port defaults to default port for the protocol - dn is manditory for ldap and must contain a '%%(user)s' identifying the username Examples: -r imap -r imaps://myimapserver.net -r pop3://mypopserver.net:2110 -r ldap://host.com/cn=%%(user)s,dc=host,dc=com -s <prefix> --session-prefix <prefix> Path/file prefix for session files. -t <file> --target <file> Compile as a file other than ./tmda-cgi. -v <user> --virt_user <user> Specify real login name to use when user logs in as a virtual user. If you specify no options, then the program will run in an interactive mode, provide defaults for all values, and remember the new values you give it as future defaults in case you need to recompile later. The -m option is seldom needed. This option is for the rare cases when a user other than root needs to compile the program for use in system-wide mode. For the resulting code to run correctly, root will have to chown the resulting program. When specifying -p, ensure that the value of -T is correct for your system. The -B and -v options are used if you have virtual users on your system. If you don't support virtual users, then leave these to the default settings. The target may be specified on the command line with the -t option. You can specify the location of the supplimental display files (icons and stylesheet) with the -d option. The default location is: /display/ Use the -c option to specify a different location for your TMDA configuration file. You may use a "~" anywhere in the path to specify "the current user". For example: %(Program)s -c /var/tmda/~/config Will look for configuration files at /var/tmda/<user>/config instead of the usual ~<user>/.tmda/config. If no ~ is specified, %(Program)s will make a "best guess". """ import compileall import getopt import glob import os.path import pickle import pwd import re import string import sys def Ask(Question, Str, ValProg = None, TestStr = None): "Ask for a member from the keyboard." global OptD while 1: print "\n" + Question Temp = raw_input("(%s): " % OptD[Str]).strip() if Temp: Limit = re.search("\[(.+,.+)\]", Question) if Limit and not (Temp in Limit.group(1).split(", ")): continue OptD[Str] = Temp if ValProg: Filename = TestStr % OptD[Str].split()[0] if not ValProg(Filename): print "Warning! Cannot locate: %s" % Filename print "Use this value anyhow? [Yes, No]" Temp = raw_input("(No):").strip().lower() if not Temp or (Temp[0] != "y"): continue break def Interactive(): "Get options interactively." global OptD Ask("Where is the Python interpreter? (version 2.1+)", "Python", os.path.isfile, "%s") Ask("""When I compile the binary executable, where should I save it? Enter the full path AND filename. Generally, you will use the path to your webserver's cgi-bin directory, but it can be stored elsewhere if you have your webserver configured to run CGI's in other directories.""", "Target") Ask("""Where did you install TMDA? For source installs, this is the directory where you unzipped the archive. You may enter a relative path (relative to the CWD) if you like. If you installed TMDA from an RPM, try: "/usr/lib/python2.2/site-packages". If you installed TMDA from a FreeBSD port, try: "/usr/local/lib/python2.2/site-packages""", "Base", os.path.isdir, "%s/TMDA") Ask("""Would you like to override the default config file location? If so, enter a "formula" to specify where to look for the config file. This formula is just a path, but it can include the character "~". This character will be replaced by the user's name during execution. To use the default config file location, enter "None".""", "Config") Ask("""How should I authentication user logins? [file, program, remote, default] "file" lets you specify a password file. "program" lets you specify the path to a program such as checkpassword "remote" lets you specify a protocol such as imap or pop3 "default" is similar to file, except it looks for password files in the default locations.""", "AuthType") if OptD["AuthType"] == "file": Ask("Where is the password file?", "AuthFile", os.path.isfile, "%s") OptD["AuthArg"] = OptD["AuthFile"] elif OptD["AuthType"] == "program": Ask("""What is the authentication command? (full path and args) * For more details, see "config --help" option -p *""", "AuthProg", os.path.isfile, "%s") OptD["AuthArg"] = OptD["AuthProg"] elif OptD["AuthType"] == "remote": Ask("What is the authentication URI? (protocol://host.domain.com[:port][/dn])", "AuthURI") OptD["AuthArg"] = OptD["AuthURI"] elif OptD["AuthType"] == "default": OptD["AuthArg"] = "None" Ask("""What is the relative or absolute web path from CGI to display directory? This is discussed in the documentation at: http://tmda.sourceforge.net/tmda-cgi/compile.html#Display""", "DispDir") Ask("What mode should the CGI run in? [system-wide, single-user, no-su]", "Mode") Ask("""Which virtual user stub and parameters should I use for locating virtual users? If your system does not have any virtual users, enter "None".""", "VLookup") if (OptD["Mode"] == "system-wide") and (OptD["VLookup"] != "None"): Ask("What real user name should I use when a virtual user logs in?", "VUser") Ask("""Where should I save temporary session files? Please enter a path and file prefix.""", "SessionPrefix") Ask("""How long (in seconds) may a temporary session file be allowed to sit before it risks being cleaned up?""", "SessionExp") Ask("What are the odds of cleanup I should use? (0.01 = 1%)", "SessionOdds") print Program = sys.argv[0] # Keep options in one handy dictionary OptD = \ { "Python": sys.executable, "Target": "/usr/local/apache/cgi-bin/tmda.cgi", "Base": "../tmda/", "Path": os.path.abspath(os.path.split(sys.argv[0])[0]) + "/", "DispDir": "/display/", "AuthType": "remote", "AuthFile": "None", "AuthProg": "/usr/sbin/checkpassword", "AuthURI": "pop3://localhost", "AuthArg": "None", "VUser": "vpopmail", "VLookup": "vpopmail1 /home/vpopmail/bin/vuserinfo ~", "SessionPrefix": "/tmp/TMDASession.", "SessionExp": "300", "SessionOdds": "0.01", "Perm": "6711" } if os.geteuid(): OptD["Mode"] = "single-user" else: OptD["Mode"] = "system-wide" if os.environ.has_key("TMDARC"): OptD["Config"] = os.environ["TMDARC"] else: OptD["Config"] = "None" if not os.path.isdir("../tmda"): Dirs = glob.glob("../tmda-[0-9]*") if Dirs: OptD["Base"] = Dirs[0] elif os.path.isdir("/usr/lib/python2.2/site-packages/TMDA"): OptD["Base"] = "/usr/lib/python2.2/site-packages/" elif os.path.isdir("/usr/local/lib/python2.2/site-packages/TMDA"): OptD["Base"] = "/usr/local/lib/python2.2/site-packages/" def Usage(Code, Msg=""): "Show usage information and possibly an error message." print __doc__ % globals() if Msg: print Msg sys.exit(Code) try: Opts, Args = getopt.getopt(sys.argv[1:], "c:d:e:f:l:m:nho:p:r:s:t:", ["base-dir=", "config-file=", "display-dir=", "session-exp", "file-auth=", "help", "mode=", "no-su", "cleanup-odds", "program-auth=", "remote-auth=", "session-prefix", "target=", "virtual-lookup="]) except getopt.error, Msg: Usage(1, Msg) # Handle any options passed in for Opt, Arg in Opts: if Opt in ("-h", "--help"): Usage(0) elif Opt in ("-b", "--base-dir"): OptD["Base"] = Arg elif Opt in ("-c", "--config-file"): OptD["Config"] = Arg elif Opt in ("-d", "--display-dir"): OptD["DispDir"] = Arg elif Opt in ("-e", "--session-exp"): OptD["SessionExp"] = Arg elif Opt in ("-f", "--file-auth"): OptD["AuthType"] = "file" OptD["AuthFile"] = Arg OptD["AuthArg"] = Arg elif Opt in ("-l", "--virtual-lookup"): OptD["VLookup"] = Arg elif Opt in ("-o", "--cleanup-odds"): OptD["SessionOdds"] = Arg elif Opt in ("-p", "--program-auth"): OptD["AuthType"] = "program" OptD["AuthProg"] = Arg OptD["AuthArg"] = Arg elif Opt in ("-r", "--remote-auth"): OptD["AuthType"] = "remote" OptD["AuthURI"] = Arg OptD["AuthArg"] = Arg elif Opt in ("-s", "--session-prefix"): OptD["SessionPrefix"] = Arg elif Opt in ("-t", "--target"): OptD["Target"] = Arg elif Opt in ("-m", "--mode"): if not Arg in ("system-wide", "single-user", "no-su"): Usage(1, "Valid modes are system-wide, single-user, and no-su") OptD["Mode"] = Arg elif Opt in ("-n", "--no-su"): OptD["Mode"] = "no-su" # No options means interactive mode if not len(Opts): # Try to load options from last interactive run try: F = open("configure.ini") OptD.update(pickle.load(F)) F.close() except IOError: pass Break = 0 try: Interactive() except KeyboardInterrupt: Break = 1 print "\nSaving settings. Delete configure.ini to reset back to defaults." try: F = open("configure.ini", "w") pickle.dump(OptD, F) F.close() except IOError: pass if Break: sys.exit() # Check that we're running in Python version 2.1 or higher if sys.version.split()[0] < '2.1': print """Compile terminated. tmda-cgi requires Python version 2.1 or higher. Either install the latest version of Python or specify the appropriate Python interpreter when you issue the compile command. Instead of typing: $ ./%(Program)s <options> Type: $ /usr/bin/python2 %(Program)s <options> (Assuming that your Python 2.1+ can be found at /usr/bin/python2.) The compiler will save the correct version of the Python interpreter and use it when tmda-cgi is run.""" % globals() sys.exit() # Check for a compatible version of TMDA sys.path.insert(0, OptD["Base"]) try: import Version Version.Test() except ImportError, ErrStr: print ErrStr sys.exit() if OptD["DispDir"][-1] != "/": OptD["DispDir"] += "/" if OptD["Mode"] == "no-su": OptD["Perm"] = "711" # Create tmda-cgi.h F = open("tmda-cgi.h", "w") F.write(""" #define PYTHON "%(Python)s" #define INSTALL "%(Path)s" #define MODE "TMDA_CGI_MODE=%(Mode)s" #define DISP_DIR "TMDA_CGI_DISP_DIR=%(DispDir)s" #define BASE_DIR "TMDA_BASE_DIR=%(Base)s" #define VUSER "TMDA_VUSER=%(VUser)s" #define SESS_PRE "TMDA_SESSION_PREFIX=%(SessionPrefix)s" #define SESS_EXP "TMDA_SESSION_EXP=%(SessionExp)s" #define SESS_ODDS "TMDA_SESSION_ODDS=%(SessionOdds)s" """ % OptD) if OptD["VLookup"] != "None": F.write('#define VLOOKUP "TMDA_VLOOKUP=%(VLookup)s"\n' % OptD) if OptD["Config"] != "None": if OptD["Config"].find("~") >= 0: OptD["Config"] = \ string.replace(OptD["Config"], "/%s/" % os.environ["USER"], "/~/") print """NOTE: tmda-cgi will look for config files at: %s Where <user> will be replaced by the user's login name. """ % string.replace(OptD["Config"], "/~/", "/<user>/") F.write('#define TMDARC "TMDARC=%(Config)s"\n' % OptD) if OptD["AuthArg"] != "None": F.write("""#define AUTH_TYPE "TMDA_AUTH_TYPE=%(AuthType)s" #define AUTH_ARG "TMDA_AUTH_ARG=%(AuthArg)s" """ % OptD) F.close() # Create Makefile F = open("Makefile", "w") F.write("""%(Target)s: tmda-cgi.h \tcc -I . %(Path)stmda-cgi.c -o tmda.cgi install: \tcp -f tmda.cgi %(Target)s \tchmod %(Perm)s %(Target)s """ % OptD) Index: .cvsignore =================================================================== RCS file: /cvsroot/tmda/tmda-cgi/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- .cvsignore 19 Apr 2003 14:29:03 -0000 1.1 +++ .cvsignore 4 May 2003 23:06:41 -0000 1.2 @@ -1 +1,4 @@ -compile.ini +configure.ini +Makefile +tmda-cgi.h +tmda.cgi Index: ChangeLog =================================================================== RCS file: /cvsroot/tmda/tmda-cgi/ChangeLog,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- ChangeLog 4 May 2003 03:26:48 -0000 1.24 +++ ChangeLog 4 May 2003 23:06:41 -0000 1.25 @@ -1,3 +1,8 @@ +2003-05-04 Gre7g Luterman <[email protected]> + + * Replaced compile with new, improved configure. Makes better guesses + about where TMDA is installed. A little more standard to use. + 2003-05-03 Gre7g Luterman <[email protected]> * Added override.py for overriding user variables. See docs. Index: TODO =================================================================== RCS file: /cvsroot/tmda/tmda-cgi/TODO,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- TODO 4 May 2003 20:26:25 -0000 1.12 +++ TODO 4 May 2003 23:06:41 -0000 1.13 @@ -1,8 +1,6 @@ Things left to do: ================== - * configure -- switch from compile to configure/make/make install - * FAQ -- should this be made a CGI? Add help on adding whitelist & blacklist options. --- compile DELETED --- _______________________________________ tmda-cvs mailing list http://tmda.net/lists/listinfo/tmda-cvs