@eeye13Allora: ora ti spiego passo passo e spero di essere chiaro.
Sulla chiavetta usb, formattata ext4, ho la toolchain, perche' non ci starebbe
sulla memoria del router. La chiavetta e' montata su
/dev/sda1(se per caso usi /dev/sda2 modifica le istruzioni opportunamente)
$ mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mtdblock2 on /overlay type jffs2 (rw,relatime,compr=zlib)
overlayfs:/overlay/bank_1 on / type overlayfs (rw,relatime,lowerdir=/,upperdir=/overlay/bank_1)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,mode=0755,size=512K)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
cgroup on /cgroups/cpumemblk type cgroup (rw,relatime,blkio,memory,cpu)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
mvfs on /tmp/mvfs type fuse.mvfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
mountd(pid5288) on /tmp/run/mountd type autofs (rw,relatime,fd=5,pgrp=5286,timeout=600,minproto=5,maxproto=5,indirect)
/dev/sda1 on /tmp/run/mountd/sda1 type ext4 (rw,relatime,data=ordered)
Come vedi l'ultima riga mostra la chiavetta regolarmente montata.
ora andiamo a vedere cosa c'e' sulla cartella m della chiavetta
$ ls -l /tmp/run/mount/sda1/m
-rw-r--r-- 1 root root 0 Jan 31 14:10 AAA-FAKE-ROOT
lrwxrwxrwx 1 user prog 7 Jan 28 15:49 bin -> usr/bin
drwxr-xr-x 2 root root 4096 Jan 31 15:39 dev
drwxr-xr-x 3 root root 4096 Feb 4 22:13 etc
drwxr-xr-x 4 root root 4096 Jan 28 16:39 home
lrwxrwxrwx 1 user prog 7 Jan 28 15:49 lib -> usr/lib
drwxr-xr-x 2 root root 4096 Nov 23 2008 proc
drwxr-xr-x 2 root root 4096 Jan 28 15:50 root
lrwxrwxrwx 1 user prog 8 Jan 28 15:49 sbin -> usr/sbin
drwxr-xr-x 2 root root 4096 Nov 23 2008 sys
drwxrwxrwx 12 root root 4096 Apr 1 13:01 tmp
drwxr-xr-x 16 root root 4096 Aug 5 2018 usr
drwxr-xr-x 3 root root 4096 Feb 3 01:53 var
Sembra proprio uguale in tutto e per tutto alla / principale....
Ma devi accertarti che abbia i files
/etc/passwd /etc/shadow /etc/groupsimili ai tuoi, altrimenti avrai problemi quando farai chroot.
Stai attento a non fare casini, sono i files di accesso!
# cp /etc/passwd /tmp/run/mountd/sda1/m/etc/passwd
# cp /etc/shadow /tmp/run/mountd/sda1/m/etc/shadow
# cp /etc/group /tmp/run/mountd/sda1/m/etc/group
Ricordati anche di creare le home directory di root e dell'utente normale
e di dare all'utente normale la proprieta' della propria home
# mkdir /tmp/run/mountd/sda1/m/root
# mkdir /tmp/run/mountd/sda1/m/home
# mkdir /tmp/run/mountd/sda1/m/home/user
# chown user.users /tmp/run/mountd/sda1/m/home/user
Bene, ora ecco il passaggio fondamentale che ti porta nell'ambiente
di compilazione, e nello stesso tempo eseguirai
ash=busybox, certo, quella "buona".
# cd /tmp/run/mountd/sda1/m
# chroot . /bin/ash
# whoami
root
Notare che il comando whoami verifica che sei nel busybox buono,
infatti nel busybox di default avresti un whoami: not found
Ora ti consiglio di cambiare utente per evitare casini e poi
prova a vedere se il compilatore funziona
# su user
$ gcc
rawgcc: no input files
Tutto ok, puoi iniziare a compilare. Ah ancora una cosa...
in alcuni casi e' richiesto il character device /dev/null
e visto che manca nella chroot, lo devi ricreare.
ATTENZIONE: VERIFICA DI ESSERE NEL CHROOT!
# mknod /dev/null c 1 3
# chmod 666 /dev/null
# ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Jan 31 14:39 /dev/null
Ricordati poi che una volta compilato il pacchetto dovrai
trasferire l'eseguibile fuori dal chroot, ovvero:
esci da tutte le shell e torna all'ambiente originario (non chroot)
# cp /tmp/run/mountd/sda1/m/home/user/tinyproxy-1.10.0/src/tinyproxy /usr/local/bin
# cp /tmp/run/mountd/sda1/m/home/user/tinyproxy-1.10.0/etc/tinyproxy.conf /usr/local/etc/tinyproxy
Bene.... siamo arrivati alla fine,
ricordati di aggiungere alla configurazione
BasicAuth nomeutente password e le altre cose
scritte nel mio post precedente e di avviare tinyproxy da root
cosi' puo' cambiarsi utente in nobody/nogroup
o qualsiasi altro utente specificato nella configurazione.
NON PUOI SBAGLIARE!