View Single Post
Old 11-04-2022, 06:58 PM   #1
elinkser
Groupie
elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.
 
Posts: 185
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
*** SECURITY REMINDER ***
You are browsing as root on an outdated kernel that is not likely to see timely security patches.
You should at least create a non-root user (e.g. using adduser), but they would need permission to use the framebuffer i.e. FBInk, if they want to use the graphical image viewer feature.

To create a user 'fbuser' with framebuffer access you can do the following:
adduser fbuser
addgroup fbgroup
adduser fbuser fbgroup
chgrp fbgroup /dev/fb0
But it looks like you have to redo that last chgrp command each session.
Furthermore, Kobo seems to have disallowed write access to /mnt/onboard to anyone but root, so other users cannot save bookmarks to .elinks/ but they can at least save downloads to the /tmp directory (of course you then have to copy them as root to a more permanent location).

*NOTE*
You can edit the "umask 002" line in /etc/init.d/rcS to "umask 000" allow all user write access to the /mnt/onboard partition, but that would defeat the security objective.
You can't have fine-grained access permission because it is a vfat format.
When you create a user with "adduser bla", a /home/bla directory is created on the root partition, which DOES have fine-grained access controls, as you can see by running "ls -l /home".
But the root partition doesn't have much free space, only about 60MB, as you can see by running "df".
So you may prefer "adduser bla -d /mnt/onboard/.adds/koreader/home/bla" to put the home directory on the /mnt/onboard partition which has many GB of free space, which the user won't be able to write to, but at least it doesn't use up valuable root partition space.
In retrospect I should have crosscompiled using "--prefix=/mnt/onboard/.adds/koreader/templib" on my desktop instead of "--prefix=$HOME/Downloads/mykobossh/templib", so I wouldn't have to use up valuable root partition space with all the certificates, as you will see.

The links near the bottom of this post point to an alternative approach using a chroot. Clara HD owners also have the option to pull out the SD card and shrink the /mnt/onboard partition with a disk utility, then creating a new /home partition that is writable by non-root users. But non-Clara owners can still create a /home partition in an image file, as was done here, (but no need to create root file system - just format it and mount it.)


**EDIT - Comment #3 has another way to get elinks by copying and may be easier.


Otherwise:
1.Back up your SD card.
2.Don't use your Kobo for sensitive info including passwords.
3.Don't browse to unsafe sites.
Or just use Firefox on your desktop to save complete webpage with image folder, or print to pdf on your cellphone, these can be webserved to your Kobo for secure graphic browsing using KOReader!
As mentioned here
***



HOW TO CROSSCOMPILE ELINKS AND WGET FOR THE KOBO CLARA HD (using linux desktop).
---
First, follow the instructions here to determine the crosscompile tool for your device. For the Kobo Clara HD, it is gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz.
Download this and source packages for openssl, elinks, and wget to $HOME/Downloads/mykobossh/.
---
To build OPENSSL:
(see also)
cd
cd Downloads/mykobossh/
tar xJf gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz
export PATH=$PWD/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin:$PATH
tar zxvf openssl-1.1.1s.tar.gz
cd openssl-1.1.1s/
mkdir $HOME/Downloads/mykobossh/templib
./Configure gcc -static -no-shared --prefix=$HOME/Downloads/mykobossh/templib --cross-compile-prefix=arm-linux-gnueabihf-
make
make install
cd ..
---
To build ELINKS:
(see also)
tar zxvf elinks-0.15.1.tar.gz
cd elinks-0.15.1/
./autogen.sh
./configure --help
./configure --host=arm-linux-gnueabihf --enable-own-libc --enable-sm-scripting --disable-nls --disable-xbel --disable-ipv6 --disable-leds --disable-backtrace --with-static --without-zlib --without-bzlib --without-gnutls --with-openssl=$HOME/Downloads/mykobossh/templib CPPFLAGS="-I$HOME/Downloads/mykobossh/templib/include" LDFLAGS="-L$HOME/Downloads/mykobossh/templib/lib"
make
cp src/elinks ../elinks111s
cd ..
---
DEVICE:
Copy elinks111s to .adds/koreader/scripts directory on Kobo Clara HD.
Run KOReader and connect to WIFI on Clara HD.
Open Terminal Emulator and you will see elinks111s in working directory (/mnt/onboard/.adds/koreader/scripts).
chmod +x elinks111s
elinks111s
(enter "mobileread.mobi/forums/")
(keep pressing return key if get ssl error message)


***EDIT***
It helps to copy certificates to a $HOME/Downloads/mykobossh/templib/ssl/certs directory that you must create on your Kobo, where $HOME is /home/user, or whatever your desktop home directory was.
I got certificates from my desktop /usr/share/ca-certificates/mozilla directory, but your case may differ. Also, a heavy page like amazon might stall, but I press q then cancel and it seems to get going again!

*Update-wget seems to handle certs differently. A workaround might be to copy the ca-certificates.crt file from your desktop (mine was in /etc/ssl/certs) to the above directory, and let wget know by creating a .wgetrc file in /mnt/onboard/.adds/koreader with the single line:
ca_certificate=/home/user/Downloads/mykobossh/templib/ssl/certs/ca-certificates.crt

(or wherever you saved it).

** Update-Courtesy of qkqw's post, here is another source of Mozilla CA certificates from the Curl website.

***


Press Esc key and down arrow key to get menu and key codes.
Use spacebar for pagedown and 'b' for pageup, 'g' followed by '.' to browse local filesystem.
Press q (followed by return key) to quit
---
NiLuJe's FBInk can be configured as an image viewer for elinks, except the image gets quickly overwritten.
But it is there long enough to decide if you want to download it.
Turns out I had to not use the FBInk that came with my installed KOReader but to download it separately from here.
EDIT elinks.conf FILE IN .elinks/ (TO CONFIGURE fbink AS IMAGE VIEWER):
set document.browse.images.display_style = 1
set document.browse.images.filename_maxlen = 50
set document.browse.images.image_link_tagging = 2
set document.browse.images.show_as_links = 1
set mime.extension.jpg="image/jpeg"
set mime.extension.jpeg="image/jpeg"
set mime.extension.png="image/png"
set mime.extension.gif="image/gif"
set mime.extension.bmp="image/bmp"
set mime.extension.pnm="image/pnm"
set mime.handler.image_viewer.unix.ask = 1
set mime.handler.image_viewer.unix-xwin.ask = 0
set mime.handler.image_viewer.unix.block = 1
set mime.handler.image_viewer.unix-xwin.block = 0
set mime.handler.image_viewer.unix.program = "/mnt/onboard/.adds/koreader/scripts/fbink -g file=%"
set mime.handler.image_viewer.unix-xwin.program = "/mnt/onboard/.adds/koreader/scripts/fbink -g file=%"
set mime.type.image.jpg = "image_viewer"
set mime.type.image.jpeg = "image_viewer"
set mime.type.image.png = "image_viewer"
set mime.type.image.gif = "image_viewer"
set mime.type.image.bmp = "image_viewer"
set mime.type.image.pnm = "image_viewer"
---

*EDIT*
Actually "fbink -G -g file=% ;sleep 2" keeps the image longer. I tried appending 2>/dev/null but that only helps outside of elinks.
*You need that space between "%" and ";" for some reason.
Another option is:
"fbink -G -y 30 -g file=% ;sleep 2"
Which keeps the image to the lower part of the display, so it doesn't get overwritten.
---
To build WGET:
(see also)
tar zxvf wget-1.21.tar.gz
cd wget-1.21/
./configure --help
env CPPFLAGS="-I$HOME/Downloads/mykobossh/templib/include" LDFLAGS="-L$HOME/Downloads/mykobossh/templib/lib" ./configure --with-ssl=openssl --with-libssl-prefix=$HOME/Downloads/mykobossh/templib --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --disable-nls --disable-ipv6 --without-zlib
make CPPFLAGS="-I$HOME/Downloads/mykobossh/templib/include" LDFLAGS="-L/$HOME/Downloads/mykobossh/templib/lib -static"
cp src/wget ../wget111s
DEVICE:
Copy wget111s to .adds/koreader/scripts directory on Kobo Clara HD.
Run KOReader and connect to WIFI on Clara HD.
Open Terminal Emulator and you will see wget111s in working directory (/mnt/onboard/.adds/koreader/scripts).
chmod +x wget111s
wget111s google.com
ls index.html
Here is a more sophisticated use:
***NOTE THE VERY IMPORTANT OPTION '-Q50M' WHICH LIMITS DOWNLOAD TO 50MB !!!***
(this is to keep you from inadvertently "downloading the internet")
wget111s --no-check-certificate --no-parent -k -nd -D www.mobileread.mobi -E -r -A jpg,jpeg,png,gif,htm.html -l1 -Q50M -P ./mywgets/ www.mobileread.mobi/forums/
------


THE NEXT SECTIONS ARE OPTIONAL, IF YOU WANT AN ASCIIVIEW IMAGE VIEWER.
*It is for ascii images - not high resolution images, from when I could not get NiLuJe's FBInk to work within elinks. So this is mostly just a fun substitute!

Spoiler:


To build NCURSES:
(see also)
tar zxvf ncurses-6.3.tar.gz
cd ncurses-6.3/
mkdir $HOME/Downloads/mykobossh/curselib
./configure --help
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ ./configure --with-static --with-shared --with-cxx-shared --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --host=i686-pc-linux --without-ada --without-gpm --without-sysmouse --enable-widec --disable-big-core --with-build-cc=gcc --prefix=$HOME/Downloads/mykobossh/curselib
make
make install
copy libncurses.so.6.3 to libncurses.so and libncurses.so.6.
copy libncursesw.so.6.3 to libncursesw.so and libncursesw.so.6.
Copy libs to .adds/koreader/libs directory on Kobo Clara HD.
cd ..
---
To build AALIB:
tar zxvf aalib-1.4rc4.tar.gz
cd aalib-1.4.0/
mkdir $HOME/Downloads/mykobossh/aalib
./configure --help
CC="arm-linux-gnueabihf-gcc" CPPFLAGS="-I$HOME/Downloads/mykobossh/curselib/include/ncurses" LDFLAGS="-L$HOME/Downloads/mykobossh/curselib/lib" ./configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --with-x11-driver=no --with-slang-driver=no --with-curses-driver=yes --with-ncurses=$HOME/Downloads/mykobossh/curselib --prefix=$HOME/Downloads/mykobossh/aalib
make
make install
Copy aafire, aaflip, aainfo,and aatest to .adds/koreader/scripts directory on Kobo Clara HD.
copy libaa.so.1.0.4 to libaa.so, libaa.so.1, and libaa.so.1.0.
Copy libs to .adds/koreader/libs directory on Kobo Clara HD.
cd ..
---
To build ASCIIVIEW:
tar zxvf aview-1.3.0rc1.tar.gz
cd aview-1.3.0/
./configure --help
CC="arm-linux-gnueabihf-gcc" CPPFLAGS="-I$HOME/Downloads/mykobossh/curselib/include/ncurses" LDFLAGS="-L$HOME/Downloads/mykobossh/curselib/lib" ./configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --with-aalib-prefix=$HOME/Downloads/mykobossh/aalib
make
Copy aview and asciiview to .adds/koreader/scripts directory on Kobo Clara HD.
cd ..
---
To extract NETPBM:
From http://archive.debian.org/debian-arc...ian/pool/main/, download and rename extension from .deb to .tgz the following:
/x/xz-utils/liblzma5_5.1.1alpha+20120614-2_armhf.deb
/j/jbigkit/libjbig0_2.1-3.1_armhf.deb
/t/tiff/libtiff5_4.0.3-12.3+deb8u5_armhf.deb
/libp/libpng/libpng12-0_1.2.50-2+deb8u3_armhf.deb
/libj/libjpeg-turbo/libjpeg62-turbo_1.3.1-12_armhf.deb
/z/zlib/zlib1g_1.2.8.dfsg-2+b1_armhf.deb
/n/netpbm-free/libnetpbm10_10.0-15.2_armhf.deb
/n/netpbm-free/netpbm_10.0-15.2_armhf.deb
From the .tgz files, extract the following libs (replacing symlinks with actual copies of the symlinked file as in aalib example) , and copy all libs to .adds/koreader/libs directory on Kobo Clara HD:
libjbig.so.0
libjpeg.so.62, libjpeg.so.62.1.0
liblzma.so.5, liblzma.so.5.0.0
libnetpbm.so.10,libnetpbm.so.10.0
libpng12.so.0, libpng12.so.0.50.0
libtiff.so.5, libtiff.so.5.2.0
libz.so.1, libz.so.1.2.8
From the .tgz files, extract the following bins/scripts , and copy all files to .adds/koreader/scripts directory on Kobo Clara HD:
anytopnm, bmptopnm, giftopnm. jpegtopnm, pngtopnm, pnmtojpeg, pnmtopng, pnmtotiff, tifftopnm
---
EDIT elinks.conf FILE IN .elinks/ (TO CONFIGURE asciiview instead of fbink AS IMAGE VIEWER). Modify only these lines:
set mime.handler.image_viewer.unix.program = "sh /mnt/onboard/.adds/koreader/scripts/asciiview %"
set mime.handler.image_viewer.unix-xwin.program = "sh /mnt/onboard/.adds/koreader/scripts/asciiview %"
---
Dependencies requirements were obtained from:
http://archive.debian.org/debian-arc...hf/Packages.xz
***YOU MUST ALSO CREATE .terminfo/ DIRECTORY IN .adds/koreader/ AND COPY TERMINFO FILES FROM /n/ncurses/ncurses-base_5.9+20140913-1+deb8u3_all.deb***
(Rename to .tgz extension and extract as before. Copy the /v directory to your .terminfo/ directory on your Kobo, or the asciiview program will abort with "Error opening terminal: vt52.")

---



Finally, if you have gotten this far and said, whew, that was a lot, then "HOWTO Create your own native development environment on your Kobo!" might be making a lot more sense now!

*EDIT:Looks like graphical browser with Xorg is also available via chroot. Extra Clara HD config steps on post #46..

So there you have an almost graphical browser.
*Actually, if you use wget (the real one you compiled above, or maybe the cURL binary installed from NiLuJe's kobostuff package - not the stripped-down one that comes with KOReader) you can with a little practice download a page WITH images and that can be opened WITH IMAGES(if they are local, like saved as complete webpage by Firefox) in KOReader for a graphical view!

Last edited by elinkser; 04-24-2023 at 02:51 PM. Reason: alt install
elinkser is offline   Reply With Quote