← Back to team overview

sslug-teknik team mailing list archive

Re: BASH: vil ikke sammenkæde strenge

 

Jon Bendtsen wrote:
On 12/03/2011, at 20.31, Thomas Rosendal Jensen wrote:

Hej Jon.

Problemet ligger i at der er karakterer med skjulte usynlige koder ligende teksten.
Jeg har fixet de meste af dem.

I hvilken tekst?


Der er helt tydeligt rettigheds problemer.
jeg har et lille håb på at det kan komme til at virke så man som almindelig bruger kan bruge programmet :|
Jeg har nok brug for hjælp til dette


koden ser nu så ledes ud

#¡/bin/bash4
set -x
USRNME=`whoami`
DOT='.'
MNDOMN='juac.dk'
USRDOMN=${1}
LNK=""
LNK=$(echo ${USRDOMN}${DOT}${USRNME}${DOT}${MNDOMN})
IP=$(echo 90${DOT}184${DOT}106${DOT}85)
DIR=${HOME}/PUBLIC_HTML
EMAIL=${2}
echo '$1=' ${1}
echo '$2=' ${2}
echo '$dot=' ${DOT}
echo '$usrnme=' ${USRNME}
echo '$MNDOMN=' ${MNDOMN}
echo '$USRDOMN=' ${USRDOMN}
echo '$LNK=' ${LNK}
echo '$ip= ' ${IP}
echo '$dir=' ${DIR}
if [ ! -d ${DIR} ];
then
    mkdir ${DIR}
fi
mkdir "${HOME}/PUBLIC_HTML/${LNK}/"
mkdir "/usr/lib/cgi-bin/${LNK}"
echo "<VirtualHost *:80>
 ServerAdmin ${EMAIL}
 ServerName www.${LNK}
 ServerAlias ${LNK}
 DocumentRoot ${DIR}/${LNK}
  # Set Document Root directory options
  <Directory />
    Options FollowSymlnks -Indexes Includes
    # Allow use of .htaccess file
    AllowOverride Limit FileInfo
  </Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/${LNK}
  # Set CGI-BIN directory options
  <Directory /cgi-bin>
    AllowOverride None
    Options +ExecCGI -Multiviews +SymlnksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>
 CustomLog /var/log/apache2/access.log common
 ErrorLog /var/log/apache2/error.log
</VirtualHost>" > /etc/apache2/sites-available/${LNK}
exec /usr/sbin/a2ensite ${LNK}
space='       '
echo "${IP}${space}www.${LNK}${space}${LNK}" >> /etc/hosts
exec /etc/init.d/apache2 reload
# end script


Outputet ser nu således ud:

tj@juac:~$ /usr/sbin/addsubdomain testxyz test


+++ whoami
++ USRNME=tj
++ DOT=.
++ MNDOMN=juac.dk
++ USRDOMN=testxyz
++ LNK=
+++ echo testxyz.tj.juac.dk
++ LNK=testxyz.tj.juac.dk
+++ echo 90.184.106.85
++ IP=90.184.106.85
++ DIR=/home/tj/PUBLIC_HTML
++ EMAIL=test
++ echo '$1=' testxyz
$1= testxyz
++ echo '$2=' test
$2= test
++ echo '$dot=' .
$dot= .
++ echo '$usrnme=' tj
$usrnme= tj
++ echo '$MNDOMN=' juac.dk
$MNDOMN= juac.dk
++ echo '$USRDOMN=' testxyz
$USRDOMN= testxyz
++ echo '$LNK=' testxyz.tj.juac.dk
$LNK= testxyz.tj.juac.dk
++ echo '$ip= ' 90.184.106.85
$ip=  90.184.106.85
++ echo '$dir=' /home/tj/PUBLIC_HTML
$dir= /home/tj/PUBLIC_HTML
++ '[' '!' -d /home/tj/PUBLIC_HTML ']'
++ mkdir /home/tj/PUBLIC_HTML/testxyz.tj.juac.dk/
++ mkdir /usr/lib/cgi-bin/testxyz.tj.juac.dk
mkdir: kan ikke oprette katalog '/usr/lib/cgi-bin/testxyz.tj.juac.dk': Adgang nægtet
++ echo '<VirtualHost *:80>
 ServerAdmin test
 ServerName www.testxyz.tj.juac.dk
 ServerAlias testxyz.tj.juac.dk
 DocumentRoot /home/tj/PUBLIC_HTML/testxyz.tj.juac.dk
  # Set Document Root directory options
  <Directory />
    Options FollowSymlnks -Indexes Includes
    # Allow use of .htaccess file
    AllowOverride Limit FileInfo
  </Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/testxyz.tj.juac.dk
  # Set CGI-BIN directory options
  <Directory /cgi-bin>
    AllowOverride None
    Options +ExecCGI -Multiviews +SymlnksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>
 CustomLog /var/log/apache2/access.log common
 ErrorLog /var/log/apache2/error.log
</VirtualHost>'
/usr/sbin/addsubdomain: line 48: /etc/apache2/sites-available/testxyz.tj.juac.dk: Adgang nægtet
++ exec /usr/sbin/a2ensite testxyz.tj.juac.dk
ERROR: Site testxyz.tj.juac.dk does not exist!


References