Surname, Name: Section: Student No: Closed Book, closed note exam. Show your work! we must follow your reasoning. You are required to write down commands with necessary arguments and options. Give the best result that you can give! Each question worths 8 points unless otherwise stated. Over 100 points is bonus. Read the instructions carefully listed below and sign the box: SIGNATURE.......... Time of Submission: 1. On machine elif.abc.net.tr you are running bind and want to be master server abc.net.tr, aliveli.com.tr and slave server buyuk.net with masters 101.102.103.104, 200.210.220.250 and tiny.com.tr with masters 15.25.25.45 and 195.205.210.200, 140.150.160.100. Write a piece code for named.conf or named.conf.local \* named.conf */ zone "abc.net.tr" { type master; file db.abc-net-tr; zone "aliveli.com.tr" { type master; file db.aliveli; zone "buyuk.net { type slave; file "SEC.buyuk"; masters { 101.102.103.104; 200.210.220.250; zone "tiny.com.tr { type slave; file "SEC.tiny"; masters { 15.25.25.45; 195.205.210.200; 240.150.160.110; 23/July/2012 CTIS486 Midterm Solution 1
2. Write zone file for aliveli.com.tr which will be on elif.abc.net.tr with name servers elif.abc.net.tr, ayse.buyuk.net, and fatma.aliveli.com.tr. MX server will ve fatma.aliveli.com.tr, ahmet.aliveli.com.tr with lowest rank and ayse.buyuk.net next level. fatma will serve as aliveli.com.tr and www.aliveli.com.tr and wiki will be served by ayse.buyuk.net and blog will be served by elif.abc.net.tr. aliveli.com.tr has network 200.210.220.0/28, and ahmet and mehmet has IP 5 and 10. And fatma has IP 11 within the segment. Any machine on the network will be able to send mail for aliveli.com.tr. Also ar-ge sub domain will be served ayse.buyuk.net and mehmet.aliveli.com.tr. Use CNAME as much as possible. 12 pts ; zone file for aliveli.com.tr ; assume fatma has IP 200.210.220.11 $TTL 86400 @ IN SOA elif.abc.net.tr. hostmaster@aliveli.com.tr. ( 2012072300 12H 3H 2W 1H ) IN A 200.210.2210.11 IN NS elif.abc.net.tr. IN NS fatma IN NS ayse.buyuk.net. IN MX 10 ahmet IN MX 10 fatma IN MX 20 ayse.buyuk.net. IN TXT "v=spf1 ipv4:200.210.220.0/28" fatma IN A 200.210.220.11 ahmet IN A 200.210.220.5 mehmet IN A 200.210.220.10 www IN CNAME fatma ;www IN A 200.210.220.11 wiki IN CNAME ayse.buyuk.net. blog IN CNAME elif.abc.net.tr. ar-ge IN NS ayse.buyuk.net. IN NS mehmet.aliveli.com.tr. 23/July/2012 CTIS486 Midterm Solution 2
3. Write down apache configuration (minimal and complete: directory, index, VirtualHost, Log and webmaster directives) for fatma machine. Web will be on /var/www # part of apache configuration <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ServerName fatma.aliveli.com.tr DocumentRoot /var/www ServerAdmin webmaster@aliveli.com.tr ErrorLog /var/log/apache2/error.log CustomLog /var/log/apache2/fatma-access.log combined NameVirtualHost * <VirtualHost *> ServerName aliveli.com.tr ServerAlias www.aliveli.com.tr DocumentRoot /var/www </VirtualHost> 4. fatma will server /usr/share directory under the name /Share/ to only users with IP of aliveli.com.tr # part of apache configuration Alias /Share/ "/usr/share/" <Directory "/usr/share/"> Options Indexes FollowSymLinks MultiViews AllowOverride None Order deny,allow Deny from all Allow from 200.210.220.0/28 </Directory> 23/July/2012 CTIS486 Midterm Solution 3
5. mail for info will be distributed to info-group, manager, boss. And a copy is saved to file /usr/local/logs/info.txt and the program /usr/local/bin/infoack will send an acknowledgment mail to sender of each mail to info. info-group contains ali, elif, ayse, filiz, busra, doga. Write necessary statements in mail configuration. Give the name of the file in which you put these statements. #/etc/aliases or /etc/postfix/aliases info: info-group, manager, boss, /usr/local/logs/info.txt, " /usr/local/bin/infoack" info-group: ali, elif, ayse, filiz, busra, doga 6. Assume you have postfix running on fatma.aliveli.com.tr. You want all mail to leave as aliveli.com.tr, and accept mail aliveli.com.tr and fatma.aliveli.com.tr, mehmet.aliveli.com.tr, ftp.aliveli.com.tr, www.aliveli.com.tr, localhost, localhost.localdomain. fatma must relay all mail from aliveli.com.tr network. Write minimal configuration #/etc/postfix/main.cf myhostname = fatma.aliveli.com.tr mydomain = aliveli.com.tr myorigin = $mydomain mydestination = $mydomain $myhostname mehmet.aliveli.com.tr ftp.aliveli.com.tr, www.aliveli.com.tr localhost localhost.localdomain mynetworks = 200.210.220.0/28, 127.0.0.0/8 7. Assume in addition, fatma.aliveli.com.tr will server as mail server for abc.com.tr xyz.info.tr, abc.tv.tr. All mail for abc.tv.tr will be delivered abc-tv user, and only mail for webmaster@abc.com.tr will be accepted and delivered to abccom, and similarly webmaster@xyz.info.tr will be delivered user xyz-info. Write necessary statements. Identify files carefully. /etc/postfix/main.cf: virtual_alias_domains = abc.com.tr xyz.info.tr virtual_alias_maps = hash:/etc/postfix/virtual abc.tv.tr /etc/postfix/virtual @abc.tv.tr abc-tv webmaster@abc.com.tr webmaster@xyz.info.tr abc-com xyz-info 23/July/2012 CTIS486 Midterm Solution 4
8. Given a a text file, say abc.txt, which contains in each line an e-mail address grade and Full Name, write a bash script which will send an -email for each person in abc.txt which will say: Dear Full Name Your grade for course XYZ will be grade Thank you for your cooperation The XYZ Course Management. Subject line should read Your XYZ Grade. You can use mailx command. You can use a here document construct. 10 pts while read adres grade isim do mailx -s "Your XYZ grade" $adres <<END Dear $isim Your XYZ course grade for XYZ will be $grade Thank you for your cooperation XYZ Management END done < abc.txt 9. You want to export /usr/share on machines elif.xyz.net to network 139.179.33.0/24 Describe as root what should be done on elif, and on client 139.179.33.15 to mount under /mnt #on elif.xy<.net in file /etc/exports /usr/share 139.139.33.0/24(ro,sync,no_subtree_check) #then as root run exportfs -a # on client 139.179.33.15 issue mount elif.xyz.net:/usr/share /mnt 10. suppose you have an account on a linux machine 140.160.170.200 which is located in US. you want to bypass restrictions in Turkey. How would you setup a VPN using ssh to view webs (port 80). Describe how would you view a web, say, xyz.net. ssh -L 8000:localhost:80 user@140.160.170.200 # set your browser for proxy at port 8000 11. Write conditions for being a free software (özgür yazilim), Be precise as much as possible. - to run without any restriction - to study and modify foe own needs - to distribute with or without money - to distribute changes/changed versions 23/July/2012 CTIS486 Midterm Solution 5
12. You have accounts on pardus and liste machines, with home as /home/ctisx. You have Project directory at both machines. The Project directories were identical, but you have added some files, changed some, and deleted some files on pardus machine. How can you make them identical with a single command? # on pardus machine at /home/ctisx rsync -av --delete Project ctisx@liste:/home/ctisx 13. Given text files Notesx.txt in which each line contains student Name(as a single word), and her average as an integer between 0-99. A student with 85-99 will get A, 75-84 will get B, 65-74 will get C, 55-64 will get D and 64 and below will get F. Determine grade for each student; print name and grade pair for each student, count number A, B, etc; and at the end, print these numbers and averages of input numbers and grade average of the class. Use Awk. 10 pts #!/bin/awk $2 <= 54 {sum=sum+$2; gradef=gradef+1; print $1 " got F" } ( 55 <= $2 ) && ( $2 <= 64 ) { sum=sum+$2; graded=graded+1; print $1 " got D " } ( 65 <= $2 ) && ( $2 <= 74 ) { sum=sum+$2; gradec=gradec+1; print $1, " got C" } ( 75 <= $2 ) && ( $2 <= 84 ) {sum=sum+$2; gradeb=gradeb+1; print $1, " got B " } 85 <= $2 { sum=sum+$2; gradea=gradea+1; print $1, " got A " } END{ total=4 * gradea + 3 * gradeb+ 3 * gradec+graded; print " Number of A: " gradea " Number of B: " gradeb print "Number of C: " gradec " Number of D: " graded " number of F: " gradef print "Number of students: " NR " input ave:" sum/nr " grade ave: " total/nr } 23/July/2012 CTIS486 Midterm Solution 6
14. write a bash script which will take an arbitrary number of integers as arguments, sum the terms, 2, 5, 8, 11, 14,... at end it will print, number of arguments, number of terms entering into summation, and total sum. It will finish with sentence That s all folks #!/bin/bash sum=0 sayi=0 toplam=$# while [ $# -ge 2 ] do sum=$(( sum + $2 )) let sayi=sayi+1 if [ $# -lt 3 ] then break fi shift 3 done echo " total number of arguments: $toplam " echo "some of selected $sayi terms: $sum" echo "That s All Folks!" exit 0 23/July/2012 CTIS486 Midterm Solution 7