Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 May 2000 16:13:02 +0100
From:      Ben Smithurst <ben@scientia.demon.co.uk>
To:        Arun Sharma <adsharma@sharmas.dhs.org>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: setuid for interpreted languages ?
Message-ID:  <20000508161302.F79359@strontium.scientia.demon.co.uk>
In-Reply-To: <20000507230115.A61438@sharmas.dhs.org>
References:  <20000507230115.A61438@sharmas.dhs.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Arun Sharma wrote:

> How do I make a python script, a setuid program in FreeBSD ? I have a
> py-kde based python script that needs to be setuid to read the temperature
> sensors on my ABit BP6. 
> 
> # chmod 4755 khm.py 
> 
> doesn't seem to do it.

Well, perl has "suidperl", maybe Python has something similar.
Otherwise you could make a small setuid wrapper around your script.  It
only needs to be as simple as:

#include <unistd.h>

extern char **environ;

int
main(int argc, char *argv[]) {

	argv[0] = "/path/to/khm.py";
	execve(argv[0], argv, environ);
	return (1); /* shouldn't get here */
}

Just compile that, make it setuid (root, presumably) and it should work.
I'll assume you already know the potential dangers of setuid programs.

-- 
Ben Smithurst / ben@scientia.demon.co.uk / PGP: 0x99392F7D


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000508161302.F79359>