From 33fec0427896c8397e487ad75e382ffaf11aef58 Mon Sep 17 00:00:00 2001 From: geos_one Date: Sat, 30 Jul 2011 11:28:15 +0000 Subject: [PATCH] app-admin/mds-core: Simple Version bump (Portage version: 2.1.10.7/svn/Linux x86_64, RepoMan options: --force) git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/mds@2994 6952d904-891a-0410-993b-d76249ca496b --- app-admin/mds-core/ChangeLog | 10 +- app-admin/mds-core/Manifest | 5 +- .../mds-core/files/mds-2.4.1-printing-1.patch | 777 ++++++++++++++++++ app-admin/mds-core/mds-core-2.4.1.ebuild | 45 + 4 files changed, 834 insertions(+), 3 deletions(-) create mode 100644 app-admin/mds-core/files/mds-2.4.1-printing-1.patch create mode 100644 app-admin/mds-core/mds-core-2.4.1.ebuild diff --git a/app-admin/mds-core/ChangeLog b/app-admin/mds-core/ChangeLog index ce5bd06..7951b94 100644 --- a/app-admin/mds-core/ChangeLog +++ b/app-admin/mds-core/ChangeLog @@ -1,7 +1,13 @@ -# ChangeLog for app-admin/mmc-agent -# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2 +# ChangeLog for app-admin/mds-core +# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2 # $Header: $ +*mds-core-2.4.1 (30 Jul 2011) + + 30 Jul 2011; Mario Fetka +mds-core-2.4.1.ebuild, + +files/mds-2.4.1-printing-1.patch: + Simple Version bump + 01 May 2010; Mario Fetka +metadata.xml: move mmc-agent to mds-core and add printing diff --git a/app-admin/mds-core/Manifest b/app-admin/mds-core/Manifest index 539a9e4..f70d582 100644 --- a/app-admin/mds-core/Manifest +++ b/app-admin/mds-core/Manifest @@ -1,6 +1,9 @@ AUX mds-2.4.0-install-target-1.patch 1776 RMD160 928128b54fa5ad09afa72ce6c3e483240c3434cb SHA1 8bd84d89ad494b9286beb2963f381e4075a9f191 SHA256 cac8648f7c44d9fc0c4e324d3526b13cb274cd819d1de774165e8c14770a497e AUX mds-2.4.0-printing-1.patch 30589 RMD160 bebf20555b4b8e61d597d1b7f5556e0a9d426473 SHA1 b82b0236b3a5215f0025928c0401b55d742ec4fc SHA256 10e162cef1fc55aa5d52b0bc49b155be823a8199be6385a75ea8bc2ea1f6bca1 +AUX mds-2.4.1-printing-1.patch 31182 RMD160 430d8ccf01f32977bcf28f5027e61a13d01da500 SHA1 514c94e38ae406c25c23ea3b4c3004d4ace34120 SHA256 9d1e4e9eeb1e52cda3f0b6b42528850642000f99ecc5fd3f057adec13c26387d DIST mds-2.4.0.tar.gz 987981 RMD160 31775873932c2f988699c85b9b0ef46caab2da5c SHA1 cb57e3519c0672580b120a8bacae86c3e44b9dbc SHA256 c2c61f39626517feeeec74792b73fd5661b7f241a4aa73b5fe057d1e599dfbc0 +DIST mds-2.4.1.tar.gz 402564 RMD160 a104456eb2dff4ed23319003facae543f140cd1c SHA1 1a5b5fa16e225e18c339ee203518ca2be27d43bd SHA256 8ea25b593d8cde59fbb35b7c953e2cbbe69702ff835a9dd36c1b7bb962deb626 EBUILD mds-core-2.4.0.ebuild 1077 RMD160 8767d4891f76a1cb6fee6ebe9c87b75c1bff944a SHA1 65e659f459537cf6853fe544394eaa4d3919d705 SHA256 5d2beb085babb41fc1ce3d13ad3d39ae3d82f31f488a00337fb4308b5efdd908 -MISC ChangeLog 2953 RMD160 57c8b49bd6d78dfc788832ba77138074dee44ddc SHA1 860a1dd5141f692d122b1d9737c66a5bc01bf7ef SHA256 95dcc2fd0ceb3c2792b4a03f2071ee5002b8f31ee7e5c942a9831a6ccced205b +EBUILD mds-core-2.4.1.ebuild 1026 RMD160 900a712104953d1825e211b17d33402711e7551a SHA1 e72d69c9d62017e9031d54331ebd788751793181 SHA256 57559bb571029d690af17f9161a09506883592d15365e87a63db36aa23bda8bc +MISC ChangeLog 3118 RMD160 0ef3192d45f13264f10a17f4bbcc99f305293e23 SHA1 e76f530e3dfd9b4d8f8bfe382a2d207633cd24f2 SHA256 174023e94df0cf5a42319991bb6c303dedf5a6de70155cbca8b6f562edeb69a7 MISC metadata.xml 226 RMD160 bebcbe7a5e3d2be83c25e006192f71ebf45abb14 SHA1 ec2b713fc2363b8c51e9c164d0802eeb59d9d296 SHA256 a9d3f7df2362a9a7ddcbe05c5d97d726eeb4bab135b21643508149a08bf6a2b2 diff --git a/app-admin/mds-core/files/mds-2.4.1-printing-1.patch b/app-admin/mds-core/files/mds-2.4.1-printing-1.patch new file mode 100644 index 0000000..f146bd2 --- /dev/null +++ b/app-admin/mds-core/files/mds-2.4.1-printing-1.patch @@ -0,0 +1,777 @@ +Submitted By: Mario Fetka (geos_one) (mario dot fetka at gmail dot com) +Date: 2011-07-30 +Initial Package Version: 2.3.1 +Origin: http://mds.mandriva.org/svn/mmc-agent/branches/printing +Upstream Status: unknown +Description: add the printing plugin from the 2.3.1 branch + +diff -uNr mds-2.4.1.orig//agent/conf/plugins/Makefile.am mds-2.4.1/agent/conf/plugins/Makefile.am +--- mds-2.4.1.orig//agent/conf/plugins/Makefile.am 2011-07-30 13:11:00.919000123 +0200 ++++ mds-2.4.1/agent/conf/plugins/Makefile.am 2011-07-30 13:12:12.477000104 +0200 +@@ -22,7 +22,7 @@ + # + pluginconfdir = $(sysconfdir)/mmc/plugins + dist_pluginconf_DATA = mail.ini network.ini proxy.ini sshlpk.ini \ +- userquota.ini bulkimport.ini ++ userquota.ini bulkimport.ini printing.ini printstats.ini + nodist_pluginconf_DATA = samba.ini + + EXTRA_DIST = samba.ini.in +diff -uNr mds-2.4.1.orig//agent/conf/plugins/printing.ini mds-2.4.1/agent/conf/plugins/printing.ini +--- mds-2.4.1.orig//agent/conf/plugins/printing.ini 1970-01-01 01:00:00.000000000 +0100 ++++ mds-2.4.1/agent/conf/plugins/printing.ini 2011-07-30 13:11:34.843000121 +0200 +@@ -0,0 +1,5 @@ ++[main] ++# Is this plugin disabled ? ++disable = 0 ++# Where are located the printers ++basePrintersDN = ou=Printers, dc=linbox, dc=com +diff -uNr mds-2.4.1.orig//agent/conf/plugins/printstats.ini mds-2.4.1/agent/conf/plugins/printstats.ini +--- mds-2.4.1.orig//agent/conf/plugins/printstats.ini 1970-01-01 01:00:00.000000000 +0100 ++++ mds-2.4.1/agent/conf/plugins/printstats.ini 2011-07-30 13:11:34.844000121 +0200 +@@ -0,0 +1,26 @@ ++[main] ++disable = 0 ++dbhost = localhost ++dbport = 5432 ++dbname = lpstats ++dbuser = lpstats ++dbpasswd = lpstats ++ ++[sql] ++history = SELECT sum(pages * copies), (SELECT EXTRACT(day FROM date)) AS day, (SELECT EXTRACT(month from date)) AS month, (SELECT EXTRACT(year from date)) AS year FROM linboxprintstats WHERE (now()::date - date::date <= %(days)d and printserver like '%(printserver)s') GROUP by day, month, year; ++ ++historybymonth = SELECT sum(pages * copies), (SELECT EXTRACT(month from date)) AS month, (SELECT EXTRACT(year from date)) AS year FROM linboxprintstats WHERE (now()::date - date::date <= %(days)d and printserver like '%(printserver)s') GROUP by month, year; ++ ++printers = select lps.printer as impr, coalesce(sum(lps.copies * lps.pages), 0) as total , (select coalesce(sum(lps2.copies * lps2.pages), 0) from linboxprintstats lps2 where (lps.printer = lps2.printer and lps2.color = 2 and lps2.date >= '%(begin)s' and lps2.date<='%(end)s' and lps2.printserver like '%(printserver)s')) as color, (select coalesce(sum(lps3.copies * lps3.pages), 0) from linboxprintstats lps3 where (lps3.printer = lps.printer and lps3.color <= 1 and lps3.date >= '%(begin)s' and lps3.date <= '%(end)s' and lps3.printserver like '%(printserver)s')) as bw from linboxprintstats lps where (lps.date >= '%(begin)s' and lps.date <= '%(end)s' and lps.printserver like '%(printserver)s') group by lps.printer order by %(orderby)s %(sort)s limit %(limit)s; ++ ++users = select lps.username, coalesce(sum(lps.copies * lps.pages), 0) as total , (select coalesce(sum(lps2.copies * lps2.pages), 0) from linboxprintstats lps2 where (lps2.username = lps.username and lps2.color = 2 and lps2.date >= '%(begin)s' and lps2.date <= '%(end)s' and lps2.printserver like '%(printserver)s')) as color, (select coalesce(sum(lps3.copies * lps3.pages), 0) from linboxprintstats lps3 where (lps3.username = lps.username and lps3.color<=1 and lps3.date >= '%(begin)s' and lps3.date <= '%(end)s' and lps3.printserver like '%(printserver)s')) as bw from linboxprintstats lps where (lps.date >= '%(begin)s' and lps.date <= '%(end)s' and lps.printserver like '%(printserver)s') group by lps.username order by %(orderby)s %(sort)s limit %(limit)s; ++ ++printer = select (select sum(lps2.copies) from linboxprintstats lps2 where (lps2.pages >= '%(lim1)d' and lps2.pages <= '%(lim2)d' and lps2.printer='%(printer)s' and lps2.date >= '%(begin)s' and date <= '%(end)s' and lps2.printserver like '%(printserver)s')), (select sum(lps3.copies) from linboxprintstats lps3 where (lps3.pages > '%(lim2)d' and lps3.pages <= '%(lim3)d' and lps3.printer='%(printer)s' and lps3.date >= '%(begin)s' and lps3.date <= '%(end)s') and lps3.printserver like '%(printserver)s'), (select sum(lps4.copies) from linboxprintstats lps4 where (lps4.pages > '%(lim3)s' and lps4.pages <= '%(lim4)s' and lps4.printer = '%(printer)s' and lps4.date >= '%(begin)s' and lps4.date <= '%(end)s' and lps4.printserver like '%(printserver)s')), (select sum(lps5.copies) from linboxprintstats lps5 where (lps5.pages > '%(lim4)s' and lps5.pages <= '%(lim5)s' and lps5.printer = '%(printer)s' and lps5.date >= '%(begin)s' and lps5.date <= '%(end)s' and lps5.printserver like '%(printserver)s')), (select sum(lps6.copies) from linboxprintstats lps6 where (lps6.pages > '%(lim5)s' and lps6.printer = '%(printer)s' and lps6.date >= '%(begin)s' and date <= '%(end)s' and lps6.printserver like '%(printserver)s')) from linboxprintstats limit 1; ++ ++user4printer = select lps.username, coalesce(sum(lps.copies * lps.pages), 0) as total , (select coalesce(sum(lps2.copies * lps2.pages), 0) from linboxprintstats lps2 where (lps2.printer = '%(printer)s' and lps2.username = lps.username and lps2.color = 2 and lps2.date >= '%(begin)s' and lps2.date <= '%(end)s' and lps2.printserver like '%(printserver)s')) as color, (select coalesce(sum(lps3.copies * lps3.pages), 0) from linboxprintstats lps3 where (lps3.printer = '%(printer)s' and lps3.username = lps.username and lps3.color <= 1 and lps3.date >= '%(begin)s' and lps3.date <= '%(end)s' and lps3.printserver like '%(printserver)s')) as bw from linboxprintstats lps where (lps.printer = '%(printer)s' and lps.date >= '%(begin)s' and lps.date <= '%(end)s' and lps.printserver like '%(printserver)s') group by username order by %(orderby)s %(sort)s limit %(limit)s; ++ ++printservers = select distinct(printserver) from linboxprintstats; ++ ++printerlist = select distinct(printer) from linboxprintstats; ++ ++colors = SELECT color,sum(copies*pages) from linboxprintstats WHERE (date >= '%(begin)s' and date <= '%(end)s' and printserver like '%(printserver)s') GROUP by color; +diff -uNr mds-2.4.1.orig//agent/mmc/Makefile.am mds-2.4.1/agent/mmc/Makefile.am +--- mds-2.4.1.orig//agent/mmc/Makefile.am 2011-07-30 13:11:00.921000123 +0200 ++++ mds-2.4.1/agent/mmc/Makefile.am 2011-07-30 13:12:53.402000129 +0200 +@@ -22,7 +22,7 @@ + # + pythonmodules = plugins.samba plugins.mail plugins.network \ + plugins.proxy plugins.sshlpk plugins.bulkimport \ +- plugins.userquota ++ plugins.userquota plugins.printing plugins.printstats + + # Expands Python modules list with found *.py files in each module given in pythonmodules + mmcpythondir = $(pythondir)/$(notdir $(realpath $(srcdir))) +diff -uNr mds-2.4.1.orig//agent/mmc/plugins/printing/__init__.py mds-2.4.1/agent/mmc/plugins/printing/__init__.py +--- mds-2.4.1.orig//agent/mmc/plugins/printing/__init__.py 1970-01-01 01:00:00.000000000 +0100 ++++ mds-2.4.1/agent/mmc/plugins/printing/__init__.py 2011-07-30 13:11:34.844000121 +0200 +@@ -0,0 +1,480 @@ ++# -*- coding: utf-8; -*- ++# ++# (c) 2004-2007 Linbox / Free&ALter Soft, http://linbox.com ++# (c) 2007-2008 Mandriva, http://www.mandriva.com ++# ++# $Id: __init__.py 642 2008-05-19 16:16:55Z cdelfosse $ ++# ++# This file is part of Mandriva Management Console (MMC). ++# ++# MMC 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. ++# ++# MMC 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 MMC; if not, write to the Free Software ++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ++ ++import ConfigParser ++import logging ++ ++import ldap ++from ldap.modlist import addModlist ++ ++from mmc.plugins.base import ldapUserGroupControl, GpoManager ++from mmc.support import mmctools ++ ++VERSION = "2.3.1" ++APIVERSION = "1:0:0" ++REVISION = int("$Rev: 642 $".split(':')[1].strip(' $')) ++ ++def getVersion(): return VERSION ++def getApiVersion(): return APIVERSION ++def getRevision(): return REVISION ++ ++def activate(): ++ """ ++ This function defines if this module can be activated ++ @return: return True if this module can be activated ++ @rtype: boolean ++ """ ++ configParser = mmctools.getConfigParser("printing") ++ logger = logging.getLogger() ++ ret = False ++ if configParser.get("main", "disable") == "1": ++ logger.info("printing plugin disabled by configuration.") ++ else: ++ # Create Printers Ou ++ p = ldapPrinters() ++ head, path = p.basePrintersDN.split(",", 1) ++ ouName = head.split("=")[1] ++ try: ++ p.addOu(ouName, path) ++ logger.info("Created OU " + p.basePrintersDN) ++ except ldap.ALREADY_EXISTS: ++ pass ++ gpomanager = GpoManager("Printers") ++ try: ++ gpomanager.add("GPOPrintServiceAccessAllowed", { "ACLPrintServiceAccess" : "True" }) ++ except ldap.ALREADY_EXISTS: ++ pass ++ try: ++ gpomanager.add("GPOPrintServiceAllRights", { "ACLPrintServiceAllRights" : "True" }) ++ except ldap.ALREADY_EXISTS: ++ pass ++ ret = True ++ return ret ++ ++# Printers management ++ ++def get(pattern = "*"): ++ return ldapPrinters().get(pattern) ++ ++def add(name, location = "", info = ""): ++ d = {} ++ d["printer-name"] = name ++ d["printer-location"] = location ++ d["printer-info"] = info ++ return ldapPrinters().add(d) ++ ++def delete(name): ++ return ldapPrinters().delete(name) ++ ++def exists(printer): ++ return ldapPrinters().exists(printer) ++ ++# User rights management ++ ++def addUserServiceAccessAllowed(uid): ++ ldapPrinters().addUserServiceAccessAllowed(uid) ++ ++def delUserServiceAccessAllowed(uid): ++ ldapPrinters().delUserServiceAccessAllowed(uid) ++ ++def isUserServiceAccessAllowed(uid): ++ return ldapPrinters().isUserServiceAccessAllowed(uid) ++ ++def addUserServiceAllRights(uid): ++ ldapPrinters().addUserServiceAllRights(uid) ++ ++def delUserServiceAllRights(uid): ++ ldapPrinters().delUserServiceAllRights(uid) ++ ++def isUserServiceAllRights(uid): ++ return ldapPrinters().isUserServiceAllRights(uid) ++ ++def addUserPrinterAccessAllowed(uid, printer): ++ ldapPrinters().addUserPrinterAccessAllowed(uid, printer) ++ ++def delUserPrinterAccessAllowed(uid, printer): ++ ldapPrinters().delUserPrinterAccessAllowed(uid, printer) ++ ++def getUserPrintersAccessAllowed(uid): ++ return ldapPrinters().getUserPrintersAccessAllowed(uid) ++ ++# Group rights management ++ ++def addGroupServiceAccessAllowed(group): ++ ldapPrinters().addGroupServiceAccessAllowed(group) ++ ++def delGroupServiceAccessAllowed(group): ++ ldapPrinters().delGroupServiceAccessAllowed(group) ++ ++def isGroupServiceAccessAllowed(group): ++ return ldapPrinters().isGroupServiceAccessAllowed(group) ++ ++def addGroupServiceAllRights(group): ++ ldapPrinters().addGroupServiceAllRights(group) ++ ++def delGroupServiceAllRights(group): ++ ldapPrinters().delGroupServiceAllRights(group) ++ ++def isGroupServiceAllRights(group): ++ return ldapPrinters().isGroupServiceAllRights(group) ++ ++def addGroupPrinterAccessAllowed(group, printer): ++ ldapPrinters().addGroupPrinterAccessAllowed(group, printer) ++ ++def delGroupPrinterAccessAllowed(group, printer): ++ ldapPrinters().delGroupPrinterAccessAllowed(group, printer) ++ ++def getGroupPrintersAccessAllowed(group): ++ return ldapPrinters().getGroupPrintersAccessAllowed(group) ++ ++# ++ ++def getUsersAccessAllowedForPrinter(printer): ++ return ldapPrinters().getUsersAccessAllowedForPrinter(printer) ++ ++def getGroupsAccessAllowedForPrinter(printer): ++ return ldapPrinters().getGroupsAccessAllowedForPrinter(printer) ++ ++# ++ ++def getUsersPrintServiceGPO(gpo): ++ return ldapPrinters().getUsersPrintServiceGPO(gpo) ++ ++def getGroupsPrintServiceGPO(gpo): ++ return ldapPrinters().getGroupsPrintServiceGPO(gpo) ++ ++ ++class ldapPrinters(ldapUserGroupControl): ++ ++ # Printers management methods ++ def __init__(self, conffile = None, conffilebase = None, gpoCreate = True): ++ """ ++ @param gpoCreate: If True, base GPO for printer rights management will be created. ++ @type gpoCreate: bool ++ """ ++ ldapUserGroupControl.__init__(self, conffilebase) ++ cp = ConfigParser.ConfigParser() ++ if not conffile: ++ cp = mmctools.getConfigParser("printing") ++ else: ++ cp = ConfigParser.ConfigParser() ++ cp.read(conffile) ++ self.basePrintersDN = cp.get("main", "basePrintersDN").replace(" ", "") ++ self.gpomanager = GpoManager("Printers", conffilebase, gpoCreate) ++ ++ def get(self, pattern="*"): ++ """ ++ Return the printers list found in the LDAP. ++ """ ++ entries = self.search("printer-name="+pattern, self.basePrintersDN) ++ result = [] ++ for entry in entries: ++ dn, attrs = entry[0] ++ result.append(attrs["printer-name"][0]) ++ result.sort() ++ return result ++ ++ def add(self, printerDesc): ++ """ ++ Add a printer into the LDAP. ++ ++ The GPOs corresponding to the printer are created too. ++ """ ++ printerDesc["objectClass"] = ("printerService") ++ modlist = addModlist(printerDesc) ++ entry = "printer-name=" + printerDesc["printer-name"] + "," + self.basePrintersDN ++ self.l.add_s(entry, modlist) ++ self.gpomanager.add("GPOPrinterAccessAllowed_" + printerDesc["printer-name"], { "PrinterServiceAccess" : "True" }) ++ ++ def delete(self, name): ++ """ ++ Delete a printer from the LDAP. ++ ++ The GPOs corresponding to the printer are deleted too. ++ """ ++ entry = "printer-name=" + name + ", " + self.basePrintersDN ++ self.delRecursiveEntry(entry) ++ self.gpomanager.delete("GPOPrinterAccessAllowed_" + name) ++ ++ def exists(self, printer): ++ """ ++ Return True if a printer with this name exists. ++ """ ++ entry = self.search("printer-name=" + printer, self.basePrintersDN) ++ return (len(entry) == 1) ++ ++ # Users rights management ++ ++ def addUserServiceAccessAllowed(self, uid): ++ """ ++ Give an user the right to access the print service ++ ++ @param uid: user to give access ++ """ ++ self.gpomanager.addUserToGPO(uid, "GPOPrintServiceAccessAllowed") ++ ++ def delUserServiceAccessAllowed(self, uid): ++ """ ++ Remove an user the right to access the print service ++ ++ @param uid: user to give access ++ """ ++ self.gpomanager.delUserFromGPO(uid, "GPOPrintServiceAccessAllowed") ++ ++ def isUserServiceAccessAllowed(self, uid): ++ """ ++ Return true if the user has print service access ++ ++ @param uid: user to get access ++ @rtype: Boolean ++ """ ++ dn = "uid=" + uid + "," + self.baseUsersDN ++ members = self.gpomanager.getUsersFromGPO("GPOPrintServiceAccessAllowed") ++ return dn in members ++ ++ def addUserServiceAllRights(self, uid): ++ """ ++ Give an user the right to access the print service without restriction ++ ++ @param uid: user to give access ++ """ ++ self.gpomanager.addUserToGPO(uid, "GPOPrintServiceAllRights") ++ ++ def delUserServiceAllRights(self, uid): ++ """ ++ Remove an user the right to access the print service without restriction ++ ++ @param uid: user to give access ++ """ ++ self.gpomanager.delUserFromGPO(uid, "GPOPrintServiceAllRights") ++ ++ def isUserServiceAllRights(self, uid): ++ """ ++ Return true if the user has print service access without restriction ++ ++ @param uid: user to get access ++ @rtype: Boolean ++ """ ++ dn = "uid=" + uid + "," + self.baseUsersDN ++ members = self.gpomanager.getUsersFromGPO("GPOPrintServiceAllRights") ++ return dn in members ++ ++ def addUserPrinterAccessAllowed(self, uid, printer): ++ """ ++ Give an user the right to use a printer ++ ++ @param uid: user to give access ++ @param printer: printer name ++ """ ++ self.gpomanager.addUserToGPO(uid, "GPOPrinterAccessAllowed_" + printer) ++ ++ def delUserPrinterAccessAllowed(self, uid, printer): ++ """ ++ Remove an user the right to access the print service ++ ++ @param uid: user to give access ++ @param printer: printer name ++ """ ++ self.gpomanager.delUserFromGPO(uid, "GPOPrinterAccessAllowed_" + printer) ++ ++ def getUserPrintersAccessAllowed(self, uid): ++ """ ++ Return the list of printers the user has right access ++ ++ @param uid: user name ++ """ ++ dn = "uid=" + uid + "," + self.baseUsersDN ++ return self.gpomanager.getResourceGpo(dn, "GPOPrinterAccessAllowed") ++ ++ # Groups rights management ++ ++ def addGroupServiceAccessAllowed(self, group): ++ """ ++ Give a group the right to access the print service ++ ++ @param group: group to give access to ++ """ ++ self.gpomanager.addGroupToGPO(group, "GPOPrintServiceAccessAllowed") ++ ++ def delGroupServiceAccessAllowed(self, group): ++ """ ++ Remove a group the right to access the print service ++ ++ @param group: group to give access to ++ """ ++ self.gpomanager.delGroupFromGPO(group, "GPOPrintServiceAccessAllowed") ++ ++ def isGroupServiceAccessAllowed(self, group): ++ """ ++ Return true if the group has print service access ++ ++ @param group: group to get access ++ @rtype: Boolean ++ """ ++ dn = "cn=" + group + "," + self.baseGroupsDN ++ members = self.gpomanager.getGroupsFromGPO("GPOPrintServiceAccessAllowed") ++ return dn in members ++ ++ def addGroupServiceAllRights(self, group): ++ """ ++ Give a group the right to access to the print service without restriction ++ ++ @param group: group to give access to ++ """ ++ self.gpomanager.addGroupToGPO(group, "GPOPrintServiceAllRights") ++ ++ def delGroupServiceAllRights(self, group): ++ """ ++ Remove a group the right to access to the print service without restriction ++ ++ @param group: group to give access to ++ """ ++ self.gpomanager.delGroupFromGPO(group, "GPOPrintServiceAllRights") ++ ++ def isGroupServiceAllRights(self, group): ++ """ ++ Return true if the group has print service access without restriction ++ ++ @param group: group to get access ++ @rtype: Boolean ++ """ ++ dn = "cn=" + group + "," + self.baseGroupsDN ++ members = self.gpomanager.getGroupsFromGPO("GPOPrintServiceAllRights") ++ return dn in members ++ ++ def addGroupPrinterAccessAllowed(self, group, printer): ++ """ ++ Give a group the right to use a printer ++ ++ @param group: group to give access ++ @param printer: printer name ++ """ ++ self.gpomanager.addGroupToGPO(group, "GPOPrinterAccessAllowed_" + printer) ++ ++ def delGroupPrinterAccessAllowed(self, group, printer): ++ """ ++ Remove a group the right to access the print service ++ ++ @param group: group to give access ++ @param printer: printer name ++ """ ++ self.gpomanager.delGroupFromGPO(group, "GPOPrinterAccessAllowed_" + printer) ++ ++ def getGroupPrintersAccessAllowed(self, group): ++ """ ++ Return the list of printers the group has right access ++ ++ @param group: group name ++ """ ++ dn = "cn=" + group + "," + self.baseGroupsDN ++ return self.gpomanager.getResourceGpo(dn, "GPOPrinterAccessAllowed") ++ ++ # Methods to know who can print on a specific printer ++ ++ def getUsersAccessAllowedForPrinter(self, printer): ++ """ ++ Return the list of users who can use this printer ++ ++ @param printer: the printer name ++ """ ++ ret = [] ++ for dn in self.gpomanager.getUsersFromGPO("GPOPrinterAccessAllowed_" + printer): ++ # Process dn to only return the uid value ++ ret.append(dn.split(",")[0].split("=")[1]) ++ return ret ++ ++ def getGroupsAccessAllowedForPrinter(self, printer): ++ """ ++ Return the list of groups who can use this printer ++ ++ @param printer: the printer name ++ """ ++ ret = [] ++ for dn in self.gpomanager.getGroupsFromGPO("GPOPrinterAccessAllowed_" + printer): ++ # Process dn to only return the cn value ++ ret.append(dn.split(",")[0].split("=")[1]) ++ return ret ++ ++ # To get print service GPO members ++ ++ def getUsersPrintServiceGPO(self, gpo): ++ """ ++ Return the list of users member of the GPO. ++ ++ @param gpo: Name of the GPO ++ """ ++ ret = [] ++ for dn in self.gpomanager.getUsersFromGPO(gpo): ++ # Process dn to only return the uid value ++ ret.append(dn.split(",")[0].split("=")[1]) ++ return ret ++ ++ def getGroupsPrintServiceGPO(self, gpo): ++ """ ++ Return the list of groups member of this GPO ++ ++ @param gpo: Name of the GPO ++ """ ++ ret = [] ++ for dn in self.gpomanager.getGroupsFromGPO(gpo): ++ # Process dn to only return the cn value ++ ret.append(dn.split(",")[0].split("=")[1]) ++ return ret ++ ++ def userCanPrintOn(self, uid, printer): ++ """ ++ This method is used by the MMC CUPS backend to check if an user can print on a printer. ++ For the moment, only access right is checked according to group membership. ++ ++ @return: True if the user uid can print on the printer ++ @rtype: boolean ++ """ ++ result = False ++ ++ groups = self.getUserGroups(uid) ++ # Get groups which has print service access ++ groupAccess = [] ++ for group in groups: ++ if self.isGroupServiceAccessAllowed(group): ++ groupAccess.append(group) ++ ++ # Get remaining group which has all rights on print service ++ groupAllrights = [] ++ for group in groupAccess: ++ if self.isGroupServiceAllRights(group): ++ groupAllrights.append(group) ++ ++ if len(groupAllrights): ++ # User is in a group which has all rights on print service. ++ # So this user can print ++ result = True ++ else: ++ # Does one of these groups has the right to use this printer ? ++ for group in groupAccess: ++ printers = self.getGroupPrintersAccessAllowed(group) ++ if printer in printers: ++ # We have a winner ++ result = True ++ break ++ ++ return result +diff -uNr mds-2.4.1.orig//agent/mmc/plugins/printstats/__init__.py mds-2.4.1/agent/mmc/plugins/printstats/__init__.py +--- mds-2.4.1.orig//agent/mmc/plugins/printstats/__init__.py 1970-01-01 01:00:00.000000000 +0100 ++++ mds-2.4.1/agent/mmc/plugins/printstats/__init__.py 2011-07-30 13:11:34.844000121 +0200 +@@ -0,0 +1,219 @@ ++# -*- coding: utf-8; -*- ++# ++# (c) 2004-2007 Linbox / Free&ALter Soft, http://linbox.com ++# (c) 2007 Mandriva, http://www.mandriva.com/ ++# ++# $Id: __init__.py 454 2008-01-18 14:09:42Z cedric $ ++# ++# This file is part of Mandriva Management Console (MMC). ++# ++# MMC 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. ++# ++# MMC 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 MMC; if not, write to the Free Software ++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ++ ++import psycopg ++import ConfigParser ++import logging ++from mmc.support import mmctools ++ ++VERSION = "2.3.1" ++APIVERSION = "1:0:0" ++REVISION = int("$Rev: 557 $".split(':')[1].strip(' $')) ++ ++def getVersion(): return VERSION ++def getApiVersion(): return APIVERSION ++def getRevision(): return REVISION ++ ++def activate(): ++ """ ++ This function defines if this module can be activated ++ @return: return True if this module can be activated ++ @rtype: boolean ++ """ ++ configParser = mmctools.getConfigParser("printstats") ++ logger = logging.getLogger() ++ ret = False ++ if configParser.get("main", "disable") == "1": ++ logger.info("printstats plugin disabled by configuration.") ++ else: ret = True ++ return ret ++ ++def getHistory(printserver, days): ++ return Printstats().getHistory(printserver, days) ++ ++def getHistoryByMonths(printserver, days): ++ return Printstats().getHistoryByMonths(printserver, days) ++ ++def getPrintersStats(printserver, begin, end, orderby, sort, limit): ++ return Printstats().getPrintersStats(printserver, begin, end, orderby, sort, limit) ++ ++def getPrinterStats(printserver, printer, begin, end, lim1, lim2, lim3, lim4, lim5): ++ return Printstats().getPrinterStats(printserver, printer, begin, end, lim1, lim2, lim3, lim4, lim5) ++ ++def getUsersStatsForPrinter(printserver, printer, begin, end, orderby, sort, limit): ++ return Printstats().getUsersStatsForPrinter(printserver, printer, begin, end, orderby, sort, limit) ++ ++def getUsersStats(printserver, begin, end, orderby, sort, limit): ++ return Printstats().getUsersStats(printserver, begin, end, orderby, sort, limit) ++ ++def getPrintServers(): ++ return Printstats().getPrintServers() ++ ++def getPrinterList(): ++ return Printstats().getPrinterList() ++ ++def getColors(printserver, begin, end): ++ return Printstats().getColors(printserver, begin, end) ++ ++class Printstats: ++ ++ def __init__(self, conffile = "/etc/mmc/plugins/printstats.ini"): ++ cp = ConfigParser.RawConfigParser() ++ cp.read(conffile) ++ self.dbhost = cp.get("main", "dbhost") ++ self.dbport = cp.get("main", "dbport") ++ self.dbname = cp.get("main", "dbname") ++ self.dbuser = cp.get("main", "dbuser") ++ self.dbpasswd = cp.get("main", "dbpasswd") ++ self.sql = {} ++ for option in cp.options("sql"): ++ self.sql[option] = cp.get("sql", option) ++ ++ def _getCursor(self): ++ l = logging.getLogger() ++ l.debug("Connecting to dbname=%s user=%s password=%s host=%s port=%s" % (self.dbname, self.dbuser, self.dbpasswd, self.dbhost, self.dbport)) ++ self.db = psycopg.connect("dbname=%s user=%s password=%s host=%s port=%s" % (self.dbname, self.dbuser, self.dbpasswd, self.dbhost, self.dbport)) ++ return self.db.cursor() ++ ++ def _prepareData(self, data): ++ ret = [] ++ for item in data: ++ if not None in item: ret.append(item) ++ else: ++ new = () ++ for i in item: ++ if i == None: new = new + (0,) ++ else: new = new + (i,) ++ ret.append(new) ++ return ret ++ ++ def _printServerQuery(self, printserver, where = False): ++ if printserver == "ALL": ret = "%" ++ else: ret = printserver ++ return ret ++ ++ def getHistory(self, printserver, days): ++ c = self._getCursor() ++ d = {} ++ d["days"] = days ++ d["printserver"] = self._printServerQuery(printserver) ++ c.execute(self.sql["history"] % d) ++ ret = c.fetchall() ++ self.db.close() ++ return ret ++ ++ def getHistoryByMonths(self, printserver, days): ++ c = self._getCursor() ++ d = {} ++ d["days"] = days ++ d["printserver"] = self._printServerQuery(printserver) ++ c.execute(self.sql["historybymonth"] % d) ++ ret = c.fetchall() ++ self.db.close() ++ return ret ++ ++ def getPrintersStats(self, printserver, begin, end, orderby, sort, limit): ++ c = self._getCursor() ++ d = {} ++ d["begin"] = begin ++ d["end"] = end ++ d["printserver"] = self._printServerQuery(printserver) ++ d["orderby"] = orderby ++ d["sort"] = sort ++ d["limit"] = limit ++ c.execute(self.sql["printers"] % d) ++ result = c.fetchall() ++ self.db.close() ++ return self._prepareData(result) ++ ++ def getUsersStats(self, printserver, begin, end, orderby, sort, limit): ++ c = self._getCursor() ++ d = {} ++ d["begin"] = begin ++ d["end"] = end ++ d["printserver"] = self._printServerQuery(printserver) ++ d["orderby"] = orderby ++ d["sort"] = sort ++ d["limit"] = limit ++ c.execute(self.sql["users"] % d) ++ ret = c.fetchall() ++ self.db.close() ++ return self._prepareData(ret) ++ ++ def getPrinterStats(self, printserver, printer, begin, end, lim1, lim2, lim3, lim4, lim5): ++ c = self._getCursor() ++ d = {} ++ d["printserver"] = self._printServerQuery(printserver, True) ++ d["printer"] = printer ++ d["begin"] = begin ++ d["end"] = end ++ d["lim1"] = lim1 ++ d["lim2"] = lim2 ++ d["lim3"] = lim3 ++ d["lim4"] = lim4 ++ d["lim5"] = lim5 ++ c.execute(self.sql["printer"] % d) ++ ret = c.fetchall() ++ self.db.close() ++ return self._prepareData(ret) ++ ++ def getUsersStatsForPrinter(self, printserver, printer, begin, end, orderby, sort, limit): ++ d = {} ++ d["printserver"] = self._printServerQuery(printserver) ++ d["printer"] = printer ++ d["begin"] = begin ++ d["end"] = end ++ d["orderby"] = orderby ++ d["sort"] = sort ++ d["limit"] = limit ++ c = self._getCursor() ++ c.execute(self.sql["user4printer"] % d) ++ ret = c.fetchall() ++ self.db.close() ++ return self._prepareData(ret) ++ ++ def getPrintServers(self): ++ c = self._getCursor() ++ c.execute(self.sql["printservers"]) ++ ret = c.fetchall() ++ self.db.close() ++ return self._prepareData(ret) ++ ++ def getPrinterList(self): ++ c = self._getCursor() ++ c.execute(self.sql["printerlist"]) ++ ret = c.fetchall() ++ self.db.close() ++ return self._prepareData(ret) ++ ++ def getColors(self, printserver, begin, end): ++ d = {} ++ d["printserver"] = self._printServerQuery(printserver) ++ d["begin"] = begin ++ d["end"] = end ++ c = self._getCursor() ++ c.execute(self.sql["colors"] % d) ++ ret = c.fetchall() ++ self.db.close() ++ return self._prepareData(ret) ++ diff --git a/app-admin/mds-core/mds-core-2.4.1.ebuild b/app-admin/mds-core/mds-core-2.4.1.ebuild new file mode 100644 index 0000000..11ece0f --- /dev/null +++ b/app-admin/mds-core/mds-core-2.4.1.ebuild @@ -0,0 +1,45 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="2" +SUPPORT_PYTHON_ABIS="1" + +inherit eutils autotools + +MY_P="${P/_p/-}" +MY_PV="${PV/_p*/}" + +DESCRIPTION="The MMC Agent and its Core Python plugins." +HOMEPAGE="http://mds.mandriva.org/" +SRC_URI="http://mds.mandriva.org/pub/mds/sources/${PV}/mds-${PV}.tar.gz" + +LICENSE="GPL-2" +KEYWORDS="~alpha ~amd64 ~arm ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd" +IUSE="" + +SLOT="0" + +RDEPEND=">=app-admin/mmc-core-${PV} + !app-admin/mds-web-core" + +DEPEND="sys-apps/lsb-release + sys-devel/gettext" + +S="${WORKDIR}/mds-${MY_PV}" + +src_prepare() { + epatch "${FILESDIR}"/mds-2.4.1-printing-1.patch + eautoreconf || die "eautoreconf failed" +} + +src_install() { + emake install DESTDIR=${D} || die "install failed" +} + +pkg_postinst() { + elog "To disable some plugin in your mmc environments, you have to set" + elog "disable to 1 in /etc/mmc/plugins/*.ini" + elog "(one config file per service)" + elog "You can't disable the base plugin." +}