LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-20-2009, 01:32 PM   #1
JacekZ
Member
 
Registered: Sep 2005
Location: Notts, England
Distribution: Debian 10
Posts: 71

Rep: Reputation: 15
Is chmod misbehaving?


I use two commands to change permissions, to ensure that all folders are executable, and all files are not:
Code:
sudo chmod -R u=rw,go= /home/username
sudo chmod -R u+X /home/username
This works, but then I put the commands (without sudo) into a script and run the script with sudo

The script runs and the first command is executed, the second complains it can't find a numerical filepath.

If I reissue the second command manually, all is well.

Yet if I replace the second command with the following:

Code:
find /home/username -type d -exec chmod 700 {} \;
the revised script runs without problems (just slower). Question is, why do the original two commands work outside a script, but fail within it. Using Ubuntu 9.10 (script used to work in Fedora 10 using 'su -c'). I tried enabling su in Ubuntu but the script still didn't work correctly.

Any ideas?
 
Old 12-20-2009, 04:32 PM   #2
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 777

Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by JacekZ View Post

Any ideas?
could be related to environtment, try with su - and test it in root login shell
 
Old 12-20-2009, 06:44 PM   #3
JacekZ
Member
 
Registered: Sep 2005
Location: Notts, England
Distribution: Debian 10
Posts: 71

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ozanbaba View Post
could be related to environtment, try with su - and test it in root login shell
I did already, same story. Also tried putting in a pause (sleep 180) inbetween the commands, and making the commands verbose so they were fully followed through. All gave the same failure when run as a script.
 
Old 12-21-2009, 02:54 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You could try
Code:
/usr/bin/sudo /usr/bin/chmod '-R' 'u=rw,go=' /home/username
/usr/bin/sudo /usr/bin/chmod '-R' 'u+X' /home/username
 
1 members found this post helpful.
Old 12-21-2009, 04:18 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Yes, it sounds like it might be related to command expansion or shell globbing in some way. If you quote things as catkin suggested, it may work normally.
 
Old 12-21-2009, 06:26 PM   #6
JacekZ
Member
 
Registered: Sep 2005
Location: Notts, England
Distribution: Debian 10
Posts: 71

Original Poster
Rep: Reputation: 15
Thumbs up

Quote:
Originally Posted by catkin View Post
You could try
Code:
/usr/bin/sudo /usr/bin/chmod '-R' 'u=rw,go=' /home/username
/usr/bin/sudo /usr/bin/chmod '-R' 'u+X' /home/username
Thanks catkin,
You were spot on - the delimiting quotes alone did the trick.
 
  


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
Apache: difference between chmod 644 and chmod 666 and chmod 600 for output/txt/dat? frenchn00b Programming 6 04-22-2009 01:10 PM
sed misbehaving? linmix Programming 9 12-04-2005 10:43 AM
A misbehaving ad - Firefox 1.0.7 Orkie LQ Suggestions & Feedback 3 10-27-2005 04:10 PM
Cups misbehaving mjrich Debian 2 02-22-2005 04:11 PM
flashdrive misbehaving linmix Linux - Hardware 9 02-06-2005 04:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 09:36 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