Web lists-archives.com

Need help regarding qfile management inside KAuth helper

Hi all,
I am working on the GSOC project "Polkit support in KIO". As a part of this project right now I am trying to add KAuth support to the 'copy' method of file ioslave. My initial plan was to let KAuth helper open the files requiring elevated privilege for reading and/or writing and then pass the file descriptor or maybe the file pointer back to the copy method of file ioslave which would then perform rest of  the copy operation.

I tried different approaches but none seemed to work. Here's what I've tried so far:
1> Created a QFile pointer to the restricted file, created a QVariant from the file pointer and then tried to pass it to KAuth helper. KIO compiled successfully but when tried to copy some read-restricted files QVariant complained about not being able to load/save the type. So I googled the warning and tried every possible solution involving qRegisterMetaType but still got no luck.

2> Casted the QFile to a QObject and then repeated the above steps but got same results as before (read nothing).

3> Tried reinterpret_cast'ing the QFile pointer to quintptr. I was hoping to retrieve the file pointer inside the helper and then opening the file for read/write operation using that pointer. But when I used this method the helper crashed.

4> One of my latest attempts was to get the file descriptor and then pass it to Kauth helper and use it there to open the file. KIO compiled but the copy operation simply didn't worked. Little bit of googling showed something called QDBusUnixFileDescriptor but I don't know how it works and wasn't able to find any examples on internet either.

5> In my most recent attempt I decided to pass only the file path and let the helper create, open and read the contents of file. And after reading is finished pass the data that has been stored in a QByteArray buffer to the copy method. Surprisingly it worked for text files. For binary files it seemed to work at first but actually the data was corrupt. Moreover this method was extremely slow.

So can anyone tell me how to send file descriptor or file pointer over dbus( since kauth helper and the ioslave interact using dbus)?
Or if anyone could point out a better (faster and secure) approach for the said task? Links to example programs, code snippet, relevant docs or forum threads would be of great help.