tour.mm revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerA Tour of the ast Commands and Libraries
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroeder.AU "Glenn Fowler" gsf MH HA6163000 2195 2B-134 "gsf@research.att.com"
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroeder.H 1 Introduction
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroedercommands and libraries were developed by the
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von SchroederSoftware Engineering Research Department
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederthe Advanced Software [Technology] Department)
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederat AT&T Bell Laboratories, Murray Hill, NJ.
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederis how its individual components
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroedercombine to form a cohesive computing environment across UNIX\u\(rg\d
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederand non-UNIX platforms.
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederis maintained by well-defined library interfaces for
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederalgorithms upon which the commands are built.
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von SchroederIn many cases a library implementation was the driving force behind
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroedercommand implementations.
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von SchroederWhy should you consider using the
91673dab8e4e249ffb3efe5edab8351dfaf4977dJonathan von SchroederAfter all, many of the commands look like what's already in
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von SchroederAlthough there is some replication, there are also some commands you
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroederwon't find anywhere else:
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroederksh93, nmake, the 3d filesystem, cia, and yeast.
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroeder.H 1 Installation
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroedersoftware installs in a single directory hierarchy, rooted at
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroeder.LR $INSTALLROOT ,
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederdirectories are:
0a81f114e958d220a0bebbb90481c0b658f94e8eJonathan von Schroeder bin executable binaries and scripts
0a81f114e958d220a0bebbb90481c0b658f94e8eJonathan von Schroeder fun \fIksh93\fP shell functions
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroeder lib/\fIcommand\fP related files for \fIcommand\fP
0a81f114e958d220a0bebbb90481c0b658f94e8eJonathan von Schroeder src/cmd/\fIxxx\fP source for command \fIxxx\fP
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroeder src/lib/lib\fIxxx\fP source for library \fIxxx\fP
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von SchroederTo access the commands and related data files:
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroederthat has a related data file
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroederis found by searching
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroeder.IL "" ../lib/ command / file ,
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroederthe magic file for the file command is
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroederthen you can selectively override standard
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroederrelated files by placing them in the directory
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroeder.IL "" $HOME/lib/ command .
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von SchroederThis allows executables to be built without hard-coded pathnames and also
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroederrequires only a change in
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von SchroederOn systems with shared libraries one of
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroederexport LD_LIBRARY_PATH=$INSTALLROOT/lib:$LD_LIBRARY_PATH
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroederexport LIBPATH=$INSTALLROOT/lib:$LIBPATH
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroederexport LPATH=$INSTALLROOT/lib:$LPATH
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroederis required to locate the
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroedershared libraries.
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroeder.H 1 Exploration
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von SchroederIt provides C style expressions on path names and elements of
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroeder.LR "struct stat" .
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von SchroederTo find suspicious executables:
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroedertw -d / -e "uid=='root' && (mode&'u+s') && parent.uid!=uid"
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroederto change the owner of all of bozo's files:
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroedertw -d / -e "uid=='bozo'" chown clown:circus
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroedercollects file pathname arguments up to the exec arg limit before it
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroederexecutes the command.
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von SchroederFor paranoid users:
9f6e5ecc1f9743ba77c699f3e533844af9b930bbJonathan von Schroederwhich is equivalent to:
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroeder(Now you don't need to add a
0a81f114e958d220a0bebbb90481c0b658f94e8eJonathan von Schroederoption to your favorite commands.)
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von SchroederTo find all source files that include
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroedertw -e "name=='*.[chly]'" grep -l '^#.*include.*["<]foo\.h[>"]'
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederhandles the magic number matching for the
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederis carefully constructed to give the same output across all architectures:
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroederatt.i386/bin/cat: elf i386 executable, 32-bit, little-endian, ..
50bd139c03ca7e618eb93731e152cfaff3aab94dJonathan von Schroederbsd.i386/bin/cat: bsd 386 executable, compact, paged, pure, no..
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroederhp.pa/bin/cat: hp pa-risc executable, shared, dynamically l..
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroedersgi.mips2/bin/cat: elf mips executable, 32-bit, dynamically lin..
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroedersol.sun4/bin/cat: elf sparc executable, 32-bit, dynamically li..
0a81f114e958d220a0bebbb90481c0b658f94e8eJonathan von Schroedersun4/bin/cat: sun sparc executable, paged, dynamically lin..
9c35e9370ba40eda65921ad592e153e8e471e130Jonathan von Schroederuses the same interface, making it easy to search for files based on type,
9c35e9370ba40eda65921ad592e153e8e471e130Jonathan von Schroedername and content.
9c35e9370ba40eda65921ad592e153e8e471e130Jonathan von SchroederThe following searches for executable scripts:
9c35e9370ba40eda65921ad592e153e8e471e130Jonathan von Schroedertw -e "(mode&'+x') && type!=DIR && magic!='*executable*'"
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederalgorithm efficiently detects file system loops, so following
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroedersymbolic links is not a problem.
9c35e9370ba40eda65921ad592e153e8e471e130Jonathan von SchroederThe same algorithm is used by all
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroedercommands that traverse
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederdirectory hierarchies,
0a81f114e958d220a0bebbb90481c0b658f94e8eJonathan von Schroederand the following options to control pathname resolution:
9c35e9370ba40eda65921ad592e153e8e471e130Jonathan von Schroeder-L (logical) follow symbolic links
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroeder-P (physical) don't follow symbolic links
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroeder-H (metaphysical) -L for command line files, -P otherwise
bf453a6867cca0aa530bc8cac9eed9c3f70594b4Jonathan von Schroederbuiltin controls the default traversal mode:
0a81f114e958d220a0bebbb90481c0b658f94e8eJonathan von Schroedergetconf PATH_RESOLVE - { logical, physical, metaphysical }
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroeder.H 1 Configuration
87d946b3c13ffd7f6391aa796e786c2b31b122b1Jonathan von Schroeder.H 1 Compression