Re: Bash assistance
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 01/18/05
- Next message: Bit Twister: "Re: Bash assistance"
- Previous message: houghi: "Re: Switching consoles"
- In reply to: Eric M. Jackson: "Bash assistance"
- Next in thread: Bit Twister: "Re: Bash assistance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 17 Jan 2005 23:11:18 GMT
On Mon, 17 Jan 2005 at 16:13 GMT, Eric M. Jackson wrote:
> I'm in the processes of building bash scripts to automate common tasks.
>
> One thing I am trying to do it create a script called securehome.sh for
> users to run that will set their home directories to be more secure. In
> doing this I set access on all files and dirs in the user's home so that
> only the user themselves has access, however, I need to then go back and
> reset the permissions on the public_html dir and all the sub directories
> and files so that the user's web page continues to remain accessible to
> others.
>
> The part of the script the locks down the users home is simple enough
>
> cd
> chmod g-rwx,o-rwx * -R
> chmod 711 public_html
>
> So I broke the public_html tasks into various parts.
>
> 1). Goto user ~homedir/public_html
> 2). Pull in "ls" of ~homedir/public_html (Storing in array, for test
> just set array up manually for now)
Why? Just:
chmod -R a+r,go-w $HOME/public_html/*
If you really want to, you can create an array of directories by:
dirs=( $HOME/public_html/*/ )
> 3). Parse array to get elements (Use while loop)
> 5). Set dir permissions, Set file permisions, store sub dirs array,
> (if statements on elements using -d test to set either chmod 711 for
> dirs or chmod 744 for files, store dirs in new array)
> 5). Recursive call to go through and set do Step 3 for all subdirs (use
> new array created).
> 6). Create log of last run in user home.
>
> So I got everything working except the essential step 2. Any advice
> would be helpful, basically I just want to know the best way to take the
> output from ls and break it down in a way that will allow me to store it
> in an array.
Why do all that?
## set $HOME/public_html to drwx--x--x
chmod 711 $HOME/public_html
## Add read permissions to all files under $HOME/public_html
chmod -R a+r $HOME/public_html
## Set execute permissions on all directories under $HOME/public_html
find $HOME/public_html -type d -exec chmod a+x,go-rw {} \;
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Next message: Bit Twister: "Re: Bash assistance"
- Previous message: houghi: "Re: Switching consoles"
- In reply to: Eric M. Jackson: "Bash assistance"
- Next in thread: Bit Twister: "Re: Bash assistance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|