Commit 14523d05 authored by Didier Raboud's avatar Didier Raboud

Imported Upstream version 3.14.1

parent 4a731652

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -155,7 +155,7 @@ dist_base_DATA = base/maint.py base/codes.py base/g.py base/pml.py base/status.p
base/device.py base/logger.py base/slp.py base/exif.py base/strings.py base/magic.py \
base/imagesize.py base/pexpect.py base/models.py base/mdns.py base/tui.py base/dime.py \
base/ldif.py base/vcard.py base/module.py base/pkit.py base/queues.py base/password.py \
base/services.py base/os_utils.py base/smart_install.py base/avahi.py
base/services.py base/os_utils.py base/smart_install.py base/avahi.py base/validation.py
# installer
installdir = $(hplipdir)/installer
......
......@@ -589,7 +589,7 @@ am__dist_base_DATA_DIST = base/maint.py base/codes.py base/g.py \
base/mdns.py base/tui.py base/dime.py base/ldif.py \
base/vcard.py base/module.py base/pkit.py base/queues.py \
base/password.py base/services.py base/os_utils.py \
base/smart_install.py base/avahi.py
base/smart_install.py base/avahi.py base/validation.py
am__dist_copier_DATA_DIST = copier/copier.py copier/__init__.py
am__dist_fax_DATA_DIST = fax/fax.py fax/__init__.py fax/coverpages.py \
fax/pmlfax.py fax/ledmfax.py fax/soapfax.py fax/ledmsoapfax.py \
......@@ -4450,7 +4450,7 @@ cups_drv = prnt/drv/hpcups.drv
@FULL_BUILD_TRUE@@HPLIP_BUILD_TRUE@ base/device.py base/logger.py base/slp.py base/exif.py base/strings.py base/magic.py \
@FULL_BUILD_TRUE@@HPLIP_BUILD_TRUE@ base/imagesize.py base/pexpect.py base/models.py base/mdns.py base/tui.py base/dime.py \
@FULL_BUILD_TRUE@@HPLIP_BUILD_TRUE@ base/ldif.py base/vcard.py base/module.py base/pkit.py base/queues.py base/password.py \
@FULL_BUILD_TRUE@@HPLIP_BUILD_TRUE@ base/services.py base/os_utils.py base/smart_install.py base/avahi.py
@FULL_BUILD_TRUE@@HPLIP_BUILD_TRUE@ base/services.py base/os_utils.py base/smart_install.py base/avahi.py base/validation.py
# installer
......
......@@ -23,18 +23,11 @@
import os
import os.path
import sys
import re
import time
import cStringIO
import ConfigParser
import shutil
import stat
# Local
from base.logger import *
from base.g import *
from base.codes import *
from base import utils, password,services
from base import utils, password
from installer import pluginhandler
# DBus
......@@ -201,10 +194,9 @@ class PolicyKitService(dbus.service.Object):
if utils.to_bool(sys_conf.get('configure', 'policy-kit')):
class BackendService(PolicyKitService):
INTERFACE_NAME = 'com.hp.hplip'
SERVICE_NAME = 'com.hp.hplip'
LOGFILE_NAME = '/tmp/hp-pkservice.log'
SERVICE_NAME = 'com.hp.hplip'
def __init__(self, connection=None, path='/', logfile=LOGFILE_NAME):
def __init__(self, connection=None, path='/'):
if connection is None:
connection = get_service_bus()
......@@ -213,8 +205,6 @@ if utils.to_bool(sys_conf.get('configure', 'policy-kit')):
self.name = dbus.service.BusName(self.SERVICE_NAME, connection)
self.loop = gobject.MainLoop()
self.version = 0
log.set_logfile("%s.%d" % (logfile, os.getpid()))
log.set_level("debug")
def run(self, version=None):
......@@ -225,7 +215,6 @@ if utils.to_bool(sys_conf.get('configure', 'policy-kit')):
return
self.version = version
log.set_where(Logger.LOG_TO_CONSOLE_AND_FILE)
log.debug("Starting back-end service loop (version %d)" % version)
self.loop.run()
......@@ -240,6 +229,7 @@ if utils.to_bool(sys_conf.get('configure', 'policy-kit')):
try:
self.check_permission_v0(sender, INSTALL_PLUGIN_ACTION)
except AccessDeniedException, e:
log.error("installPlugin: Failed due to permission error [%s]" %e)
return False
elif self.version == 1:
......@@ -328,8 +318,6 @@ class PolicyKit(object):
def run_plugin_command(required=True, plugin_reason=PLUGIN_REASON_NONE, Mode = GUI_MODE):
su_sudo = None
need_sudo = True
name = None
version = None
if utils.to_bool(sys_conf.get('configure', 'policy-kit')):
try:
......@@ -338,7 +326,7 @@ def run_plugin_command(required=True, plugin_reason=PLUGIN_REASON_NONE, Mode = G
need_sudo = False
log.debug("Using PolicyKit for authentication")
except dbus.DBusException, ex:
log.error("PolicyKit NOT installed when configured for use")
log.error("PolicyKit NOT installed when configured for use. [%s]"%ex)
if os.geteuid() == 0:
su_sudo = "%s"
......
......@@ -242,3 +242,39 @@ def disable_SmartInstall():
log.error("Failed to install plug-in.")
except ImportError:
log.warn("Import error\n")
def close_running_hp_processes():
# check systray is running?
status,output = utils.Is_Process_Running('hp-systray')
if status is True:
ok,choice = tui.enter_choice("\nSome HPLIP applications are running. Press 'y' to close applications or press 'n' to quit upgrade(y=yes*, n=no):",['y','n'],'y')
if not ok or choice =='n':
log.info("Manually close HPLIP applications and run hp-upgrade again.")
return False
try:
# dBus
from dbus import SystemBus, lowlevel
except ImportError:
log.error("Unable to load DBus.")
pass
else:
try:
args = ['', '', EVENT_SYSTEMTRAY_EXIT, prop.username, 0, '', '']
msg = lowlevel.SignalMessage('/', 'com.hplip.StatusService', 'Event')
msg.append(signature='ssisiss', *args)
log.debug("Sending close message to hp-systray ...")
SystemBus().send_message(msg)
time.sleep(0.5)
except:
log.error("Failed to send DBus message to hp-systray/hp-toolbox.")
pass
toolbox_status,output = utils.Is_Process_Running('hp-toolbox')
if toolbox_status is True:
log.error("Failed to close either HP-Toolbox/HP-Systray. Manually close and run hp-upgrade again.")
return False
return True
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# This program 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Author: Amarnath Chitumalla
#
#Global imports
import os
#Local imports
from base import utils
from base.g import *
# GPGP validation errors
DIGSIG_ERROR_NONE = 0
DIGSIG_ERROR_FILE_NOT_FOUND = 1
DIGSIG_ERROR_DIGITAL_SIGN_NOT_FOUND = 2
DIGSIG_ERROR_DIGITAL_SIGN_BAD = 3
DIGSIG_ERROR_UNABLE_TO_RECV_KEYS = 4
DIGSIG_ERROR_GPG_CMD_NOT_FOUND = 5
DIGSIG_ERROR_INCORRECT_PASSWORD = 6
DIGSIG_ERROR_GPG_CMD_NOT_FOUND_STR ="GPG Command Not Found"
class DigiSign_Verification(object):
def __init__(self):
pass
def validate(self):
pass
class GPG_Verification(DigiSign_Verification):
def __init__(self, pgp_site = 'pgp.mit.edu', key = 0xA59047B9):
self.__pgp_site = pgp_site
self.__key = key
self.__gpg = utils.which('gpg',True)
if not self.__gpg:
raise Exception(DIGSIG_ERROR_GPG_CMD_NOT_FOUND_STR)
def __gpg_check(self, hplip_package, hplip_digsig, passwordObj):
cmd = '%s --no-permission-warning --verify %s %s' % (self.__gpg, hplip_digsig, hplip_package)
cmd = passwordObj.getAuthCmd()%cmd
log.debug("Verifying file %s with digital keys: %s" % (hplip_package,cmd))
status, output = utils.run(cmd, passwordObj)
log.debug("%s status: %d output:%s" % (self.__gpg, status,output))
return status
def acquire_gpg_key(self, passwordObj):
cmd = '%s --no-permission-warning --keyserver %s --recv-keys 0x%X' \
% (self.__gpg, self.__pgp_site, self.__key)
cmd = passwordObj.getAuthCmd()%cmd
log.info("Receiving digital keys: %s" % cmd)
status, output = utils.run(cmd, passwordObj)
log.debug(output)
return status
def validate(self, hplip_package, hplip_digsig, passwordObj):
if not os.path.exists(hplip_package):
log.error("%s file doesn't exists." %(hplip_package))
return DIGSIG_ERROR_FILE_NOT_FOUND
if not os.path.exists(hplip_digsig):
log.warn("%s file doesn't exists." %(hplip_digsig))
return DIGSIG_ERROR_DIGITAL_SIGN_NOT_FOUND
log.info(log.bold("\n\nNeed authentication to validate HPLIP package."))
if not passwordObj.getPassword():
return DIGSIG_ERROR_INCORRECT_PASSWORD
status = self.acquire_gpg_key(passwordObj)
if status != 0:
return DIGSIG_ERROR_UNABLE_TO_RECV_KEYS
status = self.__gpg_check(hplip_package, hplip_digsig, passwordObj)
if status != 0:
return DIGSIG_ERROR_DIGITAL_SIGN_BAD
else:
return DIGSIG_ERROR_NONE