VirtualHere Synology Password Protection

<p>Hello,<br />
I would like to install a password query in a VirtualHere installation on a Synology.
</p>
<p>I created auth.sh in the Synolgy directory on /volume1/@appstore/VirtualHere<br />
I added the Example 1 from https://www.virtualhere.com/authorization<br />
I gave it execute permissions (chmod +x auth.sh)
</p>
<p>I added the clientAuthorization in the config.ini in /volume1/@appstore/VirtualHere<br />
clientAuthorization=/volume1/@appstore/VirtualHere/auth.sh "$VENDOR_ID$" "$PRODUCT_ID$" "$CLIENT_ID$" "$CLIENT_IP$" "$PRODUCT_SERIAL$" "$PASSWORD$" "$DEVPATH$" "$NICKNAME$" "$NUM_BINDINGS$"
</p>
<p>what else do I have to set in the client?<br />
I would just need a simple password query
</p>
<p>kind regards<br />
Martin
</p>

#2

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

#3

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"

#4

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

#5

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

#6

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

#7

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

#8

OK what is in your auth.sh file?

#9

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

#10

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

#11

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.

#12

this is the error

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

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

#13

OK great, thanks for letting me know.

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

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:~$