Differential Equations Basics

I took a break from programming today to take a look at ordinary differential equations. Below are my summary and notes for the first chapter.

Introduction

A differential equation is an equation involving an unknown function and its derivatives. For example:

Notation

Often we use a short hand notation. To represent the derivates of a function y with with respect to the independent variable under consideration, we can use:

The parentheses are used to distinguish the derivative from exponentiation. If the function is with respect to time, raised dots, instead of ticks, are often used instead.

Solutions

A solution of a differential equation in the unknown function y and the independent variable x on the interval I is a function y(x) that satisfies the differential equation identically for all x in I. For example, the function:

is a general solution of

Initial-Value and Boundary-Value Problems

We close this chapter with a brief discussion on initial-value and boundary-value problems. A differential equation with subsidiary conditions on the unknown functions and its derivatives, all given the same value of the independent variable, constitutes an initial-value problem. If the subsidiary conditions are given at more than one value of the independent variable, it becomes a boundary-value problem. Clearly, a solution to an initial-value or boundary-value problem is a function y(x) that solves the differential equation and satisfies all given subsidiary conditions.

Next time, I’ll take a look at classications of first-order differential equations, including linear equations, Bernoulli equations, and separable equations.

PHP File Upload

I’m consistently impressed by the features that PHP provides programmers when developing web applications. Today I discovered the PHP File Upload interface. It’s surprisingly simple to implement, and I’ve already used the technology on one of the web design projects that I’ve been working on recently.

Mozilla Fundamental Concepts

eb8ce3115c87897496346eac5dea4095

Right now the goal of writing a Mozilla Thunderbird extension seems very far away. I’m having a hard enough time as it is just wrapping my head around the massive set of technologies provided by the Mozilla Platform. This looks to be a long, difficult journey, with quite a bit of reading along the way. In the meantime, however, I’m going to try to make note of the documentation and resources that I’ve discovered thus far.

Standards

Mozilla Stepping Stones

Books and Tutorials

Resources

The Theoretical Model

With Advanced Linux Programming out of the way, I thought I’d try a new approach to enlightenment and tackle multiple domains at once: the abstract, applied, and concrete. Allow me to explain.

  1. The abstract includes topics such as pure mathematics and theory that has no direct, tangible effect. However, it is the basis for applied theoretical topics. The study of analog and digital communications in the frequency domain might be an example of this category.
  2. Applied topics take abstract topics and then uses them as a foundation for further study in some field. For example, using digital network theory to study modern network techniques such as ethernet or Internet addressing.
  3. A concrete topic takes an applied topic and produces an actual result. This is generally a program or a physical circuit. Writing a network program that utilizes TCP/IP to remotely read a file, or buildling an AM/FM radio, would fit into this category.

The goal is to simultaneously study a topic in each of these broad categories. Furthermore, they can be mutually exclusive. So with that out of the way, here are the texts that I intend to complete roughly within the next two months:

  1. Bronson, Richard. Differential Equations. My college studies of this subject have always been a bit weak. I did just enough to do well in course, but not enough to actually learn the material. Here’s my second chance, if you will.
  2. Tanenbaum, Andrew and Woodhull, Albert S. Operating Systems: Design and Implementation. With the conclusion of ALP, it’s time to move one step closer to the operating system internals. I’m greatly looking forward to this one.
  3. McFarlane, Nigel. Rapid Application Development with Mozilla. I have some interesting ideas for Mozilla and Firefox plugins, and this text should help turn those ideas into an actual product.
  4. Boswell, David. Creating Applications with Mozilla. After further consideration, perhaps the previous text might not be the best way to start. Instead, I may use the online text.

Let’s see how this experiment works out.

Linux Security

I conclude my discussion of Advanced Linux Programming by summarizing Chapter 10 of ALP. In this chapter, we take an introductory look at Linux security through the use of its users and and groups mechanism. This article is intentionally brief, primarily because Linux, more or less, is POSIX compliant and behaves similarly to other POSIX-like systems.

Users and Groups

Each Linux user is assigned a unique number, called a user ID or UID. When you login using a username, the system converts the username internally to a user ID. As a result, it’s entirely possible to have more than one username that refers to the same user. To share resources among multiple users, Linux provides the concept of groups. Like a UID, a group is also a unique number, called a group ID, or GID. Every group can contain multiple user IDs, and a single user can be a member of multiple groups. Groups cannot have subgroups. You can use the id command to view information the user and groups that you belong to.

The Superuser

The superuser has a user ID of 0, and is usually named root. This account can basically do anything, and should be well guarded. In particular, programs running as root must be written very carefully.

Process User IDs and Process Group IDs

Users and groups also reveal themselves when working with processes. Every process has an associated user ID and a group ID. Thus, when we say that a user performs an operation, we are really saying that a process with a corresponding user ID performs that operation.

If a program needs to modify user and group permissions, then it should use the uit_t and gid_t types. Even though user and group IDs are essentially integers, treat these fields as opaque handles for user and group identity.

File System Permissions

Each file has exactly one owning user and exactly one owning group. In general, when you create a file, the file is owned by the user and group of the creating process. The basic things that you can do with files are read, write, and execute. There are some nuances involving directories and their behavior, but it’s not worth discussing them here.

Sticky Bits

In addition to read, write, and execute permissions, there is a magic bit called the sticky bit. It applies only to directories. A directory that has the sticky bit set allows you to delete a file only if you are the owner of that file. A few directories, such as /tmp, have the stick bit set.

Real and Effective IDs

Processes aren’t really as simple as I made them out to be earlier. Every process actually hast wo user IDs. An effective user ID and a real user ID. Most of the time, the kernel only checks the effective ID. This is done using the geteuid and getegid functions. A user without root priveleges can only perform the operations with effective and real IDs:

  • set its effective user ID to be the same as its real user ID
  • set its real user ID to be the same as its effective user ID
  • swap the two user IDs

Programs like login use real and effective IDs to transfer control from one username to another.

Setuid Programs

There exists a special class of setuid programs. When a setuid program is run, the effective user ID of the process will that of the file’s owner rather than the effective user ID of the process that performed the exec call. To use setuid, use chmod +s on the command line, or the S_ISUID flag if calling chmod programmatically.

Authenticating Users

If you writing a program that requires authentication, it’s typically best to allow the system administrator to decide what kind of authentication mechanism he or she will use. Consequently, Linux uses the pluggable authentication module, or PAM to authenticate their users as a system administrator sees fit. Thus, always use PAM if developing an application that requires authentication.

FreeBSD Impressions

Since FreeBSD is now up and running, I wanted to take the opportunity to share my initial impressions about this operating system. To begin, FreeBSD has the fastest, easiest setup that I’ve ever seen. In fact, I had a FreeBSD system up and running in under fifteen minutes. And I especially like the centralized sysinstall interface, which I first encountered during the install session. It’s essentially a gateway into all of the options that one can configure on the system. The next thing I noticed was how quickly I was able to get a headless server setup up and running. Thanks to the FreeBSD Handbook, setting up a serial console was a breeze. This configuration is especially useful for me since the machine in question has no keyboard or monitor attached. As a side note, the FreeBSD Handbook is an amazing piece of documentation. It has everything necessary to get the user up to speed, and assumes just the right amount of technical knowledge for someone who is already familiar with Linux.

I always thought that my preferred operating system, Debian, was secure out of the box. It certainly is, but I soon after noticed just how much more FreeBSD does in this domain. First, it has the bare essentials of system services running. Second, most ports are closed by default. And finally, the root user is not allowed to SSH into the machine, and users by default cannot su into root without adding themselves to the wheel group. These are just some of the many security features that FreeBSD offers out of the box. The devil is in the details, no pun intended.

While I’m not quite ready to give up Debian for desktop machines, I can safely say that from now on I’ll be using FreeBSD for any server setup that comes my way. Despite only working with the operating system for a few days, I can already see why rapid FreeBSD fans are as adamant about their system as they are. It really is that good.

SMC EtherEZ 8416 on FreeBSD

This is mostly an entry that is useful only to myself, but I know that sometime in the future, I’ll be glad that I wrote it. After a day of struggling, I was finally able to get the SMC EtherEZ 8416 ISA card to work on FreeBSD. After getting a rough idea of how the FreeBSD system operates, it was a walk in the park. Here’s how I did it:

  • The SMC 8416 card is no longer manufactured. Furthermore, the only way to modify the settings on the card is through the Caldera DOS SMC EZStart software, which is difficult to find these days. It’s important enough that I’ve mirrored it on my very own site.
  • The software can be extracted in Windows by using WinImage, or by unzipping the file and using rawrite on Linux. Write the raw image to a floppy disk.
  • Boot from the disk and run ezstart.exe. Turn off PnP support, and write down the I/O base address and the IRQ.
  • Hop back into FreeBSD. Edit the /boot/device.hints file, and scroll down to the ed0 device. Here you can manually load device drivers.
  • Change the disabled variable to 0, and modify the port and irq argument with the values you wrote down earlier. I think that you can leave the maddr field alone.
  • Reboot the machine.
  • Using sysinstall, you’ll find that the device is now available for further configuration.

Bad Day

Relatively speaking, today was a bad day. I did manage to setup the Vonage equipment and it works without a hitch. They also offer Vonage Third Party Call Control API that looks quite promising for developing custom applications. The remainder of the day disappeared while helping Adam recover data off freya. I’m going to scrap the system and try again with FreeBSD 5.3, mainly because it’s different, and I because I enjoy trying out new operating systems.

While I did succesfully recover the data with the use of the INSERT Rescue CD, things went downhill from here. The freya server has an esoteric SMC 8416 ISA card which the company itself no longer supports. I eventually found the EZStart setup disk from the Linux Router project, and I hope to get everything sorted out tomorrow.

Linksys WRT54G Brick

An upgrade to the latest Alchemy 6rc1 firmware had the net effect of turning our beautiful Linksys WRT54G router into nothing more than a brick. I guess I should have done a bit more research before trying to hack the device, but luckily, I’ve finally gotten everything sorted out again. The details of what actually happened are fairly uninteresting and tedious to explain, so I’ll get to the point and tell you what to do when you completely bork your router. Hopefully it will allow you to avoid some of the tough love and hard lessons that I faced today in the realm of embedded systems.

Preventative Measures

First, let’s talk about what to do if your device is already working. These are some preventative measures that will really help out if you do eventually end up turning your router into a brick. If you’re already using a third-party firmware, for example, you should go ahead and set the boot_wait parameter to on in your nvram:

nvram set boot_wait=on
nvram commit

There should be no need to ever unset boot_wait. The variable allows you a three to five second window to tftp over new firmware at bootup and avoid otherwise catastrophic failure. The OpenWRT users guide has more details. Next, go ahead and download all the firmware and software that you’ll need to bring your router back to life. After all, Internet access can be quite problematic to obtain when your primary router is dead. So save yourself the headache and download the firmware upgrade files and the Auto Upgrade Utility.

Also, remember to disable the password when upgrading your firmware. Linksys firmware updates use the trivial FTP (tftp) protocol, but it’s a non-standard modification that supports authentication. By disabling the password, you’ll still be able to use standard tftp utilities to update the firmware. Note, however, that boot_wait will never request a password, since it essentially bypasses the standard loading mechanism. In my opinion, your best bet is to simply boot up Windows and use the official Linksys utility.

Corrupt Firmware

If you’ve forgotten to set boot_wait, but your firmware is corrupt, don’t despair. On many systems, a corrupt firmware can mean the end of a device. But the Linksys engineers did a fantastic job on this hardware and were smart enough to provide users with a way out. A corrupt firmwire can be identified by the constantly flashing red diagnostic light. When this occurs, your router has most likely gone into PROM mode, a minimalistic, base environment that has just enough functionality to upload a new, working firmware. Linksys provides instructions on how to fix a red blinking diagnostic light. Remember to set your ethernet card to 10Mb, half duplex.

Linksys Brick

The worst of all cases is when you’ve uploaded a non-corrupt firmware, but the firmware itself doesn’t actually work because of bugs. Most users don’t run into this case, but for those of us who like to hack our own firmware, this is a common dilemma. If you set the boot_wait parameter, then this is trivial to fix. If not, you’re in for a world of hurt, but revival is not insurmountable. You will, however, void your warranty. It’s time to open up your device and hack the WRT554G.

Congratulations, your Linksys router is now immortal.

CenterICQ

I’ve recently come to the conclusion that inherently text based systems should be accessed through a console interface. At first that seem like a silly idea, until I quickly recall that I already use mutt for e-mail, slrn for newsgroups, and dict for dictionary definitions. So for those crazy neoluddites like myself who continue to use consoles, I want to tell you about instant messaging, and the use of such a technology through non-graphical interfaces. Read on for my experiences.

CenterICQ is a console instant messaging client that runs on Linux and uses the ncurses library. With the aid of screen and a remote, dedicated Linux box, I’m able to access AIM, Jabber, and a host of other protocols from a centralized location, irrespective of which machine I’m currently on. As a side effect, I’m also able to remain online even when all my systems are offline.

Common intuition might dictate that console applications are less intuitive and more difficult to navigate. This is hardly the case with CenterICQ. The client has a clean, window-driven interface that, in my opinion, is actually faster to use than a traditional graphical client. If you’re a Linux geek, I strongly recommend that you give CenterICQ a try. And if for some reason things just aren’t working out, then hey, there’s always naim.