Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 16/12/2012, à 21:52

aurelien79

Chroot une application Java

Bonjour,

Je recherche a Chrooter Subsonic (une application Java de streaming de musique).

Voici la methode que j'ai utilisé :

$sudo su 

$useradd -d /home/chroot/subsonic3 -s /bin/chroot subsonic3

$nano /bin/chroot
#!/bin/bash
exec -c /usr/sbin/chroot /home/chroot/$USER /bin/bash

$cd /home/chroot/subsonic3
$mkdir bin
$cp /bin/bash bin/bash

$ldd /bin/bash
$ mkdir lib
$cp /lib/i386-linux-gnu/libtinfo.so.5 lib
$cp /lib/i386-linux-gnu/libdl.so.2 lib
$cp /lib/i386-linux-gnu/libc.so.6 lib

$su subsonic3
/usr/sbin/chroot: cannot change root directory to /home/chroot/subsonic3: Operation not permitted

J'ai suivis ce guide  Lea Linux

Je suppose que c'est une histoire de droit mais je ne vois pas où les mettre.
Pour info :

$ ll /bin/chroot
-rwxr-xr-x 1 root root 66 Dec 16 18:39 /bin/chroot*

$ll /home/chroot/ /home/chroot/subsonic3/ /home/
/home/:
total 24
drwxr-xr-x  6 root          root          4096 Dec 16 18:46 ./
drwxr-xr-x 24 root          root          4096 Dec  2 18:43 ../
drwxr-xr-x  3 subsonic3     subsonic3     4096 Dec 16 18:46 chroot/

/home/chroot/:
total 12
drwxr-xr-x 3 subsonic3 subsonic3 4096 Dec 16 18:46 ./
drwxr-xr-x 6 root      root      4096 Dec 16 18:46 ../
drwxr-xr-x 4 subsonic3 subsonic3 4096 Dec 16 19:50 subsonic3/

/home/chroot/subsonic3/:
total 16
drwxr-xr-x 4 subsonic3 subsonic3 4096 Dec 16 19:50 ./
drwxr-xr-x 3 subsonic3 subsonic3 4096 Dec 16 18:46 ../
drwxr-xr-x 2 subsonic3 subsonic3 4096 Dec 16 18:49 bin/
drwxr-xr-x 2 subsonic3 subsonic3 4096 Dec 16 19:51 lib/

Une idée ?

Apres je suppose que je devrais ajouter les librairies Java (/usr/bin/java /usr/bin/X11/java /usr/share/java /usr/share/man/man1/java.1.gz)

Hors ligne

#2 Le 17/12/2012, à 01:57

darunia_goron

Re : Chroot une application Java

Seul root peut utiliser chroot. Modifier /bin/chroot en

#!/bin/bash
sudo exec -c /usr/sbin/chroot /home/chroot/$USER /bin/bash

et ajouter subsonic3 au groupe sudo devrait palier à ton problème.

P.S. : je n'ai que lu la première moitié du message.

Dernière modification par darunia_goron (Le 17/12/2012, à 01:57)

Hors ligne

#3 Le 18/12/2012, à 19:05

aurelien79

Re : Chroot une application Java

J'ai essayé mais cela ne fonctionne pas.

$adduser subsonic3 sudo
$passwd subsonic3
$su subsonic3
[sudo] password for subsonic3: 
sudo: exec: command not found

Hors ligne

#4 Le 18/12/2012, à 20:38

darunia_goron

Re : Chroot une application Java

En effet, est-ce que ça marche avec :

#!/bin/bash
exec sudo -c /usr/sbin/chroot /home/chroot/$USER /bin/bash

?

Hors ligne

#5 Le 19/12/2012, à 22:52

aurelien79

Re : Chroot une application Java

Pas mieux et logique :

$su subsonic3
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user
            name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user
            name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
            user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
            user name|#uid] file ...

Hors ligne

#6 Le 19/12/2012, à 23:53

darunia_goron

Re : Chroot une application Java

Désolé, j'ai rédigé un peu vite sans tester (et ceux deux fois, je suis minable).

man bash a écrit :
       exec [-cl] [-a name] [command [arguments]]
              If command is specified, it replaces the shell.  No new  process
              is  created.  The arguments become the arguments to command.  If
              the -l option is supplied, the shell places a dash at the begin‐
              ning  of  the  zeroth  argument passed to command.  This is what
              login(1) does.  The -c option causes command to be executed with
              an  empty environment.  If -a is supplied, the shell passes name
              as the zeroth argument to the executed command.  If command can‐
              not  be executed for some reason, a non-interactive shell exits,
              unless the shell option execfail is enabled, in  which  case  it
              returns  failure.   An  interactive shell returns failure if the
              file cannot be executed.  If command is not specified, any redi‐
              rections take effect in the current shell, and the return status
              is 0.  If there is a redirection error, the return status is 1.

L'argument -c doit bien sûr être passé à exec et non à sudo.

La troisième fois sera-t-elle la bonne ? Essaye :

#!/bin/bash
exec -c sudo /usr/sbin/chroot /home/chroot/$USER /bin/bash

La commande est cette fois syntaxiquement correcte (contrairement aux deux fois d'avant).

Aussi, je n'en suis pas certain, mais il est probable que tu doives créer un mot de passe pour l'utilisateur subsonic3 (sudo passwd subsonic).

Hors ligne