Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
copying directory permissions{resolved}
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
muhsinzubeir
l33t
l33t


Joined: 29 Sep 2007
Posts: 948
Location: /home/muhsin

PostPosted: Sun Aug 03, 2008 1:07 pm    Post subject: copying directory permissions{resolved} Reply with quote

Introduction:
I have a directory hosting my webpage, but I am not a security expert so i really want to maintain all permissions the way they are in there.But this means a user is not allowed to edit files in it.So I decided i will create the same directory on my home with all access, edit the website(multi-page) and then update the directory on my server.This becomes tedious so i wanted to write a script(but im limited as im not fluent in bash-programming)...but i thought should be fine as its a simple program:
Code:
 #!/bin/bash

#we have 3 directories, latest(with user permissions full access to rwx), apache(some server permissions) apache.ackup(maintain server permissions)
cp -rv  /home/user/apache /home/user/apache.backup #create backup, permissions maintained here in the backup directory
#chmod of the /home/user/latest to match my server directory /home/user/apache before uploading/copy new directory
cp -rv /home/user/latest /home/user/apache
#chmod of the /home/user/latest to 777 to allower user to use GUI editors target kate
chmod -R 777 /home/user/latest


So thats the script, but im stuck on changing (latest) permissions to (apache) permissions.How would one accomplish this?Hopefully its not a lot of bash :D
thanks
_________________
~x86
p5k-se
Intel Core 2 Duo
Nvidia GT200
http://www.zanbytes.com


Last edited by muhsinzubeir on Sat Aug 16, 2008 8:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
notHerbert
Advocate
Advocate


Joined: 11 Mar 2008
Posts: 2228
Location: 45N 73W

PostPosted: Sun Aug 03, 2008 3:26 pm    Post subject: Reply with quote

Code:
man cp
...
...
       -p     same as --preserve=mode,ownership,timestamps

       --preserve[=ATTR_LIST]
              preserve the specified attributes (default: mode,ownership,time-
              stamps), if possible additional attributes: context, links, all


Is this what you're looking for?
Back to top
View user's profile Send private message
muhsinzubeir
l33t
l33t


Joined: 29 Sep 2007
Posts: 948
Location: /home/muhsin

PostPosted: Sun Aug 03, 2008 3:41 pm    Post subject: Reply with quote

i want to copy only the permissions (excluding files) en apply them to another directory....before i replace them.But im not sure if the whole idea is possible...

Edit:
If no good idea then its probably bad programming practices/idea, ill have to use files instead of directories.That way I think ill make it, in much easier way.
_________________
~x86
p5k-se
Intel Core 2 Duo
Nvidia GT200
http://www.zanbytes.com


Last edited by muhsinzubeir on Sun Aug 03, 2008 8:01 pm; edited 1 time in total
Back to top
View user's profile Send private message
muhsinzubeir
l33t
l33t


Joined: 29 Sep 2007
Posts: 948
Location: /home/muhsin

PostPosted: Sun Aug 03, 2008 7:58 pm    Post subject: Reply with quote

Code:
#!/bin/bash
#simple script to update my server from newly edited files.
#uncomment the restore part during nightmares.

#backup of the htdocs
cd /var/www/muhsinzubeir.homeftp.net
tar -cvjf /home/muhsin/htdocs.tar.gz htdocs/

#copy latest files over the server
cp -rv /home/muhsin/home_page/*      /var/www/muhsinzubeir.homeftp.net/htdocs/

Code:

#restore from backup during nightmares
#remove messed folder
rm -rv /var/www/muhsinzubeir.homeftp.net/htdocs/

#move to the server locations && restore the backup
cd /var/www/muhsinzubeir.homeftp.net/
tar -xvf /home/muhsin/htdocs.tar.gz


Thats what i came up with ...if u have any better idea pls let me know.
P:S
Pls dont use any info against me :wink:

Edit:
Any cool idea for instance to make that backup part like not to overwrite the existing tarbal instead give it number...like log file stuffs?
to fix overwritting stuffs:
Code:
tar -cvjf tar -cvjf /home/muhsin/htdocs-`date '+%d-%B-%Y'`.tar.gz htdocs/

_________________
~x86
p5k-se
Intel Core 2 Duo
Nvidia GT200
http://www.zanbytes.com
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum