From 5a2662e03d6d2206105e7c87343c17ac9d1f28b1 Mon Sep 17 00:00:00 2001 From: Yoann Vandoorselaere Date: Thu, 16 Dec 1999 16:21:28 +0000 Subject: *** empty log message *** --- init-sh/group.conf | 2 - init-sh/grpuser.sh | 30 ++++++------- init-sh/level1.sh | 9 ++-- init-sh/level2.sh | 7 +-- init-sh/lib.sh | 126 ++++++++++++++++++++++++++++++++++++----------------- 5 files changed, 107 insertions(+), 67 deletions(-) delete mode 100644 init-sh/group.conf (limited to 'init-sh') diff --git a/init-sh/group.conf b/init-sh/group.conf deleted file mode 100644 index bdbca9d..0000000 --- a/init-sh/group.conf +++ /dev/null @@ -1,2 +0,0 @@ -audio -urpmi diff --git a/init-sh/grpuser.sh b/init-sh/grpuser.sh index d2f2daf..85c303b 100755 --- a/init-sh/grpuser.sh +++ b/init-sh/grpuser.sh @@ -20,22 +20,19 @@ Usage() { } ModifyFile() { - cp /etc/${file} /tmp/${file}.old + tmpfile=`mktemp /tmp/grpuser.XXXXXX` + cp /etc/${file} ${tmpfile} - head -$((group_line_number - 1)) /tmp/${file}.old > /etc/${file} + head -$((group_line_number - 1)) ${tmpfile} > /etc/${file} echo "${new_group_line}" >> /etc/${file} - tail +$((group_line_number + 1)) /tmp/${file}.old >> /etc/${file} - - new_group_line="" + tail +$((group_line_number + 1)) ${tmpfile} >> /etc/${file} - rm -f /tmp/${file}.old + rm -f ${tmpfile} } RemoveUserFromGroup() { new_group_line=${group}`echo ${group_users} | sed -e s/,${user_name}$//g -e s/${user_name},//g -e s/${user_name}$//g` - - echo ${new_group_line} } AppendUserToGroup() { @@ -87,27 +84,28 @@ RefreshAdd() { exit 1; fi - cat /etc/security/msec/group.conf | while read group_name; do + cat /etc/security/msec/group.conf | grep -v "^$" | while read group_name; do IsGroupExisting; if [[ $? != 0 ]]; then echo "Group \"${group_name}\" doesn't exist. skiping it." else - cat /etc/security/msec/user.conf | while read user_name; do + cat /etc/security/msec/user.conf | grep -v "^$" | while read user_name; do IsUserExisting; if [[ $? != 0 ]]; then # user doesn't exist echo "Can't add user \"${user_name}\" to group \"${group_name}\" user doesn't exist. skiping." IsUserAlreadyInGroup; if [[ $? == 0 ]]; then - echo "User doesn't exist but is in a group... delete user from this group." + #User doesn't exist but is in a group... delete user from this group. + IsGroupExisting; RemoveUserFromGroup; ModifyFile; fi else echo "Adding user \"${user_name}\" to group \"${group_name}\"." - #AppendUserToGroup; - #ModifyFile; - usermod -G ${group_name} ${user_name} + IsGroupExisting; + AppendUserToGroup; + ModifyFile; fi done fi @@ -115,12 +113,12 @@ RefreshAdd() { } RefreshDel() { - cat /etc/security/msec/group.conf | while read group_name; do + cat /etc/security/msec/group.conf | grep -v "^$" | while read group_name; do IsGroupExisting; if [[ $? != 0 ]]; then echo "Group \"${group_name}\" doesn't exist. skiping it." else - cat /etc/security/msec/user.conf | while read user_name; do + cat /etc/security/msec/user.conf | grep -v "^$" | while read user_name; do IsGroupExisting; # We need some variable at each turn. IsUserAlreadyInGroup; if [[ $? == 0 ]]; then diff --git a/init-sh/level1.sh b/init-sh/level1.sh index 342752d..a7ce877 100755 --- a/init-sh/level1.sh +++ b/init-sh/level1.sh @@ -72,14 +72,13 @@ AddRules "export PATH SECURE_LEVEL" /etc/profile # Xserver echo "Allowing users to connect X server from localhost :" -AddBegRules "/usr/X11R6/bin/xhost + localhost" /etc/X11/xdm/Xsession -AddBegRules "/usr/X11R6/bin/xhost + localhost" /etc/X11/xinit/xinitrc - -### +AddBegRules /etc/X11/xdm/Xsession "/usr/X11R6/bin/xhost + localhost" +AddBegRules /etc/X11/xinit/xinitrc "/usr/X11R6/bin/xhost + localhost" # Group +echo "Adding system users to specific groups :" /etc/security/msec/init-sh/grpuser.sh --refresh - +echo -e "done.\n" diff --git a/init-sh/level2.sh b/init-sh/level2.sh index bfadce8..1760873 100755 --- a/init-sh/level2.sh +++ b/init-sh/level2.sh @@ -71,10 +71,11 @@ AddRules "export PATH SECURE_LEVEL" /etc/profile # Xserver echo "Allowing users to connect X server from localhost :" -AddBegRules "/usr/X11R6/bin/xhost + localhost" /etc/X11/xdm/Xsession quiet -AddBegRules "/usr/X11R6/bin/xhost + localhost" /etc/X11/xinit/xinitrc +AddBegRules /etc/X11/xdm/Xsession "/usr/X11R6/bin/xhost + localhost" +AddBegRules /etc/X11/xinit/xinitrc "/usr/X11R6/bin/xhost + localhost" # group +echo "Adding system users to specifics groups :" /etc/security/msec/init-sh/grpuser.sh --refresh - +echo -e "done.\n" diff --git a/init-sh/lib.sh b/init-sh/lib.sh index 891ebf1..c7d0efd 100644 --- a/init-sh/lib.sh +++ b/init-sh/lib.sh @@ -9,7 +9,6 @@ if [[ ${UID} != 0 ]]; then exit 1 fi - COMMENT="# Mandrake-Security : if you remove this comment, remove the next line too." WaitAnswer() { @@ -38,37 +37,40 @@ AddRules() { echo -e "${COMMENT}" >> ${file}; echo -e "${string}" >> ${file}; fi + if [[ -z ${3} ]]; then echo -e "done.\n" fi } AddBegRules() { - string=$1 - file=$2 - quiet=$3 - ctrl=0 + echo "Modifying config in ${2}..." + +/usr/bin/perl -e ' + my $m; - if [[ -z ${string} ]]; then - return; - fi + $file = shift or die; + $temp = `mktemp /tmp/secure.XXXXXX`; - if [[ -z ${quiet} ]]; then - echo "Modifying config in ${file}..." - fi + chomp $temp; - cp -f ${file} /tmp/secure.tmp + open FH, $file; + open FW, ">$temp"; - if ! grep -Eqx "^${string}" /tmp/secure.tmp; then - echo -e "${COMMENT}" > ${file}; - echo -e "${string}" >> ${file}; - fi + while () { + if (!/^\#/ && !/^$/ && !$m) { + print FW $ENV{"COMMENT"}; + print FW "@ARGV\n\n"; $m++; + } + print FW; + } + close FH; + close FW; - cat /tmp/secure.tmp >> ${file} + `mv -f $temp $file`; +' $@ - if [[ -z ${3} ]]; then - echo -e "done.\n" - fi + echo -e "done.\n" } @@ -77,11 +79,14 @@ CleanRules() { ctrl=0 if [[ ! -f ${file} ]]; then + echo "${file} do not exist... can not clean." return; fi echo -en "\t- Cleaning msec appended line in ${file} : " - cp -f ${file} /tmp/secure.tmp + + tmpfile=`mktemp /tmp/secure.XXXXXX` + cp ${file} ${tmpfile} while read line; do if [[ ${ctrl} == 1 ]]; then @@ -94,11 +99,11 @@ CleanRules() { fi if [[ ${ctrl} == 0 ]]; then - echo "${line}" > ${file} + echo "${line}" fi - done < /tmp/secure.tmp + done < ${tmpfile} > ${file} - rm -f /tmp/secure.tmp + rm -f ${tmpfile} echo "done." } @@ -112,16 +117,18 @@ CommentUserRules() { echo -en "\t- Cleaning user appended line in ${file} : " - cp -f ${file} /tmp/secure.tmp - - while read line; do + tmpfile=`mktemp /tmp/secure.XXXXXX` + cp -f ${file} ${tmpfile} + + while read line; do if ! echo "${line}" | grep -qE "^#"; then - echo "# ${line}" > ${file} + echo "# ${line}" fi - done < /tmp/secure.tmp + done < ${tmpfile} > ${file} - rm -f /tmp/secure.tmp - echo "done." + rm -f ${tmpfile} + + echo "done." } Syslog() { @@ -132,7 +139,7 @@ Syslog() { Ttylog() { if [[ ${TTY_WARN} == yes ]]; then - w | grep -v "load\|TTY" | awk '{print $2}' | while read line; do + w | grep -v "load\|TTY" | awk '{print $2}' | while read line; do echo -e ${1} > /dev/$i done fi @@ -156,14 +163,16 @@ LiloUpdate() { fi if [[ ! -z "${password}" ]]; then - cp -f /etc/lilo.conf /tmp/secure.tmp + tmpfile=`mktemp /tmp/secure.XXXXXX` + + cp -f /etc/lilo.conf ${tmpfile} while read line; do if ! echo "${line}" | grep -q "password"; then echo "${line}" > /etc/lilo.conf fi - done < /tmp/secure.tmp + done < ${tmpfile} - rm -f /tmp/secure.tmp + rm -f ${tmpfile} clear AddRules "password=$password" /etc/lilo.conf fi @@ -172,11 +181,6 @@ LiloUpdate() { # If we are currently installing our # system with DrakX, we don't ask anything to the user... # Instead, DrakX do it and give us a file with some variable. -if [[ -f /tmp/secure.DrakX ]]; then - . /tmp/secure.DrakX - AddRules "${DRAKX_USERS}" /etc/security/msec/security.conf -fi - if [[ -f /etc/security/msec/security.conf ]]; then . /etc/security/msec/security.conf fi @@ -197,7 +201,6 @@ CleanRules /etc/profile CleanRules /etc/lilo.conf CleanRules /etc/rc.d/rc.firewall CleanRules /etc/crontab -CleanRules /etc/security/msec/security.users CleanRules /etc/X11/xdm/Xsession CleanRules /etc/X11/xinit/xinitrc @@ -213,6 +216,47 @@ groupadd xgrp >& /dev/null usermod -G xgrp xfs /etc/security/msec/init-sh/grpuser.sh --clean +echo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1