On Sunday 11 August 2013 09:40:15 Jan Kundrát wrote:
> On Sunday, 11 August 2013 08:54:58 CEST, Pali Rohár wrote:
> > I think "trojita_plugin_" prefix is needed because plugins
> > should be usable also from application directory (when
> > trojita is not installed to system path). And it is better
> > to tell qpluginloader to try open only files which could be
> > plugins (eg. have prefix "trojita_plugin_") instead trying
> > to open all files in specified directory (e.g. application
> > directory /usr/bin/). So then /plugins/ subdir in PLUGINDIR
> > is not needed.
> 
> I didn't think of that, thank you.
> 
> It seems to me that dlopening /usr/bin/trojita_plugin_* is not
> exactly a good idea, either; the potential for collisions is
> IMHO real. What about configuring cmake to use a subdirectory
> during build, and at runtime, check
> $APPDIR/plugins/trojita_plugin_* as well as
> $PLUGINDIR/trojita_plugin_*?
> 
> Cheers,
> Jan

Ah, Compile output library path is broken due FindKDE4.cmake... I 
do not know if it is good idea to change it to another value. And 
moving KDE4 into separate CMake file will not fix this problem for 
KDE4 plugins.

Maybe /usr/bin/trojita_plugin_* collision is there, but 
QLibrary/dlopen not crashing on ELF executables or other non 
library files. And I think ELF executables (or other files which 
are *not* trojita plugins) will not be stored under name 
"trojita_plugin_*".

Also QLibrary checking for file suffix if is correct. So collision 
will be there if some very good person create file 
/usr/bin/trojita_plugin_example.so which will not be trojita ELF 
library plugin. And if yes, trojita will ignore this funny broken 
plugin and will continue...

So do you think that this is real problem?

Here is code used for searching plugins:

Q_FOREACH(const QString &dirName, pluginDirs) {
    QDir dir(dirName);
    Q_FOREACH(const QString &fileName, dir.entryList(QStringList() 
<< QLatin1String("trojita_plugin_*"), QDir::Files)) {
        const QString &absoluteFilePath = 
QFileInfo(dir.absoluteFilePath(fileName)).canonicalFilePath();
        if (absoluteFilePaths.contains(absoluteFilePath))
                continue;
        do_something_with(absoluteFilePath);
    }
}

-- 
Pali Rohár
pali.ro...@gmail.com

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to