[Zope-Checkins] CVS: Zope - Makefile:1.3.14.2 zpasswd.py:1.17.6.1

Casey Duncan casey@zope.com
Fri, 9 May 2003 15:06:24 -0400


Update of /cvs-repository/Zope
In directory cvs.zope.org:/tmp/cvs-serv30103

Modified Files:
      Tag: Zope-2_6-branch
	Makefile zpasswd.py 
Log Message:
Refactored interface check in ZCatalog indexes view so it is
no longer broken by the new Zope3 interface logic


=== Zope/Makefile 1.3.14.1 => 1.3.14.2 ===
--- Zope/Makefile:1.3.14.1	Thu Dec 19 09:56:19 2002
+++ Zope/Makefile	Fri May  9 15:05:53 2003
@@ -1,12 +1,11 @@
-PYTHON=python2.1
-WHOA_PIGGY=wo_pcgi.py
-TESTOPTS=-a -v1
+PYTHON = python
 
 all:
-	$(PYTHON) $(WHOA_PIGGY)
+	$(PYTHON) inst/compile_all.py
 
-test:
-	$(PYTHON) utilities/testrunner.py $(TESTOPTS)
+.PHONY: pcgi
+pcgi:
+	$(PYTHON) inst/build_pcgi.py
 
-clean:
-	./stupid_clean
+install:
+	$(PYTHON) inst/make_instance.py


=== Zope/zpasswd.py 1.17 => 1.17.6.1 ===
--- Zope/zpasswd.py:1.17	Wed Aug 14 17:11:39 2002
+++ Zope/zpasswd.py	Fri May  9 15:05:53 2003
@@ -1,21 +1,93 @@
 #!/usr/bin/env python
 ##############################################################################
-#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-#
+# 
+# Zope Public License (ZPL) Version 1.0
+# -------------------------------------
+# 
+# Copyright (c) Digital Creations.  All rights reserved.
+# 
+# This license has been certified as Open Source(tm).
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+# 1. Redistributions in source code must retain the above copyright
+#    notice, this list of conditions, and the following disclaimer.
+# 
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions, and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 
+# 3. Digital Creations requests that attribution be given to Zope
+#    in any manner possible. Zope includes a "Powered by Zope"
+#    button that is installed by default. While it is not a license
+#    violation to remove this button, it is requested that the
+#    attribution remain. A significant investment has been put
+#    into Zope, and this effort will continue if the Zope community
+#    continues to grow. This is one way to assure that growth.
+# 
+# 4. All advertising materials and documentation mentioning
+#    features derived from or use of this software must display
+#    the following acknowledgement:
+# 
+#      "This product includes software developed by Digital Creations
+#      for use in the Z Object Publishing Environment
+#      (http://www.zope.org/)."
+# 
+#    In the event that the product being advertised includes an
+#    intact Zope distribution (with copyright and license included)
+#    then this clause is waived.
+# 
+# 5. Names associated with Zope or Digital Creations must not be used to
+#    endorse or promote products derived from this software without
+#    prior written permission from Digital Creations.
+# 
+# 6. Modified redistributions of any form whatsoever must retain
+#    the following acknowledgment:
+# 
+#      "This product includes software developed by Digital Creations
+#      for use in the Z Object Publishing Environment
+#      (http://www.zope.org/)."
+# 
+#    Intact (re-)distributions of any official Zope release do not
+#    require an external acknowledgement.
+# 
+# 7. Modifications are encouraged but must be packaged separately as
+#    patches to official Zope releases.  Distributions that do not
+#    clearly separate the patches from the original work must be clearly
+#    labeled as unofficial distributions.  Modifications which do not
+#    carry the name Zope may be packaged in any form, as long as they
+#    conform to all of the clauses above.
+# 
+# 
+# Disclaimer
+# 
+#   THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
+#   EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
+#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+#   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+#   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+#   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+#   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+#   SUCH DAMAGE.
+# 
+# 
+# This software consists of contributions made by Digital Creations and
+# many individuals on behalf of Digital Creations.  Specific
+# attributions are listed in the accompanying credits file.
+# 
 ##############################################################################
 """Zope user bootstrap system"""
 
 __version__='$Revision$ '[11:-2]
 
-import sys,  sha, binascii, random, getopt, getpass, os
+import sys, string, sha, binascii, whrandom, getopt, getpass, os
 
 try:
     from crypt import crypt
@@ -27,10 +99,10 @@
     salt_choices = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                     "abcdefghijklmnopqrstuvwxyz"
                     "0123456789./")
-    return random.choice(salt_choices)+random.choice(salt_choices)
+    return whrandom.choice(salt_choices)+whrandom.choice(salt_choices)
 
 def generate_passwd(password, encoding):
-    encoding=encoding.upper()
+    encoding=string.upper(encoding)
     if encoding == 'SHA':
         pw = '{SHA}' + binascii.b2a_base64(sha.new(password).digest())[:-1]
     elif encoding == 'CRYPT':
@@ -41,18 +113,19 @@
     return pw
 
 def write_generated_password(home, ac_path, username):
+    import whrandom
     pw_choices = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                   "abcdefghijklmnopqrstuvwxyz"
                   "0123456789!")
     acfile=open(ac_path, 'w')
     pw = ''
     for i in range(8):
-        pw = pw + random.choice(pw_choices)
+        pw = pw + whrandom.choice(pw_choices)
     acfile.write('%s:%s' % (username, generate_passwd(pw, 'SHA')))
     acfile.close()
     os.system('chmod 644 %s' % ac_path)
     return pw
-
+    
 def write_access(home, user='', group=''):
     ac_path=os.path.join(home, 'access')
     if not os.path.exists(ac_path):
@@ -87,6 +160,31 @@
 
         import do; do.ch(ac_path, user, group)
 
+def choose_inituser(home, user='', group=''):
+    ac_path=os.path.join(home, 'inituser')
+    if not os.path.exists(ac_path):
+        print '-'*78
+        print 'Please choose a username and password.'
+        print 'This will create the initial user with which you manage Zope.'
+        username = raw_input("Username: ")
+        if username == '':
+            return
+               
+        while 1:
+            pw = getpass.getpass("Password: ")
+            verify = getpass.getpass("Verify password: ")
+            if verify == pw:
+                break
+            else:
+                pw = verify = ''
+                print "Password mismatch, please try again..."
+        acfile=open(ac_path, 'w')
+        acfile.write('%s:%s' % (username, generate_passwd(pw, 'SHA')))
+        acfile.close()
+        os.system('chmod 644 %s' % ac_path)
+
+        import do; do.ch(ac_path, user, group)
+
 
 def main(argv):
     short_options = ':u:p:e:d:'
@@ -111,17 +209,17 @@
     -d / --domains=
     Set the domain names that the user user can log in from.  Defaults to
     any. OPTIONAL.
-
+    
     Filename is required and should be the name of the file to store the
     information in (usually "inituser" or "access").
-
+    
 Copyright (C) 1999, 2000 Digital Creations, Inc.
 """ % argv[0]
 
     try:
         if len(argv) < 2:
             raise "CommandLineError"
-
+        
         optlist, args = getopt.getopt(sys.argv[1:], short_options, long_options)
 
         if len(args) != 1:
@@ -134,7 +232,7 @@
             username = ''
             encoding = 'SHA'
             domains = ''
-
+        
             for opt in optlist:
                 if (opt[0] == '-u') or (opt[0] == '--username'):
                     username = opt[1]
@@ -159,7 +257,7 @@
                 username = raw_input("Username: ")
                 if username != '':
                     break
-
+               
             while 1:
                 password = getpass.getpass("Password: ")
                 verify = getpass.getpass("Verify password: ")
@@ -173,15 +271,12 @@
                 print """
 Please choose a format from:
 
-SHA - SHA-1 hashed password (default)
+SHA - SHA-1 hashed password
 CRYPT - UNIX-style crypt password
-CLEARTEXT - no protection
+CLEARTEXT - no protection.
 """
                 encoding = raw_input("Encoding: ")
-                if encoding == '':
-                    encoding = 'SHA'
-                    break
-                if encoding.upper() in ['SHA', 'CRYPT', 'CLEARTEXT']:
+                if encoding != '':
                     break
 
             domains = raw_input("Domain restrictions: ")
@@ -190,11 +285,12 @@
             access_file.write(username + ":" +
                               generate_passwd(password, encoding) +
                               domains)
-
+            
     except "CommandLineError":
         sys.stderr.write(usage)
         sys.exit(1)
 
-
+    
 # If called from the command line
 if __name__=='__main__': main(sys.argv)
+