SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Related Sites

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files

ADMEDIT README $Revision: 1.2 $

Introduction

During my stint as a junior system administrator, I became frustrated by multiple administrators editing the same file and causing errors too numerous to count. I tried to get my fellow administrators to use vipw(8), but even when they did, this only helped the situation with the passwd file. Clearly another solution was needed, but it would have to wait until I could find some free time...

As any administrator knows, there are far more files that require periodic update than just the passwd file. So when I had a few CSTU's (copious spare time units) I wrote admedit. The idea is simple: duplicate what vipw does, but let people edit any file (and use any editor to do it).

Distribution

This program can be freely modified and redistributed under the GNU GPL, version 2, or any later version (at your option). The text of the GPL should be included with the source distribution this README was included with. If for some reason a copy was not included, you can view the text of it at this URL:

http://www.gnu.org/

Installation

At the moment, there's not much to it. I'm not really a programmer, so I wrote it to work on the systems I manage (Linux), but it will probably work on most reasonable Unix-like systems. One of my eventual goals is to keep it pretty portable, so if you find that it doesn't work on your platform, but you know how to make it work, let me know.

Basically, take a look at the Makefile, and see if the locations and permissions defined meet your needs, and edit what doesn't. Then do the following:

$ ./configure
$ make
$ su
# make install

and you should be up and running.

The configure script does have some useful options, such as allowing you to specify where vi and emacs (and eventually jed when I fix it) live, and the usual --prefix will allow you to set where the binary will get installed. admedit is a program that's intended primarily for use by system administrators, so the binary gets installed in $PREFIX/sbin by default. If you want to change that to $PREFIX/bin, you'll have to hand-edit the Makefile after you run configure. You can also define what the default editor is. By default, the default editor will be vi.

See ./configure --help for more details on what options are available.

Running admedit

Since the purpose is to edit system config files, it's intended to be run by root. One of the features it has is to create a lock file owned by the real user who ran it, assuming it can figure out who that is. The purpose of this feature is so that (especially with large administration groups) it becomes much easier for the administrator to determine who is currently editing the file, so that the two can coordinate the changes that each needs to make.

Provided the user is either a) logged in on the current tty (but not as root), b) using sudo to run admedit, c) used su to become root, without using the '-' option, this should work fine. If other methods were used to become root (i.e. su - ) and the user isn't logged in on the current tty (i.e. the getlogin() function returns NULL), then admedit may complain that it can't figure out who is running the program, and create the lock file owned by root.

The lock file is called <filename>.admlock, where <filename> should be replaced by the actual filename of the file being edited. If you wanted to edit, say, /etc/dhcpd.conf for example, you would invoke admedit like this:

# admedit /etc/dhcpd.conf

or

# cd /etc
# admedit dhcpd.conf

In either case, admedit will create a lock file called dhcpd.conf.admlock in /etc, owned by either the real user who ran admedit, or root if it can't determine who that was. Then admedit will run the default editor on the specified file.

In the event that a second person then uses admedit to edit the file while someone else is editing it, the second person will receive a message that the file is locked by user <username>, and admedit will terminate.

After the user is finished editing the file, the lock file will be removed. Some effort was made to make sure the lock file is removed if various fault conditions occur, such as admedit being killed, etc. but of course a kill -9 will leave the lock file behind, as likely would a system crash.

New with version 1.0.0, you can use admedit to lock and edit a list of files simultaneously. For example, if you were adding a host to your network, you might want to do something like this:

# admedit /etc/hosts /etc/dhcpd.conf /var/named/db.mydomain

This makes it easier to lock and edit these files all at once so someone can't sneak in on you and make incompatible changes in the mean time.

Author

admedit is written and maintained by Derek Martin, (ddm@pizzashack.org). If you have comments, suggestions, bug-fixes, etc., please send them to me at that address. Thanks!


Other Sites

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.