LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This 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


Reply
  Search this Thread
Old 04-24-2018, 03:39 PM   #1
egyasssun
LQ Newbie
 
Registered: Apr 2018
Posts: 10

Rep: Reputation: Disabled
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).

Code:
MACH1!myuser(staff,----,noView)@../myuser [41] pwd
/home/staff/myuser
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
 
Old 04-24-2018, 03:57 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
It sounds a bit like a jailed/chroot user.

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.
 
2 members found this post helpful.
Old 04-24-2018, 06:01 PM   #3
egyasssun
LQ Newbie
 
Registered: Apr 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
MensaWater,

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.
 
Old 04-24-2018, 06:30 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 04-24-2018, 07:24 PM   #5
egyasssun
LQ Newbie
 
Registered: Apr 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
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.
 
Old 04-24-2018, 09:55 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Do "pwd -P" or "pwd -L" yield anything different from plain "pwd"? Or, for that matter, "/bin/pwd"?
 
2 members found this post helpful.
Old 04-25-2018, 01:10 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by egyasssun View Post
I couldnīt find PS1 among the environment variables. Where should it be, instead ?
Your samples show a highly customized prompt. You might be running non Bourne shell.

Is the behavior better after you type these commands?

Code:
/usr/xpg4/bin/sh
PATH=/usr/xpg4/bin:/usr/bin
PS1='$PWD $ '
Quote:
But I think this question is not just related to the prompt.
When I open the Console, the prompt says Iīm at "myuser".
Yes, but you can't trust the prompt if you don't even know how it is built.

Quote:
And if I execute "pwd", Solaris confirms that Iīm there (/home/staff/myuser).
You can't trust "pwd" if you don't know what "pwd" is executed.

Quote:
But then I execute "ls", and Solaris does not show the files on "myuser". It shows the files on the root directory.
Same as the above. You can't trust "ls" if you don't know what "ls" is executed.

Last edited by jlliagre; 04-25-2018 at 01:12 AM.
 
2 members found this post helpful.
Old 04-25-2018, 08:56 AM   #8
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
Old 04-25-2018, 10:18 AM   #9
egyasssun
LQ Newbie
 
Registered: Apr 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
@rknichols:

"pwd -P" yielded this: "/home/staff/myuser -P"

"pwd -L" yielded this: "/home/staff/myuser -L"

But: "/bin/pwd" yielded "/".

I think youīve caught the answer. But as a newbie, I need to ask: what does that mean ?

Last edited by egyasssun; 04-25-2018 at 12:10 PM.
 
Old 04-25-2018, 11:12 AM   #10
egyasssun
LQ Newbie
 
Registered: Apr 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jlliagre View Post
Your samples show a highly customized prompt. You might be running non Bourne shell.
In fact, Iīm running csh.

Code:
echo $0
No file for $0

echo $SHELL;
/bin/csh
Quote:
Is the behavior better after you type these commands?
Code:
/usr/xpg4/bin/sh
PATH=/usr/xpg4/bin:/usr/bin
PS1='$PWD $ '
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 ?
 
Old 04-25-2018, 12:17 PM   #11
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Run command "which pwd" (after initial login so it is using the csh environment). What does it show?

I may be it is a script or an alias that is doing this.

Last edited by MensaWater; 04-25-2018 at 12:41 PM.
 
1 members found this post helpful.
Old 04-25-2018, 12:56 PM   #12
egyasssun
LQ Newbie
 
Registered: Apr 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jlliagre View Post
Yes, but you can't trust the prompt if you don't even know how it is built.
I found in /home/staff/config a file ".cshrc.mycompany" with the instruction:

Code:
set prompt="`uname -n | cut -f1 -d"." `\\!`whoami`($GROUP,$NCID,$VIEW)@../$cwd:t[\!] "
That was the point.
The path shown in the prompt comes from $cwd, which in some circumstances may present a value thatīs not the current directory.

That explains the prompts.

Last edited by egyasssun; 04-25-2018 at 01:07 PM.
 
Old 04-25-2018, 01:03 PM   #13
egyasssun
LQ Newbie
 
Registered: Apr 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MensaWater View Post
Run command "which pwd" (after initial login so it is using the csh environment). What does it show?

I may be it is a script or an alias that is doing this.
This is shown:
Code:
which pwd
pwd:    aliased to echo $cwd
 
Old 04-25-2018, 01:34 PM   #14
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
So it is aliased to a variable called cwd.

What does "printenv cwd" show?
 
Old 04-25-2018, 01:43 PM   #15
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by egyasssun View Post
@rknichols:

"pwd -P" yielded this: "/home/staff/myuser -P"

"pwd -L" yielded this: "/home/staff/myuser -L"

But: "/bin/pwd" yielded "/".

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.

Last edited by rknichols; 04-25-2018 at 01:46 PM.
 
  


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
Is the user root home directory needed in linux LinuxPirate Linux - Newbie 9 11-07-2015 09:29 PM
User does int getting home directory in root home in ubuntu 10.04 lucid lynx sunrised24 Linux - Server 2 03-07-2012 09:21 AM
How to set root user under home directory ? mohgam Linux - Newbie 7 01-12-2012 08:10 AM
Can root and my main user account share the same home directory? rivercat Linux - Newbie 11 02-21-2011 07:22 PM
User Home Directory now owned bt Root AndeAnderson Linux - Newbie 4 10-09-2009 03:52 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 04:23 PM.

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