LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-01-2013, 09:52 AM   #16
wolffjw
LQ Newbie
 
Registered: Apr 2013
Location: Central Florida
Posts: 6

Original Poster
Rep: Reputation: Disabled

Thanks ruario and everyone else.
I think I understand it better now, mainly that I was not expecting the /etc/profile.d to include files that set aliases.
This is unique to Linux which is why I was not familiar with it.
Thanks all for all your help (and patience).
 
Old 05-02-2013, 04:30 AM   #17
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
I'm glad you got it sorted. Please mark the thread as 'SOLVED' using the link at the top of the page.
 
Old 05-03-2013, 07:08 AM   #18
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by ruario View Post
Ok, then I misunderstood you. In that case I would go with catkin's advice and remove execute permissions on the files in /etc/profile.d/ that you do not want run.
Not exactly. Bash needs only read permission to source a file ...
Code:
c@CW8:/tmp$ echo 'echo running!' > foo
c@CW8:/tmp$ chmod 400 foo
c@CW8:/tmp$ source foo
running!
... so removing execute permission from files in /etc/profile.d does not affect bash startup functionality.
 
Old 05-03-2013, 08:34 AM   #19
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
I know they can be sourced but in Slackware at least the /etc/profile.d files are only sourced if they are executable, see the earlier code snippet from Slackware's default /etc/profile. Granted this may be different in other distros so without further testing, removing read permissions may be a safer bet.

EDIT:
Quote:
Originally Posted by ruario View Post
from Slackware's default /etc/profile:

Code:
# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
-x checks for execute permissions.

Last edited by ruario; 05-03-2013 at 08:48 AM.
 
Old 05-04-2013, 06:29 AM   #20
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by ruario View Post
I know they can be sourced but in Slackware at least the /etc/profile.d files are only sourced if they are executable, see the earlier code snippet from Slackware's default /etc/profile. Granted this may be different in other distros so without further testing, removing read permissions may be a safer bet.

EDIT:

-x checks for execute permissions.
Thanks ruario

Just checked Debian. The equivalent is
Code:
if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi  
  done
  unset i
fi
(Wouldn't that break if there were whitespace in the names in the /etc/profile.d/*.sh expansion?)

To be certain, tested for execute only permission ...
Code:
c@CW8:/tmp$ echo 'echo running!' > foo
c@CW8:/tmp$ chmod 100 foo
c@CW8:/tmp$ source foo
bash: foo: Permission denied
... and confirmed it is the read permission that matters.
 
Old 05-04-2013, 08:58 AM   #21
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Quote:
Originally Posted by catkin View Post
... and confirmed it is the read permission that matters.
Yep, I already altered my earlier post.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
What are the options "Nosuid" "mode" "size" in /etc/fstab? tuxfiles.org does not help pstein Linux - Newbie 1 11-16-2012 01:58 AM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 07:41 PM
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 08:11 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 09:31 AM


All times are GMT -5. The time now is 07:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration