The dkapp module in the dklibs library set (see
http://dklibs.sourceforge.net)
provides preferences managment, localization, logging and other features.
These features a described in detail in
http://dklibs.sourceforge.net/dklibs.pdf
In a short summary, the programs below marked as dkapp-based provide
the following command line options:
The kls program lists files and/or directories. Special features are
configurable output column order, size calculation for directories
and checksum calculation.
The program is invoked by
kls [<options>] [<path(s)>]
The following options can be used:
| n | file name | |
| s | file size | |
| t | file type | |
| p | permissions | |
| x | message digest (checksum), see the -m option | |
| l | number of links | |
| c | file creation timestamp | |
| m | last modification timestamp | |
| a | last access timestamp | |
| u | file owner UID | |
| g | file group GID | |
| d | device number | |
| r | relative device number | |
| i | inode number |
| MD5 | RSA Data Security, Inc. MD5 Message-Digest | |
| SHA-1 | SHA-1 message digest as published in FIPS PUB 180-1. |
| f | regular files | |
| d | directories | |
| p | pipes | |
| c | character special devices | |
| b | block special devices | |
| s | sockets | |
| o | all other file types |
| d | show only information about the directory itself | |
| c | show information about the directory contents |
The ksort program reads input from a file (or standard input), sorts the
lines and prints output to a file (or standard output).
Lines can be sorted by alphabetical comparisons, decimal number comparisons
or floating point number comparisons.
The following options are available:
The createp program suggests passwords. Different account types can
be prepared (i.e. for administrators and normal users), passwords
for different account types have different complexity.
Account types can be set up by
createp -c -t <type> -o default -l <range> -d <range> -s <range> -k <range> -a <prng> [-p] createp -c -t <type> -o <mode> -l <range> -a <prng> [-p]
The type argument is the account type name to set up, the
-l option specifies the password length, the -d option the number of digits
in the password, the -s argument the number of special characters and
the -k argument the number of uppercase characters.
The -a argument chooses a PRNG, choose either ``all'' or one or multiple
(separated by comma) from the list ``openssl'', ``random'', ``rand48'', ``rand''.
The -o argument specified the output mode, choose one from
``default'', ``hex'', ``ascii85'' or ``charset''. The default mode allows to
specifiy the number of digits, special and uppercase characters explicitly.
The hex mode produces hexadecimal output containing digits and the characters
``a''...``f''. The ascii85 mode creates password containing characters
in the range 33...127 (decimal). The charset mode requires an additional argument
to specify the set of usable characters. In this argument any lowercase
character represents all lowercase characters, any uppercase character represents
all uppercase characters and any digit represents all digits.
Examples:
createp -c -t admin -o ascii85 -l 8-10 -a openssl createp -c -t wpa-key-1 -o hex -l 64 -a all -p createp -c -t wpa-key-2 -o ascii85 -l 32 -a all -p createp -c -t test -o charset a0 -l 8-10 -a all createp -c -t user -o default -l 6 -d 2 -s 0 -k 0 -a all
creates the account type ``admin'', ``wpa-key-1'', ``wpa-key-2'',
``test'' and ``user''.
The ``user'' type was the last type configured, so it is the default
type.
Run
createp <username(s)> createp -t <type> <username(s)>
i.e.
createp joe jim jack createp -t admin richard
to create passwords.
In dktools-1.2.26 and above createp can use several PRNGs depending on the
system and the libraries installed on the system. The program checks
which of the PRNGs ``openssl'', ``random'', ``rand48'' and ``rand''
are allowed by the -a option (in the order shown here).
It uses the first allowed PRNG which can be seeded.
The recommended PRNG is the PRNG provided by the OpenSSL library,
the other PRNGs are more predictable.
The dksavepw application reads a password from terminal and saves it to
file. Keyboard echo is disabled while reading the password.
If the program fails to disable keyboard echo a message is printed and the
user is asked whether or not to continue reading the password.
dksavepw [<options>] <outputfile>
The following options can be used:
The dklogger program is logger clone for Windows. One can send messages by typing
dklogger [-p <feature>.<priority> ] <message>
i.e.
dklogger -p auth.notice LOGIN jim
Syslog hosts are specified in preferences, the names are
/syslog/host/<nnn>/destination
where nnn is a three-digit number in the range 000-015. An example
for a preference name is "/syslog/host/000/destination".
The preference value is a string consisting of host and port number, separated
by a colon. The host can be specified as host name or IP address.
The available features are "auth", "authpriv", "cron", "daemon", "ftp", "kern",
"lpr", "mail", "mark", "news", "security", "syslog", "user", "uucp", "local0",
"local1", "local2", "local3", "local4", "local5", "local6", and "local7".
The priorities are "alert", "crit", "debug", "emerg", "error", "info",
"none", "notice", "panic" and "warning".
The showhex program shows the contents of a binary file in hexadecimal notation. It can be invoked by
showhex [ <options> ] [ <file(s)> ]
If no filename is specified the program runs as filter.
The following options are available:
The rndbytes program writes pseudo random data to a file. The syntax
is
rndbytes options outputfile
The following options can be used:
To erase an entire disk containing confidential data run
rndbytes -b 4096 -n 0 -a all | dd of=/dev/sda bs=4096
multiple times.
Run
dd if=/dev/zero of=/dev/sda bs=512
once, so a software installation program or a disk formatting program finds
a ``new'' empty disk.
Note: The /dev/sda device name was used as an example. Make sure
to provide the correct device name of the disk you want to erase.
Note: Overwriting an entire disk using pseudo-random data may take
a very long time. The edbp
program can be used to fill an entire disk with
static patterns. Even if you run edbp multiple times to use different
patterns it is faster than using rndbytes once for pseudo-random patterns.
The text2lat program converts a text file into a corresponding
LaTeX source file. The program can also run as a filter.
The syntax is
text2lat [<options>] [<inputfile> [<outputfile>]]
The following options can be used:
A typical usage scenario is to write software documentation using Vim or other vi clones. Imagine you want to typeset text like
Install the library to C:\Program Files\My Software and use the function mylib_do_something() to do something.
Normally you would type
Install the library to
C:\textbackslash{}Program Files\textbackslash{}My Software
and use the function
mylib\textunderscore{}do\textunderscore{}something()
to do something.
in the editor.
Using Vim or another vi clone you can type the original text, find
the line numbers where the text section starts and ends and run
:11,15!text2lat
This removes the contents of lines 11...15 from the editor buffer, feeds the text as input to text2lat and inserts the programs output into the editor buffer.
The text2htm program converts text (plain text or UTF-8 encoded text) to
HTML. The program can either convert files or run as a filter.
The syntax is
text2htm [<options>] [<inputfile> [<outputfile>]]
The following options can be used:
The tape program can be used to manage backup tapes (or other backup media).
It uses a ten-tape-rotation-scheme using each media 20 times for a
200 day period (200 backups).
A tape set is a set of 10 tapes. This set is to used
a backup set (group of directories backed up together).
When a backup is to be done we have to ask for the current tape set first.
The next step is to ask for the tape number within the set.
After doing the backup we have to confirm the tape and the tape set.
The following program invokations can be used:
Example:
Imagine a typical NFS server. We want to back up user data
very often, this is backup set "A". For disaster recovery we want
to back up the "/etc" directory and some other data, this is backup
set "B".
We write a file "/etc/backup/sets", contents is
A A A A B
This means we want to back up "A" four times a week, "B" only once.
The backup script may look like
set BCKDIR = /etc/backup
set theset = `tape sn $BCKDIR/sets`
set thetape = `tape tn $BCKDR/tape.$theset`
echo Starting backup to $theset $thetape .
if ( { write_backup_to_tape $theset } ) then
tape tc $BCKDIR/tape.$theset
tape sc $BCKDIR/sets
endif
set theset = `tape sn $BCKDIR/sets`
set thetape = `tape tn $BCKDR/tape.$theset`
echo Please insert tape $theset $thetape for next backup.
The uid program searches for the first free (unused) user ID
in a given range.
The syntax is
uid <min> <max>
i.e.
uid 3111 4000
searches for the first free UID in the range 3111...4000.
Blksize changes the block size of a data stream, input is read from standard input, output is written to standard output. The syntax is
blksize blksize <size>
The intended use is restoring disk partitions (file systems) from
compressed images.
To save a partition use
dd if=/dev/hda3 bs=512 | gzip -9> image.dat
To restore the image use
gzip -dc image.dat | blksize 512 | dd of=/dev/hda3 bs=512
You can use more complicated mechanisms, i.e. use netcat to save the compressed image on a different computer.
The filtmsql application reformats output produced by mysqldump
to avoid overlong lines. Line breaks are inserted before the second
table entry and all following entries of each table.
Use
filtmsql filtmsql <inputfile> filtmsql <inputfile> <outputfile>
to run the program. Standard input and standard output are used if no file names are specified.
Windows operating systems allow to use spaces and ligatures
(i.e. german umlauts) in file names.
Samba also accepts these names.
When using scripts for doing backup spaces and umlauts may cause
problems. The cona program corrects all filenames in a given
directory and all subdirectories to have no spaces and no umlauts.
The program invokation syntax is
cona <directory>
i.e.
cona /export/home
The echo2lat program converts the command line arguments to the
corresponding LaTeX encoding.
Imagine you want to write a documentation for some software. You want
to typeset
``Install the software to C:\Program Files\My Software''
in LaTeX, you would have to write
``Install the software to C:\textbackslash{}Program Files\textbackslash{}My Software''. To avoid typing all the ``\textbackslash{}'' manually, choose
an option like ``insert a programs output'' from the editors menu. In the
dialog asking for a command, type
echo2lat C:\Program Files\My Software
As an example, in Vim (or other vi clones) use the command
:r!echo2lat C:\Program Files\My Software
The klammern program is a simple paranthesis counter for C code.
It counts opening and closing brackets, curly brackets... ("()[]{}")
and prints a report. This can be used to track down compiler errors in
large source files.
Modern editors - i.e. Vim - allow to find the matching paranthesis
of a pair by simply pressing one key. The klammern program is for
those without such an editor.
The program invokation syntax is:
klammern <inputfile>
i.e.
klammern mysource.c
The addctrld program simply pipes input to output and adds a
Ctrl-D at the end.
This is usefull to indicate the end of a PostScript print job.
The program invokation syntax is
addctrld [ <inputfile> [ <outputfile> ] ]
Source code often contains tabulators. When inserting source code
into a "verbatim"-environment in LaTeX, tabulators are ignored.
So we must replace tabulators by an appropriate sequence of spaces.
The tabrep program does this, the syntax is
tabrep [ <input-file> [ <output-file> ] ]
Instead of using tabrep you might decide to use the listings LaTeX package to include program source code in *.tex files.
The dkpwd program is a pwd clone for Windows users. It prints the
current working directory to the standard output.
Syntax is:
dkpwd [ -b ] [ -p ]
The -b option replaces all backslashes by forward slashes.
The -p option prints the directory without a trailing newline. This
can be used to generate prompt signs (i.e. in tcsh on Windows systems).
The edbp program creates an ``infinite'' sequence of blocks containing
a byte pattern. The program runs until stopped by a signal, i.e. SIGPIPE.
It can be used to overwrite entire disks.
The command line syntax is:
edbp pattern-number block-size
The pattern number must be in the range 0...7.
The following patterns are used:
| pattern number | pattern |
| 0 | 0x00 |
| 1 | 0xFF |
| 2 | 0x0F |
| 3 | 0xF0 |
| 4 | 0x33 |
| 5 | 0xCC |
| 6 | 0x55 |
| 7 | 0xAA |
To erase the sdb disk for example, run
edbp 7 4096 | dd of=/dev/sdb bs=4096 edbp 6 4096 | dd of=/dev/sdb bs=4096 edbp 5 4096 | dd of=/dev/sdb bs=4096 edbp 4 4096 | dd of=/dev/sdb bs=4096 edbp 3 4096 | dd of=/dev/sdb bs=4096 edbp 2 4096 | dd of=/dev/sdb bs=4096 edbp 1 4096 | dd of=/dev/sdb bs=4096 dd if=/dev/zero of=/dev/sdb bs=4096
For increased security you might want to use random patterns instead of static
patterns. For this purpose use the rndbytes program
instead.
Note: Using pseudo-random patterns instead of static patterns is
probably more secure but takes a significantly longer time.
The rshdown program is a daemon for Unix/Linux. If one UPS is used for powering multiple computers, only one computer (the shutdown master) has a control connection to the UPS. If a power fail shutdown is necessary this computer must notify the other computers (shutdown slaves). The shutdown master uses netcat to send an UDP data packet to the slaves. Multiple UDP packets can be sent to each slave, the first valid packet shuts down the slave, further packets are ignored. On the slaves the rshdown daemon waits for UDP data packets. If a shutdown-related data packet is received the rshdown daemon checks the packet for integrity and shuts down the slave if necessary.
Create a datafile containing up to 1500 bytes of random data (you can
use the rndbytes program to do so).
Use a secure mechanism (floppy or scp) to transfer the data packet file between master
and slaves. Make sure the data packet file is only readable by user root, other
users must not have any permissions to it.
On the shutdown master modify the runlevel scripts as follows: On each boot create an indicator file, i.e. /var/run/rshdown/rshdown.txt. The contents of this file does not matter, only presence is important. On each shutdown check for the presence of the indicator file. If the file exists, use netcat to send the contents of the data packet file as UDP datagrams to the slaves. Make sure netcat binds to a specified local port before sending datagrams, use a free privileged port (1...1023). In the example below we use port 2/UDP. In /etc/motd write some text to remind the user root to remove the indicator file before doing a scheduled (not power-related) shutdown or reboot.
Configure each of the shutdown slaves as follows:
/etc/powerfail-full > /dev/null 2>&1 &and make it executable. This script must return immediately, it can start longer processes in the background.
/usr/sbin/poweroffMake the file executable.
sender-ip 192.168.1.2 sender-port 2 receiver-ip 192.168.1.3 receiver-port 2 file /etc/rshdown-secret action /etc/powerfail-fast