SunOS confusing root directory and user home directory
Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
SunOS confusing root directory and user home directory
Hello,
Iīve just started using a Solaris machine with SunOS 5.10.
After the machine is turned on, I open a Console window and at the prompt, if I execute a pwd command, it tells me Iīm at my home directory (someone configured "myuser" as default user after init).
But the weird thing is that if I run a ls command, it shows me that in fact, itīs at the root directory (!!!)
Code:
MACH1!myuser(staff,----,noView)@../myuser [42] ls -l
(Shows directories:
/etc
/home
/usr ...)
And if I go to a subdirectory, something stranger happens.
It assumes a false path.
Code:
MACH1!myuser(staff,----,noView)@../myuser [43] cd etc
MACH1!myuser(staff,----,noView)@../etc [44] pwd
/home/staff/myuser/etc
If I try to call this false path, the shell naturally canīt do it.
Code:
MACH1!myuser(staff,----,noView)@../etc [45] cd /home/staff/myuser/etc
/home/staff/myuser/etc: No such file or directory
But if I call my home path, it works as expected.
Code:
MACH1!myuser(staff,----,noView)@../etc [46] cd /home/staff/myuser
/home/staff/myuser
MACH1!myuser(staff,----,noView)@../myuser [47] ls -l
(shows files in my home directory)
Well, Iīm not so experienced with Unix and I have no idea what can be wrong. I looked some files such as .profile, dtautologin, but couldnīt find anything that seemed to be causing this problem.
Can anyone give me a idea of whatīs wrong with the configuration of this machine ?
Last edited by egyasssun; 04-24-2018 at 07:15 PM.
Reason: Make it better readable
When one creates a jailed/chroot user they are restricting the user to only what can be seen under that user. When logged in as that user what he sees as root (/) is actually just root for that user. The real path to the the user's home as seen by a non-jailed user (e.g. the root user) would be a much longer path.
e.g. If i have a user called billybob that I've jailed (on Linux - I don't have Solaris to use for example) the full path I see to the jailed user's home directory when I'm logged in as root is:
/restricted/users/billybob/home/billybob
However when billybob himself logs in he sees his home as /home/billybob. Moreover if he tried to see /restricted/users/billybob it will fail because the jailing restricts him to only see things from his jailed directory down and not anything above it. If he lists root ("/") what he sees is actually what would be seen by the non-jailed user as /restricted/users/billybob. So that would typically contain things he'd need such as usr, etc, var, dev with limited files. The /dev/null the jailed user might see would actually be /restricted/users/billybob/dev/null for the non-jailed user. Similarly /etc/passwd he sees would in reality be /restricted/users/billybob/etc/passwd.
Last edited by MensaWater; 04-24-2018 at 03:59 PM.
Thanks for your answer. In fact this sounds a bit like jailing. But what I see is the opposite of what you described.
Iīve read that jailing is used to restrict access of users only to their home directory.
But in my case, "myuser" can see the whole file system.
In fact, as I described, this user already had access to the root while the SO was misunderstanding this user was at his home directory (/home/staff/myuser).
This is like we have two "/home/staff/myuser" directories seen by the SunOS.
One is the real path. The other is like an alias the SO gave for the root directory.
What could be causing this ? Looks like a SunOS bug for me, but I donīt know much about this SO.
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
Everything you show is very non standard so if there is a bug, or possibly a misunderstanding, it is due to the oddly configured customization that have been done on that system, and specially on the shell you use.
Standard Solaris shells do not provide such bizarre prompts. You should first tell what shell you are using and what PS1 is set to.
PS: please edit your first post in advanced mode and add code tags to make things more readable.
I couldnīt find PS1 among the environment variables. Where should it be, instead ?
But I think this question is not just related to the prompt.
When I open the Console, the prompt says Iīm at "myuser". And if I execute "pwd", Solaris confirms that Iīm there (/home/staff/myuser).
But then I execute "ls", and Solaris does not show the files on "myuser". It shows the files on the root directory.
Very strange.
Just to be clear:
If a jailed user logs in he/she will in fact see a "root" (/) heirarchy - it just won't be the REAL root heirarchy that a non-jailed user sees. You could verify what you're seeing by opening separate sessions for a non-jailed user (e.g. the root user itself) and the jailed user. Put a file in / as the non-jailed user and chmod 777 the file so it is visible by all users. Then go to the (suspected) jailed user session and do "ls -l /". If that session doesn't see the file then you have confirmed the "/" he is seeing is not the same as the one the non-jailed user saw.
Other than jailing, there are things such as symbolic links and loop back mounts (I'm not sure the latter exists in Solaris) where you can make things go to other directories or files in alternate paths than the the "real" path in which the directories or files exist.
Yes ! now it started making sense.
Now my problem is that I still need to find what was wrong.
Quote:
Yes, but you can't trust the prompt if you don't even know how it is built.
Once I found it somewhere. Iīll try to search it again.
Quote:
You can't trust "pwd" if you don't know what "pwd" is executed.
Same as the above. You can't trust "ls" if you don't know what "ls" is executed.
Ok, many thanks ... I didnīt know about these possibilities.
Does that seem that the commands Iīm using have a different behavior from what itīs expected ?
I think youīve caught the answer. But as a newbie, I need to ask: what does that mean ?
The shell's notion of the current directory reflects how it got there. For example, on this machine I have directory /var/home/ bind-mounted on /home. My home directory is officially (in /etc/passwd) "/home/rnichols", and that is what pwd reports in my login shell. If I execute "cd /var/home/rnichols" (which is the exact same directory), then the shell's built-in pwd returns "/var/home/rnichols".
In bourne-derived shells, the "-P" option on pwd causes the shell to ignore the remembered path and trace the physical filesystem tree. That's also what happens when you run the external program "/bin/pwd". For me, both of those return "/home/rnichols" regardless of how I got there. Now I see that you are using csh, which obviously does not understand the "-P" or "-L" options.
As has been suggested, it looks like you are in a chroot jail, and your home directory is also the effective filesystem root.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.