Index: pykota/trunk/conf/pykota.conf.sample
===================================================================
--- pykota/trunk/conf/pykota.conf.sample (revision 1931)
+++ pykota/trunk/conf/pykota.conf.sample (revision 1956)
@@ -216,4 +216,15 @@
 # 'Domain2/jerome' and 'jerome' are different. 
 # winbind_separator: /
+
+# When creating users or groups accounts, should we reject users
+# or groups which are unknown from the system ?
+# The default if unset is NO. This means that by default, you
+# can create users or groups for which `getent passwd username` 
+# or `getent group groupname` returns nothing.
+#
+# Allowed values : Yes | No
+# Default value : No
+#
+# reject_unknown: No
 
 # Do we want to hide jobs' title, filename and options for privacy
Index: pykota/trunk/bin/edpykota
===================================================================
--- pykota/trunk/bin/edpykota (revision 1809)
+++ pykota/trunk/bin/edpykota (revision 1956)
@@ -24,4 +24,8 @@
 #
 # $Log$
+# Revision 1.82  2004/11/22 21:53:38  jalet
+# Added the reject_unknown directive to pykota.conf to reject user/group
+# creation if user or group is unknown to the system
+#
 # Revision 1.81  2004/10/12 15:37:00  jalet
 # Now outputs the name of the offending user if a mere mortal tries to use
@@ -290,4 +294,5 @@
 import os
 import pwd
+import grp
 from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_
 from pykota.config import PyKotaConfigError
@@ -527,4 +532,5 @@
             protoentry = getattr(self.storage, "get%s" % suffix)(options["prototype"])
             
+        rejectunknown = self.config.getRejectUnknown()    
         printeradded = 0
         printers = self.storage.getMatchingPrinters(options["printer"])
@@ -620,5 +626,20 @@
                         # only remotely
                         if self.isValidName(entry.Name) :
-                            entry = getattr(self.storage, "add%s" % suffix)(entry)
+                            reject = 0
+                            if rejectunknown :
+                                if options["groups"] :
+                                    try :
+                                        grp.getgrnam(entry.Name)
+                                    except KeyError :    
+                                        self.printInfo(_("Unknown group %s") % entry.Name, "error")
+                                        reject = 1
+                                else :    
+                                    try :
+                                        pwd.getpwnam(entry.Name)
+                                    except KeyError :    
+                                        self.printInfo(_("Unknown user %s") % entry.Name, "error")
+                                        reject = 1
+                            if not reject :        
+                                entry = getattr(self.storage, "add%s" % suffix)(entry)
                         else :    
                             if options["groups"] :
Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 1952)
+++ pykota/trunk/NEWS (revision 1956)
@@ -22,4 +22,9 @@
 PyKota NEWS :
 
+    - 1.21alpha8 :
+    
+        - Added the new reject_unknown directive to reject the
+          creation of user or groups which are unknown to the system.
+          
     - 1.21alpha7 :
     
Index: pykota/trunk/pykota/config.py
===================================================================
--- pykota/trunk/pykota/config.py (revision 1916)
+++ pykota/trunk/pykota/config.py (revision 1956)
@@ -22,4 +22,8 @@
 #
 # $Log$
+# Revision 1.57  2004/11/22 21:53:38  jalet
+# Added the reject_unknown directive to pykota.conf to reject user/group
+# creation if user or group is unknown to the system
+#
 # Revision 1.56  2004/11/15 15:23:07  jalet
 # Strips spaces just in case
@@ -558,4 +562,8 @@
         return self.isTrue(self.getGlobalOption("utolower", ignore=1))
         
+    def getRejectUnknown(self) :          
+        """Returns 1 if we want to reject the creation of unknown users or groups, else 0."""
+        return self.isTrue(self.getGlobalOption("reject_unknown", ignore=1))
+        
     def getWinbindSeparator(self) :          
         """Returns the winbind separator's value if it is set, else None."""
Index: pykota/trunk/pykota/version.py
===================================================================
--- pykota/trunk/pykota/version.py (revision 1952)
+++ pykota/trunk/pykota/version.py (revision 1956)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.21alpha7_unofficial"
+__version__ = "1.21alpha8_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
