(no subject)

Jul 03, 2008 08:31

I know it's been over three weeks since I've updated. It will be impossible for me to recall every event that's happened in that timeframe, but I'll do the best I can. I'll also keep it as short as I can though my tendency to go into detail will probably mean that this will be another long entry.

It's actually been one busy summer for me, most of it dealing with projects I want to get done. One of them was to switch Rei from using IP Filter to Packet Filter, which I described in my last entry as the Software of the Week. That was actually pretty painless since the syntax for both packet filters is similar, but pf was definitely easier to use thanks to its ability to define macros. Later on I figured out that I could use this week's Software of the Week to get the same effect with not only IP Filter but the configuration files of any program I use, but after thinking about it I still would have made the switch. This was actually phase two of a four-phase project to get my network the way I want it. Phase three involves installing and configuring an intrusion detection system, or IDS. The reason is that my SSH server gets a lot of traffic from script kiddies trying various scripts that try to log into an SSH server using various common usernames very fast. Using an IDS would allow me to detect when this is happening, and then the program would add the IP address of the attacker to a file and then Packet Filter would dynamically create a rule to block that person from accessing my server. Phase four, the final phase, involves switching my DSL modem over to bridged mode and doing the PPP connection at Rei instead of at the DSL modem and giving the NAT duties back to Rei since it's easier to keep an actual computer under my control updated than it is to do the same with a black box, even if said black box is running an embedded Linux system. Plus, as you might imagine, there are some things that pf can do that iptables cannot, and I don't need a Web frontend to configure my firewall.

That's by far not the only thing I've been working on, though. On Hikari, the machine that I had OpenBSD on, I decided to wipe out that operating system and install Plan 9 from Bell Labs, referred to from here on out as simply Plan 9, instead. The reason is that OpenBSD didn't feel much different from NetBSD and I wanted more of a challenge when it comes to learning a different operating system. I definitely got it with Plan 9. For the uninitiated, which I'm sure is everyone reading this, both on and off my friends list, Plan 9 was and is still developed at Bell Labs as the successor to Research Unix beginning in the late 1980s. The idea is that everything - and I do mean everything - is represented as a file. In most if not all Unix-like OSs, network devices and connections are one of the exceptions to the "everything is a file" idea. Not so in Plan 9. Another difference is that there is a GUI and it's strongly tied to the OS, though not as tightly as the GUI on Windows or Mac OS X. But the most interesting part of the GUI to me is that even though it is more mouse-based than some X WIndow System window managers, rio, the Plan 9 GUI, is still strongly text-based. Gone are the terminal emulators that emulate an actual glass terminal. Instead the differentiation between a graphical program and a text one is reduced to the point where it barely exists; if you run a program inside a terminal window it will show up inside the same window instead of spawning a new window, and a utility called plumber (appropriately enough) easily takes data from one process and sends it to another, regardless of whether either process is graphical or text. One feature that I haven't tested yet is the ability to mount namespaces on other machines as if they are local, which is one of the main features of Plan 9. My major complaint about it so far is how difficult it is to add a user to the system. There's no "adduser" command or anything like that. Instead you add the user to the file server, give them system access if desired (there's no "root" or "Administrator" accounts on Plan 9), then create their namespace. The problem is that you have to go to a special console to perform the first two steps, one for the file server, one for the auth server unless you don't use one. Overall I like Plan 9 so far, but I need to use it more in order to get more familiar with it. Fortunately the installation CD and the live CD are one and the same, so getting into it isn't a problem.

Outside of computing things have been interesting, both online and off. Offline the biggest event was the night that Vik decided to have a barbecue after buying a cheap grill three Wednesdays ago. Nate, Alex, and Logan came over, and Vik made the mistake of buying Nate a draught keg for Nate's birthday, half of which he drank that night like water. I used my boombox outside for the first time, something that pleased the other guys since it was about the only way we had to get music outside. At first things went okay; we talked and listened to music as Vik and Alex tried to put the grill together. The trouble started after the grill was together and the fire lit. That's when Alex decided to give in to his pyro tendancies and make a Molotov cocktail using a 20 oz plastic pop bottle, the rest of the lighter fluid we didn't use to light the grill, and some paper. He set it on fire on the sidewalk by our apartment, then poured the rest of the lighter fluid around the bottle. I wanted to stop him, but it was like I was at a car wreck in that I was curious to know what would happen next and I didn't want to rock the boat so I didn't, which is something I regret. Once the bottle and the lighter fluid burned my steak was ready. It was around this time that the beer had its effect on Nate. At first it was funny hearing his slurred speech and his complaints, but then he started throwing the rocks outside our building's door and one of them almost hit my boombox. It was at this point that I was getting pissed off at him, and Vik could tell because he led Nate into the apartment while I waited for my steak to get done. I ate outside and waited for the other guys to eat their steaks before going in. Nate continued to yell in our apartment, so Vik took him away since he could tell I was about ready to kick Nate out. Alex didn't want this to happen since he was concerned about what Nate would do to Scout, the dog they had just gotten the week before. After talking for about an hour I had to go to work. When I came home the next morning I found a hole in our living room wall. Nate had punched a hole in it after I'd gone to work and Vik and Alex brought Nate back into the apartment and Nate had gone on one of his angry, drunk tirades. Fortunately Alex patched the hole and did a pretty good job of it.

The Friday of that same week Jeff had a poker night. He had to work that day and I stayed in to listen to Paul and Katon's Radio PSI shows, so the game didn't start until after 11 PM. The biggest change was the venue. We had it in the common room in Jeff and Meri's apartment complex instead of in Jeff's apartment. It was also the first time that all seven of us in our group were there and participating. It didn't last too long, though. It was definitely Jeff's night, as he got very good cards and dominated everyone else. The game was over by 2 AM, which meant that it lasted less than two and a half hours taking into account setting up the game and the food (which Jeff had gotten a lot of).

On Monday I did two things that I hadn't done in seven years: got an eye exam and went swimming. The eye exam went well; my prescription for glasses didn't change at all. I ordered some new glasses (metallic wire frame with plastic temples, making them a metal/plastic hybrid, the first time I'll have such glasses) and they should be in next Wednesday or Thursday, just in time for the convention. They will also have Transitions lenses, another first for me, and it will be interesting adapting to that. As for the swimming, I've always liked doing it, but I never took advantage of the pool on campus when I was living in the dorms when going for my first degree (the hard bodies inside the rec center made me feel bad about my own flabby body) and then when I had tubes put in my ears I would have had to wear ear plugs in the water, which in addition to my myopia would have made me pretty much blind and deaf in the water, something I didn't want to deal with. The tubes were out on their own by 2004, but for some reason I didn't have enough initiative to go swimming until Monday. Vik and I live by our apartment complex's pool, so that's where I broke the seven-year spell. It felt great to be back in the water and I was surprised at how much I was still able to do after seven years. I ended up spending an hour in there. During that time a group of people were chatting by the pool but never got in. They left after about a half-hour and then about fifteen minutes before I left a couple, what looked like the woman's daughter and the woman's sister came in. The sister went into the pool and did some of the things that I did when I was a child: underwater handstands and jumping into the pool from the side. I didn't do the latter, but the former were and are still fun. I'll definitely do some more swimming this summer.

So, overall I've been pretty busy. Once again I don't think I'm taking enough downtime for myself as even though I don't have class I'm feeling busy. It's not just my own projects that I'm involved with, either. I've been trying to get through Starmen.net's EarthBound Funktastic Game Play but I haven't been successful in keeping up so I've been playing catch-up and haven't been doing a good job of that. I've also done a lot more of playing Brawl online, mostly against Chris. It would be nice to take it easy one of these days, though. I did drop out of the Shining Wonderful Ruby Challenge since my heart really wasn't in it and I'm more of a network and system administrator than a programmer, my last three computer science classes notwithstanding. But I still feel over-committed, and what's odd is that it's not anything big that I'm involved with, but rather all these little things that add up, including the projects I do for myself that leads me to feel this way. I'll have to find some way to deal with it.

This week's Software of the Week is m4. m4 is a macro processor. As the name implies, it can be used to generate text from macros. It was originally created as a preprocessor for the Rational Fortran (Ratfor) programming language, but is also used as a general purpose macro language, and it is this second use that has earned it a place as this week's Software of the Week. The main use of a macro processor is to be able to replace repeated text by storing it in a macro and then having the processor replace the macro with its contents. An example in m4 will illustrate its basic use:

define(`ANIMAL', `cat')dnl
define(`LOCATION', `basement')dnl
The ANIMAL was found in the LOCATION. Several ANIMAL toys were found there, and it is unknown how this has affected the LOCATION.

After being processed by m4, the text would read:

The cat was found in the basement. Several cat toys were found there, and it is unknown how this has affected the basement.

Note that m4 macros need not be capitalized, I do it in order to make it easy to find the macros. Changing a macro's contents will change the text everywhere the macro is used, and this is why macros are useful. I could change "cat" to "dog" and the word "dog" would appear everywhere "cat" did in the example. This text replacement is a very basic use of macro processors in general and m4 in particular. However, m4 also has the capability to increment and decrement numbers, define conditional statements, including taking action based on whether a macro is defined or not, use arguments in macros, and even do arithmetic or use the output of a command. m4's quote characters (a backquote and a single quote) allow for easy use of quotes, and since comments (lines starting with a "#") are in most cases echoed, it's possible to easily take a configuration file, add macro definitions and macros, and have m4 process the file to generate the finished configuration file, replacing the macros with the needed text. This has made it easy to, say, add definitions for mount points for regular users on BSD systems. On BSD systems, any regular user who wishes to mount a filesystem must own the mount point, so I often create those mount points in the user's home directory. But those mount points have to be added to /etc/fstab. This is where m4 really shines because I can write out the configuration file and use the username as an argument for a macro to easily add user mountpoints as needed, then have m4 process the file to generate the new fstab. Here's an example, taken off the laptop I'm typing this on, changing the users that are on it to protect the innocent:

define(`DEV',`/dev')dnl
define(`WD',DEV`/wd'$1$2)dnl
define(`SD',DEV`/sd'$1$2)dnl
define(`FD',DEV`/fd'$1$2)dnl
define(`CD',DEV`/cd'$1$2)dnl
define(`HOME',`/home')dnl
define(`MEDIA',`/media')dnl
define(`MSDOS_OPTIONS',`rw,noauto,-l,-m=0644,-M=0755')dnl
define(`USER',`# for $1
FD(0,a) HOME/$1'MEDIA`/floppy-fat msdos MSDOS_OPTIONS 0 0
FD(0,a) HOME/$1'MEDIA`/floppy-ffs ffs rw,softdep,noauto 0 0
FD(0,a) HOME/$1'MEDIA`/floppy-ext2 ext2fs rw,noauto 0 0
CD(0,a) HOME/$1'MEDIA`/cdrom cd9660 ro,noauto 0 0
SD(2,e) HOME/$1'MEDIA`/sd-fat msdos MSDOS_OPTIONS 0 0
SD(2,a) HOME/$1'MEDIA`/sd-lfs lfs rw,noauto 0 0
SD(4,a) HOME/$1'MEDIA`/usb-fat msdos MSDOS_OPTIONS 0 0
SD(4,e) HOME/$1'MEDIA`/usb-lfs lfs rw,noauto 0 0')dnl
# System mounts
WD(0,a) / ffs rw,softdep 1 1
WD(0,b) none swap sw 0 0
WD(0,e) /usr ffs rw,softdep 1 2
WD(0,f) /var ffs rw,softdep 1 2
WD(0,g) /home lfs rw,nodev,nosuid 1 2
kernfs /kern kernfs rw
procfs /proc procfs rw
ptyfs DEV/pts ptyfs rw
fdesc DEV fdesc rw,union
/etc/portal.conf /p portal rw 0 0
# tmpfs mount
tmpfs /tmp tmpfs rw,-s=32m,nodev,nosuid 0 0
# System NFS mounts (mainly for binary packages)
kaworu:/usr/pkgsrc/packages /usr/bin-pkgs nfs rw,noauto,-r=2048,-w=2048,-s,-i 0 0
# Null mounts
#/tmp /var/tmp null rw,hidden 0 0
# System removable media mounts
FD(0,a) MEDIA/floppy-fat msdos MSDOS_OPTIONS 0 0
FD(0,a) MEDIA/floppy-ext2 ext2fs rw,noauto 0 0
CD(0,a) MEDIA/cdrom cd9660 ro,noauto 0 0
SD(0,e) MEDIA/usb-fat msdos MSDOS_OPTIONS 0 0
SD(0,a) MEDIA/usb-lfs lfs rw,noauto 0 0
# User removable mounts
USER(john)
USER(beth)
# Linux proc mount. Must come *after* the null mount for /emul/linux
procfs /emul/linux/proc procfs rw,linux

Running this through m4 would produce this:

# System mounts
/dev/wd0a / ffs rw,softdep 1 1
/dev/wd0b none swap sw 0 0
/dev/wd0e /usr ffs rw,softdep 1 2
/dev/wd0f /var ffs rw,softdep 1 2
/dev/wd0g /home lfs rw,nodev,nosuid 1 2
kernfs /kern kernfs rw
procfs /proc procfs rw
ptyfs /dev/pts ptyfs rw
fdesc /dev fdesc rw,union
/etc/portal.conf /p portal rw 0 0
# tmpfs mount
tmpfs /tmp tmpfs rw,-s=32m,nodev,nosuid 0 0
# System NFS mounts (mainly for binary packages)
kaworu:/usr/pkgsrc/packages /usr/bin-pkgs nfs rw,noauto,-r=2048,-w=2048,-s,-i 0 0
# Null mounts
#/tmp /var/tmp null rw,hidden 0 0
# System removable media mounts
/dev/fd0a /media/floppy-fat msdos rw,noauto,-l,-m=0644,-M=0755 0 0
/dev/fd0a /media/floppy-ext2 ext2fs rw,noauto 0 0
/dev/cd0a /media/cdrom cd9660 ro,noauto 0 0
/dev/sd0e /media/usb-fat msdos rw,noauto,-l,-m=0644,-M=0755 0 0
/dev/sd0a /media/usb-lfs lfs rw,noauto 0 0
# User removable mounts
# for john
/dev/fd0a /home/john/media/floppy-fat msdos rw,noauto,-l,-m=0644,-M=0755 0 0
/dev/fd0a /home/john/media/floppy-ffs ffs rw,softdep,noauto 0 0
/dev/fd0a /home/john/media/floppy-ext2 ext2fs rw,noauto 0 0
/dev/cd0a /home/john/media/cdrom cd9660 ro,noauto 0 0
/dev/sd2e /home/john/media/sd-fat msdos rw,noauto,-l,-m=0644,-M=0755 0 0
/dev/sd2a /home/john/media/sd-lfs lfs rw,noauto 0 0
/dev/sd4a /home/john/media/usb-fat msdos rw,noauto,-l,-m=0644,-M=0755 0 0
/dev/sd4e /home/john/media/usb-lfs lfs rw,noauto 0 0
# for beth
/dev/fd0a /home/beth/media/floppy-fat msdos rw,noauto,-l,-m=0644,-M=0755 0 0
/dev/fd0a /home/beth/media/floppy-ffs ffs rw,softdep,noauto 0 0
/dev/fd0a /home/beth/media/floppy-ext2 ext2fs rw,noauto 0 0
/dev/cd0a /home/beth/media/cdrom cd9660 ro,noauto 0 0
/dev/sd2e /home/beth/media/sd-fat msdos rw,noauto,-l,-m=0644,-M=0755 0 0
/dev/sd2a /home/beth/media/sd-lfs lfs rw,noauto 0 0
/dev/sd4a /home/beth/media/usb-fat msdos rw,noauto,-l,-m=0644,-M=0755 0 0
/dev/sd4e /home/beth/media/usb-lfs lfs rw,noauto 0 0
# Linux proc mount. Must come *after* the null mount for /emul/linux
procfs /emul/linux/proc procfs rw,linux

To add removable mount points for a new user, all I would have to do is add another USER(username) entry to the m4 file, then process it with m4 and save the output as /etc/fstab. The command would be

m4 fstab.m4 > /etc/fstab

And that's it! I first discovered m4 when looking around at FVWM and finding out it uses m4, but I didn't try to learn it until after I used the macros in the configuration file for pf. Of course, m4 can be used to generate text for any type of file. It can be a big help for dealing with repeating text, and for me makes program and system configuration easier. As for availability, it's standard issue on most if not all Unix systems; you'll find it in /usr/bin on most of them. Linux systems use the GNU version of m4, while NetBSD uses its own version which has most if not all of the GNU extensions. The GNU version has been ported to Windows and can be found here. Unfortunately it is not included in the fourth edition of Plan 9, though I've seen some source code files for it on the sources section of the Plan 9 Web site, so it may be included in an update.

For more information on how to use m4, including using the more advanced features not shown in my examples, I recommend reading these notes.

I have more to tell, but this entry has gotten long enough so this will be all for now. I'll be at Jeff's for his Independence Day celebration, which means most likely I'll be skipping the Friday night Radio PSI shows this week.

friends, computing, sotw, personal, starmen.net

Previous post Next post
Up