0

I'm using Ubuntu 14.04.

I have Pipelight installed - this NPAPI browser plugin allows me to view Silverlight & new Flash based stuff in Firefox.

However this has an unfortunate side effect - all web-browsers that support NPAPI plugins such as WebKit also load this plugin.

Programatically, I would like to disable all browser plugins when I create the WebKit.WebView - thus to my question. How do I do this?


Investigations:

I've looked at using WebKit2 - this does work probably because WebKit2 does not have NPAPI support. However I cannot use this method because Rhythmbox by default has another native plugin which is WebKit i.e. I'm creating another Rhythmbox plugin. When I attempt to load both a WebKit.WebView and WebKit2.WebView at the same time then the process hangs.

I've looked at using WebKit.WebSettings and its enable-plugins property but it appears you cannot apply the new WebSettings instance until after the WebView has been created (thus the pipelight browser plugin is already loaded).

Again - I've tried to assign the new WebSettings instance via the constructor but no joy: x = WebKit.WebView(settings=webkit_settings)

When you have pipelight installed a simple test program (web.py) like this shows the issue:

from gi.repository import WebKit

webkit_settings = WebKit.WebSettings.new()
webkit_settings.props.enable_plugins=False
x = WebKit.WebView.new()
x.set_settings(webkit_settings)

Then running python web.py shows an example output of

[PIPELIGHT:LIN:unknown] attached to process.
[PIPELIGHT:LIN:unknown] checking environment variable PIPELIGHT_SILVERLIGHT5_0_CONFIG.
[PIPELIGHT:LIN:unknown] searching for config file pipelight-silverlight5.0.
[PIPELIGHT:LIN:unknown] trying to load config file from '/home/foss/.config/pipelight-silverlight5.0'.
[PIPELIGHT:LIN:unknown] unrecognized configuration key 'diagnosticmode'.
[PIPELIGHT:LIN:unknown] sandbox not found or not installed!
[PIPELIGHT:LIN:silverlight5.0] using wine prefix directory /home/foss/.wine-pipelight.

I've posed this question to the Pipelight developers and they have indicated that I need to disable plugins via the WebKit engine. As you can see - I thought WebKit2 was my solution but I cannot use this as stated above.

I've seen this stackoverflow question but I'm not really after disabling specific plugins - at least I dont think so - just want to disable all external plugins

I'm writing this using Python3 but I dont think the python version is the issue here since I've run the test program using both the python and python3 interpreter and the same results are seen.

Community
  • 1
  • 1
fossfreedom
  • 2,903
  • 2
  • 19
  • 40

1 Answers1

0

I hacked this by writing my own access() function which calls strstr(pathname, "/plugins/"); If this returns non-null function sets errno to ENOENT and returns -1.

Otherwise my access() calls the original access() (system call wrapper) from c library.

In c program such a function can just be implemented, for other programs separate c module and LD_PRELOAD can be used...

like this:

static void * dlsym_next(const char * symbol)
{
    void * sym = dlsym(RTLD_NEXT, symbol);
    char * str = dlerror();

    if (str != null)
        exit(1);

    return sym;
}
#define set_next(name) *(void**)(&name##_next) = dlsym_next(#name)

int access(const char * pathname, int mode)
{
    static int (*access_next)(const char *, int) = NULL;
    if (! access_next)
        set_next(access);

    if (strstr(pathname, "/plugins/") != NULL) {
        errno = ENOENT;
        return -1;
    }
    return access_next(pathname, mode);
}
tomi
  • 153
  • 1
  • 4