Changeset 1956

Show
Ignore:
Timestamp:
11/22/04 22:53:38 (19 years ago)
Author:
jalet
Message:

Added the reject_unknown directive to pykota.conf to reject user/group
creation if user or group is unknown to the system

Location:
pykota/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r1809 r1956  
    2424# 
    2525# $Log$ 
     26# Revision 1.82  2004/11/22 21:53:38  jalet 
     27# Added the reject_unknown directive to pykota.conf to reject user/group 
     28# creation if user or group is unknown to the system 
     29# 
    2630# Revision 1.81  2004/10/12 15:37:00  jalet 
    2731# Now outputs the name of the offending user if a mere mortal tries to use 
     
    290294import os 
    291295import pwd 
     296import grp 
    292297from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_ 
    293298from pykota.config import PyKotaConfigError 
     
    527532            protoentry = getattr(self.storage, "get%s" % suffix)(options["prototype"]) 
    528533             
     534        rejectunknown = self.config.getRejectUnknown()     
    529535        printeradded = 0 
    530536        printers = self.storage.getMatchingPrinters(options["printer"]) 
     
    620626                        # only remotely 
    621627                        if self.isValidName(entry.Name) : 
    622                             entry = getattr(self.storage, "add%s" % suffix)(entry) 
     628                            reject = 0 
     629                            if rejectunknown : 
     630                                if options["groups"] : 
     631                                    try : 
     632                                        grp.getgrnam(entry.Name) 
     633                                    except KeyError :     
     634                                        self.printInfo(_("Unknown group %s") % entry.Name, "error") 
     635                                        reject = 1 
     636                                else :     
     637                                    try : 
     638                                        pwd.getpwnam(entry.Name) 
     639                                    except KeyError :     
     640                                        self.printInfo(_("Unknown user %s") % entry.Name, "error") 
     641                                        reject = 1 
     642                            if not reject :         
     643                                entry = getattr(self.storage, "add%s" % suffix)(entry) 
    623644                        else :     
    624645                            if options["groups"] : 
  • pykota/trunk/conf/pykota.conf.sample

    r1931 r1956  
    216216# 'Domain2/jerome' and 'jerome' are different.  
    217217# winbind_separator: / 
     218 
     219# When creating users or groups accounts, should we reject users 
     220# or groups which are unknown from the system ? 
     221# The default if unset is NO. This means that by default, you 
     222# can create users or groups for which `getent passwd username`  
     223# or `getent group groupname` returns nothing. 
     224# 
     225# Allowed values : Yes | No 
     226# Default value : No 
     227# 
     228# reject_unknown: No 
    218229 
    219230# Do we want to hide jobs' title, filename and options for privacy 
  • pykota/trunk/NEWS

    r1952 r1956  
    2222PyKota NEWS : 
    2323 
     24    - 1.21alpha8 : 
     25     
     26        - Added the new reject_unknown directive to reject the 
     27          creation of user or groups which are unknown to the system. 
     28           
    2429    - 1.21alpha7 : 
    2530     
  • pykota/trunk/pykota/config.py

    r1916 r1956  
    2222# 
    2323# $Log$ 
     24# Revision 1.57  2004/11/22 21:53:38  jalet 
     25# Added the reject_unknown directive to pykota.conf to reject user/group 
     26# creation if user or group is unknown to the system 
     27# 
    2428# Revision 1.56  2004/11/15 15:23:07  jalet 
    2529# Strips spaces just in case 
     
    558562        return self.isTrue(self.getGlobalOption("utolower", ignore=1)) 
    559563         
     564    def getRejectUnknown(self) :           
     565        """Returns 1 if we want to reject the creation of unknown users or groups, else 0.""" 
     566        return self.isTrue(self.getGlobalOption("reject_unknown", ignore=1)) 
     567         
    560568    def getWinbindSeparator(self) :           
    561569        """Returns the winbind separator's value if it is set, else None.""" 
  • pykota/trunk/pykota/version.py

    r1952 r1956  
    2222# 
    2323 
    24 __version__ = "1.21alpha7_unofficial" 
     24__version__ = "1.21alpha8_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""