Exemple #1
0
import subprocess
import notifier
import notifier.threads

import univention.info_tools as uit
import univention.management.console as umc
import univention.management.console.modules as umcm
from univention.management.console.log import MODULE
from univention.management.console.modules.decorators import simple_response, sanitize
from univention.management.console.modules.sanitizers import PatternSanitizer
from univention.management.console.protocol.definitions import *

import univention.service_info as usi
import univention.config_registry

_ = umc.Translation('univention-management-console-module-services').translate


class Instance(umcm.Base):
    def _run_it(self, services, action):
        failed = []
        for srv in services:
            if subprocess.call(('/usr/sbin/invoke-rc.d', srv, action)):
                failed.append(srv)
        return failed

    @sanitize(pattern=PatternSanitizer(default='.*'))
    @simple_response
    def query(self, pattern):
        srvs = usi.ServiceInfo()
        ucr = univention.config_registry.ConfigRegistry()
Exemple #2
0
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

import ipaddr
import re

from univention.management.console.log import MODULE
from univention.management.console.protocol.definitions import *
import univention.config_registry as ucr
import univention.management.console as umc

_ = umc.Translation('univention-management-console-module-firewall').translate

REGEX_RULE = re.compile(r'^security/packetfilter'  # prefix
                        r'(/package/(?P<package>[^/]+))?/'  # package rule
                        r'(?P<protocol>tcp|udp)/'  # protocol
                        r'(?P<port>[^/]+)/'  # port
                        r'(?P<address>[^/]+)'  # address
                        r'(/(?P<property>[^/]+))?')  # property (e.g. 'en')
REGEX_RULE_PORT = re.compile(r'^(?P<start>[0-9]+)'  # start port
                             r'((:|-)(?P<end>[0-9]+))?$')  # end port
REGEX_RULE_ADDRESS = re.compile(r'^(all|ipv4|ipv6)$')


class Error(Exception):
    pass
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

import notifier

import univention.management.console as umc
from univention.management.console.log import MODULE
from univention.management.console.protocol.definitions import MODULE_ERR, SUCCESS

import df
import mtab
import tools
from univention.lib import fstab

_ = umc.Translation('univention-management-console-module-quota').translate


class Commands(object):
    def partitions_query(self, request):
        result = []
        message = None
        try:
            fs = fstab.File()
            mt = mtab.File()
        except IOError as error:
            MODULE.error('Could not open %s' % error.filename)
            message = _('Could not open %s') % error.filename
            request.status = MODULE_ERR
        else:
            partitions = fs.get(['xfs', 'ext4', 'ext3', 'ext2'], False)
import traceback
from threading import Thread

from univention.config_registry import ConfigRegistry
import univention.management.console as umc
import univention.management.console.modules as umcm
from univention.management.console.protocol.definitions import SUCCESS, BAD_REQUEST, MODULE_ERR_COMMAND_FAILED
from univention.management.console.log import MODULE
from univention.management.console.modules.decorators import simple_response
# from univention.lib.package_manager import CMD_DISABLE_EXEC, CMD_ENABLE_EXEC

from univention.management.console.modules.adtakeover import takeover

ucr = ConfigRegistry()
ucr.load()
_ = umc.Translation(
    'univention-management-console-module-adtakeover').translate


def background(func):
    def _foreground(self, request):
        def _background(self, request):
            self.progress.reset()
            MODULE.process('Running %s' % func.__name__)
            result = None
            message = None
            status = SUCCESS
            try:
                result = func(self, request)
            except takeover.TakeoverError as exc:
                status = BAD_REQUEST
                MODULE.warn('Error during %s: %s' % (func.__name__, exc))
Exemple #5
0
from univention.management.console.modules.decorators import simple_response, sanitize
from univention.management.console.modules.sanitizers import StringSanitizer

from urllib import urlencode
from urlparse import urlunparse

# local module that overrides functions in urllib2
import univention.management.console.modules.sysinfo.upload

import urllib2
import httplib

import univention.config_registry
ucr = univention.config_registry.ConfigRegistry()

_ = umc.Translation('univention-management-console-module-sysinfo').translate


class Instance(umcm.Base):

	def __init__(self):
		umcm.Base.__init__(self)
		self.mem_regex = re.compile('([0-9]*) kB')

	def _call(self, command):
		try:
			process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			(stdoutdata, stderrdata, ) = process.communicate()
			return (process.returncode, stdoutdata, stderrdata, )
		except OSError:
			return (True, None, None, )
Exemple #6
0
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

import univention.management.console as umc
import univention.management.console.dialog as umcd
import univention.management.console.protocol as umcp

import univention.debug as ud

import notifier.popen

import tools

_ = umc.Translation( 'univention.management.console.handlers.cups' ).translate

class Commands( object ):
	def cups_printer_quota_show( self, object ):
		if object.incomplete:
			self.finished( object.id(), [] )
			return

		cmd = '/usr/bin/lpstat -o %s' % object.options[ 'printer' ]
		ud.debug( ud.ADMIN, ud.INFO, 'CUPS.show: command: %s' % cmd )
		proc = notifier.popen.Shell( cmd, stdout = True )
		cb = notifier.Callback( self._cups_printer_show_return, object )
		proc.signal_connect( 'finished', cb )
		proc.start()

	def _cups_printer_show_return( self, pid, status, buffer, object ):
Exemple #7
0
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <https://www.gnu.org/licenses/>.

import univention.config_registry
import univention.management.console as umc
import univention.management.console.modules as umcm
from univention.management.console.log import MODULE
from univention.management.console.base import LDAP_ServerDown
from univention.management.console.modules.sanitizers import Sanitizer, StringSanitizer, DictSanitizer, BooleanSanitizer
from univention.management.console.modules.appcenter.app_center import AppcenterServerContactFailed
from univention.appcenter.actions.credentials import ConnectionFailedServerDown, ConnectionFailedInvalidMachineCredentials, ConnectionFailedInvalidUserCredentials, ConnectionFailedSecretFile
from univention.appcenter.exceptions import Abort
from univention.appcenter.app_cache import Apps

_ = umc.Translation('univention-management-console-module-appcenter').translate


def error_handling(etype, exc, etraceback):
    if isinstance(exc, (ConnectionFailedSecretFile, )):
        MODULE.error(str(exc))
        error_msg = [
            _('Cannot connect to the LDAP service.'),
            _('The server seems to be lacking a proper password file.'),
            _('Please check the join state of the machine.')
        ]
        raise umcm.UMC_Error('\n'.join(error_msg), status=500)
    if isinstance(exc, (ConnectionFailedInvalidUserCredentials, )):
        MODULE.error(str(exc))
        error_msg = [
            _('Cannot connect to the LDAP service.'),
from sqlalchemy.exc import OperationalError

from univention.config_registry import ConfigRegistry

from univention.management.console.base import Base
from univention.management.console.modules.decorators import simple_response
import univention.management.console.modules as umcm
import univention.management.console as umc
from univention.management.console.log import MODULE

from univention.admindiary.client import add_comment
from univention.admindiary.backend import get_client, get_engine
from univention.admindiary.events import DiaryEvent

_ = umc.Translation(
    'univention-management-console-module-admindiary').translate


class Instance(Base):
    def _format_entry(self, entry, client):
        message = entry['message']
        if entry['event_name'] != 'COMMENT':
            message = client.translate(entry['event_name'],
                                       self.locale.language)
        try:
            message = message.format(**entry['args'])
        except (AttributeError, IndexError, KeyError):
            if entry['args']:
                message = '%s (%s)' % (message, ', '.join([
                    '%s=%s' % (key, arg)
                    for (key, arg) in entry['args'].iteritems()
Exemple #9
0
# cryptographic keys etc. are subject to a license agreement between
# you and Univention and not subject to the GNU AGPL V3.
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

import subprocess
import univention.info_tools as uit
import univention.management.console as umc
import univention.management.console.modules as umcm

from univention.management.console.log import MODULE
from univention.management.console.protocol.definitions import *

_ = umc.Translation('univention-management-console-modules-mrtg').translate

# Teststring zum Wiederfinden


class Instance(umcm.Base):
    def init(self):
        uit.set_language(str(self.locale))
Exemple #10
0
#
# The source code of this program is made available
# under the terms of the GNU Affero General Public License version 3
# (GNU AGPL V3) as published by the Free Software Foundation.
#
# Binary versions of this program provided by Univention to you as
# well as other copyrighted, protected or trademarked materials like
# Logos, graphics, fonts, specific documentations and configurations,
# cryptographic keys etc. are subject to a license agreement between
# you and Univention and not subject to the GNU AGPL V3.
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <https://www.gnu.org/licenses/>.

import univention.management.console as umc
from univention.management.console.modules import Base

_ = umc.Translation('univention-management-console-module-reboot').translate


class Instance(Base):
    pass
Exemple #11
0
# <http://www.gnu.org/licenses/>.

import pprint
import subprocess
import univention.management.console as umc
import univention.management.console.modules as umcm
import univention.config_registry
import univention.admin.uldap

from fnmatch import *
import re

from univention.management.console.log import MODULE
from univention.management.console.protocol.definitions import *

_ = umc.Translation('univention-management-console-module-printers').translate


class Instance(umcm.Base):
    def init(self):

        self.ucr = univention.config_registry.ConfigRegistry()
        self.ucr.load()

        self._hostname = self.ucr.get('hostname')

    def list_printers(self, request):
        """ Lists the printers for the overview grid. """

        # ----------- DEBUG -----------------
        MODULE.info("printers/query invoked with:")
Exemple #12
0
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

import pprint
import univention.management.console as umc
import univention.management.console.modules as umcm
import univention.config_registry
import univention.pkgdb as updb

from univention.management.console.log import MODULE

from univention.management.console.protocol.definitions import *

_ = umc.Translation('univention-management-console-module-pkgdb').translate

RECORD_LIMIT = 100000			# never return more than this many records

CRITERIA = {
	'systems': [
		'sysname','sysrole','sysversion'
	],
	'packages':	[
		'pkgname','vername',							# head fields
		'selectedstate','inststate','currentstate',		# state fields
		'sysversion'									# informational
	],
	'problems': [
		'systems_not_updated',
		'incomplete_packages'
Exemple #13
0
import univention.management.console.protocol as umcp
import univention.management.console as umc

import univention.uvmm.node as uvmmn

import univention.debug as ud

import copy
import os.path

from treeview import *
from tools import *
from uvmmd import UvmmError
from xml.sax.saxutils import escape as xml_escape

_ = umc.Translation('univention.management.console.handlers.uvmm').translate
_uvmm_locale = umc.Translation('univention.virtual.machine.manager').translate


class DriveCommands(object):
    def uvmm_drive_create(self, object):
        """Create new drive using a wizard."""
        ud.debug(
            ud.ADMIN, ud.INFO,
            'UVMM.drive_create(action=%(action)s)' % ddict(object.options))
        tv = TreeView(self.uvmm, object)
        try:
            res = tv.get_tree_response(TreeView.LEVEL_DOMAIN)
            node_uri = tv.node_uri
            domain_info = tv.domain_info
            node_info = tv.node_info