You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by elvelux <os...@lantalde.net> on 2018/05/30 14:09:31 UTC

Extension not working

Hello, i´m new to guacamole and i have managed to get it working with
proxmox.

But I have a problem. I am trying to add an extension to run a linux script
when an user logs into guacamole.

I have followed the guacamole manual in its 22th chapter and I have got the
extension loaded into guacamole (log file says Extension "lantalde" loaded).
The extension adds an event listener, but the code inside the listener is
never run.

I´m not sure if the problem is with the code or if i´m not creating the .jar
correctly. The only way to get the extension loaded that I have find is
creatin the .har with winrar including the guac-manifest.json and the
pom.xml into it. I have tried to generate the .jar with a mvn package
command, but then guacamole does not load the plugin because the manifest is
not in the root of the .jar file.

I´m not sure if I have to put the .java class file into the .jar or into the
guacamole client source code and then compile, I have tried both with no
success.

I suppose I am failing at something very basic because I´m new to guacamole
and Java. Can you see what is the problem? Thanks!

the files of the extension:

LantaldeListener.java
/package org.apache.guacamole.event;

import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.net.event.listener.Listener;
import org.apache.guacamole.net.event.AuthenticationSuccessEvent;
import java.io.IOException;

public class LantaldeListener implements Listener {
    @Override
    public void handleEvent(Object event) throws GuacamoleException {
        if (event instanceof AuthenticationSuccessEvent) {
			try { 
				Process p =
Runtime.getRuntime().exec("/var/lib/tomcat8/webapps/lanzar.sh");                        
				p.waitFor();
			} catch (Exception e) {
			}
        }
    }
}

/

guac-manifest.json
/{
    "guacamoleVersion" : "*",
    "name" : "lantalde",
    "namespace" : "lantalde",
    
    "listeners" : [
        "org.apache.guacamole.event.LantaldeListener"
    ]
}/

pom.xml
/	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.apache.guacamole</groupId>
	<artifactId>lantalde</artifactId>
	<version>0.9.14</version>
	<name>lantalde</name>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	
	
    <build>
        <plugins>

            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

        </plugins>
    </build>
	
	<dependencies>
        <dependency>
            <groupId>org.apache.guacamole</groupId>
            <artifactId>guacamole-ext</artifactId>
            <version>0.9.14</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>/



--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Extension not working

Posted by Nick Couchman <vn...@apache.org>.
On Wed, May 30, 2018 at 10:09 AM, elvelux <os...@lantalde.net> wrote:

> Hello, i´m new to guacamole and i have managed to get it working with
> proxmox.
>
> But I have a problem. I am trying to add an extension to run a linux script
> when an user logs into guacamole.
>
> I have followed the guacamole manual in its 22th chapter and I have got the
> extension loaded into guacamole (log file says Extension "lantalde"
> loaded).
> The extension adds an event listener, but the code inside the listener is
> never run.
>
> I´m not sure if the problem is with the code or if i´m not creating the
> .jar
> correctly. The only way to get the extension loaded that I have find is
> creatin the .har with winrar including the guac-manifest.json and the
> pom.xml into it. I have tried to generate the .jar with a mvn package
> command, but then guacamole does not load the plugin because the manifest
> is
> not in the root of the .jar file.
>

I strongly advise that you do not try to create the JAR file manually.  You
should set up a Maven project, with a working pom.xml, and allow Maven to
assembly it for you.  It is possible to do on your own, but you'll have
much better success getting it to work if you allow the tool to do it.

Your Java class and pom.xml look okay, but it looks like maybe you're
missing the parts that actually do the packaging.  I suggest looking at the
other extensions already in the source code to see how they implement it.
For example, in pom.xml, you should see this:

            <!-- Assembly plugin - for easy distribution -->
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>

<finalName>${project.artifactId}-${project.version}</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/main/assembly/dist.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-dist-archive</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Then, you'll need to create the src/main/assembly/dist.xml file in the
extension and populate it.  Again, look at any existing extension and copy
what's in there and customize to suit your needs.

-Nick