|
Lines 36-41
KBluetoothdApp::KBluetoothdApp() :
Link Here
|
| 36 |
// Enable autostart |
36 |
// Enable autostart |
| 37 |
m_config->setGroup("General"); |
37 |
m_config->setGroup("General"); |
| 38 |
m_config->writeEntry("AutoStart", true); |
38 |
m_config->writeEntry("AutoStart", true); |
|
|
39 |
{ |
| 40 |
int pagent_pid = m_config->readNumEntry("PassKeyAgentPid", 0); |
| 41 |
if( pagent_pid >= 0 ) |
| 42 |
{ |
| 43 |
if( pagent_pid > 0 && ::kill(pagent_pid, 0) ) |
| 44 |
{ |
| 45 |
QString proc = QString("/proc/%1/").arg(pagent_pid); |
| 46 |
char buf[PATH_MAX]; |
| 47 |
int num = ::readlink((proc+"exe").latin1(), buf, PATH_MAX); |
| 48 |
if( num > 0 && qstrncmp(buf, "/usr/bin/passkey-agent", num) != 0 ) |
| 49 |
pagent_pid = 0; |
| 50 |
if( pagent_pid > 0 ) |
| 51 |
{ |
| 52 |
QFile proc_status(proc+"status"); |
| 53 |
if( proc_status.open(IO_ReadOnly) ) |
| 54 |
{ |
| 55 |
QString qbuf; |
| 56 |
int uid = ::getuid(); |
| 57 |
while( proc_status.readLine(qbuf, 256) ) |
| 58 |
{ |
| 59 |
if( qbuf.startsWith("Uid:") ) |
| 60 |
{ |
| 61 |
if( uid != (QStringList::split("\t", qbuf, false)[1]).toInt() ) |
| 62 |
pagent_pid = 0; |
| 63 |
break; |
| 64 |
} |
| 65 |
qbuf = ""; |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
if( pagent_pid == 0 ) |
| 71 |
{ |
| 72 |
pid_t new_pid = 0; |
| 73 |
m_config->writeEntry("PassKeyAgentPid", new_pid); |
| 74 |
if(::access("/usr/bin/passkey-agent", X_OK) == 0) |
| 75 |
{ |
| 76 |
new_pid = fork(); |
| 77 |
if( new_pid == 0 ) |
| 78 |
{ |
| 79 |
::execl("/usr/bin/passkey-agent", "/usr/bin/passkey-agent", "--default", "/usr/sbin/kbluepin", NULL); |
| 80 |
} |
| 81 |
} |
| 82 |
if( new_pid > 0 ) |
| 83 |
m_config->writeEntry("PassKeyAgentPid", new_pid); |
| 84 |
} |
| 85 |
} |
| 86 |
} |
| 39 |
m_config->sync(); |
87 |
m_config->sync(); |
| 40 |
|
88 |
|
| 41 |
metaServer = NULL; |
89 |
metaServer = NULL; |