LINUX.ORG.RU

Сообщения Krovavii

 

Использование системной шины DBus

Форум — General

Доброго времени суток! Есть необходимость задействовать DBus для связи приложений, запущенных от разных юзверей (root<->user). С sessionBus проблем нет, а вот с systemBus наблюдается очень плохая картина. И то, и другое на Qt.

Прототип сервера:

#include <QtCore/QCoreApplication>
#include <QtDBus/QtDBus>
#include "apserver.h"
#include <QDebug>
#define _NameObject_ "com.wifi.hostapd.ap.server"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    APServer ServerAP;

    QDBusConnection connection = QDBusConnection::systemBus();
    if(!connection.isConnected())
    {
        qDebug() << "Unconnected. Exit.";
        return -2;
    }

    bool ret = connection.registerService(_NameObject_);
    if(ret)
        qDebug()  << "Registred 1";
    else {
        qDebug() << "Unregistred 1. Exit.";
        return -1;
    }
    ret = connection.registerObject("/", &ServerAP, QDBusConnection::ExportAllSlots);
    if(ret)
        qDebug()  << "Registred 2";
    
    return a.exec();
}
Заголовок класса APServer
#ifndef APSERVER_H
#define APSERVER_H
#include "traffic.h"

class APServer : public Traffic
{
    Q_OBJECT
public:
    APServer();
    
signals:
    
public slots:
    Q_INVOKABLE void test(QString a);
    
};

#endif // APSERVER_H

Прототип клиента:

#include <QtGui/QApplication>
#include "apclient.h"
#include <QDebug>
#include <QtDBus>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    if(!QDBusConnection::systemBus().isConnected()) {
        qDebug() << "Error connection to DBus";
        return 1;
    }

    QDBusInterface iface("com.wifi.hostapd.ap.server", "/", "", QDBusConnection::systemBus());
    iface.call("test", "test from client");

    //APClient w;
    //w.show();
    
    return a.exec();
}

В файле /etc/dbus-1/system.d/com.wifi.hostapd.ap.server.conf сейчас такое содержимое (по образу и подобию skype.conf из того же каталога):

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <!-- ../system.conf have denied everything, so we just punch some holes -->

  <policy context="default">
    <allow own="com.wifi.hostapd.ap.server"/>

    <allow send_destination="com.wifi.hostapd.ap.server"/>
    <allow receive_sender="com.wifi.hostapd.ap.server"/>

    <allow send_path="/"/>
  </policy>

</busconfig>

Результат: тишина. qdbusviewer при попытке обратиться к объекту выдаёт:

Error: Call to object / at com.wifi.hostapd.ap.server: org.freedesktop.DBus.Error.AccessDenied (Rejected send message, 1 matched rules; type=«method_call», sender=":1.72" (uid=1000 pid=19780 comm=«qdbusviewer ») interface=«org.freedesktop.DBus.Introspectable» member=«Introspect» error name="(unset)" requested_reply=«0» destination=«com.wifi.hostapd.ap.server» (uid=1000 pid=18059 comm="./WiFi-Hostapd-AP-Server ")) failed

Система:

1. DBus: D-Bus Message Bus Daemon 1.4.18 Copyright (C) 2002, 2003 Red Hat, Inc., CodeFactory AB, and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2. OS: Ubuntu 12.04.2 x64

3. Qt: версия 4.8.1.

Что посоветуете? Заранее, спасибо!

PS, к сожалению, все примеры в сети только для sessionBus, потому не подходят (да, читал. И по ним же разбирался, что есть что).

 , , , , qtdbus

Krovavii
()

Зависание ноутбука при питании от батареи [Asus K50ID + Ubuntu 10.10]

Форум — General

Здравствуйте!

При питании от батареи ноутбук намертво виснет. Причём в любое время дня и ночи, не зависимо от того, какие операции выполняются.

Последнее, что есть в логах -

Kern.log

Feb 18 15:14:42 egor-ubuntu kernel: [ 9559.195754] scsi19 : usb-storage 1-3:1.5
Feb 18 15:14:43 egor-ubuntu kernel: [ 9560.187760] scsi 18:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
Feb 18 15:14:43 egor-ubuntu kernel: [ 9560.196262] sr1: scsi-1 drive
Feb 18 15:14:43 egor-ubuntu kernel: [ 9560.196403] sr 18:0:0:0:
Attached scsi CD-ROM sr1 Feb 18 15:14:43 egor-ubuntu kernel: [ 9560.196489] sr 18:0:0:0:
Attached scsi generic sg2 type 5 Feb 18 15:14:43 egor-ubuntu kernel: [ 9560.203661] scsi 19:0:0:0:
Direct-Access HUAWEI SD Storage 2.31 PQ: 0 ANSI: 2 Feb 18 15:14:43 egor-ubuntu kernel: [ 9560.211935] sd 19:0:0:0:
Attached scsi generic sg3 type 0 Feb 18 15:14:43 egor-ubuntu kernel: [ 9560.213607] sd 19:0:0:0: [sdb]
Attached SCSI removable disk Feb 18 15:46:20 egor-ubuntu kernel: [11457.960641] Monitor-Mwait will
be used to enter C-2 state Feb 18 15:46:20 egor-ubuntu kernel: [11458.118629] EXT4-fs (sda6):
re-mounted. Opts: errors=remount-ro,commit=600 Feb 18 15:46:21 egor-ubuntu kernel: [11458.777299] EXT4-fs (sda7):
re-mounted. Opts: commit=600 Feb 18 15:49:05 egor-ubuntu kernel: [11622.465367] CE: hpet increased
min_delta_ns to 7500 nsec

auth.log:

Feb 18 15:15:21 egor-ubuntu dbus-daemon: last message repeated 4 times
Feb 18 15:17:01 egor-ubuntu CRON[2765]: pam_unix(cron:session):
session opened for user root by (uid=0) Feb 18 15:17:01 egor-ubuntu CRON[2765]: pam_unix(cron:session):
session closed for user root Feb 18 15:21:09 egor-ubuntu sudo: egor : TTY=unknown ;
PWD=/home/egor ; USER=root ; COMMAND=/usr/sbin/synaptic Feb 18 15:46:20 egor-ubuntu pkexec: pam_unix(polkit-1:session):
session opened for user root by (uid=1000) Feb 18 15:46:20 egor-ubuntu pkexec: pam_ck_connector(polkit-
1:session): cannot determine display-device
Feb 18 15:46:20 egor-ubuntu pkexec[8073]: egor: Executing command

Feb 18 16:02:03 egor-ubuntu pkexec: pam_unix(polkit-1:session):
session opened for user root by (uid=1000) Feb 18 16:02:03 egor-ubuntu pkexec: pam_ck_connector(polkit-
1:session): cannot determine display-device
Feb 18 16:02:03 egor-ubuntu pkexec[8223]: egor: Executing command

Feb 18 16:02:34 egor-ubuntu pkexec: pam_unix(polkit-1:session):
session opened for user root by (uid=1000) Feb 18 16:02:34 egor-ubuntu pkexec: pam_ck_connector(polkit-
1:session): cannot determine display-device
Feb 18 16:02:34 egor-ubuntu pkexec[8225]: egor: Executing command

messages:

Feb 18 15:15:11 egor-ubuntu pppd[2686]: Connect: ppp0 <--> /dev/ttyUSB0
Feb 18 15:15:11 egor-ubuntu pppd[2686]: CHAP authentication succeeded
Feb 18 15:15:11 egor-ubuntu pppd[2686]: CHAP authentication succeeded
Feb 18 15:15:14 egor-ubuntu pppd[2686]: Could not determine remote IP
address: defaulting to 10.64.64.64 Feb 18 15:15:14 egor-ubuntu pppd[2686]: local IP address
10.65.178.225 Feb 18 15:15:14 egor-ubuntu pppd[2686]: remote IP address 10.64.64.64
Feb 18 15:15:14 egor-ubuntu pppd[2686]: primary DNS address
213.87.0.1 Feb 18 15:15:14 egor-ubuntu pppd[2686]: secondary DNS address
213.87.1.1 Feb 18 15:45:46 egor-ubuntu pppd[2686]: Protocol-Reject for
unsupported protocol 0x34cd Feb 18 15:46:20 egor-ubuntu kernel: [11458.118629] EXT4-fs (sda6):
re-mounted. Opts: errors=remount-ro,commit=600 Feb 18 15:46:21 egor-ubuntu kernel: [11458.777299] EXT4-fs (sda7):
re-mounted. Opts: commit=600 Feb 18 15:49:05 egor-ubuntu kernel: [11622.465367] CE: hpet increased
min_delta_ns to 7500 nsec Feb 18 16:02:34 egor-ubuntu pulseaudio[1697]: ratelimit.c: 867 events
suppressed

Система:

egor@egor-ubuntu:~$ uname -a Linux egor-ubuntu 2.6.35-25-generic-pae #44-Ubuntu SMP Fri Jan 21 19:01:46 UTC 2011 i686 GNU/Linux

egor@egor-ubuntu:~$ lscpu Architecture: i686
CPU op-mode(s): 32-bit, 64-bit
CPU(s): 2
Thread(s) per core: 1
Core(s) per socket: 2
CPU socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 23
Stepping: 10
CPU MHz: 1200.000
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 2048K

egor@egor-ubuntu:~$ lsusb
Bus 004 Device 002: ID 0b05:1788 ASUSTek Computer, Inc.
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 003: ID 05d5:8001 Super Gate Technology Co., Ltd
Bus 003 Device 002: ID 0458:002e KYE Systems Corp. (Mouse Systems)
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 006: ID 12d1:140c Huawei Technologies Co., Ltd.
Bus 001 Device 005: ID 13d3:5130 IMC Networks
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

egor@egor-ubuntu:~$ lspci
00:00.0 Host bridge: nVidia Corporation MCP79 Host Bridge (rev b1)
00:00.1 RAM memory: nVidia Corporation MCP79 Memory Controller (rev b1)
00:03.0 ISA bridge: nVidia Corporation MCP79 LPC Bridge (rev b2)
00:03.1 RAM memory: nVidia Corporation MCP79 Memory Controller (rev b1)
00:03.2 SMBus: nVidia Corporation MCP79 SMBus (rev b1)
00:03.3 RAM memory: nVidia Corporation MCP79 Memory Controller (rev b1)
00:03.5 Co-processor: nVidia Corporation MCP79 Co-processor (rev b1)
00:04.0 USB Controller: nVidia Corporation MCP79 OHCI USB 1.1 Controller (rev b1)
00:04.1 USB Controller: nVidia Corporation MCP79 EHCI USB 2.0 Controller (rev b1)
00:06.0 USB Controller: nVidia Corporation MCP79 OHCI USB 1.1 Controller (rev b1)
00:06.1 USB Controller: nVidia Corporation MCP79 EHCI USB 2.0 Controller (rev b1)
00:08.0 Audio device: nVidia Corporation MCP79 High Definition Audio (rev b1)
00:09.0 PCI bridge: nVidia Corporation MCP79 PCI Bridge (rev b1)
00:0b.0 SATA controller: nVidia Corporation MCP79 AHCI Controller (rev b1)
00:0c.0 PCI bridge: nVidia Corporation MCP79 PCI Express Bridge (rev b1)
00:15.0 PCI bridge: nVidia Corporation MCP79 PCI Express Bridge (rev b1)
00:16.0 PCI bridge: nVidia Corporation MCP79 PCI Express Bridge (rev b1)
02:00.0 VGA compatible controller: nVidia Corporation GT216 [GeForce GT 320M] (rev a2)
02:00.1 Audio device: nVidia Corporation High Definition Audio Controller (rev a1)
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 03)
04:00.0 Network controller: Atheros Communications Inc. AR9285
Wireless Network Adapter (PCI-Express) (rev 01)

-----------------------------------------------

Кратко о системе:
Ноутбук Asus K50ID
Intel Core 2 Duo 2.2 GHZ T6670
Geforce GT 320M (версия драйвера 260.19.29)
4GB of RAM
Ubuntu 10.10 32 бит. Ядро 2.6.35-25-pae. + все обновления.

==============================

Писал на официальном форуме - тишина. Надеюсь на вашу помощь! Спасибо! :)

Krovavii
()

RSS подписка на новые темы