Nov 7 2002


                    LINUX NEWS
            http://www.Cramsession.com
          November 7, 2002 -- Issue #106


TABLE OF CONTENTS

1) Sean’s Notes

2) Linux News

Red Hat Announces New Certification
GNOME Foundation Board Elections
A Bug or Two... Or Six
Missing Chapter From Mitnick's Book

3) Linux Resources

Everything You Ever Wanted to Know About LDAPv3
                       (But Were Afraid to Ask)
Enterprise Snort Installation
Securely Speaking
Fighting Spam
Python Resources

4) App o’ the Week

~~~~~~~~~~~~~~~~~~~~~~ ADVERTISEMENT ~~~~~~~~~~~~~~~~~~~~~~~

Gain study time and enhance your learning! Hear hundreds of certification exam questions on audio CDs or cassettes. Learn while you commute to and from work, exercise, or walk the dog. Ideal for those times when you can’t read. 90-day money back guarantee if you’re not happy.

http://ad.brainbuzz.com/?RC06&AIW49

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For information on how to advertise in this newsletter please contact mailto:adsales@CramSession.com or visit http://cramsession.com/marketing/default.asp


1) Sean’s Notes

Like many people with a Linux box on a cable modem, I’ve got a web server. Nothing fancy, but one of the things it does is let my brother and I post pictures of our kids for our family to see. So, we scan in the pictures, create a directory, and upload the files.

However, what you end up with is a pathetic looking directory listing that Apache gives you. What I’d rather have is a page of thumbnails, each linked to the full sized picture. In shell, this is pretty easy:

echo "My pictures <br>" > index.html
for i in `ls \*.jpg | grep -v ^tn_`; do
  convert -interlace NONE -geometry 133x133 $i tn_$i
  echo "<a href=$i><img src=tn_$i></a><p>" >> index.html
done

Basically, that iterates through each .jpg that doesn’t begin with tn_, and uses the ImageMagick “convert” command to make a 133x133 thumbnail of it called tn_imagename.jpg. The rest is some simple HTML. It’s not too much from there to make this iterate over some directories.

Ick. Each time I re-run this script, it has to recreate the thumbnail from the original file, even if the original file hasn’t changed. Then, even if none of the files have changed, the index file has to be recreated. What a waste. This was fine for a while, but my brother is some sort of scanning freak, and updating his page became a 10 minute job.

What we need is some sort of dependency system. Developers have had this for ages, it’s called “make”. Make’s job is to take a config file that describes the relationship between files, and to execute the proper commands to bring everything up to date.

For example, a programmer might have 100 source files. Each file is compiled into an object file, and all the object files are linked together into an executable. If one source file is updated, then only one object file has to be recreated and the linking step redone to get the final executable. It saves a lot of time.

Makefiles are pretty simple. If we had two .c files that we wanted to build into an executable called “program”, we could do:

program: file1.o file2.o gcc file1.o file2.o -o program

%.o: %.c gcc -c $< -o $@

Call it “Makefile”, and all you have to type is “make” at the command line. This makefile has two stages. Each stage consists of:

target: dependencies instructions for creating target more instructions note that there are no blank lines, and it is tab indented

The first target is for the “program” executable itself. It says that “program” needs “file1.o” and “file2.o”. If either are newer than program, then program has to be rebuilt. You rebuild it by invoking gcc.

The second stage is what is called an implicit rule. Since the commands to build file1.o are the same as building file2.o, I use an implicit rule to say “to build a .o file from a .c file, do this”. $< is expanded to the name of the original (or dependency) file, and $@ is the name of the target.

If you don’t specify which target to make, the first target is built. Thus, “make”, or “make program” are the same. Likewise, to rebuild file2.o, you could run “make file2.o”.

Back on to the pictures. Makefiles sound like a great fit. Nothing says that my makefile has to use a compiler! I’ll use some basic shell scripting to build the HTML, and good old ImageMagick to make the thumbnails like I did in my original script.

At the beginning of my Makefile, I defined some variables (note the use of := to define a variable, and the “shell” command to insert the results of a shell command).

INDEXFILE := index.html
# Precompute the names of the thumbnails
# sed is used to prefix each filename with tn_
THUMBS := $(shell ls \*.jpg | grep -v "^tn_" | sed 's/^/tn_/')

Next, I state that index.html depends on all the thumbnails. To build the index file, I iterate through all the thumbnails, and make a table with five columns.

$(INDEXFILE): $(THUMBS)
        @echo "Building index"
        @n=0
        @echo "&lt;table>" > $(INDEXFILE)
        @for i in $(THUMBS); do \
                if [ "$$n" == "" ] ; then  \
                    echo "&lt;tr valign=top>" >> $(INDEXFILE);  \
                fi;  \
                PIC=`echo $$i | sed 's/^tn_//'`; \
echo "&lt;td>&lt;a href=$$PIC>&lt;img src=$$i>&lt;/a>&lt;/td>"  >> $(INDEXFILE) ; \
                if [ "$$n" == "4" ]; then \
                        echo "&lt;/tr>" >> $(INDEXFILE); \
                fi; \
                n=$$((n+1));  \
                n=$$((n % 5));  \
        done
        @echo "&lt;/tr>&lt;/table>" >> $(INDEXFILE);

A few things to note. It’s all shell scripting within the action part, but since it’s being executed under make, some changes have to be made. For one, if you want to reference a shell variable, you need two dollar signs instead of one. Otherwise, make tries to evaluate the variable itself (that’s why THUMBS only has one $ and i and n have two). Secondly, there are a lot of \ characters in there. They mean “continue this line”. In a normal shell script, you don’t need them, but if you want to do loops within a makefile, you do. Finally, most commands are prefixed with an @. This simply means “don’t output the actual command”. Remove them, and you’ll see what I mean, as a lot of extra stuff will be spit out.

So, I’ve told make how to build index.html out of all the thumbnails. But how do I build the thumbnails? With the implicit rules, it’s pretty easy.:

tn_%.jpg: %.jpg convert -interlace NONE -geometry 133x133 “$<” “$@”

So, if I add a new picture to the directory, I rerun “make” and only one thumbnail is generated, along with the new index file:

$ touch 1.jpg $ make convert -interlace NONE -geometry 133x133 “1.jpg” “tn_1.jpg” Building index

And, if I try to run it again:

$ make make: ‘index.html’ is up to date.

Now I’m off to scan the latest batch of pictures!

Long live the Penguin,

Sean mailto:swalberg@cramsession.com


2) Linux News


Red Hat Announces New Certification

The Red Hat Certified Technician certification was just announced by Red Hat. The RHCT is a half day, practical exam, and is ideal for people moving over from other Unixes into Linux, or those that want a stepping stone to the prestigious RHCE.

http://www.redhat.com/about/presscenter/2002/press_rhct.html


GNOME Foundation Board Elections

It’s that time again… the GNOME Foundation has just closed nominations for its board of directors. As of closing day, only 11 people had been nominated (the board is 11 strong), including Richard Stallman. The list is announced with 23 people in the running.

http://foundation.gnome.org/ballot-summary.html


A Bug or Two… Or Six

Yikes. Six serious security related bugs in Mozilla. It isn’t going to stop me from using this fantastic product, but you can bet I’ll be upgrading as soon as there is a fix.

http://www.theregister.co.uk/content/55/27934.html


Missing Chapter From Mitnick’s Book

Kevin Mitnick, who made the news with his feats of social engineering and subsequent legal troubles, wrote a book about the ordeal. One chapter that was in the preview version of the book never ended up in the final copy, presumably because of the content. Here’s the chapter (sorry for it being in .doc format).

http://www.prognosisx.com/Images/bannedchapter1.doc


3) Linux Resources


Everything You Ever Wanted to Know About LDAPv3

(But Were Afraid to Ask)

This slide show gets into the real details of LDAP, and the improvements made in version 3. LDAP lets you build a central directory for authentication or other information. It is highly scalable, not to mention lightweight (guess what the ‘L’ stands for?).

ftp://kalamazoolinux.org/pub/pdf/ldapv3.pdf


Enterprise Snort Installation

I’ve long been a fan of the Open Source Snort IDS, even though enterprise management has been lacking. This document pulls together many different software tools, and detailed instructions, to build the system.

http://www.superhac.com/snort/snort_enterprise.pdf


Securely Speaking

Here’s a relatively new site devoted to fostering security related discussions. It’s also run by Cramsession user RobnHood, who is a regular on the Linux and Security boards.

http://www.securelyspeaking.com


Fighting Spam

I’ve passed along many links dealing with technical ways to combat spam, but another effective approach involves changing some of your behavior. The advice in this article is easy to follow, and should do a bit to lower the number of junk emails you get.

http://www.macdevcenter.com/pub/a/mac/2002/11/01/spam.html


Python Resources

Python is a scripting language, much like Perl, except much cleaner and a better focus on objects. If you’re looking to get into some Python programming, here are a bunch of links to get you started.

http://www.thinkspot.net/materdei/apcompsci/python/


4) App o’ the Week

“Totem is simple movie player for the Gnome desktop based on xine. It features a simple playlist, a full-screen mode, seek and volume controls, as well as a pretty complete keyboard navigation.”

http://www.hadess.net/totem.php3


(C) 2002 BrainBuzz.com, Inc. All Rights Reserved.


      This message is from CramSession

You are currently subscribed to the following list Hottest Linux News and Resources as: sean@ertw.com

To un-subscribe from this newsletter by e-mail, send a blank email message to: mailto:leave-linuxnews-3825955Y@list.cramsession.com

To subscribe to this newsletter and many others visit our site at: http://newsletters.cramsession.com/signup/default.asp