Rclone functioning via Debian CLI, but not through PHP exec()

I don't have access to anywhere not in /nfs so far as I know? the folder i have it I guess can be accessed from /users/.home/ as well, but I don't think that's what you mean. I can't access /tmp either, and honestly can't find PHP or Apache logs. I've been meaning to get on support with my host to find out that much at least, but two different techs have told me they're not allowed to debug this particular issue with me any further. So I really appreciate your help and patience.

fitaf570.com@n17:~$ cat /etc/fstab
# UNCONFIGURED FSTAB FOR BASE SYSTEM
fitaf570.com@n17:~$ cat /proc/mounts
10.10.0.6:/export/roots/jessie-6-amd64 / nfs ro,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=1800,acregmax=1800,acdirmin=1800,acdirmax=1800,hard,nocto,nolock,noacl,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.6,mountvers=3,mountproto=tcp,local_lock=all,addr=10.10.0.6 0 0
sysfs /sys sysfs rw,relatime 0 0
proc /proc proc rw,relatime,hidepid=2 0 0
tmpfs /dev tmpfs rw,relatime 0 0
devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=13174892k,mode=755 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
tmpfs /var tmpfs rw,relatime,size=409600k,mode=755 0 0
tmpfs /var/apache2 tmpfs rw,relatime,mode=700,uid=33,gid=33 0 0
tmpfs /var/scantmp tmpfs rw,relatime,size=204800k,mode=755 0 0
tmpfs /var/tmp tmpfs rw,relatime,size=204800k,mode=755 0 0
tmpfs /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=26349780k 0 0
tmpfs /dev tmpfs rw,relatime 0 0
devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0
tmpfs /var tmpfs rw,relatime,size=409600k,mode=755 0 0
tmpfs /var/apache2 tmpfs rw,relatime,mode=700,uid=33,gid=33 0 0
tmpfs /var/scantmp tmpfs rw,relatime,size=204800k,mode=755 0 0
tmpfs /var/tmp tmpfs rw,relatime,size=204800k,mode=755 0 0
rpc_pipefs /run/rpc_pipefs rpc_pipefs rw,relatime 0 0
tmpfs /var/spool/exim4 tmpfs rw,relatime,size=409600k,mode=750 0 0
tmpfs /root tmpfs rw,relatime,size=5120k,mode=700 0 0
10.10.0.6:/localexport/state /opt/mt/var nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.6,mountvers=3,mountport=57964,mountproto=tcp,local_lock=none,addr=10.10.0.6 0 0
10.10.0.6:/export/home /nfs/c10/home/mnt nfs ro,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=30,acregmax=30,acdirmax=30,hard,nocto,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.6,mountvers=3,mountport=57964,mountproto=tcp,local_lock=none,addr=10.10.0.6 0 0
tmpfs /nfs/c10/home/mnt/default tmpfs rw,relatime,size=5120k,mode=755 0 0
10.10.0.215:/frontend0/c10/h05 /nfs/c10/h05/mnt nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=25,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.215,mountvers=3,mountport=64186,mountproto=tcp,local_lock=all,addr=10.10.0.215 0 0
10.10.0.215:/frontend0/c10/h06 /nfs/c10/h06/mnt nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=25,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.215,mountvers=3,mountport=64186,mountproto=tcp,local_lock=all,addr=10.10.0.215 0 0
10.10.0.215:/frontend0/c10/h07 /nfs/c10/h07/mnt nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=25,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.215,mountvers=3,mountport=64186,mountproto=tcp,local_lock=all,addr=10.10.0.215 0 0
10.10.0.215:/frontend0/c10/h08 /nfs/c10/h08/mnt nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=25,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.215,mountvers=3,mountport=64186,mountproto=tcp,local_lock=all,addr=10.10.0.215 0 0
10.10.0.216:/frontend1/c10/h09 /nfs/c10/h09/mnt nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=25,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.216,mountvers=3,mountport=49887,mountproto=tcp,local_lock=all,addr=10.10.0.216 0 0
10.10.0.216:/frontend1/c10/h10 /nfs/c10/h10/mnt nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=25,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.216,mountvers=3,mountport=49887,mountproto=tcp,local_lock=all,addr=10.10.0.216 0 0
10.10.0.216:/frontend1/c10/h11 /nfs/c10/h11/mnt nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=25,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.216,mountvers=3,mountport=49887,mountproto=tcp,local_lock=all,addr=10.10.0.216 0 0
10.10.0.216:/frontend1/c10/h12 /nfs/c10/h12/mnt nfs rw,noatime,nodiratime,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=25,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.10.0.216,mountvers=3,mountport=49887,mountproto=tcp,local_lock=all,addr=10.10.0.216 0 0
tmpfs /nfs/c10/h01 tmpfs rw,relatime,size=1024k,mode=755 0 0
tmpfs /nfs/c10/h02 tmpfs rw,relatime,size=1024k,mode=755 0 0
tmpfs /nfs/c10/h03 tmpfs rw,relatime,size=1024k,mode=755 0 0
tmpfs /nfs/c10/h04 tmpfs rw,relatime,size=1024k,mode=755 0 0

There's nothing obvious there.

If it were me, i'd try to narrow this down a little by executing something else in a different path if possible. Perhaps create a simple shell script.

echo "echo hi; exit 0" > /nfs/c10/h10/mnt/somescript.sh
chmod 777 /nfs/c10/h10/mnt/somescript.sh

Try to shell_exec or similar to ensure what you can execute and where. It all seems like a permission issue somewhere in the mount of the directory structure.

I do not have access to that high a level in the path. The best I could do is /nfs/c10/h10/mnt/228932/domains for creating the "hi" script. It executed successfully from that path.

However, after copying rclone there, I am still getting a 126 return code that it was not executable.

If it matters,

exec('/bin/bash /nfs/c10/h10/mnt/228932/domains/rclone copy /nfs/c10/h10/mnt/228932/domains/fitaf570.com/html/doc "gd:/lance/Fit AF/"',$out,$retCode);
exec('sh /nfs/c10/h10/mnt/228932/domains/rclone copy /nfs/c10/h10/mnt/228932/domains/fitaf570.com/html/doc "gd:/lance/Fit AF/"',$out,$retCode);

return 126 whereas

exec('/nfs/c10/h10/mnt/228932/domains/rclone copy /nfs/c10/h10/mnt/228932/domains/fitaf570.com/html/doc "gd:/lance/Fit AF/"',$out,$retCode);

returns 2 (Misuse of shell builtins (according to Bash documentation))

Just so you know. You can't do this:

/bin/bash /nfs/c10/h10/mnt/228932/domains/rclone copy /nfs/c10/h10/mnt/228932/domains/fitaf570.com/html/doc "gd:/lance/Fit AF/"

its not a bash nor sh script.

example:

root@s163042:# bash /usr/bin/rclone
/usr/bin/rclone: : cannot execute binary file
root@s163042:# echo $?
126

and i'd stick with "/nfs/c10/h10/mnt/228932/domains/rclone -V" for testing because that is simple and doesn't rely on a 'remote'.

Oh, I had seen that on another forum, but I guess it wasn't about a binary... so with the relevant error code changing, does that change your instincts on how to debug further?

I'm not sure where to go from here. But this should return zero. Whats the output and return code of this.

exec('/nfs/c10/h10/mnt/228932/domains/rclone -V 2>&1',$out,$retCode);

If they have safemode on in PHP, you'll only be able to execute files within the [safe_mode_exec_dir].

You can check like this I think. (although that's gone in php6)

if( ini_get('safe_mode') ){
// safe mode is on
}else{
// it's not
}

Return String

runtime/asm_amd64.s:214 +0x125 fp=0x7ffe7b5a40b8 sp=0x7ffe7b5a40b0 pc=0x4655e5

$out

Array ( [0] => fatal error: failed to reserve page summary memory [1] => [2] => runtime stack: [3] => runtime.throw(0x199dffa, 0x25) [4] => runtime/panic.go:1116 +0x72 fp=0x7ffe7b5a3f48 sp=0x7ffe7b5a3f18 pc=0x434bc2 [5] => runtime.(*pageAlloc).sysInit(0x2a1a128) [6] => runtime/mpagealloc_64bit.go:80 +0x17e fp=0x7ffe7b5a3fd8 sp=0x7ffe7b5a3f48 pc=0x42a58e [7] => runtime.(*pageAlloc).init(0x2a1a128, 0x2a1a120, 0x2a2f3f8) [8] => runtime/mpagealloc.go:297 +0x75 fp=0x7ffe7b5a4000 sp=0x7ffe7b5a3fd8 pc=0x4281e5 [9] => runtime.(*mheap).init(0x2a1a120) [10] => runtime/mheap.go:694 +0x274 fp=0x7ffe7b5a4028 sp=0x7ffe7b5a4000 pc=0x425404 [11] => runtime.mallocinit() [12] => runtime/malloc.go:470 +0xff fp=0x7ffe7b5a4058 sp=0x7ffe7b5a4028 pc=0x40b61f [13] => runtime.schedinit() [14] => runtime/proc.go:545 +0x60 fp=0x7ffe7b5a40b0 sp=0x7ffe7b5a4058 pc=0x4382e0 [15] => runtime.rt0_go(0x7ffe7b5a40e8, 0x2, 0x7ffe7b5a40e8, 0x0, 0x0, 0x2, 0x7ffe7b5a47a2, 0x7ffe7b5a47c9, 0x0, 0x7ffe7b5a47cc, ...) [16] => runtime/asm_amd64.s:214 +0x125 fp=0x7ffe7b5a40b8 sp=0x7ffe7b5a40b0 pc=0x4655e5 )

$retCode = 2

As far as safe mode goes, a quick google confirms that you're right about it being removed. I'm running version 7. But, also, if I'm able to execute the .sh we made, wouldn't that have ruled out that consideration already? Or might there be some feature which classifies .sh and binaries differently?

[0] => fatal error: failed to reserve page summary memory
[1] => 
[2] => runtime stack: 
[3] => runtime.throw(0x199dffa, 0x25) 
[4] => runtime/panic.go:1116 +0x72 fp=0x7ffe7b5a3f48 sp=0x7ffe7b5a3f18 pc=0x434bc2 
[5] => runtime.(*pageAlloc).sysInit(0x2a1a128) 
[6] => runtime/mpagealloc_64bit.go:80 +0x17e fp=0x7ffe7b5a3fd8 sp=0x7ffe7b5a3f48 pc=0x42a58e 
[7] => runtime.(*pageAlloc).init(0x2a1a128, 0x2a1a120, 0x2a2f3f8) 
[8] => runtime/mpagealloc.go:297 +0x75 fp=0x7ffe7b5a4000 sp=0x7ffe7b5a3fd8 pc=0x4281e5 
[9] => runtime.(*mheap).init(0x2a1a120) 
[10] => runtime/mheap.go:694 +0x274 fp=0x7ffe7b5a4028 sp=0x7ffe7b5a4000 pc=0x425404 
[11] => runtime.mallocinit() 
[12] => runtime/malloc.go:470 +0xff fp=0x7ffe7b5a4058 sp=0x7ffe7b5a4028 pc=0x40b61f 
[13] => runtime.schedinit() 
[14] => runtime/proc.go:545 +0x60 fp=0x7ffe7b5a40b0 sp=0x7ffe7b5a4058 pc=0x4382e0 
[15] => runtime.rt0_go(0x7ffe7b5a40e8, 0x2, 0x7ffe7b5a40e8, 0x0, 0x0, 0x2, 0x7ffe7b5a47a2, 0x7ffe7b5a47c9, 0x0, 0x7ffe7b5a47cc, ...) 
[16] => runtime/asm_amd64.s:214 +0x125 fp=0x7ffe7b5a40b8 sp=0x7ffe7b5a40b0 pc=0x4655e5 )`
~                                                                                                                                             

There ya go. Its executing. and crashing. I wonder if its php limiting memory. increase it in your php.ini

memory_limit = 500M

(or your hosting provider may be able to help you with increasing it. Will likely need more than that depending on what you're copying)

My memory limit was 1024M. I increased to 10240M with no change. The file I'm attempting to push up is only 32K...

I can get the same error playing with ulimit

so

$ ulimit -v 1024000
ncw@dogger:~$ rclone version
rclone v1.52.1-070-g4ac08f98-vfs-beta
- os/arch: linux/amd64
- go version: go1.14.3
$ ulimit -v 500000
$ rclone version
fatal error: failed to reserve page summary memory

runtime stack:
runtime.throw(0x217bc1a, 0x25)
	/opt/go/go1.14/src/runtime/panic.go:1116 +0x72 fp=0x7ffc78982558 sp=0x7ffc78982528 pc=0xbfa162
runtime.(*pageAlloc).sysInit(0x315a248)
	/opt/go/go1.14/src/runtime/mpagealloc_64bit.go:80 +0x17e fp=0x7ffc789825e8 sp=0x7ffc78982558 pc=0xbefb2e
runtime.(*pageAlloc).init(0x315a248, 0x315a240, 0x316f5d8)
	/opt/go/go1.14/src/runtime/mpagealloc.go:297 +0x75 fp=0x7ffc78982610 sp=0x7ffc789825e8 pc=0xbed785
runtime.(*mheap).init(0x315a240)
	/opt/go/go1.14/src/runtime/mheap.go:694 +0x274 fp=0x7ffc78982638 sp=0x7ffc78982610 pc=0xbea9a4
runtime.mallocinit()
	/opt/go/go1.14/src/runtime/malloc.go:470 +0xff fp=0x7ffc78982668 sp=0x7ffc78982638 pc=0xbd0bbf
runtime.schedinit()
	/opt/go/go1.14/src/runtime/proc.go:545 +0x60 fp=0x7ffc789826c0 sp=0x7ffc78982668 pc=0xbfe580
runtime.rt0_go(0x7ffc789827d8, 0x2, 0x7ffc789827d8, 0x1c85960, 0x7fa2d37f50b3, 0x7fa2d3a33620, 0x7ffc789827d8, 0x200000000, 0xc2b760, 0x1c85960, ...)
	/opt/go/go1.14/src/runtime/asm_amd64.s:214 +0x125 fp=0x7ffc789826c8 sp=0x7ffc789826c0 pc=0xc2b895

So it looks like the ulimit for virtual memory needs to be increased. 1GB of virtual memory sounds like a lot, but rclone won't actually use that much memory it will only use a few 10s of MB of memory. The go runtime likes to allocate lots of virtual memory which it never uses :man_shrugging:

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.