270 | | user = thefilter.storage.getUser(thefilter.username) |
271 | | if not user.Exists : |
272 | | # The user is unknown from the Quota Storage perspective |
273 | | # Depending on the default policy for this printer, we |
274 | | # either let the job pass through or reject it, but we |
275 | | # log a message in any case. |
276 | | policy = thefilter.config.getPrinterPolicy(thefilter.printername) |
277 | | if policy == "ALLOW" : |
278 | | action = "POLICY_ALLOW" |
| 283 | for compteur in range(2) : |
| 284 | user = thefilter.storage.getUser(thefilter.username) |
| 285 | if user.Exists : |
| 286 | break |
280 | | action = "POLICY_DENY" |
281 | | thefilter.logger.log_message(_("User %s not registered in the PyKota system, applying default policy (%s) for printer %s") % (thefilter.username, action, thefilter.printername), "warn") |
282 | | if action == "POLICY_DENY" : |
283 | | return thefilter.removeJob() |
284 | | else : |
| 288 | # The user is unknown from the Quota Storage perspective |
| 289 | # Depending on the default policy for this printer, we |
| 290 | # either let the job pass through or reject it, but we |
| 291 | # log a message in any case. |
| 292 | (policy, args) = thefilter.config.getPrinterPolicy(thefilter.printername) |
| 293 | if policy == "ALLOW" : |
| 294 | action = "POLICY_ALLOW" |
| 295 | elif policy == "EXTERNAL" : |
| 296 | commandline = format_commandline(printer, user, args) |
| 297 | thefilter.logger.log_message(_("User %s not registered in the PyKota system, applying external policy (%s) for printer %s") % (thefilter.username, commandline, thefilter.printername), "info") |
| 298 | if os.system(commandline) : |
| 299 | thefilter.logger.log_message(_("External policy %s for printer %s produced an error. Job rejected. Please check PyKota's configuration files.") % (commandline, thefilter.printername), "error") |
| 300 | return thefilter.removeJob() |
| 301 | else : |
| 302 | # here we try a second time, because the goal |
| 303 | # of the external action was to add the user |
| 304 | # in the database. |
| 305 | continue |
| 306 | else : |
| 307 | action = "POLICY_DENY" |
| 308 | thefilter.logger.log_message(_("User %s not registered in the PyKota system, applying default policy (%s) for printer %s") % (thefilter.username, action, thefilter.printername), "warn") |
| 309 | if action == "POLICY_DENY" : |
| 310 | return thefilter.removeJob() |
| 311 | # when we get there, the printer policy allows the job to pass |
| 312 | break |
| 313 | |
| 314 | # if user exists, do accounting |
| 315 | if user.Exists : |