PostNuke

Flexible Content Management System

News

Script to set permission

Contributed by on Nov 26, 2001 - 10:46 PM

The original Idea was to set files R/W to websevrer and the FTP user, so the files will have the FTP Users username (from FTP aupload) and we set all files to the Webservers group and the chmod to 664, so the may be readable and writeable for both, webserver and user.





I am not sure if my permissions are chosen wise. A paranoid sysadmin would rather set files to 660 .




Here goes setpermission.sh


#!/bin/sh


# ------------------------------------------------------------------------------


# File: $Id$


# ------------------------------------------------------------------------------


# POST-NUKE Content Management System


# Copyright (C) 2001 by the Post-Nuke Development Team.


# http://www.postnuke.com/


# ------------------------------------------------------------------------------


# Based on:


# PHP-NUKE Web Portal System - http://phpnuke.org/


# Thatware - http://thatware.org/


# ------------------------------------------------------------------------------


# LICENSE


#


# This program is free software; you can redistribute it and/or


# modify it under the terms of the GNU General Public License (GPL)


# as published by the Free Software Foundation; either version 2


# of the License, or (at your option) any later version.


#


# This program is distributed in the hope that it will be useful,


# but WITHOUT ANY WARRANTY; without even the implied warranty of


# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the


# GNU General Public License for more details.


#


# To read the license please visit http:#www.gnu.org/copyleft/gpl.html


# ------------------------------------------------------------------------------


# Original Author of file: Simon Wunderlin


# Purpose of file:


# setting up propper file permissions


# ------------------------------------------------------------------------------




#if [[ $UID != 0 ]]; then


# echo "This script must be run as root!";


# exit 1;


#fi




## configuration


DIRMASK="775" # premissions to set on directories


FILEMASK="664" # premissions to set on files


GROUP="httpd"; # default group of httpd, we try to detect it later


CONFILE='' # httpd's config file, we try to get the group from there


HTMLDIR='./html' # the directory containing all the html files


CMD_HTTPD=`which httpd`




## check if we have permission to run httpd, if not, we cant deect the group


if [[ -x $CMD_HTTPD ]]; then


## lets try to get the configuration file's path


BASEDIR=`httpd -V | grep "HTTPD_ROOT"`


BASEDIR="${BASEDIR#*/}"; BASEDIR="/${BASEDIR%"*}"


CONFILE=`httpd -V | grep "SERVER_CONFIG_FILE"`


CONFILE="${CONFILE#*"}"; CONFILE="${BASEDIR}/${CONFILE%"*}"




## get the group apache is running as


if [[ -r $CONFILE ]]; then


GROUP=`cat $CONFILE | grep "^Group[[:space:]]" | awk '{print $2}'`


fi


fi




## explain dude what we are going to do


echo "`cat /install.php |


| |


+------------------------------------------------------------+


nn




EOF`"







1436