VMware 12.1.1 and 4.7.0-1

VMware 12.1.1 and 4.7.0-1 [openSUSE Tumbleweed (20160730) (x86_64)]:

1. VMware Virtual ethernet module:

/usr/lib/vmware/modules/source/vmnet-only/netif.c: In function ‘VNetNetifStartXmit’:
/usr/lib/vmware/modules/source/vmnet-only/netif.c:468:7: error: ‘struct net_device’ has no member named ‘trans_start’; did you mean ‘mem_start’?
    dev->trans_start = jiffies;
       ^~

Robert Gadsdon’s solution was to remove that line entirely:
http://rglinuxtech.com/?p=1746

Also virtualbox developers did basically the same:
https://www.virtualbox.org/ticket/15444
https://www.virtualbox.org/changeset/61429/vbox

VMware and 4.6.1-1

Today while trying to compile kernel modules for VMware Workstation 12.1.1 + 4.6.1-1-default [openSUSE Tumbleweed (20160422) (x86_64)] I got two compilation errors:

1. VMware Virtual ethernet module:

/usr/lib/vmware/modules/source/vmnet-only/userif.c:116:13: error: too many arguments to function ‘get_user_pages’
    retval = get_user_pages(current, current->mm, addr,
             ^

2. VMware Virtual machine monitor:

/usr/lib/vmware/modules/source/vmmon-only/linux/hostif.c:1165:13: error: too many arguments to function ‘get_user_pages’
    retval = get_user_pages(current, current->mm, (unsigned long)uvAddr,
             ^

VMware Community member alexsandr1981 has the correct answer in the discussion, which is to replace every get_user_pages call with get_user_pages_remote calls.
After replacing the original tar, the compilation succeeded for me.

Python generator functions simulated in C++ with Boost Coroutines

I recently looked into a somewhat older Open-STD paper here about “Resumable Functions v.2”, which suggests resumable lambdas as generator expressions:

C++ does not need generator expressions… it already has them!

The paper compares a Python generator expression with a proposed C++ resumable lambda.

Generator expressions are basically additional shortcut to build generators, an alternative to generator functions.

And then I started thinking about generator functions.
So how would a standard C++14 && Boost Coroutine based solution compare to Python generator functions?

For the sake of comparison I took a nice Python generator example from here:

def fibonacci(max):
    a, b = 0, 1
    while a < max:
        yield a
        a, b = b, a + b

for n in fibonacci(500):
    print(n, end=' ')

Google link for tutorialspoint’s execute_python3_online
Direct link to the same thing

Then first I implemented the same functionality in C++ (with Boost Asymmetric Coroutine), having the exact same a while loop and the exact same LOC value:

auto fibonacci=[](ac::push_type& yield, int max){
        int a=0, b=1, c;
        while(a<max)
            yield(a),
            c=a+b, a=b, b=c; };

for(ac::pull_type f(std::bind(fibonacci,_1,500)); f; f())
        std::cout<<f.get()<<' ';

Then as a cosmetic change, I switched to a for loop, scoped variables, and one less (172 vs 171) non-whitespace character 🙂
Which is a non-argument, only an interesting fact:

'while'(5) => 'for'(3) + ';'(1)

So here it is:

auto fibonacci=[](ac::push_type& yield, int max){
            for(int a=0, b=1, c;
                a<max;
                yield(a), c=a+b, a=b, b=c); };

for(ac::pull_type f(std::bind(fibonacci,_1,500)); f; f())
        std::cout<<f.get()<<' ';

And here is the complete C++ code:

#include <iostream>
#include <functional>
#include <boost/coroutine/asymmetric_coroutine.hpp>

using ac = boost::coroutines::asymmetric_coroutine<int>;
using namespace std::placeholders;

int main()
{
    auto fibonacci=[](ac::push_type& yield, int max){
                for(int a=0, b=1, c;
                    a<max;
                    yield(a), c=a+b, a=b, b=c); };

    for(ac::pull_type f(std::bind(fibonacci,_1,500)); f; f())
            std::cout<<f.get()<<' ';
}

If you feel like taking this code to a spin, than check out the CoLiRu archive.

VMware and linux 4.0.5-3

Today on openSUSE Tumbleweed, the usual module recompilation with

vmware-modconfig --console --install-all

failed, with

Unable to parse gcc version

This is because the guys releasing Tumbleweed started compiling everything with gcc 5, even the kernel, which made the vmware-modconfig unhappy:

workstation:/tmp # uname -a
Linux workstation 4.0.5-3-desktop #1 SMP PREEMPT Thu Jun 18 15:11:06 UTC 2015 (56152db) x86_64 x86_64 x86_64 GNU/Linux
workstation:/tmp # cat /etc/os-release
NAME=openSUSE
VERSION="20150702 (Tumbleweed)"
VERSION_ID="20150702"
PRETTY_NAME="openSUSE 20150702 (Tumbleweed) (x86_64)"
ID=opensuse
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:opensuse:20150702"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://opensuse.org/"
ID_LIKE="suse"
workstation:/tmp # vmware --version
VMware Workstation 11.1.0 build-2496824
workstation:/tmp # tail -n 6 /tmp/vmware-root/vmware-14006.log
2015-07-07T22:43:30.926+02:00| modconfig| I120: Trying to find a suitable PBM set for kernel "4.0.5-3-desktop".
2015-07-07T22:43:30.926+02:00| modconfig| I120: No matching PBM set was found for kernel "4.0.5-3-desktop".
2015-07-07T22:43:30.926+02:00| modconfig| I120: Found compiler at "/usr/bin/gcc"
2015-07-07T22:43:30.929+02:00| modconfig| I120: Got gcc version "5".
2015-07-07T22:43:30.930+02:00| modconfig| I120: Unable to parse gcc version
2015-07-07T22:43:30.932+02:00| modconfig| I120: We are now shutdown. Ready to die!
workstation:/tmp #

Here is a remedy from rainerklier posted in this vmware community link.

cd /usr/lib/vmware/modules/source
tar -xf vmnet.tar
cd vmnet-only
make
cd ..
tar -xf vmmon.tar
cd vmmon-only
make
cd ..
cp vmmon.o /lib/modules/`uname -r`/misc/vmmon.ko
cp vmnet.o /lib/modules/`uname -r`/misc/vmnet.ko
depmod -a
/etc/init.d/vmware restart

Linux, Flash and DRM content playback

Currently Chromium’s and Chrome’s Pepper Plugin Api (PPAPI) flash doesn’t have DRM support and it looks like a “won’t fix”, so if you want to play DRM-enabled flash content on Linux natively, (and by that I mean without running Windows plugins in Wine like Pipelight does) then you are left with the ancient abandoned Linux Flash plugin.
Since it’s abandoned, it depends on ancient libhal libs, that your current distro probably doesn’t provide, or at a cost of dependency hell.

But, Chris Horler has this project on github, which is a very lightweight, (no dependency hell)

libhal stub library forwarding to UDisks

, basically the library that flashplayer depends on when dealing with DRM -enabled media.

If you don’t want to compile it for yourself, then for openSUSE the usual suspect is the
the libhal1-flash search term on software.opensuse.org

Probably it’s just me, but for Ubuntu the PPA search is hardly usable. Anyhow for my Precise machine I used flash-hal-helper from Chris Coulson’s PPA

Oh and in case you don’t know how to test ( or you don’t even know what I am talking about), then here is _THE_ test case, quote from Chris Horler’s site:

Enter this into your browser:
http://drmtest2.adobe.com:8080/SVP/SampleVideoPlayer_FP.html
Enter this into the form:
http://drmtest2.adobe.com:8080/Content/anonymous.f4v
Press play.

Java: “Your Security Settings Have Blocked A Self Signed Application From Running”

My current employer has a Citrix XenApp solution which requires users to run a self signed Java applet. In most of the cases the Java security settings don’t allow this by default, and display this message:

Your Security Settings Have Blocked A Self Signed Application From Running

To fix this start by accessing the Java Control Panel

DISPLAY=:0.0 jcontrol

alternatively:

export DISPLAY=:0.0
/usr/java/jdk1.8.0_25/bin/ControlPanel

Go to:

Security > Edit Site List > Add

here add the site of your employer like “https://vpn.us.employer.net”
hit OK & Apply and then it should work.

Chromium doesn’t play audio (openSUSE edition)

The usual chromium distributions tend to have audio problems. A good testcase is duolingo where sounds just doesn’t play in contrast to Firefox where everything works like a charm (for the moment).
This seems to be a well know problem among Ubuntu users:
http://askubuntu.com/questions/284202/chromium-doesnt-play-sound

But here is how to do the same thing on openSUSE.:
If you have installed chromium from the network:chromium repo, then don’t install the chromium-beta-ffmpegsumo package, but use the one from google, so go to google’s beta download site pick “64 bit .rpm (Fedora/openSUSE)” download and extract it like this.:

rpm2cpio google-chrome-beta_current_x86_64.rpm \
| cpio -i --to-stdout ./opt/google/chrome-beta/libffmpegsumo.so 2>/dev/null \
> /usr/lib64/chromium/libffmpegsumo.so

Enjoy!

P.S: Here is a web page with tons of test cases to verify correct functioning:

http://tools.woolyss.com/html5-audio-video-tester/

Hacking Java Bytecode (minimalist example)

Given an java application in a jar file, that you want to change.
For example in my case it’s tightvnc-jviewer.jar (2.7.2) which has a really annoying behaviour that even if I set up all the command line parameters from an automated bash script, it still requires the user to click “Connect” to proceed. I really don’t want this, I want it to connect immediately.
So what can you do?

Use midnight commander or whatever to decompress the jar file, since the jar file is signed, and any alternation will make it fail to run with a SecurityException like this:

Exception in thread "main" java.lang.SecurityException: SHA1 digest error for com/glavsoft/viewer/Viewer.class
        at sun.security.util.ManifestEntryVerifier.verify(ManifestEntryVerifier.java:220)
        at java.util.jar.JarVerifier.processEntry(JarVerifier.java:241)
        at java.util.jar.JarVerifier.update(JarVerifier.java:228)
        at java.util.jar.JarVerifier$VerifierStream.read(JarVerifier.java:483)
        at sun.misc.Resource.getBytes(Resource.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:444)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
 

Then you need to download jd-gui the java decompiler gui, to check the code.
Start up with ./jd-gui and open the tightvnc-jviewer.jar file and navigate to com>glavsoft>viewer>Viewer>run

 

  public void run()
  {
    boolean hasJsch = checkJsch();
    boolean allowInteractive = (this.allowAppletInteractiveConnections) || (!this.isApplet);
    this.connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive);
    this.connectionPresenter.addModel("ConnectionParamsModel", this.connectionParams);
    ConnectionView connectionView = new ConnectionView(this, this.connectionPresenter, hasJsch);

    this.connectionPresenter.addView("ConnectionView", connectionView);
    if (this.isApplet) {
      this.connectionPresenter.addView("AppletStatusStringView", new View() {
        public void showView() {
        }
        public void closeView() {
        }

        public void setMessage(String message) {
          Viewer.this.getAppletContext().showStatus(message);
        }
      });
    }

The important part is this line:

boolean allowInteractive = (this.allowAppletInteractiveConnections) || (!this.isApplet);

This is what we want to change to evaluate it to false! At this point you could probably save the source code and recompile, but if you have to start getting the JDK a build environment and resolving the dependencies from scratch then it might take some time.
An alternative is editing the bytecode directly.

Shall you decide to do so, then you will need JBE the Java Bytecode Editor.
The provided jbe.sh script for linux might not work out of the box:

: No such file or directory
Error: Could not find or load main class ee.ioc.cs.jbe.browser.BrowserApplication

Since it currently contains CRLF line endings. You either have to convert it like this:

dos2unix jbe.sh

put it the code into a decent bash script or run it manually:

cd bin
java ee.ioc.cs.jbe.browser.BrowserApplication

Open the Viewer.class file and navigate to Methods>run>[0]Code and switch to CodeEditor tab.

Original run method of the Viewer class looks like this:

aload_0
invokespecial com/glavsoft/viewer/Viewer/checkJsch()Z
istore_1
aload_0
getfield com/glavsoft/viewer/Viewer/allowAppletInteractiveConnections Z
ifne 10
aload_0
getfield com/glavsoft/viewer/Viewer/isApplet Z
ifne 12
iconst_1
goto 13
iconst_0
istore_2
aload_0
new com/glavsoft/viewer/ConnectionPresenter

Check jvm specification regarding iconst_1 and ifne

You should modify it like this:

--- d1.txt      2014-11-13 17:02:48.543388146 +0100
+++ d2.txt      2014-11-13 17:03:05.719539329 +0100
@@ -7,7 +7,7 @@
 aload_0
 getfield com/glavsoft/viewer/Viewer/isApplet Z
 ifne 12
-iconst_1
+iconst_0
 goto 13
 iconst_0
 istore_2

To end up with this:

aload_0
invokespecial com/glavsoft/viewer/Viewer/checkJsch()Z
istore_1
aload_0
getfield com/glavsoft/viewer/Viewer/allowAppletInteractiveConnections Z
ifne 10
aload_0
getfield com/glavsoft/viewer/Viewer/isApplet Z
ifne 12
iconst_0
goto 13
iconst_0
istore_2
aload_0
new com/glavsoft/viewer/ConnectionPresenter

After modification click “Save method” and if you had write permission then your new Viewer.class is patched and you can run it by

java -cp . com.glavsoft.viewer.Viewer

Also if you check again in jd-gui, then you will notice, that the new run method contains this line:

boolean bool2 = (!this.allowAppletInteractiveConnections) && (this.isApplet);

So we managed to do this modification by editing the bytecode:

--- d1.txt      2014-11-13 17:33:30.923590233 +0100
+++ d2.txt      2014-11-13 17:33:41.947687055 +0100
@@ -1 +1 @@
-(this.allowAppletInteractiveConnections) || (!this.isApplet);
+(!this.allowAppletInteractiveConnections) && (this.isApplet);

P.S: later on I found out that this guy made the source code available on github.com here. I don’t know about the legal implications though.