2014-04-18 9 views
5

시스템 버스에서 실행되는 데몬 서비스를 만들려고합니다.이 서비스에서 송수신 권한을 다른 사람에게 완전히 공개해야합니다. 보안은이 서비스에 대한 관심이 아닙니다. QtDbus (PyQt를 사용하여)를 사용하여 서비스를 등록하려고 할 때,이 오류가 발생합니다 : "Connection": 1.0 "은 구성 파일의 보안 정책으로 인해"org.dbus.arduino "서비스를 소유 할 수 없습니다" . 이 다른 스택 오버플로는 같은 오류가 있지만 어떤 이유로이 상황에서 전혀 도움이되지 않습니다. dbus_bus_request_name(): Connections are not allowed to own the service.시스템 dbus가 conf 파일로 소유권을 펀치 아웃 할 수 없음

일반적으로 system.conf 파일을 그대로두고 system.d 디렉토리에 구성 파일을 "punch out"권한을 추가해야합니다. 나는이 일을했지만 아무리 열어도 허가를받는 것과 관계없이 아무 것도 변하지 않는 것처럼 보입니다. 사실 나는 아무것도 바꾸지 않는 것이 거의 긍정적입니다! 이 순간에 내 conf 파일이 있습니다.

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

<busconfig> 
    <policy user="myUser"> 
     <allow own="*"/> 
     <allow own="org.dbus.arduino"/> 
     <allow send_type="method_call" log="true"/> 
    </policy>     
    <policy user="root">   
     <allow own="*"/> 
     <allow own="org.dbus.arduino"/> 
     <allow send_type="method_call" log="true"/> 
    </policy>       
    <policy context="default">    
    </policy>              
</busconfig>     

내가 이와 같은 작업을 수행하더라도 여전히 작동하지 않습니다.

<busconfig>    
    <policy context="default">  
     <allow own="*"/> 
     <allow own="org.dbus.arduino"/> 
     <allow send_type="method_call" log="true"/>  
    </policy>              
</busconfig> 

나는 심지어에서 읽어 맨 마지막 하나가 될 수 있도록 AZ로 시작하는 파일의 이름을 넣어. 여기의 system.conf 파일입니다, 내가 주석 한 곳 "할 수 있습니다 자신의 "섹션. 이것은 이것이 작동하도록하는 유일한 방법입니다 (그리고 가능한 최악의 "수정").

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

    <!-- Our well-known bus type, do not change this --> 
    <type>system</type> 

    <!-- Run as special user --> 
    <user>messagebus</user> 

    <!-- Fork into daemon mode --> 
    <fork/> 

    <!-- We use system service launching using a helper --> 
    <standard_system_servicedirs/> 

    <!-- This is a setuid helper that is used to launch system services --> 
    <servicehelper>/lib/dbus-1/dbus-daemon-launch-helper</servicehelper> 

    <!-- Write a pid file --> 
    <pidfile>/var/run/dbus/pid</pidfile> 

    <!-- Enable logging to syslog --> 
    <syslog/> 

    <!-- Only allow socket-credentials-based authentication --> 
    <auth>EXTERNAL</auth> 

    <!-- Only listen on a local socket. (abstract=/path/to/socket 
     means use abstract namespace, don't really create filesystem 
     file; only Linux supports this. Use path=/whatever on other 
     systems.) --> 
    <listen>unix:path=/var/run/dbus/system_bus_socket</listen> 

    <policy context="default"> 
    <!-- All users can connect to system bus --> 
    <allow user="*"/> 

    <!-- Holes must be punched in service configuration files for 
     name ownership and sending method calls --> 
    <deny own="*"/> 
    <deny send_type="method_call" log="true"/> 

    <!-- THIS IS THE ONLY WAY TO GET THIS TO WORK 
    <allow own="*"/> 
    <allow send_type="method_call" log="true"/> 
    --> 



    <!-- Signals and reply messages (method returns, errors) are allowed 
     by default --> 
    <allow send_type="signal"/> 
    <allow send_requested_reply="true" send_type="method_return"/> 
    <allow send_requested_reply="true" send_type="error"/> 

    <!-- All messages may be received by default --> 
    <allow receive_type="method_call"/> 
    <allow receive_type="method_return"/> 
    <allow receive_type="error"/> 
    <allow receive_type="signal"/> 

    <!-- Allow anyone to talk to the message bus --> 
    <allow send_destination="org.freedesktop.DBus"/> 
    <!-- But disallow some specific bus services --> 
    <deny send_destination="org.freedesktop.DBus" 
      send_interface="org.freedesktop.DBus" 
      send_member="UpdateActivationEnvironment"/> 

    </policy> 

    <!-- Config files are placed here that among other things, punch 
     holes in the above policy for specific services. --> 
    <includedir>system.d</includedir> 

    <!-- This is included last so local configuration can override what's 
     in this standard file --> 
    <include ignore_missing="yes">system-local.conf</include> 

    <include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include> 

</busconfig> 

나는 절대적으로 내가하는 GUI없이 라즈베리 파이에 그것을 배포하지 않습니다 (더 X11, 어떤 세션 버스)이기 때문에 시스템 버스를 사용합니다. 나는 시스템 버스의 모든 것을 완전히 허용함으로써 라스베리 파이를 얻을 수있었습니다 (보안은이 장치에서 거의 큰 거래가 아닙니다). 분명히, 내 개발 기계에서 발생하는 것을 허용하는 방법은 없습니다. 배경으로 나는 Opensuse 12.2를 사용하고 있고 나무 딸기 파이는 Debian Squeeze입니다. 권한을 완전히 열지 않으면 내 사용자 계정이나 루트 권한으로 서비스를 소유 할 수 없습니다.이 경우에는 정상적으로 작동합니다. 나는 또한 시스템 dbus를 완전히 열었을 때 데몬 (terminate 명령)에 메시지를 보내려면 여전히 루트를 사용해야한다는 것을 기억할 것입니다. 나는 루트 권한을 가진 특정 사용자를 통해 접근 할 수있는 솔루션을 원한다. 나는 또한 동일한 사용자와 루트 만이 메시지를 보낼 수 있도록 해주는 솔루션을 사용해도 좋다.

어떤 도움을 주셔서 감사합니다.

+0

변경할 수있는 arduino conf 파일이 있습니까? – JB0x2D1

+0

게시 한 처음 두 conf 파일은 system.d에있는 conf 파일입니다. 그 이름은 "org.dbus.arduino"입니다. 이 파일에 무엇을 넣든간에 (또는 다른 복사 파일을 복사하여 붙여 넣고 넣어도) 서비스를 소유 할 수있는 권한은 변경되지 않습니다. – Mike

+1

당신은' ... "문장을'system.conf'에''deny all '과'all '을 허락하는 매체로 넣으려고 했습니까? 여기서 구문을 잘 모르겠다면, 아니면 도움을 주려는 것일 수도 있습니다. – JB0x2D1

답변

5

마침내 문제가 발견되었습니다. Dbus가 (소유권과 같은) 권한을 뚫어 내기위한 구성 파일을 찾으면 파일은 system.d /에 있어야 할뿐만 아니라 .conf로 끝나야합니다.

구성 파일 "org.dbus.arduino"는 "org.dbus.arduino.conf"여야합니다. system.conf에서 코드를 제거했습니다. "system.d/org.dbus.arduino.conf"에 구성 파일을 만들었습니다. 권한이 부여되었습니다. 그런 다음 파일 이름을 "org.dbus.arduino"로 바꾸고 권한이 거부되었음을 확인했습니다.

+0

비슷한 문제가 발생했습니다. 세션 버스를 사용하여 생각하기 : dbus-launch를 사용하여 세션 버스를 시작하고 반환 된 env를 잘 알려진 파일에 저장하십시오. dbus 서버 및 클라이언트에서 세션 버스에 연결할 수 있도록 env 파일을 제공합니다. 거기에 어떤 단점이 보이십니까? – minghua