CPS 346 & 444/544 Lecture notes: Terminals
Coverage: [UPE] Chapter 2 (pp. 52, 65-70) and [USP] §6.5
(pp. 203-213)
crypt program
- encrypts data
- reads from standard input and writes to standard output
- requires a key
- your password is encrypted in the password file;
encryption algorithm has the property that
it is easy to go from the unencrypted to the encrypted form,
but very hard to go in the other direction
Terminals
- tty0, tty1, ..., ptty00
- user terminals
- owned by user
- names vary
- tty
- controlling terminals cannot be redirected from the command line;
consider users storing passwords in a file!
- how to find out which terminal you are using
$ tty
/dev/pts/2
$ ls -l /dev/pts/2
lrwxrwxrwx 1 root root 28 Aug 1 2005 /dev/pts/2 -> ../../devices/pseudo/pts@0:2
$
$ ls -l /devices/pseudo/pts@0:2
crw--w---- 1 cps445-n1.03 tty 24, 2 Feb 19 18:02 /devices/pseudo/pts@0:2
- notice that cps445-n1.03 owns it and has read and write
permission on it
- notice that those in the tty group (i.e., everybody)
can write to it
- chmod 600 /devices/pseudo/pts@0:2 (same as mesg n)
- use /dev/tty when program
needs to interact with a user even when
standard input and output are redirected
$ crypt <cleartext >crypted text
Enter key:
$
Echo off
- notice that in addition to explicitly reading from /dev/tty,
crypt also turns off automatic character echoing
- illustrated and experimented with code to turn echo off;
necessary for all sorts of authentication services
Communication
- getting write to work right
- what about talk? the precursor to instant messaging
- mesg [y/n]
- dmesg (system message buffer)
- biff [y/n]
- mail << HERE
References
| [UPE] |
B.W. Kernighan and R. Pike. The UNIX Programming Environment.
Prentice Hall, Upper Saddle River, NJ, Second edition, 1984.
|
| [USP] |
K.A. Robbins and S. Robbins.
UNIX Systems Programming: Concurrency, Communication, and Threads.
Prentice Hall, Upper Saddle River, NJ, Second edition, 2003
|
|