[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: [linux-team] setuid program



si je suis ton raisonnement il suffit de copier le shell et de mettre +s

mais ca ne marche pas

$ ll vincent_ksh
-r-sr-s---   1 load   dgr      159744 Nov 17 08:29 vincent_ksh
$ ll sleep*
-rw-r-----   1 load   dgr           9 Nov 17 08:33 sleep5
$ whoami
id97
$ ./vincent_ksh sleep5 &
[1]     22146
$ ps -f
     UID   PID  PPID  C    STIME TTY       TIME COMMAND
    id97 22146 22109  2 08:36:01 ttyp4     0:00 ./vincent_ksh sleep5
    id97 22109 22108  0 08:34:37 ttyp4     0:00 -ksh
    id97 22148 22109  3 08:36:04 ttyp4     0:00 ps -f
    root 22108  1445  0 08:34:37 ttyp4     0:00 telnetd
    id97 22147 22146  2 08:36:01 ttyp4     0:00 sleep 60

je pense que le lanceur doit faire appel à la fonction "setuid"
je me trompe ?

>-----Message d'origine-----
>Date: Wed, 17 Nov 1999 10:07:49 +0100
>De: Pascal Bleser <pbleser@atos-group.com>
>A: linux-team@rtfm.be
>Sujet: Re: [linux-team] setuid program
>
>On Wed, Nov 17, 1999 at 09:09:15AM +0100, vincent.louviaux@netcourrier.com wrote:
>> je voudrais qu un autre utilisateur lance un de mes program mais que je suis le owner du process
>> 
>> je sais qu il faut le "set-owner-id" bit et que le program a besoin de faire un "setuid"
>> 
>> et comme il y a longtemps et que je ne suis pas expert en C, je me demandais si vous ne pourrriez pas m aider à réaliser ce petit program (setuid + prend en argument le program à lancer)
>
>En fait, il y a bien plus facile:
>
>chown moi.groupe programme
>chmod u=rxs,g=rx,o= programme
>
>(à faire depuis le shell en tant que root)
>
>Remplace "moi" par ton acompte et "groupe" par un groupe d'utilisateur(s) autorisé(s)
>à éxécuter ce programme sur ton acompte.
>
>Voilà, that's it ;-))
>
>NB: ça ne marche pas pour des scripts (perl, bash, python, ...) - c'est refusé par le kernel
>    pour des raisons de sécurité (facile à modifier, un script, si on n'a pas fait attention
>	 au niveau des droits d'accès) - dans ce cas, il suffit d'écrire un petit "wrapper" en C
>	 qui ne fait rien d'autre que d'éxécuter le script:
>
>	 #include <unistd.h>
>	 #include <stdio.h>
>	 /* remplace ici par le chemin _complet_ vers ton programme */
>	 static char *prog = "/usr/local/bin/programme";
>	 int main(int argc, char *argv[])
>	 {
>	 	execl(prog, prog, NULL); /* !! pas oublier le NULL comme dernier argument !! */
>		fprintf(stderr, "Execution failed\n"; /* message quand ça n'a pas marché */
>		return 1; /* retourner un code d'erreur (0=ok, autre chose=erreur) */
>	 }
>
>    Voilà, tu compiles ça avec:
>	 cc -o prog.wrap prog.wrap.c
>    Encore un petit
>	 strip prog.wrap
>	 pour le "rapetisser", et tu appliques les commandes suid sur le wrapper:
>
>	 chown moi.groupe prog.wrap
>	 chmod u=rxs,g=rx,o= prog.wrap
>
>Voilà... encore des questions ? :))
>
>-- 
>  -o) / Pascal Bleser          ATOS Payment Systems|
>  /\\ \ C++/UNIX Development        Aachen, Germany|
> _\_v  \<guru@linuxbe.org> <pbleser@atos-group.com>|
>---------------------------------------------------|
>A consultant is a person who borrows your watch,   :
>tells you what time it is, pockets the watch, and  :
>sends you a bill for it.                           :
>---------------------------------------------------'
>
>---------
>Visit the Linux Supertore Online: http://www.redcorp.com !
>If you want to be deleted from the list, send a mail to
>majordomo@rtfm.be with "unsubscribe linux-team" in the body.
>Archive of the list: http://tania.be.linux.org/
>
>

----- La messagerie itinérante sans abonnement NetCourrier -----
Web : www.netcourrier.com     Minitel : 3615 et 3623 NETCOURRIER
                  Tél : 08 36 69 00 21
---------
Visit the Linux Supertore Online: http://www.redcorp.com !
If you want to be deleted from the list, send a mail to
majordomo@rtfm.be with "unsubscribe linux-team" in the body.
Archive of the list: http://tania.be.linux.org/