Quantcast
Username/Email:  Password: 

TinyLogin: Booting up in Small Places

Nicholas gives us a head start on reducing the Linux footprint with TinyLogin.

The feature sets of many of the latest Linux products are often so vast that it may take four to six CDs to hold them all. But a number of developers are going the other direction, slimming Linux down to the bare minimum to meet the needs of the latest embedded Linux systems. Embedded Linux systems are growing in number, popularity and usefulness. Witness the launch of Embedded Linux Journal as a sign of the times.

TinyLogin is a utility intended for embedded systems. It provides the functionality of ten login and user-management utilities in a single tiny binary. TinyLogin was started by Sean Bastille back in 1998. It is now maintained as an open-source project by Erik Andersen, sponsored by his employer, Lineo, Inc. Erik also maintains the BusyBox utility; it's no coincidence that the two are designed to work well together.

Why have a single binary for these ten login utilities? The standard utilities that TinyLogin replaces occupy 140K. That isn't much space, but the attitude of an embedded Linux developer is generally to avoid wasting any space on things that are not needed. The TinyLogin binary is 40K. It doesn't have all the options of the programs it replaces, but most embedded systems don't need them all.

Furthermore, since many developers use GNU libc, TinyLogin allows embedded Linux systems the option to bypass the GNU Name Service Switch (NSS) libraries. These libraries allow GNU libc to use a number of alternative methods for obtaining information such as user names and passwords. Most embedded systems have no need for this functionality, so by eliminating these libraries from their target systems, developers can save another 200K.

How It Works

Linux distributions normally include packages with many separate utilities, often in sets named initscripts, textutils, shellutils or something similar. These utilities and scripts are generally quite feature ladened. The command to list files, ls, supports over 50 command-line options. Because these utilities are so full-featured, they are sometimes larger than expected. For example, on my system the ls command (dynamically linked) occupies 48KB of disk space. While you wouldn't notice that on a standard PC, many of the 50 options are just wasted space on an embedded system or boot disk. TinyLogin combines numerous utilities in a single binary, limiting the features of each utility to those most commonly needed. As another example, the adduser command in TinyLogin supports only three options rather than the 20-plus options of a typical adduser command.

When you enter the name of a utility in a shell it attempts to locate a binary with that name and then execute it. When you install TinyLogin, it creates symbolic links in your filesystem so that instead of having a real adduser command, you have a symbolic link that refers to the TinyLogin binary. A directory listing of adduser would then appear like this:

lrwxrwxrwx 1 nwells users 12 Jan 17 14:47
<@cont_arrow><\#229><@$p>adduser -> /bin/tinylogin

Typing adduser at the command prompt causes the shell to launch the TinyLogin program, which in turn examines the text that you entered to launch it. The program does this by examining the argv programming variable (similar to the positional variables in shell scripting). Seeing that you entered adduser, the TinyLogin program proceeds to act like adduser, interpreting any additional items on the command line as adduser would.

What Does TinyLogin Include?

TinyLogin includes the following ten utilities:

  1. adduser to add new user accounts.

  2. addgroup to add new group accounts.

  3. deluser to delete users from the /etc/passwd and /etc/shadow files.

  4. delgroup to delete groups from /etc/group.

  5. passwd to change a user's password.

  6. getty to manage terminals and start the login process.

  7. login to begin a login session.

  8. su to change current user ID (substitute user, normally used to become root for a while).

  9. sulogin for single-user login (runlevel 1)--this functionality is disabled by default but can be turned on in the Config.h file.

  10. vlock to lock a virtual console until a password is entered--this functionality is disabled by default but can be turned on by modifying the config.h file.

You'll have to judge for yourself if the features included with each of these commands will meet the needs of your embedded-system project. For example, the getty command implemented in TinyLogin doesn't use the /etc/gettydefs or /etc/gettytab configuration files. Instead it relies on a number of command-line options. Fortunately, TinyLogin is completely modular. If you need a more full-featured utility, you can always disable any of the TinyLogin utilities that you prefer not to use and use the standard Linux tools to provide those features.

______________________

Comments

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.
  • Use to create page breaks.

More information about formatting options