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

ITP: sid - Run commands in your /sid chroot



Well not really, but I am using a program called 'sid' for some years
now, and I thought I would share it with you.

sid is a straight-forward wrapper that do 'chroot /sid' that does not
get in the way as dchroot does (IMHO), since it does not take options
and preserve the environment, cwd, etc, and is faster to type.

Compile it, install it suid root, and go. This assume your chroot is
called /sid, though you can change CHROOT_PATH. Obviously you can
also call it 'sarge' or 'ia32'. 

Some usage:
sid                         - run $SHELL is the chroot
sid gimp                    - run gimp 2.2 instead of gimp 1.2 
LANG=eo_EO sid update-menus --help
                            - Test the new update-menus help text in Esperanto
sid /etc/init.d/apache      - start apache running in the chroot
sid apt-get upgrade         - upgrade your chroot.
CC=gcc-3.4 sid ./configure && sid make
                            - test compilation with gcc-3.4

I usually include a symlink /sid/sid ->/, so I can also do
sid /sid/etc/init.d/apache
which take advantage of shell completion.

Cheers,
-- 
Bill. <ballombe@debian.org>

Imagine a large red swirl here. 

----------------------------
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#define CHROOT_PATH "/sid/"
#define LEN_CHROOT_PATH strlen(CHROOT_PATH)

void die(char *s)
{
  fprintf(stderr,"sid (%s): %s\n",s,strerror(errno));
  exit(1);
}
int
main(int argc, char **argv )
{
  char *shell;
  if (chroot(CHROOT_PATH)) die("chroot");
  if (seteuid(getuid())) die("seteuid");
  /*Now most security problem are ended.*/
  if (argc>1)
    if (execvp(argv[1],argv+1)) die("execv");
  if (!(shell=getenv("SHELL"))) die("shell");
    if (execl(shell,shell,NULL)) die("execv");
  return 0;
}



Reply to: