Re: `jq` won't chroot?

2021-07-17 Thread Stuart Henderson
On 2021-07-17, Kent Watsen  wrote:
> Thanks Theo!
>
>
>> It seems you copied libjq and libonig into usr/local/lib in the chroot.
>> By default, ld.so only looks for shared objects in /usr/lib, so it can't
>> find them.
>> 
>> # env LD_LIBRARY_PATH=/usr/lib:/usr/local/lib chroot /var/www 
>> /usr/local/bin/jq --version
>> 
>> should work.
>
> Indeed it did.  Shorter:
>
> env LD_LIBRARY_PATH='/usr/local/lib:$LD_LIBRARY_PATH' /usr/local/bin/jq 
> --version
>
>
>> Chrooting to / works because rc(8) runs ldconfig(8) to add
>> /usr/local/lib and /usr/X11R6/lib if they're present.
>> 
>> You can copy all the libraries into /var/www/usr/lib, you can set
>> LD_LIBRARY_PATH=/usr/local/lib:/usr/, or you can run ldconfig in the
>> chroot.
>> 
>> Read ld.so(1) and ldconfig(8)for more details.
>
> Yes, setting `ldconfig -n /usr/local/lib` is a more sticky option.  
>
> The `env` approach seems best when just one `jq` command, whereas the 
> `ldconfig` approach seems better when there is more than one `jq` command...

Copying the various libraries to /var/www/usr/lib is pretty
straightforward. Remember they might need updating, I copy them from
rc.local so I don't forget.




Re: `jq` won't chroot?

2021-07-16 Thread Kent Watsen
Thanks Theo!


> It seems you copied libjq and libonig into usr/local/lib in the chroot.
> By default, ld.so only looks for shared objects in /usr/lib, so it can't
> find them.
> 
> # env LD_LIBRARY_PATH=/usr/lib:/usr/local/lib chroot /var/www 
> /usr/local/bin/jq --version
> 
> should work.

Indeed it did.  Shorter:

env LD_LIBRARY_PATH='/usr/local/lib:$LD_LIBRARY_PATH' /usr/local/bin/jq 
--version


> Chrooting to / works because rc(8) runs ldconfig(8) to add
> /usr/local/lib and /usr/X11R6/lib if they're present.
> 
> You can copy all the libraries into /var/www/usr/lib, you can set
> LD_LIBRARY_PATH=/usr/local/lib:/usr/, or you can run ldconfig in the
> chroot.
> 
> Read ld.so(1) and ldconfig(8)for more details.

Yes, setting `ldconfig -n /usr/local/lib` is a more sticky option.  

The `env` approach seems best when just one `jq` command, whereas the 
`ldconfig` approach seems better when there is more than one `jq` command...


Thanks!

K.



Re: `jq` won't chroot?

2021-07-16 Thread Theo Buehler
On Fri, Jul 16, 2021 at 10:24:10PM +, Kent Watsen wrote:
> I’ve spent a few hours on this and am lost.  I have plenty experience moving 
> executables into a chroot environments, but `jq` is proving to be 
> exceptionally difficult.
> 
> The executable is found when chrooted to ‘/‘ but not ' /var/www’.  Yes, of 
> course I copied all the files referenced from `ldd` into the chroot, and set 
> their file permissions to 777 (and likewise all the parent directories):
> 
> # pkg_add jq
> 
> # chroot / /usr/local/bin/jq --version 
> jq-1.6
> 
> *** COPY `ldd /usr/local/bin/jq` DEPENDENCIES INTO  /var/www/ HERE ***
> 
> # chroot /var/www /usr/local/bin/jq --version  
> ld.so: jq: can't load library 'libonig.so.7.1’
> 
> 
> Any ideas?

It seems you copied libjq and libonig into usr/local/lib in the chroot.
By default, ld.so only looks for shared objects in /usr/lib, so it can't
find them.

# env LD_LIBRARY_PATH=/usr/lib:/usr/local/lib chroot /var/www /usr/local/bin/jq 
--version

should work.

Chrooting to / works because rc(8) runs ldconfig(8) to add
/usr/local/lib and /usr/X11R6/lib if they're present.

You can copy all the libraries into /var/www/usr/lib, you can set
LD_LIBRARY_PATH=/usr/local/lib:/usr/, or you can run ldconfig in the
chroot.

Read ld.so(1) and ldconfig(8) for more details.



Re: `jq` won't chroot?

2021-07-16 Thread Kent Watsen
Easy button for putting all the dependency files into the chroot:

# for f in `ldd /usr/local/bin/jq  | grep '0' | awk '{print $7}'`; do  
d=`dirname $f | sed 's#^/##’`   
 
mkdir -p /var/www/$d
 
cp $f /var/www/$d/  
 
done

K.


> On Jul 16, 2021, at 6:24 PM, Kent Watsen  wrote:
> 
> I’ve spent a few hours on this and am lost.  I have plenty experience moving 
> executables into a chroot environments, but `jq` is proving to be 
> exceptionally difficult.
> 
> The executable is found when chrooted to ‘/‘ but not ' /var/www’.  Yes, of 
> course I copied all the files referenced from `ldd` into the chroot, and set 
> their file permissions to 777 (and likewise all the parent directories):
> 
> # pkg_add jq
> 
> # chroot / /usr/local/bin/jq --version 
> jq-1.6
> 
> *** COPY `ldd /usr/local/bin/jq` DEPENDENCIES INTO  /var/www/ HERE ***
> 
> # chroot /var/www /usr/local/bin/jq --version  
> ld.so: jq: can't load library 'libonig.so.7.1’
> Killed
> 
> Any ideas?
> 
> K.
> 



`jq` won't chroot?

2021-07-16 Thread Kent Watsen
I’ve spent a few hours on this and am lost.  I have plenty experience moving 
executables into a chroot environments, but `jq` is proving to be exceptionally 
difficult.

The executable is found when chrooted to ‘/‘ but not ' /var/www’.  Yes, of 
course I copied all the files referenced from `ldd` into the chroot, and set 
their file permissions to 777 (and likewise all the parent directories):

# pkg_add jq

# chroot / /usr/local/bin/jq --version 
jq-1.6

*** COPY `ldd /usr/local/bin/jq` DEPENDENCIES INTO  /var/www/ HERE ***

# chroot /var/www /usr/local/bin/jq --version  
ld.so: jq: can't load library 'libonig.so.7.1’


Any ideas?

K.