> > I'd like to create some accounts in RHL 7.1 that are very restrictive. Only
> > allowing a user to run a few commands like ping traceroute and exit.
> > How can I stop a user running any other command or changing the path,
> > viewing files etc.
> > Also where can I read a bit more about how user access is restricted granted
> > on shell commands etc.
> Perhaps a good start would be to make a chrooted account.
> You can let the users shell be an executable that will
> chroot to a particular directory, then chdir("/") and
> finally execute a real shell.
If you also make the users home directory owned by root
and not writeable by anybody else you should be very safe.
It could look like this:
drwxr-x--- 3 root chroot 1024 Oct 17 13:29 /home/chroot
Then use the program below as the users shell, it need to
be suid root but it only needs to be executable by the
chroot user:
-rwsr-x--- 1 root chroot 3664 Oct 17 13:26 chrootshell
I guess it would be safest to place this executable
outside the chrooted environment. Here is the code I
came up with, can anybodu spot any problems in these
lines?
#include <stdio.h>
#include <unistd.h>
static char * ENV[] =
{ "HOME=/", "PATH=/bin", "SHELL=/bin/sh", "TERM=linux" };
int main(int argc, char ** argv)
{
if (chdir("/home/chroot")||
chroot(".")||
chdir("/")) return 1;
setuid(getuid());
argv[0]="/bin/sh";
execve(argv[0],argv,ENV);
perror(argv[0]);
return 1;
Quote:}
--
Kasper Dupont