[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [linux-team] setuid program
- To: linux-team@rtfm.be
- Subject: Re: [linux-team] setuid program
- From: Pascal Bleser <pbleser@atos-group.com>
- Date: Wed, 17 Nov 1999 10:07:49 +0100
- In-reply-to: <mnet1.942826135.8579.vincent.louviaux@netcourrier.com>; from vincent.louviaux@netcourrier.com on Wed, Nov 17, 1999 at 09:09:15AM +0100
- Mail-followup-to: linux-team@rtfm.be
- Organisation: LinuxBe.org
- References: <mnet1.942826135.8579.vincent.louviaux@netcourrier.com>
- Reply-to: linux-team@rtfm.be
- Sender: owner-linux-team@rtfm.be
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/