[ Avaa Bypassed ]




Upload:

Command:

www-data@3.17.139.45: ~ $
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2003-2015 HP 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: Don Welch
#

__version__ = '0.1'
__title__ = "Services and Status System Tray Device I/O Child Process"
__mod__ = 'hpdio'
__doc__ = "Provides device I/O process isolation for system tray application."


# StdLib
import sys
import struct
import os
import time
from base.sixext.moves import queue
import select
from pickle import dumps, HIGHEST_PROTOCOL

# Local
from base.g import *
from base.codes import *
from base import utils, device, status, models
from base.sixext import PY3

# dBus
try:
    from dbus import lowlevel, SessionBus
except ImportError:
    log.error("dbus failed to load (python-dbus ver. 0.80+ required). Exiting...")
    sys.exit(1)

# Globals
PIPE_BUF = 4096
session_bus = None
r2, w3 = None, None
devices = {} # { 'device_uri' : device.Device(), ... }


def send_message(device_uri, event_code, bytes_written=0):
    args = [device_uri, '', event_code, prop.username, 0, '', '', bytes_written]
    msg = lowlevel.SignalMessage('/', 'com.hplip.StatusService', 'Event')
    msg.append(signature='ssisissi', *args)
    SessionBus().send_message(msg)


def run(read_pipe2=None,  # pipe from hpssd
        write_pipe3=None): # pipe to hpssd

    global r2, w3
#    tmp_dir = '/tmp'
    os.umask(0o111)

    try:
        log.set_module("hp-systray(hpdio)")
        log.debug("PID=%d" % os.getpid())

        r2, w3 = read_pipe2, write_pipe3

        fmt = "80s80sI32sI80sf" # TODO: Move to Event class
        fmt_size = struct.calcsize(fmt)

        response = {}
        dev = None
        m = ''
        while True:
            try:
                r, w, e = select.select([r2], [], [r2], 1.0)
            except KeyboardInterrupt:
                break
            except select.error as e:
                if e[0] == errno.EINTR:
                    continue
                else:
                    break

            if not r: continue
            if e: break
            m = os.read(r2, fmt_size)
            if not m:
                break

            while len(m) >= fmt_size:
                response.clear()
                event = device.Event(*[x.rstrip(b'\x00').decode('utf-8') if isinstance(x, bytes) else x for x in struct.unpack(fmt, m[:fmt_size])])
                m = m[fmt_size:]

                action = event.event_code
                if PY3:
                     device_uri = event.device_uri
                else:
                     device_uri = str(event.device_uri)

                log.debug("Handling event...")
                event.debug()

                send_message(device_uri, EVENT_DEVICE_UPDATE_ACTIVE)

                if action in (EVENT_DEVICE_UPDATE_REQUESTED, EVENT_POLLING_REQUEST):
                    #try:
                    if 1:
                        #log.debug("%s starting for %s" % (ACTION_NAMES[action], device_uri))

                        try:
                            dev = devices[device_uri]
                        except KeyError:
                            dev = devices[device_uri] = device.Device(device_uri, disable_dbus=True)

                        try:
                            #print "Device.open()"
                            dev.open()
                        except Error as e:
                            log.error(e.msg)
                            response = {'error-state': ERROR_STATE_ERROR,
                                        'device-state': DEVICE_STATE_NOT_FOUND,
                                        'status-code' : EVENT_ERROR_DEVICE_IO_ERROR}

                        if dev.device_state == DEVICE_STATE_NOT_FOUND:
                            dev.error_state = ERROR_STATE_ERROR
                        else:
                            if action == EVENT_DEVICE_UPDATE_REQUESTED:
                                try:
                                    #print "Device.queryDevice()"
                                    dev.queryDevice()

                                except Error as e:
                                    log.error("Query device error (%s)." % e.msg)
                                    dev.error_state = ERROR_STATE_ERROR
                                    dev.status_code = EVENT_ERROR_DEVICE_IO_ERROR

                                response = dev.dq
                                #print response

                                log.debug("Device state = %d" % dev.device_state)
                                log.debug("Status code = %d" % dev.status_code)
                                log.debug("Error state = %d" % dev.error_state)

                            else: # EVENT_POLLING_REQUEST
                                try:
                                    dev.pollDevice()

                                except Error as e:
                                    log.error("Poll device error (%s)." % e.msg)
                                    dev.error_state = ERROR_STATE_ERROR

                                else:
                                    response = {'test' : 1}

                    #finally:
                    if 1:
                        if dev is not None:
                            dev.close()

                    #thread_activity_lock.release()

                elif action == EVENT_USER_CONFIGURATION_CHANGED:
                    pass

                elif action == EVENT_SYSTEMTRAY_EXIT:
                    log.debug("Exiting")
                    sys.exit(1)

                send_message(device_uri, EVENT_DEVICE_UPDATE_INACTIVE)

                if action == EVENT_DEVICE_UPDATE_REQUESTED:
                    #print response
                    data = dumps(response, HIGHEST_PROTOCOL)

                    log.debug("Sending data through pipe to hpssd...")
                    total_written = 0
                    while True:
                        total_written += os.write(w3, data[:PIPE_BUF])
                        data = data[PIPE_BUF:]
                        if not data:
                            break

                    log.debug("Wrote %d bytes" % total_written)

                    send_message(device_uri, EVENT_DEVICE_UPDATE_REPLY, total_written)

                elif action == EVENT_POLLING_REQUEST:
                    # TODO: Translate into event: scan requested, copy requested, etc.. send as event
                    #try:
                    #    os.write
                    pass


    except KeyboardInterrupt:
        log.debug("Ctrl-C: Exiting...")

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
base Folder 0755
copier Folder 0755
data Folder 0755
fax Folder 0755
installer Folder 0755
pcard Folder 0755
prnt Folder 0755
scan Folder 0755
ui5 Folder 0755
__init__.py File 808 B 0755
align.py File 9.14 KB 0755
check-plugin.py File 9.8 KB 0755
check.py File 39.17 KB 0755
clean.py File 7.05 KB 0755
colorcal.py File 9.08 KB 0755
config_usb_printer.py File 6.98 KB 0755
devicesettings.py File 2.68 KB 0755
diagnose_plugin.py File 3.77 KB 0755
diagnose_queues.py File 3.65 KB 0755
doctor.py File 12.69 KB 0755
fab.py File 24.38 KB 0755
faxsetup.py File 2.56 KB 0755
firmware.py File 6.47 KB 0755
hpdio.py File 7.04 KB 0755
hplip_clean.sh File 1.81 KB 0644
hpssd.py File 20.37 KB 0755
info.py File 6.26 KB 0755
levels.py File 6.85 KB 0755
linefeedcal.py File 2.53 KB 0755
logcapture.py File 12.15 KB 0755
makecopies.py File 11.41 KB 0755
makeuri.py File 5.6 KB 0755
pkservice.py File 3.13 KB 0755
plugin.py File 13.62 KB 0755
pqdiag.py File 2.44 KB 0755
print.py File 4.23 KB 0755
printsettings.py File 2.95 KB 0755
probe.py File 7.98 KB 0755
query.py File 4.94 KB 0755
scan.py File 86.87 KB 0755
sendfax.py File 21.62 KB 0755
setup.py File 37.25 KB 0755
signing-key.asc File 1.63 KB 0644
systray.py File 4.95 KB 0755
testpage.py File 5.98 KB 0755
timedate.py File 3.31 KB 0755
toolbox.py File 8.79 KB 0755
uiscan.py File 2.18 KB 0755
uninstall.py File 3.27 KB 0755
unload.py File 24.3 KB 0755
wificonfig.py File 2.79 KB 0755