[Buildd-tools-devel] schroot inquiry

Roger Leigh rleigh at whinlatter.ukfsn.org
Wed Apr 25 22:49:01 UTC 2007


Roger Leigh <rleigh at whinlatter.ukfsn.org> writes:

> Tim Freedom <tim_freedom at yahoo.com> writes:
>
> (your message did get to the list, BTW.)
>
>> I recently started using schroot yet there doesn't seem to be an easy
>> way to tell if one is in a schroot "session" or not.  There are no
>> environmental variables that get set (akin to SUDO_USER with sudo)
>> and as such I haven't been able to modify my prompt to indicate that
>> I'm schroot'ing.
>
> One method is to check /etc/debian_chroot.  This will only exist
> inside the chroot.

Tonight, I added support similar to sudo (on the trunk).  This is it
in action:

% schroot -c sid -- sh -c set | grep ^SCHROOT_
I: [sid-d0cbc3ad-c732-473e-90f2-36e2c0373fd1 chroot] Running command: ¡Èsh -c set¡É
SCHROOT_COMMAND='sh -c set'
SCHROOT_GID=1001
SCHROOT_GROUP=sbuild
SCHROOT_UID=1000
SCHROOT_USER=rleigh

Hopefully, this is the sort of thing you were wanting.  If not,
there's time for it to be changed if you wish.  Is this OK?

This was done simply by modifying the environment before executing the
command:

  // Add equivalents to sudo's SUDO_USER, SUDO_UID, SUDO_GID, and
  // SUDO_COMMAND.
  env.add(std::make_pair("SCHROOT_COMMAND",
                         string_list_to_string(command, " ")));
  env.add(std::make_pair("SCHROOT_USER", get_ruser()));
  env.add(std::make_pair("SCHROOT_GROUP", get_rgroup()));
  env.add("SCHROOT_UID", get_ruid());
  env.add("SCHROOT_GID", get_rgid());



Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20070425/e137aecc/attachment.pgp


More information about the Buildd-tools-devel mailing list