[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Unix /etc/profile confirming existance of home directory

Posted on 2011-10-10
5
Medium Priority
?
296 Views
Last Modified: 2013-12-04
Simple question.  I need to confirm that a home directory exists when a user logs into Solaris and Linux boxes.  If no home, no access.  Ideas?  I was going to use the /etc/profile.  Any examples?
0
Comment
Question by:Craig Sharp
5 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 2000 total points
ID: 36948066
Here's the example"

# In case $HOME does not exists  exit, otherwise keep going

if [ ! -d "$HOME" ]  ;   then
         echo " $USER home directory does not exists !"
         exit 1
fi
   
0
 
LVL 6

Expert Comment

by:Tomunique
ID: 36948235
We were trying to do similar when we converted from local accounts to LDAP.  But, be aware not all protocols use /etc/profile

If they (s)ftp into the box for example, it may not run /etc/profile
If they ssh with a command parm  (ssh {hostname} ls)  it may not run /etc/profile

Are you converting to LDAP?

Tom
0
 
LVL 3

Author Closing Comment

by:Craig Sharp
ID: 36948644
Perfect, thanks!  I was in brain lock lol.
0
 
LVL 3

Author Comment

by:Craig Sharp
ID: 36948663
Tom,

I just saw your comments.  Thank you.  Yes we are converting to LDAP, but our only concern based on how our systems are setup is to prevent the developers to login to a command line.
0
 
LVL 22

Expert Comment

by:Brian Utterback
ID: 36949232
The accepted solution as listed above is not secure, if your intention is to prevent a user from logging into the system if that person does not have a home directory. By the time the shell is executing and the /etc/profile script is being run, the tty stream is set up and accepting data from the controlling terminal. Is the terminal sends an interrupt signal, the execution will be interrupted and the user will be logged in anyway.

On Solaris, the right way to do this is to use a PAM module. Linux supports PAM as well, so it is probably the right thing on Linux as well.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us in IT utilize a combination of roaming profiles and folder redirection to ensure user information carries over from one workstation to another; in my environment, it was to enable virtualization without needing a separate desktop for each…
The term "Bad USB" is a buzz word that is usually used when talking about attacks on computer systems that involve USB devices. In this article, I will show what possibilities modern windows systems (win8.x and win10) offer to fight these attacks wi…
Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question