runfalk / synology-wireguard

WireGuard support for some Synology NAS drives
MIT License
919 stars 131 forks source link

DSM 7.0 41882 compile failed #88

Open tbirz opened 3 years ago

tbirz commented 3 years ago

Hi guys, DSM Ver 7.0 41882 (DS1019+) tried to compile using matiges instructions (refer pull request #71). Did not compile. See putty output:

root@NAS:/etc/synology-wireguard# sudo docker run --rm --privileged --env PACKAGE_ARCH=apollolake --env DSM_VER=7.0 -v $(pwd)/artifacts:/result_spk synobuild
WireGuard version:        1.0.20210606
WireGuard tools version:  1.0.20210424
libmnl version:           1.0.4

Cloning into 'pkgscripts-ng'...
[2021-07-02 00:07:33,875] INFO: Download... https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/base_env-7.0.txz
[2021-07-02 00:29:06,495] INFO: Download... https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/ds.apollolake-7.0.env.txz
[2021-07-02 00:32:09,806] INFO: Download... https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/ds.apollolake-7.0.dev.txz
[2021-07-02 00:33:59,277] INFO: tar -xhf /toolkit_tarballs/base_env-7.0.txz -C /build_env/ds.apollolake-7.0
[2021-07-02 00:34:20,979] INFO: tar -xhf /toolkit_tarballs/ds.apollolake-7.0.env.txz -C /build_env/ds.apollolake-7.0
[2021-07-02 00:35:27,435] INFO: tar -xhf /toolkit_tarballs/ds.apollolake-7.0.dev.txz -C /build_env/ds.apollolake-7.0
[2021-07-02 00:36:06,126] INFO: All task finished.
============================================================
                   Parse argument result
------------------------------------------------------------
platforms     : apollolake
env_section   : default
env_version   : 7.0
dep_level     : 1
parallel_proj : 1
branch        : master
suffix        :
collect       : True
collecter     : True
link          : True
update_link   : False
build         : True
install       : True
only_install  : False
parallel      : 4
build_opt     : -J
install_opt   :
print_log     : True
tee           : True
sdk_ver       : 6.2
package       : WireGuard

Processing [7.0-40955]: apollolake
============================================================
              Start to run "Traverse project"
------------------------------------------------------------
Projects: WireGuard

============================================================
                Start to run "Link Project"
------------------------------------------------------------
Link /pkgscripts-ng -> /build_env/ds.apollolake-7.0/pkgscripts-ng
Link //source/WireGuard -> /build_env/ds.apollolake-7.0/source/WireGuard

============================================================
                Start to run "Build Package"
------------------------------------------------------------
[apollolake] env PackageName=WireGuard /pkgscripts-ng/SynoBuild --apollolake -c --min-sdk 6.2 -J WireGuard
/pkgscripts-ng/include/check: line 93: /dev/null: Permission denied
ERROR: This script must be run as root
Traceback (most recent call last):
  File "/pkgscripts-ng/include/python/exec_env.py", line 76, in execute
    output = commandrunner.run(cmd, display=display, **kwargs)
  File "/pkgscripts-ng/include/python/commandrunner.py", line 39, in run
    raise RunShellFailed(p.returncode, cmd, output)
commandrunner.RunShellFailed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/pkgscripts-ng/include/python/parallel.py", line 15, in __call__
    result = self.__callable(*args, **kwargs)
  File "/pkgscripts-ng/include/python/pkgcommon.py", line 191, in run_command
    env.execute(cmd, display=len(self.env_config.platforms)
  File "/pkgscripts-ng/include/python/exec_env.py", line 79, in execute
    raise EnvError(
exec_env.EnvError: ('Execute chroot /build_env/ds.apollolake-7.0 env PackageName=WireGuard /pkgscripts-ng/SynoBuild --apollolake -c --min-sdk 6.2 -J WireGuard failed', '/pkgscripts-ng/include/check: line 93: /dev/null: Permission denied\nERROR: This script must be run as root')
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/pkgscripts-ng/include/python/exec_env.py", line 76, in execute
    output = commandrunner.run(cmd, display=display, **kwargs)
  File "/pkgscripts-ng/include/python/commandrunner.py", line 39, in run
    raise RunShellFailed(p.returncode, cmd, output)
commandrunner.RunShellFailed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/pkgscripts-ng/include/python/parallel.py", line 15, in __call__
    result = self.__callable(*args, **kwargs)
  File "/pkgscripts-ng/include/python/pkgcommon.py", line 191, in run_command
    env.execute(cmd, display=len(self.env_config.platforms)
  File "/pkgscripts-ng/include/python/exec_env.py", line 79, in execute
    raise EnvError(
exec_env.EnvError: ('Execute chroot /build_env/ds.apollolake-7.0 env PackageName=WireGuard /pkgscripts-ng/SynoBuild --apollolake -c --min-sdk 6.2 -J WireGuard failed', '/pkgscripts-ng/include/check: line 93: /dev/null: Permission denied\nERROR: This script must be run as root')
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "pkgscripts-ng/PkgCreate.py", line 184, in <module>
    main(sys.argv[1:])
  File "pkgscripts-ng/PkgCreate.py", line 177, in main
    packer.pack_package()
  File "/pkgscripts-ng/include/python/pkguniform.py", line 437, in pack_package
    worker.execute()
  File "/pkgscripts-ng/include/python/pkgcommon.py", line 86, in execute
    self._process_output(self._run(*argv))
  File "/pkgscripts-ng/include/python/pkgcommon.py", line 212, in _run
    return doPlatformParallel(self.run_command, self.env_config.platforms)
  File "/pkgscripts-ng/include/python/parallel.py", line 60, in doPlatformParallel
    output[item] = results[item].get()
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
exec_env.EnvError: ('Execute chroot /build_env/ds.apollolake-7.0 env PackageName=WireGuard /pkgscripts-ng/SynoBuild --apollolake -c --min-sdk 6.2 -J WireGuard failed', '/pkgscripts-ng/include/check: line 93: /dev/null: Permission denied\nERROR: This script must be run as root')
Build log
=========
/pkgscripts-ng/include/check: line 93: /dev/null: Permission denied
ERROR: This script must be run as root
Install log
===========
cat: /build_env/ds.apollolake-7.0/logs.install: No such file or directory

root@NAS:/etc/synology-wireguard#

Can any one shed light on this issue please? I also ran as root rm /dev/null mknod /dev/null c 1 3 chmod 666 /dev/null

then tried to compile again! still no joy!

slysiou commented 2 years ago

Similar issue for me on:

sudo docker run --rm --privileged --env PACKAGE_ARCH=braswell --env DSM_VER=7.0 -v $(pwd)/artifacts:/result_spk synobuild

WireGuard version:        1.0.20210606
WireGuard tools version:  1.0.20210424
libmnl version:           1.0.4

Cloning into 'pkgscripts-ng'...
Download... https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/base_env-7.0.txz
Download destination: /toolkit_tarballs/base_env-7.0.txz%
Download... https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/ds.braswell-7.0.env.txz
Download destination: /toolkit_tarballs/ds.braswell-7.0.env.txz
Download... https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/ds.braswell-7.0.dev.txz
Download destination: /toolkit_tarballs/ds.braswell-7.0.dev.txz
tar -xhf /toolkit_tarballs/base_env-7.0.txz -C /build_env/ds.braswell-7.0
tar -xhf /toolkit_tarballs/ds.braswell-7.0.env.txz -C /build_env/ds.braswell-7.0
tar -xhf /toolkit_tarballs/ds.braswell-7.0.dev.txz -C /build_env/ds.braswell-7.0
All task finished.

============================================================
                   Parse argument result
------------------------------------------------------------
env_section  : default
env_version  : 7.0
dep_level    : 1
branch       : master
suffix       :
collect      : True
update       : True
link         : True
build        : True
install      : True
only_install : False
sign         : False
build_opt    : -J
install_opt  :
print_log    : True
sdk_ver      : 6.0
package      : WireGuard

Processing [7.0-42176]: braswell

============================================================
              Start to run "Traverse project"
------------------------------------------------------------
[INFO] Branch projects: WireGuard
[INFO] Tag projects:
[INFO] Reference projects:
[INFO] Reference tag projects:

============================================================
                Start to run "Link Project"
------------------------------------------------------------
Link /pkgscripts-ng -> /build_env/ds.braswell-7.0/pkgscripts-ng
Link //source/WireGuard -> /build_env/ds.braswell-7.0/source/WireGuard

============================================================
                Start to run "Build Package"
------------------------------------------------------------
[braswell] set -o pipefail; env PackageName=WireGuard /pkgscripts-ng/SynoBuild --braswell -c --min-sdk 6.0 -J WireGuard 2>&1 | tee logs.build
Traceback (most recent call last):
  File "/pkgscripts-ng/include/python/parallel.py", line 12, in __call__
    result = self.__callable(*args, **kwargs)
  File "pkgscripts-ng/PkgCreate.py", line 408, in run_command
    with open(os.devnull, 'wb') as null:
PermissionError: [Errno 13] Permission denied: '/dev/null'

multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/pkgscripts-ng/include/python/parallel.py", line 12, in __call__
    result = self.__callable(*args, **kwargs)
  File "pkgscripts-ng/PkgCreate.py", line 408, in run_command
    with open(os.devnull, 'wb') as null:
PermissionError: [Errno 13] Permission denied: '/dev/null'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "pkgscripts-ng/PkgCreate.py", line 722, in <module>
    main(sys.argv[1:])
  File "pkgscripts-ng/PkgCreate.py", line 716, in main
    packer.pack_package()
  File "pkgscripts-ng/PkgCreate.py", line 663, in pack_package
    worker.execute()
  File "pkgscripts-ng/PkgCreate.py", line 158, in execute
    self._process_output(self._run(*argv))
  File "pkgscripts-ng/PkgCreate.py", line 428, in _run
    return doPlatformParallel(self.run_command, self.env_config.platforms)
  File "/pkgscripts-ng/include/python/parallel.py", line 57, in doPlatformParallel
    output[item] = results[item].get()
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
PermissionError: [Errno 13] Permission denied: '/dev/null'
Build log
=========
cat: /build_env/ds.braswell-7.0/logs.build: No such file or directory

Install log
===========
cat: /build_env/ds.braswell-7.0/logs.install: No such file or directory
slysiou commented 2 years ago

It looks this is specific to docker rights on Synology. I have compiled on a Debian linux X86 machine without any issue. But, unfortunately, the package can not be installed due to new security rules on DSM 7.0 Any way to force unsigned spk on DSM 7.0 ?

tbirz commented 2 years ago

Thanks for the feedback. Unfortunately I am not experienced with docker permissions. It looks as though i might have to go with a vm solution

slysiou commented 2 years ago

@tbirz But, Synology have reenforce security rules on DSM 7.0. I didn't find a way to force custom package installation. Due to this limitation, I have switched back to openvpn and I am planning to not use Synology accept for their native application.

mcdallas commented 2 years ago

@tbirz have you read the installation instructions? you can allow unsigned spks from the control panel

tbirz commented 2 years ago

@mcdallas Sorry, don't have an unsigned spk for dsm 7.0 (thats why I wanted to compile one). Do you have or know of anyone who has an spk for DSM 7.0 apollolake?

mcdallas commented 2 years ago

@tbirz sorry I meant to tag @slysiou , I only have one for geminilake I am afraid but compilation is super easy on macos/linux just follow the instructions

slysiou commented 2 years ago

@mcdallas I didn't find where to allow unsigned spk on control panel. Can you share link of installation instruction?

jaromirrivera commented 2 years ago

Has anyone tried recently to compile and install? I have just compiled successfully on macOS but cannot install the package in DSM 7.0.

I am running the latest DSM 7 version: DSM 7.0-41890

Compiled for apollolake... I have the spk but when I go to install, I get "Invalid File Format. Please contact the package developer."

slysiou commented 2 years ago

Has anyone tried recently to compile and install? I have just compiled successfully on macOS but cannot install the package in DSM 7.0.

I am running the latest DSM 7 version: DSM 7.0-41890

Compiled for apollolake... I have the spk but when I go to install, I get "Invalid File Format. Please contact the package developer."

Same for me. I didn't find the way to force install of unsigned package...

mcdallas commented 2 years ago

I am running the latest DSM 7 version: DSM 7.0-41890

Compiled for apollolake... I have the spk but when I go to install, I get "Invalid File Format. Please contact the package developer."

I believe you need to compile from the DSM 7 branch that’s not merged in yet for DSM 7

tbirz commented 2 years ago

Has anyone tried recently to compile and install? I have just compiled successfully on macOS but cannot install the package in DSM 7.0. I am running the latest DSM 7 version: DSM 7.0-41890 Compiled for apollolake... I have the spk but when I go to install, I get "Invalid File Format. Please contact the package developer."

Same for me. I didn't find the way to force install of unsigned package...

Hi Guys, I too am running the latest version: DSM 7.0-41890. I have now managed to get Wireguard working. I used the spk apollolake file from matige's issue #71. If memory serves me correctly, the invalid file format comes from trying to install via the package centre. This does not work for DSM7.0. You must use SSH. Loaded SSH using putty Completed username & password sudo -i copied spk file to root then run the following commands (in root): sudo synopkg install WireGuard-apollolake-xxxxxxxxxxxx.spk sudo /var/packages/WireGuard/scripts/start

You can then complete the rest of your wireguard setup........

jaromirrivera commented 2 years ago

I am running the latest DSM 7 version: DSM 7.0-41890 Compiled for apollolake... I have the spk but when I go to install, I get "Invalid File Format. Please contact the package developer."

I believe you need to compile from the DSM 7 branch that’s not merged in yet for DSM 7

This was the piece I overlooked... I recompiled using the DSM 7 branch that hasnt been merged yet and it works perfectly. https://github.com/Matige/synology-wireguard.git Branch: DSM7.0

Need to install from command line.

Pasternak8 commented 2 years ago

@mcdallas ... did you compiled the geminilake version for DSM7.0? I tried, but got the same error like above: "/pkgscripts-ng/include/check: line 93: /dev/null: Permission denied ERROR: This script must be run as root"

Could you publish your geminilake build (for me or for all)?

mcdallas commented 2 years ago

@Pasternak8 you can find it here https://keybase.pub/mcdallas/WireGuard-geminilake-1.0.20210219.spk

Pasternak8 commented 2 years ago

@mccdallas: thanks a lot. After

wireguard works like before - with the old key an configurations.

Well done!

Nitrousoxide commented 2 years ago

@mccdallas: thanks a lot. After

  • uninstall the old wireguard package
  • installing on the shell like tbirz wrote: (sudo synopkg install WireGuard-geminilake-1.0.20210219.spk)
  • starting the wireguard package in the DSM
  • and running wg-quick up wg0

wireguard works like before - with the old key an configurations.

Well done!

I got an error when attempting to install 20210219.spk

{"error":{"code":0},"results":[{"action":"install","beta":false,"betaIncoming":false,"error":{"code":0},"finished":true,"installReboot":false,"installing":true,"language":"enu","last_stage":"postreplace","package":"WireGuard","packageName":"WireGuard","pid":26044,"spk":"WireGuard-geminilake-1.0.20210219.spk","stage":"installed_and_stopped","status":"stop","success":true,"username":""}],"success":true}

The DSM also fails to run the package service. Any idea what's up with this?

mcdallas commented 2 years ago

@Nitrousoxide what is the model of your NAS? Are you sure that geminilake is the one you want? You can check here https://github.com/runfalk/synology-wireguard#compatibility-list

Nitrousoxide commented 2 years ago

@mcdallas Yep, it's a 920+ so should be a geminilake.

landcraft commented 2 years ago

anyone got an apollolake build? Tried to compile it myself but when I tried to run it after installing from command line, DSM GUI said it failed...

Faeton73 commented 2 years ago

anyone got an apollolake build? Tried to compile it myself but when I tried to run it after installing from command line, DSM GUI said it failed...

I am looking also for an apollolake build (DS918+). I have tried the buld mentioned above with installation from command line, but it says it is the wrong format (?)

mkowalski commented 2 years ago

anyone got an apollolake build?

Apollolake built correctly for me with cross-compilation from x86_64 - https://github.com/runfalk/synology-wireguard/pull/102

Faeton73 commented 2 years ago

anyone got an apollolake build?

Apollolake built correctly for me with cross-compilation from x86_64 - #102

This worked perfectly on my DS918+. Thansk!

Networkwilliams commented 2 years ago

@mcdallas Yep, it's a 920+ so should be a geminilake.

Did you ever get this working

I have the same model and SPK file doesnt run

SirNoish commented 2 years ago

@mcdallas Yep, it's a 920+ so should be a geminilake.

Did you ever get this working

I have the same model and SPK file doesnt run

Try the spk from my github https://github.com/SirNoish/synology-wireguard/releases/tag/1.0.20211208

bb-Ricardo commented 2 years ago

Well I guess I found the solution:

diff --git a/build.sh b/build.sh
index ee8a382..89fe673 100755
--- a/build.sh
+++ b/build.sh
@@ -114,6 +114,9 @@ fi
 # Disable quit if errors to allow printing of logfiles
 set +e

+# bind mount /dev into build env chroot
+mount -o bind /dev $build_env/dev
+
 # Build packages
 #   -p              package arch
 #   -v              DSM version

Adding this line and running a

sudo docker build -t synobuild .

worked out of the box.

Would have create a PR but I'm not sure if this can be considered a general solution.