VirtualHere Synology Password Protection

13 posts / 0 new
Last post
MaWe
VirtualHere Synology Password Protection

Hello,
I would like to install a password query in a VirtualHere installation on a Synology.

I created auth.sh in the Synolgy directory on /volume1/@appstore/VirtualHere
I added the Example 1 from https://www.virtualhere.com/authorization
I gave it execute permissions (chmod +x auth.sh)

I added the clientAuthorization in the config.ini in /volume1/@appstore/VirtualHere
clientAuthorization=/volume1/@appstore/VirtualHere/auth.sh "$VENDOR_ID$" "$PRODUCT_ID$" "$CLIENT_ID$" "$CLIENT_IP$" "$PRODUCT_SERIAL$" "$PASSWORD$" "$DEVPATH$" "$NICKNAME$" "$NUM_BINDINGS$"

what else do I have to set in the client?
I would just need a simple password query

kind regards
Martin

Michael
.

Nothing needs to change in the client. Its only a server setting

1. Put this into /volume1/@appstore/VirtualHere/auth.sh

#!/bin/sh
# Example script for performing basic user authorization for virtualhere
# Also includes a simple password protection mechanism for accessing a device
# Return 2 if the user needs to provide a password (or the password is incorrect) to use the device
# Return 1 if the user is allowed to access this device
# Return 0 if the user is not allowed to access this device
# Parameters are passed in as:
# $1 = VENDOR_ID
# $2 = PRODUCT_ID
# $3 = CLIENT_ID
# $4 = CLIENT_IP
# $5 = PRODUCT_SERIAL
# $6 = PASSWORD
# $7 = DEVPATH
# $8 = NICKNAME
# $9 = NUM_BINDINGS
logger "Authorizing -> '$1' '$2' '$3' '$4' '$5' '$6' '$7' '$8' '$9'"
# "mypassword" = "34819d7beeabb9260a5c854bc85b3e44" as an MD5 hash
if [ "$6" == "34819d7beeabb9260a5c854bc85b3e44" ]; then
  echo "Password ok"
else
  exit 2
fi
exit 1

2. Stop the VirtualHere package in the DSM Package Center
3. Edit the config.ini file and add the line

ClientAuthorization=/volume1/@appstore/VirtualHere/auth.sh "$VENDOR_ID$" "$PRODUCT_ID$" "$CLIENT_ID$" "$CLIENT_IP$" "$PRODUCT_SERIAL$" "$PASSWORD$" "$DEVPATH$" "$NICKNAME$" "$NUM_BINDINGS$"

4. Save the config.ini changes and start the virtualhere server using the DSM

5. Try to use a device, when it asks for a password put in mypassword

MaWe
There was a error using this device

Hi Michael,

- I inserted the file auth.sh
- I stopped the VH Server
- the file config.ini has been edited
- I restarted the server

when I try to use the dongle, the error message appears "There was a error using this device"

MaWe
access permissions

-rwxrwxrwx 1 admin users 825 Mar 25 09:02 auth.sh
-rwxrwxrwx 1 admin users 415 Mar 25 09:34 config.ini
drwxrwxr-x 1 root root 80 Mar 14 15:34 ui
-rwxrwxr-x 1 root root 390276 Mar 11 01:41 vhusbd
-rwxrwxr-x 1 root root 118 Mar 11 01:41 VirtualHere.sc

Michael
.

On the synology go to /var/log/virtualhere.log and see what it says in there. Any errors will be logged there

MaWe
virtualhere.log

Mon Mar 25 10:15:35 2019 LOG_INFO >>> Shutdown <<<
Mon Mar 25 10:15:37 CET 2019 Stopped successfully
Mon Mar 25 10:15:49 CET 2019 Starting VirtualHere...
Mon Mar 25 10:15:50 2019 LOG_INFO >>> Starting VirtualHere USB Server v3.8.5 (Built: Mar 11 2019, 11:38:52)<<<
Mon Mar 25 10:15:50 2019 LOG_INFO Using configuration /volume1/@appstore/VirtualHere/config.ini
Mon Mar 25 10:15:50 CET 2019 Started successfully
Mon Mar 25 10:15:50 2019 LOG_INFO Server licensed to=XXXXXXXXXXXX max_devices=unlimited
Mon Mar 25 10:15:50 2019 LOG_INFO Using large URB's
Mon Mar 25 10:15:50 2019 LOG_INFO Listening on all network interfaces at TCP port 17570
Mon Mar 25 10:15:50 2019 LOG_INFO Found Full speed device [0529:0001] "XXXXXXL" at address 13
Mon Mar 25 10:16:04 2019 LOG_INFO xxx.xxx.xxx.xxx connected as connection 1
Mon Mar 25 10:16:06 2019 LOG_ERR Unknown return value 126 from clientAuthorization
Mon Mar 25 10:16:06 2019 LOG_ERR Error binding device 13 [0529:0001] to connection 1, BIND_ERROR

MaWe
System Messages from the VH Client

2019-03-25 10:41:25 INFO :In file ../src/msw/window.cpp at line 594: 'SetFocus' failed with error 0x00000057 (Falscher Parameter.).

Michael
.

OK what is in your auth.sh file?

MaWe
auth.sh

#!/bin/sh
# Example script for performing basic user authorization for virtualhere
# Also includes a simple password protection mechanism for accessing a device
# Return 2 if the user needs to provide a password (or the password is incorrect) to use the device
# Return 1 if the user is allowed to access this device
# Return 0 if the user is not allowed to access this device
# Parameters are passed in as:
# $1 = VENDOR_ID
# $2 = PRODUCT_ID
# $3 = CLIENT_ID
# $4 = CLIENT_IP
# $5 = PRODUCT_SERIAL
# $6 = PASSWORD
# $7 = DEVPATH
# $8 = NICKNAME
# $9 = NUM_BINDINGS
logger "Authorizing -> '$1' '$2' '$3' '$4' '$5' '$6' '$7' '$8' '$9'"
# "mypassword" = "34819d7beeabb9260a5c854bc85b3e44" as an MD5 hash
if [ "$6" == "34819d7beeabb9260a5c854bc85b3e44" ]; then
echo "Password ok"
else
exit 2
fi
exit 1

Michael
.

Ok that file works fine on my synology.

Im wondering if your synology doesnt have the /bin/sh interpreter. Try changing the top line to #!/bin/bash instead

MaWe
changing the interpreter to #

changing the interpreter to #!/bin/bash changed nothing

I started the whole thing again from "nothing" and now it is working.

I have no idea what it was. Maybe a line end was not Linux compliant.

maurioski
fix the ==

this is the error

if [ "$6" == "34819d7beeabb9260a5c854bc85b3e44" ]; then <--

reemplace if [ "$6" = "34819d7beeabb9260a5c854bc85b3e44" ]; then <-- check the =. the original post have 2 = that why fail

Michael
.

OK great, thanks for letting me know.

Yes I wrote the script for bash (https://unix.stackexchange.com/questions/382003/what-are-the-differences...)

The double equals works on my synology so the shell must be different to yours. Here is my shell on the synology

admin@DiskStation:~$ /bin/sh --help
GNU bash, version 4.3.48(1)-release-(armle-unknown-linux-gnu)
Usage:  /bin/sh [GNU long option] [option] ...
        /bin/sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -ilrsD or -c command or -O shopt_option         (invocation only)
        -abefhkmnptuvxBCHP or -o option
Type `/bin/sh -c "help set"' for more information about shell options.
Type `/bin/sh -c help' for more information about shell builtin commands.
Use the `bashbug' command to report bugs.
admin@DiskStation:~$
Log in or register to post comments