LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 03-24-2006, 06:10 PM   #1
websinger
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: LMDE-2 3.11.2amd64
Posts: 35

Rep: Reputation: 15
finding a test for *chroot*- edness


Hi;
I've built a chroot to hold the 32 bit apps and libraries that don't have 64 bit counterparts (yet) on my AMD64x2 box. Is there a command line test that i could script into my .bashrc file and change my $PS= value and change my prompt if Im chrooted ?

thanks

Jeff
 
Old 03-24-2006, 06:29 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Dunno but here's some code to show/check you're chrooted:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>

int main(int argc, char **argv) {
  struct stat x;

  if (stat("/", &x)) {
    printf("Unable to stat /");
    exit(EXIT_FAILURE);
  }

  if (x.st_ino==2) {
    printf("NOT chrooted\n");
  } else {
    printf("chrooted OK\n");
  }
  exit(EXIT_SUCCESS);
}
As you see, basically check if the toplevel dir inode number equals "2".
 
Old 03-24-2006, 06:38 PM   #3
websinger
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: LMDE-2 3.11.2amd64
Posts: 35

Original Poster
Rep: Reputation: 15
re: chrooted-ness

thanks I'll try it. I just found the chroot doesn't
have a /lib64 dir (duh :-) ) so I can test for that.
but I just found that my PS1 code in .bashrc has been modified
with a "${ debian_chroot } reference so I'll be researching that as well :-) "theres a world of education in these strange boxes"

thanks again

Jeff
 
Old 03-24-2006, 07:55 PM   #4
websinger
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: LMDE-2 3.11.2amd64
Posts: 35

Original Poster
Rep: Reputation: 15
here's the scoop - chroot modifies the $PS1 ( prompt ) code in the .bashrc file in your home directory so as to insert the contents of the /etc/debian_chroot file into the front of your prompt ($PS1). So all I needed to do was to put some informative text in the /etc/debian_chroot file, .bashrc tests for the existence of the /etc/debian_chroot file and changes the prompt appropriately.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 10:30 AM
Cannot chroot aznluvsmc Linux - Software 5 04-06-2005 09:18 PM
FC4 Test 1 CD Test failes every DISC Jimbo99 Linux - Software 1 03-18-2005 03:16 PM
help? gettext fails test under chroot env jobesd Linux From Scratch 2 01-19-2005 07:13 PM
chroot XPediTioN Fedora 0 04-07-2004 06:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 02:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration