--- kdebluetooth-1.0/kdebluetooth/kbluetoothd/kbluetoothd/application.cpp~ 2006-11-11 20:32:32 +0300 +++ kdebluetooth-1.0/kdebluetooth/kbluetoothd/kbluetoothd/application.cpp 2007-05-02 18:58:43 +0400 @@ -36,6 +36,54 @@ KBluetoothdApp::KBluetoothdApp() : // Enable autostart m_config->setGroup("General"); m_config->writeEntry("AutoStart", true); + { + int pagent_pid = m_config->readNumEntry("PassKeyAgentPid", 0); + if( pagent_pid >= 0 ) + { + if( pagent_pid > 0 && ::kill(pagent_pid, 0) ) + { + QString proc = QString("/proc/%1/").arg(pagent_pid); + char buf[PATH_MAX]; + int num = ::readlink((proc+"exe").latin1(), buf, PATH_MAX); + if( num > 0 && qstrncmp(buf, "/usr/bin/passkey-agent", num) != 0 ) + pagent_pid = 0; + if( pagent_pid > 0 ) + { + QFile proc_status(proc+"status"); + if( proc_status.open(IO_ReadOnly) ) + { + QString qbuf; + int uid = ::getuid(); + while( proc_status.readLine(qbuf, 256) ) + { + if( qbuf.startsWith("Uid:") ) + { + if( uid != (QStringList::split("\t", qbuf, false)[1]).toInt() ) + pagent_pid = 0; + break; + } + qbuf = ""; + } + } + } + } + if( pagent_pid == 0 ) + { + pid_t new_pid = 0; + m_config->writeEntry("PassKeyAgentPid", new_pid); + if(::access("/usr/bin/passkey-agent", X_OK) == 0) + { + new_pid = fork(); + if( new_pid == 0 ) + { + ::execl("/usr/bin/passkey-agent", "/usr/bin/passkey-agent", "--default", "/usr/sbin/kbluepin", NULL); + } + } + if( new_pid > 0 ) + m_config->writeEntry("PassKeyAgentPid", new_pid); + } + } + } m_config->sync(); metaServer = NULL;