Archive for April, 2006
Configuring the subversion server
Posted by aaron in Linux, Server Software on April 30th, 2006
I didn’t realize it before, but the subversion server running without tunneling over ssh doesn’t actually send the password in the clear when authenticating users. From the subversion book:
At the time of writing, the server only knows how to send a CRAM-MD5 authentication challenge. In essence, the server sends a bit of data to the client. The client uses the MD5 hash algorithm to create a fingerprint of the data and password combined, then sends the fingerprint as a response. The server performs the same computation with the stored password to verify that the result is identical. At no point does the actual password travel over the network.
This makes me feel much more comfortable. So I’ve been switching all my repositories to use just the svn:// protocol. This means I have to run the svnserve program, since by using svn+ssh, no daemon is required.
I want to use xinetd to start the svnserve program. There was already a config file called /etc/xinetd.d/svn which would start the server. However, the path to svnserve was wrong. I changed it to look like this:
service svn
{
id = stream
socket_type = stream
protocol = tcp
user = svn
wait = no
disable = no
server = /usr/local/bin/svnserve
server_args = -i -r /svn
}
I removed the line type=INTERNAL.
Turns out you can’t specify arguments to pass to the program on the server= line, you have to do it in the server_args line (which wasn’t there before). Note: -r /svn makes svnserve only serve repositories under the /svn folder.
You might at some point get a “svn: Malformed header” error message. This will happen if svnserve is run by xinetd.d but not running with the -i switch.
Now that svnserve is finally running, I can configure access to each repository individually. There are details on how to do this in the Subversion Book. I wasn’t able to control access on a repository-by-repository level when running with svn+ssh (aside from configuring unix users/groups, but that would be a pain.)
System information from linux command line
I was just reading this webpage about shell scripting, and discovered that you can get a lot of information about your cpu and memory from the command line.
Return details about your processor:
# cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 6
model : 8
model name : AMD Athlon(tm) XP 2700+
stepping : 1
cpu MHz : 2164.892
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 mmx fxsr sse syscall mmxext 3dnowext 3dnow
bogomips : 4243.45
in doing this, I discovered that my AMD 2700 Athlon processor has a 256kb cache, while my 600mhz Athlon processor has 512kb!
Return just one line with the CPU model or clock speed:
# cat /proc/cpuinfo | grep model\ name
model name : AMD Athlon(tm) XP 2700+
# cat /proc/cpuinfo | grep MHz
cpu MHz : 2164.892
Get details about system memory:
# cat /proc/meminfo
MemTotal: 483684 kB
MemFree: 1924 kB
Buffers: 23512 kB
Cached: 379796 kB
SwapCached: 12 kB
Active: 61876 kB
Inactive: 369916 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 483684 kB
LowFree: 1924 kB
SwapTotal: 1052248 kB
SwapFree: 1051996 kB
Dirty: 6108 kB
Writeback: 0 kB
Mapped: 40692 kB
Slab: 39788 kB
Committed_AS: 112332 kB
PageTables: 1080 kB
VmallocTotal: 3645432 kB
VmallocUsed: 3548 kB
VmallocChunk: 3641332 kB
HugePages_Total: 0
HugePages_Free: 0
Hugepagesize: 4096 kB
Similarly, you can grep for certain fields. For example:
# cat /proc/meminfo | grep MemFree
MemFree: 1732 kB
# cat /proc/meminfo | grep MemTotal
MemTotal: 483684 kB
problems when unmounting filesystems in linux
Posted by aaron in Linux, Server Software, Troubleshooting on April 29th, 2006
I’m reconfiguring my RAID 5 array in one of my servers (called malachite), and having some problems doing so.
What I’m trying to do is to completely delete the current RAID 5 array, and rebuild it with different sized partitions on the same disks.
I can’t unmount the raid array directly, because linux reports back to me:
# umount /raid
umount: /raid: device is busy
So I’m trying to trace this back to see why it’s busy. I’m guessing it’s because this folder is mounted with nfs to my other server (called onyx). However, I also can’t unmount that folder because it is also busy. There is a neat command which tells you what processes are accessing a certain file. I found it here.
# fuser -v -m /RAIDmalachite
will list all processes using the /RAIDmalachite folder. After doing this, I saw that indeed, Samba is using that folder.
Once I took care of that, I still couldn’t unmount the drive on malachite. This is probably because nfs is still exporting it. Note that the kernel nfs server doesn’t count as a process, so it won’t show up by running the above command. It is necessary to stop nfs with:
# /etc/init.d/nfs stop
Now I can unmount the drive:
# umount /raid
At this point, I can now go back into Webmin and delete the RAID array, and then remove all the partitions on the drives.
After creating my new raid array, I can watch the status of it rebuilding in real time from the command line:
# watch -n 1 cat /proc/mdstat
What is even better is that I can format, and start copying files back to the array even before it has completely been rebuilt. The files just won’t be redundant until after it finishes reubilding. Looks like it will take about 2 hours to rebuild the 650gb array.
Reduce the number of multiplications required for the product of two polynomials
This was a problem done in my CIS 315 Algorithms class in Spring 2006.
The product of two linear polynomials ax+b and cx+d
[tex]\LARGE (ax+b)(cx+d)[/tex]
is
[tex]\LARGE acx^2 + (ad+bc)x + bd[/tex]
Note that this requires 4 different multiplications of the coefficients:
ac, ad, bc and bd.
We want to find a way to determine this product with only 3 multiplications.
let:
L = (a+b)(c+d)
note what happens when we FOIL L:
L = ac + ad + bc + bd
We think that maybe we can combine the middle term (ad+bc) with only one multiplication. What we want is ad + bc, so subtract ac and bd from L:
J = ac
K = bd
L – J – K = (ac + ad + bc + bd) – ac – bd
Note at this point we can rewrite the original FOILed product as:
[tex]\LARGE Jx^2 + (L – J – K)x + K[/tex]
We now have solved the problem with only 3 multiplications. They are:
J, K and L, or ac, bd, and (a+b)(c+d)
Installing majordomo mailing list manager
Posted by aaron in Uncategorized on April 25th, 2006
First, I downloaded the Majordomo source code from here. Following the instructions in the included INSTALL file, I was able to get Majordomo installed relatively quickly. I ran into problems when I started trying to actually send email to the new list. The first problem I ran into was that sendmail wasn’t started, but that was just silly.
The first real problem was something they actually mentioned in the FAQ. I sent a message to the list, and got a response back:
550 5.2.4 :include:/usr/local/majordomo/lists/asuoweb… Cannot open /usr/local/majordomo/lists/asuoweb: Group writable file
This error is mentioned in the FAQ page here. I added the line into the sendmail configuration file, but that didn’t fix the problem. I did the other thing they mentioned which was removing group write permissions on the lists folder and all its contents. That should have fixed it, but it didn’t. I figured it had something to do with the group that owned the files. I originally set up majordomo to use the ‘majordomo’ user and group, so the files were owned by the ‘majordomo’ group. I changed all the files to be owned by ‘daemon,’ and that seems to have fixed the problem. Although, I did a poor job of narrowing down the problem, so I’m not sure which of the steps I tried actually was necessary. For example, I don’t think adding “DontBlameSendmail=groupwritabledirpathsafe” to the configuration was necessary, since now there is no group write bit set.
Now I have a mailing list server running on the Honors College server. I have yet to try to install Majordomo on my VPS which is running Postfix.
/etc/hosts – The hosts file
Posted by aaron in Uncategorized on April 19th, 2006
The other day I decided to set up my iBook so that I can do web development on it.
While setting up my new server, I was moving a domain name to the new server, but didn’t want to actually change the DNS for the domain until I knew Apache was configured properly. I needed some way to test Apache’s virtual host configuration without actually making the DNS change. Turns out, since OS X is based on UNIX, you can add dns entries to your computer manually.
Edit the file /etc/hosts, and include the name and IP address for the host you want to add. For example:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
123.123.123.123 domainname.com
You’ll need to do this with root privileges, since it is a system file. You’ll have to do something like
sudo vi /etc/hosts
Update: In OS X 10.5 it is no longer necessary to reload the hosts file. It will happen automatically.
After you save the file, you’ll need to get OS X to refresh its hosts database.
sudo niload -v -m hosts . < /etc/hosts
After that, you should be all set! Your computer will resolve dommainname.com to 123.123.123.123 without contacting any DNS servers.
Note, this is not an OSX-specific feature. Windows also has a hosts file. It is usually located at:
c:\windows\system32\drivers\etc\hosts
To get Windows to recognize the changes, you need to flush the DNS.
ipconfig /flushdns
You can also read about the hosts file on Wikipedia.
Trouble restarting Apache
Posted by aaron in Server Software, Troubleshooting on April 19th, 2006
My VPS was restarted yesterday, and apparently Apache wasn’t shut down gracefully. I tried to go to my website, but Apache wasn’t running. I SSH’d into my machine to restart apache. I typed
/etc/init.d/httpd restart
I can’t remember exactly what it said back to me, but it gave me the PID of Apache (1039) and said it was running. Apache was most definitely not running. I found this out by getting a list of all running processes:
ps -ax
That gave me a list of PIDs corresponding to programs, and 1039 was not httpd. It occurred to me that if Apache thinks it’s running, it has to have some way of knowing that. In Apache’s log file directory, there is a file which holds the PID of Apache when it’s running. That file is called httpd.pid. By removing that file, Apache no longer thinks it’s already running, and will actually try to start. If you don’t know where httpd.pid is, run this command:
whereis httpd.pid
That should find it. If not, it is probably in /usr/local/apache2/logs if you installed with the default values. Then you just need to rm httpd.pid, and restart apache again. I got everything back up and running with just under 10 minutes of troubleshooting!
TeX markup
Posted by aaron in Uncategorized on April 16th, 2006
I just found the TeX plugin for Serendipity. It lets you draw cool math symbols like
[tex]\LARGE x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/tex]
The Serendipity plugin is on this page, or you can download the zip file directly.
You’ll also need the mimetex program, which actually creates the gif image from the text expression.
I downloaded the mimetex binary directly, from here. I moved it to the /usr/src/ directory.
There was one trick with getting it to work with serendipity. That was making sure the “images” folder inside the plugin’s folder was writable by the web server. Either “chown apache images” or “chmod 777 images” will work. This is necessary because the plugin will cache the image once it’s created, so it only has to use the mimetex binary file once to generate that first image, and from that point on it will always use the cached one. It uses an md5 hash to generate a unique string to identify each math expression. Very clever.
Lorem ipsum dolor
Posted by aaron in Uncategorized on April 15th, 2006
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
If you’ve ever used a desktop publishing program or something similar, you probably recognize this text. It is commonly seen as dummy text when creating page layouts for print or web. If instead you were to use phrases such as “Your content here” or “The quick brown fox jumps over the lazy dog,” you would have to repeat these sentences to fill up the allotted space. Your eye would immediately pick up on the stacking patterns that would be created, distracting you from what you are really interested in, which is the layout as opposed to the content.
I’ve always wondered what exactly “Lorem ipsum dolor…” was and where it came from. Today I needed to plop some dummy text down in a new website design, so I did a search for the phrase, and came upon a great website describing its history and usage. Lorem ipsum dolor. It has a neat feature which lets you generate an arbitrary length of this dummy text to use.