This commit is contained in:
SunnyQjm committed 2021-08-25 14:31:32 +08:00
commit 42ffff312c
18797 files changed
+5224904

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
Releases is copyrighted by The Regents of the University of California.
Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the University of
California, Berkeley and its contributors.
4. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
The Institute of Electrical and Electronics Engineers and the American
National Standards Committee X3, on Information Processing Systems have
given us permission to reprint portions of their documentation.
In the following statement, the phrase ``this text'' refers to portions
of the system documentation.
Portions of this text are reprinted and reproduced in electronic form in
the second BSD Networking Software Release, from IEEE Std 1003.1-1988, IEEE
Standard Portable Operating System Interface for Computer Environments
(POSIX), copyright C 1988 by the Institute of Electrical and Electronics
Engineers, Inc. In the event of any discrepancy between these versions
and the original IEEE Standard, the original IEEE Standard is the referee
document.
In the following statement, the phrase ``This material'' refers to portions
of the system documentation.
This material is reproduced with permission from American National
Standards Committee X3, on Information Processing Systems. Computer and
Business Equipment Manufacturers Association (CBEMA), 311 First St., NW,
Suite 500, Washington, DC 20001-2178. The developmental work of
Programming Language C was completed by the X3J11 Technical Committee.
The views and conclusions contained in the software and documentation are
those of the authors and should not be interpreted as representing official
policies, either expressed or implied, of the Regents of the University
of California.
View File
Whitespace-only changes.
+53
View File
@@ -0,0 +1,53 @@
#
# @(#)aliases 8.2 (Berkeley) 3/5/94
#
# Aliases in this file will NOT be expanded in the header from
# Mail, but WILL be visible over networks or from /bin/mail.
#
# >>>>>>>>>> The program "newaliases" must be run after
# >> NOTE >> this file is updated for any changes to
# >>>>>>>>>> show through to sendmail.
#
# Basic system aliases -- these MUST be present.
MAILER-DAEMON: postmaster
postmaster: root
# General redirections for pseudo accounts.
bin: root
daemon: root
games: root
ingres: root
nobody: root
system: root
toor: root
uucp: root
# Well-known aliases.
manager: root
dumper: root
operator: root
# trap decode to catch security attacks
decode: root
# OFFICIAL CSRG/BUG ADDRESSES
# Ftp maintainer.
ftp: ftp-bugs
ftp-bugs: bigbug@cs.berkeley.edu
# Distribution office.
bsd-dist: bsd-dist@cs.berkeley.edu
# Fortune maintainer.
fortune: fortune@cs.berkeley.edu
# Termcap maintainer.
termcap: termcap@cs.berkeley.edu
# General bug address.
ucb-fixes: bigbug@cs.berkeley.edu
ucb-fixes-request: bigbug@cs.berkeley.edu
bugs: bugs@cs.berkeley.edu
# END OFFICIAL BUG ADDRESSES
+11
View File
@@ -0,0 +1,11 @@
# map for /home
/defaults type:=nfs;opts:=rw,-T,-i,-b,-q;rhost:=${key/};rfs:=${path}
# MACHINE is the machine hostname.
# import an individual file system
MACHINE host!=MACHINE;rfs:=/a host==MACHINE;type:=link;fs:=/a
# import an entire machine's exported file systems
MACHINE type:=auto;pref:=MACHINE/;fs:=${map}
MACHINE/a host!=MACHINE;rfs:=/a host==MACHINE;type:=link;fs:=/a
MACHINE/b host!=MACHINE;rfs:=/a host==MACHINE;type:=link;fs:=/b
+3
View File
@@ -0,0 +1,3 @@
# map for /n
/defaults opts:=rw,intr;fs:=${autodir}/${rhost}
* rhost:=${key};type:=host;rfs:=/
+47
View File
@@ -0,0 +1,47 @@
# @(#)changelist 8.1 (Berkeley) 6/9/93
#
# List of files which the security script backs up and checks
# for modifications.
/etc/Distfile
/etc/aliases
/etc/changelist
/etc/crontab
/etc/csh.cshrc
/etc/csh.login
/etc/daily
/etc/distfile
/etc/exports
/etc/fstab
/etc/ftpusers
/etc/group
/etc/hosts.equiv
/etc/mail.rc
/etc/master.passwd
/etc/monthly
/etc/named.boot
/etc/netstart
/etc/networks
/etc/nfsstart
/etc/passwd
/etc/printcap
/etc/protocols
/etc/rc
/etc/rc.local
/etc/remote
/etc/security
/etc/sendmail.cf
/etc/sendmail.cw
/etc/services
/etc/shells
/etc/slip.hosts
/etc/slip.login
/etc/start-amd
/etc/syslog.conf
/etc/ttys
/etc/weekly
/root/.cshrc
/root/.klogin
/root/.login
/root/.profile
/root/.rhosts
+13
View File
@@ -0,0 +1,13 @@
# Crontab file; see cron(8) for more information.
#
# @(#)crontab 8.1 (Berkeley) 6/9/93
0,15,30,45 * * * * root /usr/libexec/atrun
#0 1 * * * daemon /usr/contrib/news/daily
#0 0 * * * uucp /etc/uucp.daily
#7 5,12,18 * * * uucp /etc/uucp.6hours
0 2 * * * root /bin/sh /etc/daily 2>&1 | tee /var/log/daily.out | mail -s "daily output" root
30 3 * * 6 root /bin/sh /etc/weekly 2>&1 | tee /var/log/weekly.out | mail -s "weekly output" root
30 5 1 * * root /bin/sh /etc/monthly 2>&1 | tee /var/log/monthly.out | mail -s "monthlyoutput" root
+3
View File
@@ -0,0 +1,3 @@
# Crontab.local file; see cron(8) for more information.
#
# @(#)crontab.local 8.1 (Berkeley) 6/9/93
+1
View File
@@ -0,0 +1 @@
# System-wide .cshrc file for csh(1).
+1
View File
@@ -0,0 +1 @@
# System-wide .login file for csh(1).
+1
View File
@@ -0,0 +1 @@
# System-wide .logout file for csh(1).
+164
View File
@@ -0,0 +1,164 @@
#!/bin/sh -
#
# @(#)daily 8.2 (Berkeley) 1/25/94
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
host=`hostname`
echo "Subject: $host daily run output"
bak=/var/backups
echo ""
echo "Removing scratch and junk files:"
if [ -d /tmp ]; then
cd /tmp && {
find . -type f -atime +3 -exec rm -f -- {} \;
find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
>/dev/null 2>&1; }
fi
if [ -d /var/tmp -a "X$CLEANVARTMP" = X1 ]; then
cd /var/tmp && {
find . ! -name . -atime +7 -exec rm -f -- {} \;
find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
>/dev/null 2>&1; }
fi
if [ -d /scratch ]; then
cd /scratch && {
find . ! -name . -atime +1 -exec rm -f -- {} \;
find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
>/dev/null 2>&1; }
fi
if [ -d /var/preserve ]; then
cd /var/preserve && {
find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
fi
if [ -d /var/rwho ] ; then
cd /var/rwho && {
find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
fi
cd /tmp
TMP=daily.$$
find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
-name 'lost+found' -a -prune -o \
-name '*.core' -a -print -o \
\( -name '[#,]*' -o -name '.#*' -o -name a.out \
-o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
-a -atime +3 -a -exec rm -f -- {} \; -a -print > $TMP
echo ""
echo "Possible core dumps:"
egrep '\.core' $TMP
echo ""
echo "Deleted files:"
egrep -v '\.core' $TMP
rm -f $TMP
msgs -c
if [ -f /etc/news.expire ]; then
/etc/news.expire
fi
echo ""
echo "Purging accounting records:"
mv /var/account/acct.2 /var/account/acct.3
mv /var/account/acct.1 /var/account/acct.2
mv /var/account/acct.0 /var/account/acct.1
cp /var/account/acct /var/account/acct.0
sa -s > /dev/null
# If ROOTBACKUP is set to 1 in the environment, and
# if filesystem named /altroot is type ufs, on /dev/* and mounted "xx",
# use it as a backup root filesystem to be updated daily.
[ "X$ROOTBACKUP" = X1 ] && {
rootdev=`awk '$2 == "/" && $1 ~ /^\/dev\// && $3 == "ufs" && \
$4 == "rw" \
{ print substr($1, 6) }' < /etc/fstab`
rootbak=`awk '$2 == "/altroot" && $1 ~ /^\/dev\// && $3 == "ufs" && \
$4 == "xx" \
{ print substr($1, 6) }' < /etc/fstab`
[ X$rootdev != X -a X$rootbak != X ] && {
sync
echo ""
echo "Backing up root filesystem:"
echo "copying /dev/r$rootdev to /dev/r$rootbak"
dd if=/dev/r$rootdev of=/dev/r$rootbak bs=16b seek=1 skip=1 \
conv=noerror,sync
fsck -y /dev/r$rootbak
}
}
echo ""
echo "Running calendar:"
calendar -a
echo ""
echo "Rotating mail log:"
cd /var/log
rm -f maillog.7
if [ -f maillog.6 ]; then mv -f maillog.6 maillog.7; fi
if [ -f maillog.5 ]; then mv -f maillog.5 maillog.6; fi
if [ -f maillog.4 ]; then mv -f maillog.4 maillog.5; fi
if [ -f maillog.3 ]; then mv -f maillog.3 maillog.4; fi
if [ -f maillog.2 ]; then mv -f maillog.2 maillog.3; fi
if [ -f maillog.1 ]; then mv -f maillog.1 maillog.2; fi
if [ -f maillog.0 ]; then mv -f maillog.0 maillog.1; fi
mv -f maillog maillog.0
cp /dev/null maillog
chmod 644 maillog
kill -1 `cat /var/run/syslog.pid`
cd /
if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
echo ""
echo "Cleaning up UUCP:"
echo /etc/uuclean.daily | su daemon
fi
echo ""
echo ""
echo "Checking subsystem status:"
echo ""
echo "disks:"
env BLOCKSIZE=1k df
echo ""
dump W
echo ""
echo ""
echo "mail:"
mailq
if [ -d /var/spool/uucp ]; then
echo ""
echo "uucp:"
uusnap
fi
echo ""
echo "network:"
netstat -i
echo ""
ruptime
echo ""
echo "Checking filesystems:"
fsck -n | grep -v '^\*\* Phase'
echo ""
if [ -f /etc/Distfile ]; then
echo "Running rdist:"
if [ -d /var/log/rdist ]; then
logf=`date | awk '{printf "%s.%s.%s", $6, $2, $3}'`
rdist -f /etc/Distfile 2>&1 | tee /var/log/rdist/$logf
else
rdist -f /etc/Distfile
fi
fi
sh /etc/security 2>&1 | mail -s "$host daily insecurity output" root
+19
View File
@@ -0,0 +1,19 @@
#
# Game Control File
# @(#)dm.conf 8.1 (Berkeley) 6/9/93
#
# TTYNAME
# badtty /dev/tty19 # news
# badtty /dev/tty20 # news/mail
# DAY OF WEEK START STOP
# time Monday 7 16 # 7am to 4pm
# time Tuesday 7 16
# time Wednesday 7 16
# time Thursday 7 16
# time Friday 7 16
# GAME MAX LOAD MAX USERS PRIORITY
# default must be the last entry for the ``game'' keyword
game default 5 * *
View File
Whitespace-only changes.
+2
View File
@@ -0,0 +1,2 @@
/usr -alldirs -root=0 local_work_group
/usr -alldirs others
+4
View File
@@ -0,0 +1,4 @@
# list of users disallowed any ftp access.
# read by ftpd(8).
root
uucp
+3
View File
@@ -0,0 +1,3 @@
myname.my.domain -- Ftp server.
+143
View File
@@ -0,0 +1,143 @@
# @(#)gettytab 8.2 (Berkeley) 4/20/94
#
# Most of the table entries here are just copies of the old getty table,
# it is by no means certain, or even likely, that any of them are optimal
# for any purpose whatever. Nor is it likely that more than a couple are
# even correct.
#
# The default gettytab entry, used to set defaults for all other
# entries, and in cases where getty is called with no table name
#
default:\
:ap:fd#1000:im=\r\n\r\n4.4BSD-Lite (%h) (%t)\r\n\r\r\n\r:sp#1200:
#
# Fixed speed entries
#
# The "std.NNN" names are known to the special case
# portselector code in getty, however they can
# be assigned to any table desired.
# The "NNN-baud" names are known to the special case
# autobaud code in getty, and likewise can
# be assigned to any table desired (hopefully the same speed).
#
a|std.110|110-baud:\
:nd#1:cd#1:uc:sp#110:
b|std.134|134.5-baud:\
:ep:nd#1:cd#2:ff#1:td#1:sp#134:ht:nl:
1|std.150|150-baud:\
:ep:nd#1:cd#2:td#1:fd#1:sp#150:ht:nl:lm=\E\72\6\6\17login\72 :
c|std.300|300-baud:\
:nd#1:cd#1:sp#300:
d|std.600|600-baud:\
:nd#1:cd#1:sp#600:
f|std.1200|1200-baud:\
:fd#1:sp#1200:
6|std.2400|2400-baud:\
:sp#2400:
7|std.4800|4800-baud:\
:sp#4800:
2|std.9600|9600-baud:\
:sp#9600:
g|std.19200|19200-baud:\
:sp#19200:
#
# Dial in rotary tables, speed selection via 'break'
#
0|d300|Dial-300:\
:nx=d1200:cd#2:sp#300:
d1200|Dial-1200:\
:nx=d150:fd#1:sp#1200:
d150|Dial-150:\
:nx=d110:lm@:tc=150-baud:
d110|Dial-110:\
:nx=d300:tc=300-baud:
#
# Fast dialup terminals, 2400/1200/300 rotary (can start either way)
#
D2400|d2400|Fast-Dial-2400:\
:nx=D1200:tc=2400-baud:
3|D1200|Fast-Dial-1200:\
:nx=D300:tc=1200-baud:
5|D300|Fast-Dial-300:\
:nx=D2400:tc=300-baud:
#
#telebit (19200)
#
t19200:\
:nx=t2400:tc=19200-baud:
t2400:\
:nx=t1200:tc=2400-baud:
t1200:\
:nx=t19200:tc=1200-baud:
#
#telebit (9600)
#
t9600:\
:nx=t2400a:tc=19200-baud:
t2400a:\
:nx=t1200a:tc=2400-baud:
t1200a:\
:nx=t9600:tc=1200-baud:
#
# Odd special case terminals
#
-|tty33|asr33|Pity the poor user of this beast:\
:tc=110-baud:
4|Console|Console Decwriter II:\
:nd@:cd@:rw:tc=300-baud:
e|Console-1200|Console Decwriter III:\
:fd@:nd@:cd@:rw:tc=1200-baud:
i|Interdata console:\
:uc:sp#0:
l|lsi chess terminal:\
:sp#300:
X|Xwindow|X window system:\
:fd@:nd@:cd@:rw:sp#9600:
P|Pc|Pc console:\
:np:ap:sp#9600:
#
# Wierdo special case for fast crt's with hardcopy devices
#
8|T9600|CRT with hardcopy:\
:nx=T300:tc=9600-baud:
9|T300|CRT with hardcopy (300):\
:nx=T9600:tc=300-baud:
#
# Plugboard, and misc other terminals
#
plug-9600|Plugboard-9600:\
:pf#1:tc=9600-baud:
p|P9600|Plugboard-9600-rotary:\
:pf#1:nx=P300:tc=9600-baud:
q|P300|Plugboard-300:\
:pf#1:nx=P1200:tc=300-baud:
r|P1200|Plugboard-1200:\
:pf#1:nx=P9600:tc=1200-baud:
#
# XXXX Port selector
#
s|DSW|Port Selector:\
:ps:sp#2400:
#
# Auto-baud speed detect entry for Micom 600.
# Special code in getty will switch this out
# to one of the NNN-baud entries.
#
A|Auto-baud:\
:ab:sp#2400:f0#040:
+17
View File
@@ -0,0 +1,17 @@
wheel:*:0:root
daemon:*:1:daemon
kmem:*:2:root
sys:*:3:root
tty:*:4:root
operator:*:5:root
bin:*:7:
news:*:8:
wsrc:*:9:
games:*:13:
staff:*:20:root
guest:*:31:root
nobody:*:39:
utmp:*:45:
ingres:*:74:ingres
dialer:*:117:
nogroup:*:32766:
+13
View File
@@ -0,0 +1,13 @@
#
# Host Database
# This file should contain the addresses and aliases
# for local hosts that share this file.
# It is used only for "ifconfig" and other operations
# before the nameserver is started.
#
#
127.1 localhost localhost.my.domain
#
# Imaginary network.
0.2 myname.my.domain myname
0.3 myfriend.my.domain myfriend
+2
View File
@@ -0,0 +1,2 @@
localhost
my_very_good_friend.domain
+1
View File
@@ -0,0 +1 @@
machine.domain
+36
View File
@@ -0,0 +1,36 @@
#
# Internet server configuration database
#
# @(#)inetd.conf 8.2 (Berkeley) 3/18/94
#
ftp stream tcp nowait root /usr/libexec/ftpd ftpd -ll
telnet stream tcp nowait root /usr/libexec/telnetd telnetd
shell stream tcp nowait root /usr/libexec/rshd rshd
login stream tcp nowait root /usr/libexec/rlogind rlogind
exec stream tcp nowait root /usr/libexec/rexecd rexecd
#uucpd stream tcp nowait root /usr/libexec/uucpd uucpd
#nntp stream tcp nowait usenet /usr/libexec/nntpd nntpd
finger stream tcp nowait nobody /usr/libexec/fingerd fingerd
#tftp dgram udp wait nobody /usr/libexec/tftpd tftpd
comsat dgram udp wait root /usr/libexec/comsat comsat
talk dgram udp wait root /usr/old/bin/talkd talkd
ntalk dgram udp wait root /usr/libexec/ntalkd ntalkd
tcpmux stream tcp nowait root internal
echo stream tcp nowait root internal
discard stream tcp nowait root internal
chargen stream tcp nowait root internal
daytime stream tcp nowait root internal
time stream tcp nowait root internal
echo dgram udp wait root internal
discard dgram udp wait root internal
chargen dgram udp wait root internal
daytime dgram udp wait root internal
time dgram udp wait root internal
qotd stream tcp nowait nobody /usr/games/fortune fortune
# Kerberos authenticated services
klogin stream tcp nowait root /usr/libexec/rlogind rlogind -k
eklogin stream tcp nowait root /usr/libexec/rlogind rlogind -k -x
kshell stream tcp nowait root /usr/libexec/rshd rshd -k
# Services run ONLY on the Kerberos server
#krbupdate stream tcp nowait root /usr/libexec/registerd registerd
#kpasswd stream tcp nowait root /usr/libexec/kpasswdd kpasswdd
+35
View File
@@ -0,0 +1,35 @@
# @(#)README 8.1 (Berkeley) 6/9/93
Notes about the contents of the /etc/kerberosIV directory:
The file master_key contains a copy of the master key under which the
entire Kerberos database is encrypted. Disclosing this key would be bad
news. The reason it is stored in the filesystem is because the following
programs need to inspect or modify the kereros database, and so the key
must be available for them, (or else it would have to be typed in by
hand):
- kerberos (the server itself)
- registerd (for new user registration)
- kpasswdd (for changing passwords)
The srvtab file contains the encryption keys for each service on the local
host. Any host offering network services would have a key here, although
many such files can be used.
The principal.* files comprise the Kerberos database itself, and contain
keys for all principles, and should not be world-readable.
The kerberos.conf file contains the configuration for this machine:
- which realm I'm in
- which servers I should talk to for this realm
The kerberos.realms file contains the name of Kerberos servers for
various (sub)domains.
Kerberos log information it placed in /var/log/kerberos.log
(see rc.local to change it)
The register_keys directory contains a set of files (all of which begin
with "."), each of which contains a des key used for registering new users
with the system. It is used only by the "registerd" program, and only on
a Kerberos server host.
+2
View File
@@ -0,0 +1,2 @@
me.MY.DOMAIN
me.MY.DOMAIN my.TRUSTED.FRIEND
+1
View File
@@ -0,0 +1 @@
.MY.DOMAIN me.MY.DOMAIN
+46
View File
@@ -0,0 +1,46 @@
# Sheer, raging paranoia...
_version BSD.2
# The whatis/apropos database.
_whatdb /usr/share/man/whatis.db
# Subdirectories for paths ending in '/', IN SEARCH ORDER.
_subdir cat{1,8,6,2,3,4,5,7,3f}
# Files typed by suffix and their commands.
# Note the order, .Z must come after .[1-9].Z, or it will match first.
_suffix .0
_build .[1-9] /usr/bin/nroff -man %s
_build .[1-9].Z /usr/bin/zcat %s | /usr/bin/nroff -man
_build .Z /usr/bin/zcat %s
_build .0.Z /usr/bin/zcat %s
_build .gz /usr/contrib/bin/gunzip %s
_build .z /usr/contrib/bin/gunzip %s
_build .nr /usr/bin/nroff -man %s
# Sections and their directories.
# All paths ending in '/' are the equivalent of entries specifying that
# directory with all of the subdirectories listed for the keyword _subdir.
# default
_default /usr/{share,X11,contrib,local}/{man,man/old}/
# Other sections that represent complete man subdirectories.
X11 /usr/X11R4/man/
X11R4 /usr/X11R4/man/
contrib /usr/contrib/man/
local /usr/local/man/
new /usr/contrib/man/
old /usr/share/man/old/
# Specific section/directory combinations.
1 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat1
2 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat2
3 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat3
3F /usr/share/man/cat3f
3f /usr/share/man/cat3f
4 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat4
5 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat5
6 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat6
7 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat7
8 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat8
+18
View File
@@ -0,0 +1,18 @@
root::0:10::0:0:Charlie &:/root:/bin/csh
toor::0:10::0:0:Bourne-again Superuser:/root:
daemon:*:1:31::0:0:The devil himself:/root:/sbin/nologin
operator:*:2:28::0:0:System &:/usr/guest/operator:/bin/csh
news:*:6:8::0:0:Network News:/var/spool/news:/sbin/nologin
bin:*:3:7::0:0:Binaries Commands and Source:/:/sbin/nologin
games:*:7:13::0:0:Games pseudo-user:/usr/games:/sbin/nologin
uucp:*:66:1::0:0:UNIX-to-UNIX Copy:/var/spool/uucppublic:/usr/lib/uucp/uucico
nobody:*:32767:9999::0:0:Unprivileged user:/nonexistent:/sbin/nologin
dmr:*:10:31::0:0:Dennis Ritchie:/var/users/guest/dmr:
ken:*:11:31::0:0:& Thompson:/var/users/guest/ken:
ingres:*:267:74::0:0:& Group:/usr/ingres:/bin/csh
mckusick:*:647:31::0:0:Kirk &,1614 Oxford St. Berkeley CA 94709-1608,510-843-9542,510-843-9542:/var/users/guest/mckusick:/bin/csh
ralph:*:987:31::0:0:& Campbell,,,:/var/users/guest/ralph:/bin/csh
bostic:*:1547:31::0:0:Keith &,394 East Riding Rd. Carlisle MA 01741,508-287-4781,508-287-4781:/var/users/guest/bostic:/bin/csh
torek:*:2282:31::0:0:Chris &,,,:/var/users/guest/torek:/bin/csh
hibler:*:2430:31::0:0:Mike &,Univ of Utah,,:/var/users/guest/hibler:/bin/csh
falcon:*:32766:31::0:0:Prof. Steven &:/usr/games:/usr/games/wargames
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh -
#
# @(#)monthly 8.1 (Berkeley) 6/9/93
#
host=`hostname`
echo "Subject: $host monthly run output"
# echo ""
# echo "Doing login accounting:"
# ac -p | sort -nr +1
echo ""
echo -n "Rotating log files:"
cd /var/log
for i in ftp.log kerberos.log lpd-errs wtmp; do
echo -n " $i"
if [ -f $i.5 ]; then mv -f $i.5 $i.6; fi
if [ -f $i.4 ]; then mv -f $i.4 $i.5; fi
if [ -f $i.3 ]; then mv -f $i.3 $i.4; fi
if [ -f $i.2 ]; then mv -f $i.2 $i.3; fi
if [ -f $i.1 ]; then mv -f $i.1 $i.2; fi
if [ -f $i.0 ]; then mv -f $i.0 $i.1; fi
if [ -f $i ]; then mv -f $i $i.0; fi
>$i
done
kill -1 `cat /var/run/syslog.pid`
echo ""
+4
View File
@@ -0,0 +1,4 @@
4.4BSD-Lite UNIX #1: Fri Apr 01 00:00:00 PDT 1994
Welcome to 4.4BSD-Lite!
File diff suppressed because it is too large. Load diff
+162
View File
@@ -0,0 +1,162 @@
# @(#)special 8.2 (Berkeley) 1/23/94
#
# Hand-crafted mtree specification for the dangerous files.
#
. type=dir mode=0755 uname=root gname=wheel
dev type=dir mode=0755 uname=root gname=wheel
drum type=char mode=640 uname=root gname=kmem
fd type=dir mode=0755 uname=root gname=wheel ignore
.. #dev/fd
kmem type=char mode=640 uname=root gname=kmem
mem type=char mode=640 uname=root gname=kmem ignore
.. #dev
etc type=dir mode=0755 uname=root gname=wheel
aliases type=file mode=0644 uname=root gname=wheel
aliases.db type=file mode=0644 uname=root gname=wheel
crontab type=file mode=0644 uname=root gname=wheel
csh.cshrc type=file mode=0644 uname=root gname=wheel
csh.login type=file mode=0644 uname=root gname=wheel
csh.logout type=file mode=0644 uname=root gname=wheel
daily type=file mode=0644 uname=root gname=wheel
disklabels type=dir mode=0755 uname=root gname=wheel ignore
.. #disklabels
exports type=file mode=0644 uname=root gname=wheel
fstab type=file mode=0644 uname=root gname=wheel
ftpusers type=file mode=0644 uname=root gname=wheel
group type=file mode=0644 uname=root gname=wheel
hosts.equiv type=file mode=0600 uname=root gname=wheel
kerberosIV type=dir mode=0755 uname=root gname=wheel ignore
.. #kerberosIV
mail.rc type=file mode=0644 uname=root gname=wheel
master.passwd type=file mode=600 uname=root gname=wheel
monthly type=file mode=0644 uname=root gname=wheel
mtree type=dir mode=0755 uname=root gname=wheel
special type=file mode=0600 uname=root gname=wheel
.. #mtree
named.boot type=file mode=0644 uname=root gname=wheel
netstart type=file mode=0744 uname=root gname=wheel
passwd type=file mode=644 uname=root gname=wheel
printcap type=file mode=0644 uname=root gname=wheel
rc type=file mode=0644 uname=root gname=wheel
rc.local type=file mode=0644 uname=root gname=wheel
security type=file mode=0644 uname=root gname=wheel
sendmail.cf type=file mode=0644 uname=root gname=wheel
shells type=file mode=0644 uname=root gname=wheel
spwd.db type=file mode=0600 uname=root gname=wheel
syslog.conf type=file mode=0644 uname=root gname=wheel
ttys type=file mode=0644 uname=root gname=wheel
weekly type=file mode=0644 uname=root gname=wheel
.. #etc
root type=dir mode=0755 uname=root gname=wheel
.cshrc type=file mode=0644 uname=root gname=wheel
.klogin type=file mode=0600 uname=root gname=wheel
.login type=file mode=0644 uname=root gname=wheel
.profile type=file mode=0644 uname=root gname=wheel
.rhosts type=file mode=0600 uname=root gname=wheel
.. #root
sbin type=dir mode=0755 uname=root gname=wheel ignore
.. #sbin
usr type=dir mode=0755 uname=root gname=wheel
bin type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/bin
contrib type=dir mode=0755 uname=root gname=wheel
bin type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/contrib/bin
lib type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/contrib/lib
.. #usr/contrib
games type=dir mode=0755 uname=root gname=wheel
hide type=dir mode=0700 uname=games gname=wheel ignore
.. #usr/games/hide
.. #usr/games
include type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/include
lib type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/lib
libdata type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/libdata
libexec type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/libexec
local type=dir mode=0755 uname=root gname=wheel
bin type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/local/bin
lib type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/local/lib
.. #usr/local
new type=dir mode=0755 uname=root gname=wheel
bin type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/new/bin
lib type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/new/lib
.. #usr/new
old type=dir mode=0755 uname=root gname=wheel
bin type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/old/bin
lib type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/old/lib
.. #usr/old
sbin type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/sbin
share type=dir mode=0755 uname=root gname=wheel ignore
.. #usr/share
src type=dir mode=0775 uname=root gname=wsrc ignore
.. #usr/src
.. #usr
var type=dir mode=0755 uname=root gname=wheel
account type=dir mode=0755 uname=root gname=wheel
acct type=file mode=644 uname=root gname=wheel
.. #var/account
at type=dir mode=0755 uname=root gname=daemon ignore
.. #var/at
backups type=dir mode=0755 uname=root gname=wheel ignore
.. #var/backups
db type=dir mode=0755 uname=root gname=wheel ignore
kvm_vmunix.db type=file mode=0644 uname=root gname=wheel
.. #var/db
log type=dir mode=0755 uname=root gname=wheel
secure type=file mode=0600 uname=root gname=wheel
wtmp type=file mode=0644 uname=root gname=wheel
.. #var/log
mail type=dir mode=0755 uname=root gname=wheel ignore
.. #var/mail
preserve type=dir mode=0755 uname=root gname=wheel ignore
.. #var/preserve
run type=dir mode=0755 uname=root gname=wheel
utmp type=file mode=0664 uname=root gname=utmp
.. #var/run
spool type=dir mode=0755 uname=root gname=wheel
ftp type=dir mode=0755 uname=root gname=wheel
bin type=dir mode=0755 uname=root gname=wheel
ls type=file mode=555 uname=root gname=wheel
.. #var/spool/ftp/bin
etc type=dir mode=0755 uname=root gname=wheel
group type=file mode=644 uname=root gname=wheel
localtime type=file mode=644 uname=root gname=wheel
master.passwd type=file mode=644 uname=root gname=wheel
passwd type=file mode=644 uname=root gname=wheel
.. #var/spool/ftp/etc
hidden type=dir mode=0111 uname=root gname=wheel ignore
.. #var/spool/ftp/hidden
pub type=dir mode=0777 uname=root gname=wheel ignore
.. #var/spool/ftp/pub
.. #var/spool/ftp
mqueue type=dir mode=0755 uname=root gname=wheel ignore
.. #var/spool/mqueue
news type=dir mode=0755 uname=root gname=wheel ignore
.. #var/spool/news
output type=dir mode=0755 uname=root gname=wheel ignore
.. #var/spool/output
secretmail type=dir mode=0755 uname=root gname=wheel ignore
.. #var/spool/secretmail
uucp type=dir mode=0755 uname=uucp gname=daemon ignore
.. #var/spool/uucp
uucppublic type=dir mode=0777 uname=uucp gname=daemon ignore
.. #var/spool/uucppublic
.. #var/spool
+10
View File
@@ -0,0 +1,10 @@
; @(#)localhost.rev 8.1 (Berkeley) 6/9/93
@ IN SOA ucbvax.Berkeley.EDU. rwh.ucbvax.Berkeley.EDU. (
1.4 ; Serial
3600 ; Refresh
300 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS ucbvax.Berkeley.EDU.
1 IN PTR localhost.Berkeley.EDU.
+21
View File
@@ -0,0 +1,21 @@
; @(#)named.boot 8.1 (Berkeley) 6/9/93
; boot file for secondary name server
; Note that there should be one primary entry for each SOA record.
sortlist 128.3.0.0
directory /etc/namedb
; type domain source host/file backup file
cache . root.cache
primary 0.0.127.IN-ADDR.ARPA localhost.rev
; example secondary server config:
; secondary Berkeley.EDU 128.32.130.11 128.32.133.1 ucbhosts.bak
; secondary 32.128.IN-ADDR.ARPA 128.32.130.11 128.32.133.1 ucbhosts.rev.bak
; example primary server config:
; primary Berkeley.EDU ucbhosts
; primary 32.128.IN-ADDR.ARPA ucbhosts.rev
+22
View File
@@ -0,0 +1,22 @@
; @(#)root.cache 8.1 (Berkeley) 6/9/93
; Initial cache data for root domain servers.
. IN NS NS.NIC.DDN.MIL.
IN NS A.ISI.EDU.
IN NS AOS.BRL.MIL.
IN NS C.NYSER.NET.
IN NS GUNTER-ADAM.AF.MIL.
IN NS NS.NASA.GOV.
IN NS TERP.UMD.EDU.
; Prep the cache (hotwire the addresses). Order does not matter.
NS.NIC.DDN.MIL IN A 192.67.67.53
A.ISI.EDU IN A 26.3.0.103
IN A 128.9.0.107
AOS.BRL.MIL IN A 128.20.1.2
IN A 192.5.25.82
C.NYSER.NET. IN A 192.33.4.12
GUNTER-ADAM.AF.MIL. IN A 26.1.0.13
NS.NASA.GOV. IN A 128.102.16.10
IN A 192.52.195.10
TERP.UMD.EDU. IN A 128.8.10.90
+2
View File
@@ -0,0 +1,2 @@
local_work_group (friend.my.domain,,)
others (guest.my.domain,,) (guest.far.away.domain,,)
Executable
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh -
#
# @(#)netstart 8.1 (Berkeley) 7/23/93
routedflags=-q
timedflags=YES
rwhod=NO
# myname is my symbolic name
# my-netmask is specified in /etc/networks
#
hostname=myname.my.domain
hostname $hostname
ifconfig ace0 inet $hostname netmask my-netmask
ifconfig ex0 inet $hostname netmask my-netmask
ifconfig imp0 inet $hostname
ifconfig le0 inet $hostname netmask my-netmask
ifconfig ne0 inet $hostname netmask my-netmask
ifconfig we0 inet $hostname netmask my-netmask
# For en ethernet interface, load microcode before ifconfig
# /etc/enpload /dev/enp0ram /etc/enpcode > /dev/console 2>&1
ifconfig en0 inet $hostname netmask my-netmask
# set the address for the loopback interface
ifconfig lo0 inet localhost
# use loopback, not the wire
route add $hostname localhost
+7
View File
@@ -0,0 +1,7 @@
# @(#)phones 8.1 (Berkeley) 6/9/93
#
# phones -- remote host phone number data base
# see tip(1), phones(5)
system1 9=1112223333
system2 1112223333
+32
View File
@@ -0,0 +1,32 @@
# @(#)printcap 8.1 (Berkeley) 6/9/93
lp|local line printer:\
:lp=/dev/lp:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:
# DecWriter over a tty line.
#decwriter|LA-180 DecWriter III:\
# :br#1200:fs#06320:tr=\f:of=/usr/libexec/lpr/lpf:lf=/var/log/lpd-errs:
# Typical remote printer entry.
#remote|Line Printer:\
# :lp=:rm=remote_machine:sd=/var/spool/output/remotelpd:\
# :lf=/var/log/lpd-errs:
#varian|Benson Varian:\
# :lp=/dev/va0:sd=/var/spool/output/vad:\
# :mx#2000:pl#58:px#2112:py#1700:tr=\f:\
# :of=/usr/libexec/lpr/vpf:if=/usr/libexec/lpr/vpf:\
# :tf=/usr/libexec/lpr/rvcat:cf=/usr/libexec/lpr/vdmp:\
# :gf=/usr/libexec/lpr/vplotf:df=/usr/local/dvif:\
# :vf=/usr/libexec/lpr/vpltdmp:lf=/var/log/lpd-errs:
#vp|versatec|Versatec plotter:\
# :lp=/dev/vp0:sd=/var/spool/output/vpd:\
# :sb:sf:mx#0:pw#106:pl#86:px#7040:py#2400:\
# :of=/usr/libexec/lpr/vpfW:if=/usr/libexec/lpr/vpsf:\
# :tf=/usr/libexec/lpr/vcat:cf=/usr/libexec/lpr/vdmp:\
# :gf=/usr/libexec/lpr/vplotf:vf=/usr/libexec/lpr/vpltdmp:\
# :lf=/var/log/lpd-errs:\
# :tr=\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
#\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
#\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n:
+19
View File
@@ -0,0 +1,19 @@
#
# Internet (IP) protocols
#
# @(#)protocols 8.1 (Berkeley) 6/9/93
#
ip 0 IP # internet protocol, pseudo protocol number
icmp 1 ICMP # internet control message protocol
igmp 2 IGMP # internet group management protocol
ggp 3 GGP # gateway-gateway protocol
tcp 6 TCP # transmission control protocol
egp 8 EGP # exterior gateway protocol
pup 12 PUP # PARC universal packet protocol
udp 17 UDP # user datagram protocol
hmp 20 HMP # host monitoring protocol
xns-idp 22 XNS-IDP # Xerox NS IDP
rdp 27 RDP # reliable data protocol
iso-tp4 29 ISO-TP4 # ISO Transport Protocol Class 4
iso-ip 80 ISO-IP # ISO Internet Protocol
encap 98 ENCAP # RFC1241 encapsulation
+171
View File
@@ -0,0 +1,171 @@
# @(#)rc 8.2 (Berkeley) 3/17/94
# System startup script run by init on autoboot
# or after single-user.
# Output and error are redirected to console by init,
# and the console is the controlling terminal.
stty status '^T'
# Set shell to ignore SIGINT (2), but not children;
# shell catches SIGQUIT (3) and returns to single user after fsck.
trap : 2
trap : 3 # shouldn't be needed
HOME=/; export HOME
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
if [ -r /fastboot ]
then
echo "Fast boot: skipping disk checks."
elif [ $1x = autobootx ]
then
echo "Automatic boot in progress: starting file system checks."
fsck -p
case $? in
0)
;;
2)
exit 1
;;
4)
echo "Rebooting..."
reboot
echo "Reboot failed; help!"
exit 1
;;
8)
echo "Automatic file system check failed; help!"
exit 1
;;
12)
echo "Boot interrupted."
exit 1
;;
130)
# interrupt before catcher installed
exit 1
;;
*)
echo "Unknown error; help!"
exit 1
;;
esac
fi
trap "echo 'Boot interrupted.'; exit 1" 3
swapon -a
umount -a >/dev/null 2>&1
mount -a -t nonfs
rm -f /fastboot # XXX (root now writeable)
# set hostname, turn on network
echo 'starting network'
. /etc/netstart
mount -a -t nfs >/dev/null 2>&1 & # XXX shouldn't need background
# clean up left-over files
rm -f /etc/nologin
rm -f /var/spool/uucp/LCK.*
rm -f /var/spool/uucp/STST/*
(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
echo -n 'starting system logger'
rm -f /dev/log
syslogd
# $timedflags is imported from /etc/netstart;
# if $timedflags == NO, timed isn't run.
if [ X${timedflags} != X"NO" ]; then
echo -n ', time daemon'; timed $timedflags
fi
echo '.'
# /var/crash should be a directory or a symbolic link
# to the crash directory if core dumps are to be saved.
if [ -d /var/crash ]; then
echo checking for core dump...
savecore /var/crash
fi
echo -n 'checking quotas:'
quotacheck -a
echo ' done.'
quotaon -a
# build ps databases
kvm_mkdb
dev_mkdb
chmod 666 /dev/tty[pqrs]*
# check the password temp/lock file
if [ -f /etc/ptmp ]
then
logger -s -p auth.err \
'password file may be incorrect -- /etc/ptmp exists'
fi
echo preserving editor files
(cd /var/tmp && /usr/libexec/ex3.7preserve -a &&
rm -f Ex[0-9][0-9][0-9][0-9][0-9] Rx[0-9][0-9][0-9][0-9][0-9])
echo clearing /tmp
# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
# is not needed with mfs /tmp, but doesn't hurt anything).
(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
find . ! -name . ! -name lost+found ! -name quotas -type d -prune \
-exec rm -rf -- {} \;)
echo 'turning on accounting'; accton /var/account/acct
echo -n standard daemons:
echo -n ' update'; update
echo -n ' cron'; cron
echo '.'
echo -n starting network daemons:
# $gated and $routedflags are imported from /etc/netstart.
# If $gated == YES, gated is used; otherwise routed.
# If $routedflags == NO, routed isn't run.
if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
echo -n ' gated'; gated $gatedflags
elif [ X${routedflags} != X"NO" ]; then
echo -n ' routed'; routed $routedflags
fi
echo -n ' named'; named
# $rwhod is imported from /etc/netstart;
# if $rwhod is set to something other than NO, rwhod is run.
if [ ${rwhod-NO} != "NO" ]; then
echo -n ' rwhod'; rwhod
fi
echo -n ' printer'; lpd
echo -n ' portmap'; portmap
echo -n ' mountd'; mountd
echo -n ' nfsd'; nfsd -u -t 6
echo -n ' nfsiod'; nfsiod 4
echo -n ' sendmail'; sendmail -bd -q30m
echo -n ' inetd'; inetd
echo -n ' amd';
cd /; amd -l /var/log/amd -r -a /amd -p > /var/run/amd.pid \
/home /etc/amd-home \
/n /etc/amd-n \
&
echo '.'
sh /etc/rc.local
date
exit 0
+26
View File
@@ -0,0 +1,26 @@
#
# site-specific startup actions, daemons
#
# @(#)rc.local 8.1 (Berkeley) 6/10/93
#
T=/tmp/_motd
rm -f $T
strings /vmunix | grep UNIX > $T
echo "" >> $T
sed '1,/^$/d' < /etc/motd >> $T
cp $T /etc/motd
chmod 666 /etc/motd
rm -f $T
echo -n 'starting local daemons:'
if [ -f /usr/contrib/lib/jove/recover ]; then
echo -n ' jove'
(/usr/contrib/lib/jove/recover -syscrash)
fi
# Kerberos runs ONLY on the Kerberos server machine
#echo -n ' kerberos'; kerberos >> /var/log/kerberos.log &
echo '.'
+40
View File
@@ -0,0 +1,40 @@
# @(#)remote 8.1 (Berkeley) 6/10/93
#
# remote -- remote host description file
# see tip(1), remote(5)
#
# dv device to use for the tty
# el EOL marks (default is NULL)
# du make a call flag (dial up)
# pn phone numbers (@ =>'s search phones file; possibly taken from
# PHONES environment variable)
# at ACU type
# ie input EOF marks (default is NULL)
# oe output EOF string (default is NULL)
# cu call unit (default is dv)
# br baud rate (defaults to 300)
# fs frame size (default is BUFSIZ) -- used in buffering writes on
# receive operations
# tc to continue a capability
# UNIX system definitions
unix1200|1200 Baud dial-out to another UNIX system:\
:el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:tc=dial1200:
unix300|300 Baud dial-out to another UNIX system:\
:el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:tc=dial300:
# General dialer definitions used below
#
# COURIER switch settings:
# switch: 1 2 3 4 5 6 7 8 9 10
# setting: D U D U D D U D U U
# Rackmount: U U D U D U D D U D
#
dial2400|2400 Baud Hayes attributes:\
:dv=/dev/tty19:br#2400:cu=/dev/tty19:at=hayes:du:
dial1200|1200 Baud Hayes attributes:\
:dv=/dev/tty19:br#1200:cu=/dev/tty19:at=hayes:du:
# Hardwired line
# REMEMBER NOT TO USE PARITY!
console:dv=/dev/tty01:br#9600:pa=none:
Symlink
+1
View File
@@ -0,0 +1 @@
/usr/sbin/rmt
+534
View File
@@ -0,0 +1,534 @@
#!/bin/sh -
#
# @(#)security 8.1 (Berkeley) 6/9/93
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
umask 077
ERR=/tmp/_secure1.$$
TMP1=/tmp/_secure2.$$
TMP2=/tmp/_secure3.$$
TMP3=/tmp/_secure4.$$
LIST=/tmp/_secure5.$$
OUTPUT=/tmp/_secure6.$$
trap 'rm -f $ERR $TMP1 $TMP2 $TMP3 $LIST $OUTPUT' 0
# Check the master password file syntax.
MP=/etc/master.passwd
awk -F: '{
if ($0 ~ /^[ ]*$/) {
printf("Line %d is a blank line.\n", NR);
next;
}
if (NF != 10)
printf("Line %d has the wrong number of fields.\n", NR);
if ($1 !~ /^[A-Za-z0-9]*$/)
printf("Login %s has non-alphanumeric characters.\n", $1);
if (length($1) > 8)
printf("Login %s has more than 8 characters.\n", $1);
if ($2 == "")
printf("Login %s has no password.\n", $1);
if (length($2) != 13 && ($10 ~ /.*sh$/ || $10 == ""))
printf("Login %s is off but still has a valid shell.\n", $1);
if ($3 == 0 && $1 != "root" && $1 != "toor")
printf("Login %s has a user id of 0.\n", $1);
if ($3 < 0)
printf("Login %s has a negative user id.\n", $1);
if ($4 < 0)
printf("Login %s has a negative group id.\n", $1);
}' < $MP > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking the $MP file:\n"
cat $OUTPUT
fi
awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\n$MP has duplicate user names.\n"
column $OUTPUT
fi
awk -F: '{ print $1 " " $3 }' $MP | sort -n +1 | tee $TMP1 |
uniq -d -f 1 | awk '{ print $2 }' > $TMP2
if [ -s $TMP2 ] ; then
printf "\n$MP has duplicate user id's.\n"
while read uid; do
grep -w $uid $TMP1
done < $TMP2 | column
fi
# Backup the master password file; a special case, the normal backup
# mechanisms also print out file differences and we don't want to do
# that because this file has encrypted passwords in it.
CUR=/var/backups/`basename $MP`.current
BACK=/var/backups/`basename $MP`.backup
if [ -s $CUR ] ; then
if cmp -s $CUR $MP; then
:
else
cp -p $CUR $BACK
cp -p $MP $CUR
chown root.wheel $CUR
fi
else
cp -p $MP $CUR
chown root.wheel $CUR
fi
# Check the group file syntax.
GRP=/etc/group
awk -F: '{
if ($0 ~ /^[ ]*$/) {
printf("Line %d is a blank line.\n", NR);
next;
}
if (NF != 4)
printf("Line %d has the wrong number of fields.\n", NR);
if ($1 !~ /^[A-za-z0-9]*$/)
printf("Group %s has non-alphanumeric characters.\n", $1);
if (length($1) > 8)
printf("Group %s has more than 8 characters.\n", $1);
if ($3 !~ /[0-9]*/)
printf("Login %s has a negative group id.\n", $1);
}' < $GRP > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking the $GRP file:\n"
cat $OUTPUT
fi
awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\n$GRP has duplicate group names.\n"
column $OUTPUT
fi
# Check for root paths, umask values in startup files.
# The check for the root paths is problematical -- it's likely to fail
# in other environments. Once the shells have been modified to warn
# of '.' in the path, the path tests should go away.
> $OUTPUT
rhome=/root
umaskset=no
list="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login"
for i in $list ; do
if [ -f $i ] ; then
if egrep umask $i > /dev/null ; then
umaskset=yes
fi
egrep umask $i |
awk '$2 % 100 < 20 \
{ print "Root umask is group writeable" }
$2 % 10 < 2 \
{ print "Root umask is other writeable" }' >> $OUTPUT
/bin/csh -f -s << end-of-csh > /dev/null 2>&1
unset path
source $i
/bin/ls -ldgT \$path > $TMP1
end-of-csh
awk '{
if ($10 ~ /^\.$/) {
print "The root path includes .";
next;
}
}
$1 ~ /^d....w/ \
{ print "Root path directory " $10 " is group writeable." } \
$1 ~ /^d.......w/ \
{ print "Root path directory " $10 " is other writeable." }' \
< $TMP1 >> $OUTPUT
fi
done
if [ $umaskset = "no" -o -s $OUTPUT ] ; then
printf "\nChecking root csh paths, umask values:\n$list\n"
if [ -s $OUTPUT ]; then
cat $OUTPUT
fi
if [ $umaskset = "no" ] ; then
printf "\nRoot csh startup files do not set the umask.\n"
fi
fi
> $OUTPUT
rhome=/root
umaskset=no
list="${rhome}/.profile"
for i in $list; do
if [ -f $i ] ; then
if egrep umask $i > /dev/null ; then
umaskset=yes
fi
egrep umask $i |
awk '$2 % 100 < 20 \
{ print "Root umask is group writeable" } \
$2 % 10 < 2 \
{ print "Root umask is other writeable" }' >> $OUTPUT
/bin/sh << end-of-sh > /dev/null 2>&1
PATH=
. $i
list=\`echo \$PATH | /usr/bin/sed -e 's/:/ /g'\`
/bin/ls -ldgT \$list > $TMP1
end-of-sh
awk '{
if ($10 ~ /^\.$/) {
print "The root path includes .";
next;
}
}
$1 ~ /^d....w/ \
{ print "Root path directory " $10 " is group writeable." } \
$1 ~ /^d.......w/ \
{ print "Root path directory " $10 " is other writeable." }' \
< $TMP1 >> $OUTPUT
fi
done
if [ $umaskset = "no" -o -s $OUTPUT ] ; then
printf "\nChecking root sh paths, umask values:\n$list\n"
if [ -s $OUTPUT ]; then
cat $OUTPUT
fi
if [ $umaskset = "no" ] ; then
printf "\nRoot sh startup files do not set the umask.\n"
fi
fi
# Root and uucp should both be in /etc/ftpusers.
if egrep root /etc/ftpusers > /dev/null ; then
:
else
printf "\nRoot not listed in /etc/ftpusers file.\n"
fi
if egrep uucp /etc/ftpusers > /dev/null ; then
:
else
printf "\nUucp not listed in /etc/ftpusers file.\n"
fi
# Uudecode should not be in the /etc/aliases file.
if egrep 'uudecode|decode' /etc/aliases; then
printf "\nThere is an entry for uudecode in the /etc/aliases file.\n"
fi
# Files that should not have + signs.
list="/etc/hosts.equiv /etc/hosts.lpd"
for f in $list ; do
if egrep '\+' $f > /dev/null ; then
printf "\nPlus sign in $f file.\n"
fi
done
# Check for special users with .rhosts files. Only root and toor should
# have a .rhosts files. Also, .rhosts files should not plus signs.
awk -F: '$1 != "root" && $1 != "toor" && \
($3 < 100 || $1 == "ftp" || $1 == "uucp") \
{ print $1 " " $6 }' /etc/passwd |
while read uid homedir; do
if [ -f ${homedir}/.rhosts ] ; then
rhost=`ls -ldgT ${homedir}/.rhosts`
printf "$uid: $rhost\n"
fi
done > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking for special users with .rhosts files.\n"
cat $OUTPUT
fi
awk -F: '{ print $1 " " $6 }' /etc/passwd | \
while read uid homedir; do
if [ -f ${homedir}/.rhosts ] && \
egrep '\+' ${homedir}/.rhosts > /dev/null ; then
printf "$uid: + in .rhosts file.\n"
fi
done > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking .rhosts files syntax.\n"
cat $OUTPUT
fi
# Check home directories. Directories should not be owned by someone else
# or writeable.
awk -F: '{ print $1 " " $6 }' /etc/passwd | \
while read uid homedir; do
if [ -d ${homedir}/ ] ; then
file=`ls -ldgT ${homedir}`
printf "$uid $file\n"
fi
done |
awk '$1 != $4 && $4 != "root" \
{ print "user " $1 " home directory is owned by " $4 }
$2 ~ /^-....w/ \
{ print "user " $1 " home directory is group writeable" }
$2 ~ /^-.......w/ \
{ print "user " $1 " home directory is other writeable" }' > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking home directories.\n"
cat $OUTPUT
fi
# Files that should not be owned by someone else or readable.
list=".netrc .rhosts"
awk -F: '{ print $1 " " $6 }' /etc/passwd | \
while read uid homedir; do
for f in $list ; do
file=${homedir}/${f}
if [ -f $file ] ; then
printf "$uid $f `ls -ldgT $file`\n"
fi
done
done |
awk '$1 != $5 && $5 != "root" \
{ print "user " $1 " " $2 " file is owned by " $5 }
$3 ~ /^-...r/ \
{ print "user " $1 " " $2 " file is group readable" }
$3 ~ /^-......r/ \
{ print "user " $1 " " $2 " file is other readable" }
$3 ~ /^-....w/ \
{ print "user " $1 " " $2 " file is group writeable" }
$3 ~ /^-.......w/ \
{ print "user " $1 " " $2 " file is other writeable" }' > $OUTPUT
# Files that should not be owned by someone else or writeable.
list=".bashrc .cshrc .emacsrc .exrc .forward .klogin .login .logout \
.profile .tcshrc"
awk -F: '{ print $1 " " $6 }' /etc/passwd | \
while read uid homedir; do
for f in $list ; do
file=${homedir}/${f}
if [ -f $file ] ; then
printf "$uid $f `ls -ldgT $file`\n"
fi
done
done |
awk '$1 != $5 && $5 != "root" \
{ print "user " $1 " " $2 " file is owned by " $5 }
$3 ~ /^-....w/ \
{ print "user " $1 " " $2 " file is group writeable" }
$3 ~ /^-.......w/ \
{ print "user " $1 " " $2 " file is other writeable" }' >> $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking dot files.\n"
cat $OUTPUT
fi
# Mailboxes should be owned by user and unreadable.
ls -l /var/mail | sed 1d | \
awk '$3 != $9 \
{ print "user " $9 " mailbox is owned by " $3 }
$1 != "-rw-------" \
{ print "user " $9 " mailbox is " $1 ", group " $4 }' > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking mailbox ownership.\n"
cat $OUTPUT
fi
# File systems should not be globally exported.
awk '{
readonly = 0;
for (i = 2; i <= NF; ++i) {
if ($i ~ /-ro/)
readonly = 1;
else if ($i !~ /^-/)
next;
}
if (readonly)
print "File system " $1 " globally exported, read-only."
else
print "File system " $1 " globally exported, read-write."
}' < /etc/exports > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking for globally exported file systems.\n"
cat $OUTPUT
fi
# Display any changes in setuid files and devices.
printf "\nChecking setuid files and devices:\n"
(find / ! -fstype local -a -prune -o \
\( -perm -u+s -o -perm -g+s -o ! -type d -a ! -type f -a ! -type l -a \
! -type s \) | \
sort | sed -e 's/^/ls -ldgT /' | sh > $LIST) 2> $OUTPUT
# Display any errors that occurred during system file walk.
if [ -s $OUTPUT ] ; then
printf "Setuid/device find errors:\n"
cat $OUTPUT
printf "\n"
fi
# Display any changes in the setuid file list.
egrep -v '^[bc]' $LIST > $TMP1
if [ -s $TMP1 ] ; then
# Check to make sure uudecode isn't setuid.
if grep -w uudecode $TMP1 > /dev/null ; then
printf "\nUudecode is setuid.\n"
fi
CUR=/var/backups/setuid.current
BACK=/var/backups/setuid.backup
if [ -s $CUR ] ; then
if cmp -s $CUR $TMP1 ; then
:
else
> $TMP2
join -110 -210 -v2 $CUR $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "Setuid additions:\n"
tee -a $TMP2 < $OUTPUT
printf "\n"
fi
join -110 -210 -v1 $CUR $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "Setuid deletions:\n"
tee -a $TMP2 < $OUTPUT
printf "\n"
fi
sort +9 $TMP2 $CUR $TMP1 | \
sed -e 's/[ ][ ]*/ /g' | uniq -u > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "Setuid changes:\n"
column -t $OUTPUT
printf "\n"
fi
cp $CUR $BACK
cp $TMP1 $CUR
fi
else
printf "Setuid additions:\n"
column -t $TMP1
printf "\n"
cp $TMP1 $CUR
fi
fi
# Check for block and character disk devices that are readable or writeable
# or not owned by root.operator.
>$TMP1
DISKLIST="dk fd hd hk hp jb kra ra rb rd rl rx rz sd up wd"
for i in $DISKLIST; do
egrep "^b.*/${i}[0-9][0-9]*[a-h]$" $LIST >> $TMP1
egrep "^c.*/r${i}[0-9][0-9]*[a-h]$" $LIST >> $TMP1
done
awk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \
{ printf("Disk %s is user %s, group %s, permissions %s.\n", \
$11, $3, $4, $1); }' < $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking disk ownership and permissions.\n"
cat $OUTPUT
printf "\n"
fi
# Display any changes in the device file list.
egrep '^[bc]' $LIST | sort +10 > $TMP1
if [ -s $TMP1 ] ; then
CUR=/var/backups/device.current
BACK=/var/backups/device.backup
if [ -s $CUR ] ; then
if cmp -s $CUR $TMP1 ; then
:
else
> $TMP2
join -111 -211 -v2 $CUR $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "Device additions:\n"
tee -a $TMP2 < $OUTPUT
printf "\n"
fi
join -111 -211 -v1 $CUR $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "Device deletions:\n"
tee -a $TMP2 < $OUTPUT
printf "\n"
fi
# Report any block device change. Ignore character
# devices, only the name is significant.
cat $TMP2 $CUR $TMP1 | \
sed -e '/^c/d' | \
sort +10 | \
sed -e 's/[ ][ ]*/ /g' | \
uniq -u > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "Block device changes:\n"
column -t $OUTPUT
printf "\n"
fi
cp $CUR $BACK
cp $TMP1 $CUR
fi
else
printf "Device additions:\n"
column -t $TMP1
printf "\n"
cp $TMP1 $CUR
fi
fi
# Check special files.
# Check system binaries.
#
# Create the mtree tree specifications using:
#
# mtree -cx -pDIR -kcksum,gid,mode,nlink,size,link,time,uid > DIR.secure
# chown root.wheel DIR.SECURE
# chmod 600 DIR.SECURE
#
# Note, this is not complete protection against Trojan horsed binaries, as
# the hacker can modify the tree specification to match the replaced binary.
# For details on really protecting yourself against modified binaries, see
# the mtree(8) manual page.
if cd /etc/mtree; then
mtree -e -p / -f /etc/mtree/special > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\nChecking special files and directories.\n"
cat $OUTPUT
fi
> $OUTPUT
for file in *.secure; do
tree=`sed -n -e '3s/.* //p' -e 3q $file`
mtree -f $file -p $tree > $TMP1
if [ -s $TMP1 ]; then
printf "\nChecking $tree:\n" >> $OUTPUT
cat $TMP1 >> $OUTPUT
fi
done
if [ -s $OUTPUT ] ; then
printf "\nChecking system binaries:\n"
cat $OUTPUT
fi
fi
# List of files that get backed up and checked for any modifications. Each
# file is expected to have two backups, /var/backups/file.{current,backup}.
# Any changes cause the files to rotate.
if [ -s /etc/changelist ] ; then
for file in `cat /etc/changelist`; do
CUR=/var/backups/`basename $file`.current
BACK=/var/backups/`basename $file`.backup
if [ -s $file ]; then
if [ -s $CUR ] ; then
diff $CUR $file > $OUTPUT
if [ -s $OUTPUT ] ; then
printf "\n======\n%s diffs (OLD < > NEW)\n======\n" $file
cat $OUTPUT
cp -p $CUR $BACK
cp -p $file $CUR
chown root.wheel $CUR $BACK
fi
else
cp -p $file $CUR
chown root.wheel $CUR
fi
fi
done
fi
+84
View File
@@ -0,0 +1,84 @@
#
# Network services, Internet style
#
# @(#)services 8.1 (Berkeley) 6/9/93
#
tcpmux 1/tcp # TCP port multiplexer (RFC1078)
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
systat 11/tcp users
daytime 13/tcp
daytime 13/udp
netstat 15/tcp
qotd 17/tcp quote
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
ftp 21/tcp
telnet 23/tcp
smtp 25/tcp mail
time 37/tcp timserver
time 37/udp timserver
rlp 39/udp resource # resource location
nameserver 42/tcp name # IEN 116
whois 43/tcp nicname
domain 53/tcp nameserver # name-domain server
domain 53/udp nameserver
mtp 57/tcp # deprecated
# Bootp experimental (sellgren@vangogh)
bootp 67/udp # bootp server
#bootpc 68/udp # bootp client
#
tftp 69/udp
rje 77/tcp netrjs
finger 79/tcp
link 87/tcp ttylink
supdup 95/tcp
hostnames 101/tcp hostname # usually from sri-nic
tsap 102/tcp # part of ISODE.
#csnet-cs 105/?
pop 109/tcp postoffice
sunrpc 111/tcp
sunrpc 111/udp
auth 113/tcp authentication
sftp 115/tcp
uucp-path 117/tcp
nntp 119/tcp readnews untp # USENET News Transfer Protocol
ntp 123/udp
snmp 161/udp
snmp-trap 162/udp
#
# UNIX specific services
#
exec 512/tcp
biff 512/udp comsat
login 513/tcp
who 513/udp whod
shell 514/tcp cmd # no passwords used
syslog 514/udp
printer 515/tcp spooler # line printer spooler
talk 517/udp
ntalk 518/udp
route 520/udp router routed
timed 525/udp timeserver
tempo 526/tcp newdate
courier 530/tcp rpc
conference 531/tcp chat
netnews 532/tcp readnews
netwall 533/udp # -for emergency broadcasts
uucp 540/tcp uucpd # uucp daemon
rdist 541/tcp rdistd # rdist daemon
remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem
ingreslock 1524/tcp
#
# Kerberos (Project Athena/MIT) services
#
kerberos 750/udp kdc # Kerberos (server) udp
kerberos 750/tcp kdc # Kerberos (server) tcp
krbupdate 760/tcp kreg # Kerberos registration
kpasswd 761/tcp kpwd # Kerberos "passwd"
klogin 543/tcp # Kerberos rlogin
eklogin 2105/tcp # Kerberos encrypted rlogin
kshell 544/tcp krcmd # Kerberos remote shell
+6
View File
@@ -0,0 +1,6 @@
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/sh
/bin/csh
+17
View File
@@ -0,0 +1,17 @@
*.err;kern.*;auth.notice;authpriv.none;mail.crit /dev/console
*.notice;*.info;authpriv,ftp.none;kern.debug;mail.crit /var/log/messages
# The authpriv log file should be restricted access; these
# messages shouldn't go to terminals or publically-readable
# files.
authpriv.* /var/log/secure
lpr.info /var/log/lpd-errs
mail.* /var/log/maillog
uucp.info /var/spool/uucp/ERRORS
ftp.* /var/log/ftp.log
*.emerg *
*.alert root
*.err,authpriv.none root
*.notice;auth.debug root
+1
View File
@@ -0,0 +1 @@
/usr/share/misc/termcap
+55
View File
@@ -0,0 +1,55 @@
#
# @(#)ttys 5.2 (Berkeley) 6/10/93
#
# name getty type status comments
#
# If the console is marked insecure, single-user requires
# the root password.
console "/usr/libexec/getty std.9600" unknown on secure
#tahoe's only
#remote "/usr/libexec/getty std.1200" pt on # diagnostics
# Hardwired lines are marked off, by default, so getty(8)
# is quiet when they don't exist.
tty00 "/usr/libexec/getty std.9600" unknown off secure
tty01 "/usr/libexec/getty std.9600" unknown off secure
tty02 "/usr/libexec/getty std.9600" unknown off secure
tty03 "/usr/libexec/getty std.9600" unknown off secure
tty04 "/usr/libexec/getty std.9600" unknown off secure
tty05 "/usr/libexec/getty std.9600" unknown off secure
tty06 "/usr/libexec/getty std.9600" unknown off secure
tty07 "/usr/libexec/getty std.9600" unknown off secure
ttyp0 none network
ttyp1 none network
ttyp2 none network
ttyp3 none network
ttyp4 none network
ttyp5 none network
ttyp6 none network
ttyp7 none network
ttyp8 none network
ttyp9 none network
ttypa none network
ttypb none network
ttypc none network
ttypd none network
ttype none network
ttypf none network
ttyq0 none network
ttyq1 none network
ttyq2 none network
ttyq3 none network
ttyq4 none network
ttyq5 none network
ttyq6 none network
ttyq7 none network
ttyq8 none network
ttyq9 none network
ttyqa none network
ttyqb none network
ttyqc none network
ttyqd none network
ttyqe none network
ttyqf none network
+69
View File
@@ -0,0 +1,69 @@
#!/bin/sh -
#
# @(#)weekly 8.2 (Berkeley) 1/2/94
#
PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec
export PATH
host=`hostname`
echo "Subject: $host weekly run output"
#echo ""
#echo "Removing old .o files:"
#find /usr/src -name '*.o' -atime +21 -print -a -exec rm -f {} \;
# see if /usr/src exists and is local
# before looking there for checked-out files
if [ -d /usr/src -a \
X"`find -f /usr/src ! -fstype local -prune -or -type d -print -prune`" != X ];
then
echo "looking for checked out files:"
TDIR=/tmp/_checkout$$
mkdir $TDIR
for file in `find -f /usr/src ! -fstype local -prune -or \
-name 'p.*' -print | egrep 'SCCS/p\.'`; do
owner=`awk '{ print $3 }' $file`
echo "$owner $file"
echo $file >> $TDIR/$owner
done | sed -e 's,SCCS/p.,,' | sort
if test -n "`ls $TDIR`"; then
for file in $TDIR/*; do
sed -e 's,SCCS/p.,,' $file | \
Mail -s 'checked out files' `basename $file`
done
fi
rm -rf $TDIR
fi
if [ -f /usr/lib/uucp/clean.weekly ]; then
echo ""
echo "Cleaning up UUCP:"
echo /usr/lib/uucp/clean.weekly | su daemon
fi
echo ""
echo ""
echo -n "Rotating log files:"
cd /var/log
for i in amd messages; do
echo -n " $i"
if [ -f $i.5 ]; then mv -f $i.5 $i.6; fi
if [ -f $i.4 ]; then mv -f $i.4 $i.5; fi
if [ -f $i.3 ]; then mv -f $i.3 $i.4; fi
if [ -f $i.2 ]; then mv -f $i.2 $i.3; fi
if [ -f $i.1 ]; then mv -f $i.1 $i.2; fi
if [ -f $i.0 ]; then mv -f $i.0 $i.1; fi
if [ -f $i ]; then mv -f $i $i.0; fi
>$i
done
echo ""
kill -1 `cat /var/run/syslog.pid`
cd /
echo ""
echo "Rebuilding locate database:"
echo /usr/libexec/locate.updatedb | nice -5 su -m nobody 2>/dev/null
+18
View File
@@ -0,0 +1,18 @@
root::0:10::0:0:Charlie &:/root:/bin/csh
toor::0:10::0:0:Bourne-again Superuser:/root:
daemon:*:1:31::0:0:The devil himself:/root:/sbin/nologin
operator:*:2:28::0:0:System &:/usr/guest/operator:/bin/csh
news:*:6:8::0:0:Network News:/var/spool/news:/sbin/nologin
bin:*:3:7::0:0:Binaries Commands and Source:/:/sbin/nologin
games:*:7:13::0:0:Games pseudo-user:/usr/games:/sbin/nologin
uucp:*:66:1::0:0:UNIX-to-UNIX Copy:/var/spool/uucppublic:/usr/lib/uucp/uucico
nobody:*:32767:9999::0:0:Unprivileged user:/nonexistent:/sbin/nologin
dmr:*:10:31::0:0:Dennis Ritchie:/var/users/guest/dmr:
ken:*:11:31::0:0:& Thompson:/var/users/guest/ken:
ingres:*:267:74::0:0:& Group:/usr/ingres:/bin/csh
mckusick:*:647:31::0:0:Kirk &,1614 Oxford St. Berkeley CA 94709-1608,510-843-9542,510-843-9542:/var/users/guest/mckusick:/bin/csh
ralph:*:987:31::0:0:& Campbell,,,:/var/users/guest/ralph:/bin/csh
bostic:*:1547:31::0:0:Keith &,394 East Riding Rd. Carlisle MA 01741,508-287-4781,508-287-4781:/var/users/guest/bostic:/bin/csh
torek:*:2282:31::0:0:Chris &,,,:/var/users/guest/torek:/bin/csh
hibler:*:2430:31::0:0:Mike &,Univ of Utah,,:/var/users/guest/hibler:/bin/csh
falcon:*:32766:31::0:0:Prof. Steven &:/usr/games:/usr/games/wargames
+26
View File
@@ -0,0 +1,26 @@
set history=1000
set path=(/sbin /usr/sbin /bin /usr/bin /usr/contrib/bin /usr/old/bin)
# directory stuff: cdpath/cd/back
set cdpath=(/sys /usr/src/{bin,sbin,usr.{bin,sbin},lib,libexec,share,contrib,local,games,old})
alias h history -r
alias hup 'kill -HUP `cat /var/run/\!$.pid`'
alias j jobs -l
alias k jobs -l
alias ll ls -l
alias x exit
alias z suspend
alias back 'set back=$old; set old=$cwd; cd $back; unset back; dirs'
alias cd 'set old=$cwd; chdir \!*'
alias pd pushd
alias pd2 pushd +2
alias pd3 pushd +3
alias pd4 pushd +4
alias tset 'set noglob histchars=""; eval `\tset -s \!*`; unset noglob histchars'
if ($?prompt) then
set prompt="`hostname -s`# "
endif
umask 022
+2
View File
@@ -0,0 +1,2 @@
user1.root@your.realm.wherever
user2.root@your.realm.wherever
+9
View File
@@ -0,0 +1,9 @@
setenv BLOCKSIZE 1k
tset -Q \?$TERM
echo 'erase ^H, kill ^U, intr ^C status ^T'
stty erase '^H' kill '^U' intr '^C' status '^T' crt
umask 022
echo "Don't login as root, use the su command."
+15
View File
@@ -0,0 +1,15 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
BLOCKSIZE=1k
export BLOCKSIZE
#export TERM for single user shells.
export TERM
echo 'erase ^H, kill ^U, intr ^C status ^T'
stty erase '^H' kill '^U' intr '^C' status '^T' crt
umask 022
echo "Don't login as root, use the su command."
+1
View File
@@ -0,0 +1 @@
trustedhost.wherever.domain
Symlink
+1
View File
@@ -0,0 +1 @@
usr/src/sys
Symlink
+1
View File
@@ -0,0 +1 @@
X11R5
+1
View File
@@ -0,0 +1 @@
/usr/X11/bin
Symlink
+1
View File
@@ -0,0 +1 @@
/usr/hpux/lib/X
+1
View File
@@ -0,0 +1 @@
/usr/X11/lib
+1
View File
@@ -0,0 +1 @@
/usr/hpux/lib/grmd
+1
View File
@@ -0,0 +1 @@
/usr/share/tmac
+16
View File
@@ -0,0 +1,16 @@
# @(#)Makefile 8.1 (Berkeley) 6/19/93
SUBDIR= bin contrib games include kerberosIV lib libexec old sbin \
share usr.bin usr.sbin
afterinstall:
(cd share/man && make makedb)
build:
(cd include && make install)
make cleandir
(cd lib && make depend && make && make install)
(cd kerberosIV && make depend && make && make install)
make depend && make && make install
.include <bsd.subdir.mk>
+3
View File
@@ -0,0 +1,3 @@
getopt -- application getopt template
indent.pro -- indent defaults to approximate style standards
style -- style document
+38
View File
@@ -0,0 +1,38 @@
/*
* Main/getopt(3) fragment.
*
* @(#)getopt 5.4 (Berkeley) 3/30/94
*/
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
void usage __P((void));
int
main(argc, argv)
int argc;
char *argv[];
{
int ch;
while ((ch = getopt(argc, argv, "")) != EOF)
switch (ch) {
case '':
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
}
void
usage()
{
(void)fprintf(stderr, "usage: program [-abc] [-f file]\n");
exit(1);
}
+20
View File
@@ -0,0 +1,20 @@
-bap
-br
-ce
-ci4
-cli0
-d0
-di8
-i8
-ip
-l79
-nbc
-ncdb
-ndj
-nei
-nfc1
-nlp
-npcs
-psl
-sc
-sob
+314
View File
@@ -0,0 +1,314 @@
/*
* Style guide for the 4BSD KNF (Kernel Normal Form).
*
* @(#)style 1.13 (Berkeley) 4/2/94
*/
/*
* VERY important single-line comments look like this.
*/
/* Most single-line comments look like this. */
/*
* Multi-line comments look like this. Make them real sentences. Fill
* them so they look like real paragraphs.
*/
/*
* Kernel include files come first; normally, you'll need <sys/types.h>
* OR <sys/param.h>, but not both! <sys/types.h> includes <sys/cdefs.h>,
* and it's okay to depend on that.
*/
#include <sys/types.h> /* Non-local includes in brackets. */
/* If it's a network program, put the network include files next. */
#include <net/if.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <netinet/in.h>
#include <protocols/rwhod.h>
/*
* Then there's a blank line, followed by the /usr include files.
* The /usr include files should be sorted!
*/
#include <stdio.h>
/*
* Global pathnames are defined in /usr/include/paths.h. Pathnames local
* to the program go in pathnames.h in the local directory.
*/
#include <paths.h>
/* Then, there's a blank line, and the user include files. */
#include "pathnames.h" /* Local includes in double quotes. */
/*
* Macros are capitalized, parenthesized, and should avoid side-effects.
* If they are an inline expansion of a function, the function is defined
* all in lowercase, the macro has the same name all in uppercase. If the
* macro needs more than a single line, use braces. Right-justify the
* backslashes, it makes it easier to read.
*/
#define MACRO(x, y) { \
variable = (x) + (y); \
(y) += 2; \
}
/* Enum types are capitalized. */
enum enumtype { ONE, TWO } et;
/*
* When declaring variables in structures, declare them sorted by use, then
* by size, and then by alphabetical order. The first category normally
* doesn't apply, but there are exceptions. Each one gets its own line.
* Put a tab after the first word, i.e. use "int^Ix;" and "struct^Ifoo *x;".
*
* Major structures should be declared at the top of the file in which they
* are used, or in separate header files, if they are used in multiple
* source files. Use of the structures should be by separate declarations
* and should be "extern" if they are declared in a header file.
*/
struct foo {
struct foo *next; /* List of active foo */
struct mumble amumble; /* Comment for mumble */
int bar;
};
struct foo *foohead; /* Head of global foo list */
/* Make the structure name match the typedef. */
typedef struct _bar {
int level;
} BAR;
/*
* ANSI function declarations for private functions (i.e. functions not used
* elsewhere) go at the top of the first source module. Use the __P macro
* from the include file <sys/cdefs.h>. Only the kernel has a name associated
* with the types, i.e. in the kernel use:
*
* void function __P((int fd));
*
* in user land use:
*
* void function __P((int));
*/
static char *function __P((int, const char *));
static void usage __P((void));
/*
* All major routines should have a comment briefly describing what
* they do. The comment before the "main" routine should describe
* what the program does.
*/
int
main(argc, argv)
int argc;
char *argv[];
{
extern char *optarg;
extern int optind;
long num;
int ch;
char *ep;
/*
* For consistency, getopt should be used to parse options. Options
* should be sorted in the getopt call and the switch statement, unless
* parts of the switch cascade. Elements in a switch statement that
* cascade should have a FALLTHROUGH comment. Numerical arguments
* should be checked for accuracy. Code that cannot be reached should
* have a NOTREACHED comment.
*/
while ((ch = getopt(argc, argv, "abn")) != EOF)
switch (ch) { /* Indent the switch. */
case 'a': /* Don't indent the case. */
aflag = 1;
/* FALLTHROUGH */
case 'b':
bflag = 1;
break;
case 'n':
num = strtol(optarg, &ep, 10);
if (num <= 0 || *ep != '\0')
err("illegal number -- %s", optarg);
break;
case '?':
default:
usage();
/* NOTREACHED */
}
argc -= optind;
argv += optind;
/*
* Space after keywords (while, for, return, switch). No braces are
* used for control statements with zero or only a single statement.
*
* Forever loops are done with for's, not while's.
*/
for (p = buf; *p != '\0'; ++p);
for (;;)
stmt;
/*
* Parts of a for loop may be left empty. Don't put declarations
* inside blocks unless the routine is unusually complicated.
*/
for (; cnt < 15; cnt++) {
stmt1;
stmt2;
}
/* Second level indents are four spaces. */
while (cnt < 20)
z = a + really + long + statment + that + needs + two lines +
gets + indented + four + spaces + on + the + second +
and + subsequent + lines.
/*
* Closing and opening braces go on the same line as the else.
* Don't add braces that aren't necessary.
*/
if (test)
stmt;
else if (bar) {
stmt;
stmt;
} else
stmt;
/* No spaces after function names. */
if (error = function(a1, a2))
exit(error);
/*
* Unary operators don't require spaces, binary operators do. Don't
* use parenthesis unless they're required for precedence, or the
* statement is really confusing without them.
*/
a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1;
k = !(l & FLAGS);
/*
* Exits should be 0 on success, and 1 on failure. Don't denote
* all the possible exit points, using the integers 1 through 300.
*/
exit(0); /* Avoid obvious comments such as "Exit 0 on success." */
}
/*
* If a function type is declared, it should be on a line
* by itself preceeding the function.
*/
static char *
function(a1, a2, fl, a4)
int a1, a2, a4; /* Declare ints, too, don't default them. */
float fl; /* List in order declared, as much as possible. */
{
/*
* When declaring variables in functions declare them sorted by size,
* then in alphabetical order; multiple ones per line are okay. Old
* style function declarations can go on the same line. ANSI style
* function declarations should go in the include file "externs.h".
* If a line overflows reuse the type keyword.
*
* DO NOT initialize variables in the declarations.
*/
extern u_char one;
extern char two;
struct foo three, *four;
double five;
int *six, seven, eight();
char *nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen;
char *overflow __P((void));
void *mymalloc __P((u_int));
/*
* Casts and sizeof's are not followed by a space. NULL is any
* pointer type, and doesn't need to be cast, so use NULL instead
* of (struct foo *)0 or (struct foo *)NULL. Also, test pointers
* against NULL, i.e. use:
*
* (p = f()) == NULL
* not:
* !(p = f())
*
* Don't use '!' for tests unless it's a boolean, e.g. use
* "if (*p == '\0')", not "if (!*p)".
*
* Routines returning void * should not have their return values cast
* to any pointer type.
*
* Use err/warn(3), don't roll your own!
*/
if ((four = malloc(sizeof(struct foo))) == NULL)
err(1, NULL);
if ((six = (int *)overflow()) == NULL)
errx(1, "Number overflowed.");
return (eight);
}
/*
* Don't use ANSI function declarations unless you absolutely have too,
* i.e. you're declaring functions with variable numbers of arguments.
*
* ANSI function return values and braces look like regular functions.
*/
int
function(int a1, int a2)
{
...
}
/* Variable numbers of arguments should look like this. */
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
vaf(const char *fmt, ...)
#else
vaf(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
STUFF;
va_end(ap); /* No return needed for void functions. */
}
static void
usage()
{ /* Insert an empty line if the function has no local variables. */
/*
* Use printf(3), not fputs/puts/putchar/whatever, it's faster and
* usually cleaner, not to mention avoiding stupid bugs.
*
* Usage statements should look like the manual pages. Options w/o
* operands come first, in alphabetical order inside a single set of
* braces. Followed by options with operands, in alphabetical order,
* each in braces. Followed by required arguments in the order they
* are specified, followed by optional arguments in the order they
* are specified. A bar ('|') separates either/or options/arguments,
* and multiple options/arguments which are specified together are
* placed in a single set of braces.
*
* "usage: f [-ade] [-b b_arg] [-m m_arg] req1 req2 [opt1 [opt2]]\n"
* "usage: f [-a | -b] [-c [-de] [-n number]]\n"
*/
(void)fprintf(stderr, "usage: f [-ab]\n");
exit(1);
}
+6
View File
@@ -0,0 +1,6 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
SUBDIR= cat chmod cp csh date dd df echo ed expr hostname kill ln ls \
mkdir mv pax ps pwd rcp rm rmail rmdir sh sleep stty sync test
.include <bsd.subdir.mk>
+3
View File
@@ -0,0 +1,3 @@
# @(#)Makefile.inc 8.1 (Berkeley) 5/31/93
BINDIR?= /bin
+5
View File
@@ -0,0 +1,5 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= cat
.include <bsd.prog.mk>
+121
View File
@@ -0,0 +1,121 @@
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)cat.1 8.1 (Berkeley) 6/29/93
.\"
.Dd June 29, 1993
.Dt CAT 1
.Os BSD 3
.Sh NAME
.Nm cat
.Nd concatenate and print files
.Sh SYNOPSIS
.Nm cat
.Op Fl benstuv
.Op Fl
.Op Ar
.Sh DESCRIPTION
The
.Nm cat
utility reads files sequentially, writing them to the standard output.
The
.Ar file
operands are processed in command line order.
A single dash represents the standard input.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl b
Implies the
.Fl n
option but doesn't number blank lines.
.It Fl e
Implies the
.Fl v
option, and displays a dollar sign
.Pq Ql \&$
at the end of each line
as well.
.It Fl n
Number the
.Ar output
lines, starting at 1.
.It Fl s
Squeeze multiple adjacent empty lines, causing the output to be
single spaced.
.It Fl t
Implies the
.Fl v
option, and displays tab characters as
.Pq Ql ^I
as well.
.It Fl u
The
.Fl u
option guarantees that the output is unbuffered.
.It Fl v
Displays non-printing characters so they are visible.
Control characters print as
.Ql ^X
for control-X; the delete
character (octal 0177) prints as
.Ql ^?
Non-ascii characters (with the high bit set) are printed as
.Ql M-
(for meta) followed by the character for the low 7 bits.
.El
.Pp
The
.Nm cat
utility exits 0 on success, and >0 if an error occurs.
.Sh BUGS
Because of the shell language mechanism used to perform output
redirection, the command
.Dq Li cat file1 file 2 > file1
will cause the original data in file1 to be destroyed!
.Sh SEE ALSO
.Xr head 1 ,
.Xr more 1 ,
.Xr pr 1 ,
.Xr tail 1
.Rs
.%A Rob Pike
.%T "UNIX Style, or cat -v Considered Harmful"
.%J "USENIX Summer Conference Proceedings"
.%D 1983
.Re
.Sh HISTORY
A
.Nm
command appeared in Version 6 AT&T UNIX.
+251
View File
@@ -0,0 +1,251 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kevin Fall.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)cat.c 8.1 (Berkeley) 7/19/93";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int bflag, eflag, nflag, sflag, tflag, vflag;
int rval;
char *filename;
void cook_args __P((char *argv[]));
void cook_buf __P((FILE *));
void raw_args __P((char *argv[]));
void raw_cat __P((int));
int
main(argc, argv)
int argc;
char *argv[];
{
extern int optind;
int ch;
while ((ch = getopt(argc, argv, "benstuv")) != EOF)
switch (ch) {
case 'b':
bflag = nflag = 1; /* -b implies -n */
break;
case 'e':
eflag = vflag = 1; /* -e implies -v */
break;
case 'n':
nflag = 1;
break;
case 's':
sflag = 1;
break;
case 't':
tflag = vflag = 1; /* -t implies -v */
break;
case 'u':
setbuf(stdout, (char *)NULL);
break;
case 'v':
vflag = 1;
break;
case '?':
(void)fprintf(stderr,
"usage: cat [-benstuv] [-] [file ...]\n");
exit(1);
}
argv += optind;
if (bflag || eflag || nflag || sflag || tflag || vflag)
cook_args(argv);
else
raw_args(argv);
if (fclose(stdout))
err(1, "stdout");
exit(rval);
}
void
cook_args(argv)
char **argv;
{
register FILE *fp;
fp = stdin;
filename = "stdin";
do {
if (*argv) {
if (!strcmp(*argv, "-"))
fp = stdin;
else if ((fp = fopen(*argv, "r")) == NULL) {
warn("%s", *argv);
++argv;
continue;
}
filename = *argv++;
}
cook_buf(fp);
if (fp != stdin)
(void)fclose(fp);
} while (*argv);
}
void
cook_buf(fp)
register FILE *fp;
{
register int ch, gobble, line, prev;
line = gobble = 0;
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
if (prev == '\n') {
if (ch == '\n') {
if (sflag) {
if (!gobble && putchar(ch) == EOF)
break;
gobble = 1;
continue;
}
if (nflag && !bflag) {
(void)fprintf(stdout, "%6d\t", ++line);
if (ferror(stdout))
break;
}
} else if (nflag) {
(void)fprintf(stdout, "%6d\t", ++line);
if (ferror(stdout))
break;
}
}
gobble = 0;
if (ch == '\n') {
if (eflag)
if (putchar('$') == EOF)
break;
} else if (ch == '\t') {
if (tflag) {
if (putchar('^') == EOF || putchar('I') == EOF)
break;
continue;
}
} else if (vflag) {
if (!isascii(ch)) {
if (putchar('M') == EOF || putchar('-') == EOF)
break;
ch = toascii(ch);
}
if (iscntrl(ch)) {
if (putchar('^') == EOF ||
putchar(ch == '\177' ? '?' :
ch | 0100) == EOF)
break;
continue;
}
}
if (putchar(ch) == EOF)
break;
}
if (ferror(fp)) {
warn("%s", filename);
clearerr(fp);
}
if (ferror(stdout))
err(1, "stdout");
}
void
raw_args(argv)
char **argv;
{
register int fd;
fd = fileno(stdin);
filename = "stdin";
do {
if (*argv) {
if (!strcmp(*argv, "-"))
fd = fileno(stdin);
else if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
warn("%s", *argv);
++argv;
continue;
}
filename = *argv++;
}
raw_cat(fd);
if (fd != fileno(stdin))
(void)close(fd);
} while (*argv);
}
void
raw_cat(rfd)
register int rfd;
{
register int nr, nw, off, wfd;
static int bsize;
static char *buf;
struct stat sbuf;
wfd = fileno(stdout);
if (buf == NULL) {
if (fstat(wfd, &sbuf))
err(1, "%s", filename);
bsize = MAX(sbuf.st_blksize, 1024);
if ((buf = malloc((u_int)bsize)) == NULL)
err(1, "");
}
while ((nr = read(rfd, buf, bsize)) > 0)
for (off = 0; nr; nr -= nw, off += nw)
if ((nw = write(wfd, buf + off, nr)) < 0)
err(1, "stdout");
if (nr < 0)
warn("%s", filename);
}
+1
View File
@@ -0,0 +1 @@
/usr/obj/bin/cat
+5
View File
@@ -0,0 +1,5 @@
Mcat cat.c /^main(argc, argv)$/
cook_args cat.c /^cook_args(argv)$/
cook_buf cat.c /^cook_buf(fp)$/
raw_args cat.c /^raw_args(argv)$/
raw_cat cat.c /^raw_cat(rfd)$/
+5
View File
@@ -0,0 +1,5 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= chmod
.include <bsd.prog.mk>
+294
View File
@@ -0,0 +1,294 @@
.\" Copyright (c) 1989, 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
.\"
.Dd March 31, 1994
.Dt CHMOD 1
.Os
.Sh NAME
.Nm chmod
.Nd change file modes
.Sh SYNOPSIS
.Nm chmod
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
.Ar mode
.Ar file ...
.Sh DESCRIPTION
The
.Nm chmod
utility modifies the file mode bits of the listed files
as specified by the
.Ar mode
operand.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl H
If the
.Fl R
option is specified, symbolic links on the command line are followed.
(Symbolic links encountered in the tree traversal are not followed.)
.It Fl L
If the
.Fl R
option is specified, all symbolic links are followed.
.It Fl P
If the
.Fl R
option is specified, no symbolic links are followed.
.It Fl R
Change the modes of the file hierarchies rooted in the files
instead of just the files themselves.
.El
.Pp
Symbolic links do not have modes, so unless the
.Fl H
or
.Fl L
option is set,
.Nm chmod
on a symbolic link always succeeds and has no effect.
The
.Fl H ,
.Fl L
and
.Fl P
options are ignored unless the
.Fl R
option is specified.
In addition, these options override each other and the
command's actions are determined by the last one specified.
.Pp
Only the owner of a file or the super-user is permitted to change
the mode of a file.
.Pp
The
.Nm chmod
utility exits 0 on success, and >0 if an error occurs.
.Sh MODES
Modes may be absolute or symbolic.
An absolute mode is an octal number constructed by
.Ar or-ing
the following values:
.Pp
.Bl -tag -width 6n -compact -offset indent
.It Li 4000
set-user-ID-on-execution
.It Li 2000
set-group-ID-on-execution
.It Li 1000
sticky bit, see chmod(2)
.It Li 0400
read by owner
.It Li 0200
write by owner
.It Li 0100
execute (or search for directories) by owner
.It Li 0070
read, write, execute/search by group
.It Li 0007
read, write, execute/search by others
.El
.Pp
The read, write, and execute/search values for group and others
are encoded as described for owner.
.Pp
The symbolic mode is described by the following grammar:
.Bd -literal -offset indent
mode ::= clause [, clause ...]
clause ::= [who ...] [action ...] last_action
action ::= op [perm ...]
last_action ::= op [perm ...]
who ::= a | u | g | o
op ::= + | \- | =
perm ::= r | s | t | w | x | X | u | g | o
.Ed
.Pp
The
.Ar who
symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
of the mode bits, respectively.
The
.Ar who
symbol ``a'' is equivalent to ``ugo''.
.Pp
.ne 1i
The
.Ar perm
symbols represent the portions of the mode bits as follows:
.Pp
.Bl -tag -width Ds -compact -offset indent
.It r
The read bits.
.It s
The set-user-ID-on-execution and set-group-ID-on-execution bits.
.It t
The sticky bit.
.It w
The write bits.
.It x
The execute/search bits.
.It X
The execute/search bits if the file is a directory or any of the
execute/search bits are set in the original (unmodified) mode.
Operations with the
.Ar perm
symbol ``X'' are only meaningful in conjunction with the
.Ar op
symbol ``+'', and are ignored in all other cases.
.It u
The user permission bits in the mode of the original file.
.It g
The group permission bits in the mode of the original file.
.It o
The other permission bits in the mode of the original file.
.El
.Pp
The
.Ar op
symbols represent the operation performed, as follows:
.Bl -tag -width 4n
.It +
If no value is supplied for
.Ar perm ,
the ``+'' operation has no effect.
If no value is supplied for
.Ar who ,
each permission bit specified in
.Ar perm ,
for which the corresponding bit in the file mode creation mask
is clear, is set.
Otherwise, the mode bits represented by the specified
.Ar who
and
.Ar perm
values are set.
.It \&\-
If no value is supplied for
.Ar perm ,
the ``\-'' operation has no effect.
If no value is supplied for
.Ar who ,
each permission bit specified in
.Ar perm ,
for which the corresponding bit in the file mode creation mask
is clear, is cleared.
Otherwise, the mode bits represented by the specified
.Ar who
and
.Ar perm
values are cleared.
.It =
The mode bits specified by the
.Ar who
value are cleared, or, if no who value is specified, the owner, group
and other mode bits are cleared.
Then, if no value is supplied for
.Ar who ,
each permission bit specified in
.Ar perm ,
for which the corresponding bit in the file mode creation mask
is clear, is set.
Otherwise, the mode bits represented by the specified
.Ar who
and
.Ar perm
values are set.
.El
.Pp
Each
.Ar clause
specifies one or more operations to be performed on the mode
bits, and each operation is applied to the mode bits in the
order specified.
.Pp
Operations upon the other permissions only (specified by the symbol
``o'' by itself), in combination with the
.Ar perm
symbols ``s'' or ``t'', are ignored.
.Sh EXAMPLES
.Bl -tag -width "u=rwx,go=u-w" -compact
.It Li 644
make a file readable by anyone and writable by the owner only.
.Pp
.It Li go-w
deny write permission to group and others.
.Pp
.It Li =rw,+X
set the read and write permissions to the usual defaults, but
retain any execute permissions that are currently set.
.Pp
.It Li +X
make a directory or file searchable/executable by everyone if it is
already searchable/executable by anyone.
.Pp
.It Li 755
.It Li u=rwx,go=rx
.It Li u=rwx,go=u-w
make a file readable/executable by everyone and writable by the owner only.
.Pp
.It Li go=
clear all mode bits for group and others.
.Pp
.It Li g=u-w
set the group bits equal to the user bits, but clear the group write bit.
.El
.Sh BUGS
There's no
.Ar perm
option for the naughty bits.
.Sh SEE ALSO
.Xr install 1 ,
.Xr chmod 2 ,
.Xr stat 2 ,
.Xr umask 2 ,
.Xr fts 3 ,
.Xr setmode 3 ,
.Xr symlink 7 ,
.Xr chown 8
.Sh STANDARDS
The
.Nm chmod
utility is expected to be POSIX 1003.2
compatible with the exception of the
.Ar perm
symbols
.Dq t
and
.Dq X
which are not included in that standard.
+201
View File
@@ -0,0 +1,201 @@
/*
* Copyright (c) 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1989, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include <err.h>
#include <errno.h>
#include <fts.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void usage __P((void));
int
main(argc, argv)
int argc;
char *argv[];
{
FTS *ftsp;
FTSENT *p;
mode_t *set;
long val;
int oct, omode;
int Hflag, Lflag, Pflag, Rflag, ch, fflag, fts_options, hflag, rval;
char *ep, *mode;
Hflag = Lflag = Pflag = Rflag = fflag = hflag = 0;
while ((ch = getopt(argc, argv, "HLPRXfgorstuwx")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
Lflag = Pflag = 0;
break;
case 'L':
Lflag = 1;
Hflag = Pflag = 0;
break;
case 'P':
Pflag = 1;
Hflag = Lflag = 0;
break;
case 'R':
Rflag = 1;
break;
case 'f': /* XXX: undocumented. */
fflag = 1;
break;
case 'h':
/*
* In System V (and probably POSIX.2) the -h option
* causes chmod to change the mode of the symbolic
* link. 4.4BSD's symbolic links don't have modes,
* so it's an undocumented noop. Do syntax checking,
* though.
*/
hflag = 1;
break;
/*
* XXX
* "-[rwx]" are valid mode commands. If they are the entire
* argument, getopt has moved past them, so decrement optind.
* Regardless, we're done argument processing.
*/
case 'g': case 'o': case 'r': case 's':
case 't': case 'u': case 'w': case 'X': case 'x':
if (argv[optind - 1][0] == '-' &&
argv[optind - 1][1] == ch &&
argv[optind - 1][2] == '\0')
--optind;
goto done;
case '?':
default:
usage();
}
done: argv += optind;
argc -= optind;
if (argc < 2)
usage();
fts_options = FTS_PHYSICAL;
if (Rflag) {
if (hflag)
errx(1,
"the -R and -h options may not be specified together.");
if (Hflag)
fts_options |= FTS_COMFOLLOW;
if (Lflag) {
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
}
}
mode = *argv;
if (*mode >= '0' && *mode <= '7') {
errno = 0;
val = strtol(mode, &ep, 8);
if (val > INT_MAX || val < 0)
errno = ERANGE;
if (errno)
err(1, "invalid file mode: %s", mode);
if (*ep)
errx(1, "invalid file mode: %s", mode);
omode = val;
oct = 1;
} else {
if ((set = setmode(mode)) == NULL)
errx(1, "invalid file mode: %s", mode);
oct = 0;
}
if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
err(1, NULL);
for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
switch (p->fts_info) {
case FTS_D:
if (Rflag) /* Change it at FTS_DP. */
continue;
fts_set(ftsp, p, FTS_SKIP);
break;
case FTS_DNR: /* Warn, chmod, continue. */
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
rval = 1;
break;
case FTS_ERR: /* Warn, continue. */
case FTS_NS:
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
rval = 1;
continue;
case FTS_SL: /* Ignore. */
case FTS_SLNONE:
/*
* The only symlinks that end up here are ones that
* don't point to anything and ones that we found
* doing a physical walk.
*/
continue;
default:
break;
}
if (chmod(p->fts_accpath, oct ? omode :
getmode(set, p->fts_statp->st_mode)) && !fflag) {
warn(p->fts_path);
rval = 1;
}
}
if (errno)
err(1, "fts_read");
exit(rval);
}
void
usage()
{
(void)fprintf(stderr,
"usage: chmod [-R [-H | -L | -P]] mode file ...\n");
exit(1);
}
+1
View File
@@ -0,0 +1 @@
/usr/obj/bin/chmod
+2
View File
@@ -0,0 +1,2 @@
Mchmod chmod.c /^main(argc, argv)$/
usage chmod.c /^usage()$/
+6
View File
@@ -0,0 +1,6 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= cp
SRCS= cp.c utils.c
.include <bsd.prog.mk>
+211
View File
@@ -0,0 +1,211 @@
.\" Copyright (c) 1989, 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
.\"
.Dd April 18, 1994
.Dt CP 1
.Os BSD 4
.Sh NAME
.Nm cp
.Nd copy files
.Sh SYNOPSIS
.Nm cp
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl fip
.Ar source_file target_file
.Nm cp
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl fip
.Ar source_file ... target_directory
.Sh DESCRIPTION
In the first synopsis form, the
.Nm cp
utility copies the contents of the
.Ar source_file
to the
.Ar target_file .
In the second synopsis form,
the contents of each named
.Ar source_file
is copied to the destination
.Ar target_directory .
The names of the files themselves are not changed.
If
.Nm cp
detects an attempt to copy a file to itself, the copy will fail.
.Pp
The following options are available:
.Bl -tag -width flag
.It Fl H
If the
.Fl R
option is specified, symbolic links on the command line are followed.
(Symbolic links encountered in the tree traversal are not followed.)
.It Fl L
If the
.Fl R
option is specified, all symbolic links are followed.
.It Fl P
If the
.Fl R
option is specified, no symbolic links are followed.
.It Fl R
If
.Ar source_file
designates a directory,
.Nm cp
copies the directory and the entire subtree connected at that point.
This option also causes symbolic links to be copied, rather than
indirected through, and for
.Nm cp
to create special files rather than copying them as normal files.
Created directories have the same mode as the corresponding source
directory, unmodified by the process' umask.
.It Fl f
For each existing destination pathname, remove it and
create a new file, without prompting for confirmation
regardless of its permissions.
(The
.Fl i
option is ignored if the
.Fl f
option is specified.)
.It Fl i
Causes
.Nm cp
to write a prompt to the standard error output before copying a file
that would overwrite an existing file.
If the response from the standard input begins with the character
.Sq Li y ,
the file copy is attempted.
.It Fl p
Causes
.Nm cp
to preserve in the copy as many of the modification time, access time,
file flags, file mode, user ID, and group ID as allowed by permissions.
.Pp
If the user ID and group ID cannot be preserved, no error message
is displayed and the exit value is not altered.
.Pp
If the source file has its set user ID bit on and the user ID cannot
be preserved, the set user ID bit is not preserved
in the copy's permissions.
If the source file has its set group ID bit on and the group ID cannot
be preserved, the set group ID bit is not preserved
in the copy's permissions.
If the source file has both its set user ID and set group ID bits on,
and either the user ID or group ID cannot be preserved, neither
the set user ID or set group ID bits are preserved in the copy's
permissions.
.El
.Pp
For each destination file that already exists, its contents are
overwritten if permissions allow, but its mode, user ID, and group
ID are unchanged.
.Pp
In the second synopsis form,
.Ar target_directory
must exist unless there is only one named
.Ar source_file
which is a directory and the
.Fl R
flag is specified.
.Pp
If the destination file does not exist, the mode of the source file is
used as modified by the file mode creation mask
.Pf ( Ic umask ,
see
.Xr csh 1 ) .
If the source file has its set user ID bit on, that bit is removed
unless both the source file and the destination file are owned by the
same user.
If the source file has its set group ID bit on, that bit is removed
unless both the source file and the destination file are in the same
group and the user is a member of that group.
If both the set user ID and set group ID bits are set, all of the above
conditions must be fulfilled or both bits are removed.
.Pp
Appropriate permissions are required for file creation or overwriting.
.Pp
Symbolic links are always followed unless the
.Fl R
flag is set, in which case symbolic links are not followed, by default.
The
.Fl H
or
.Fl L
flags (in conjunction with the
.Fl R
flag) cause symbolic links to be followed as described above.
The
.Fl H ,
.Fl L
and
.Fl P
options are ignored unless the
.Fl R
option is specified.
In addition, these options override each other and the
command's actions are determined by the last one specified.
.Pp
.Nm Cp
exits 0 on success, >0 if an error occurred.
.Sh COMPATIBILITY
Historic versions of the
.Nm cp
utility had a
.Fl r
option.
This implementation supports that option, however, its use is strongly
discouraged, as it does not correctly copy special files, symbolic links
or fifo's.
.Sh SEE ALSO
.Xr mv 1 ,
.Xr rcp 1 ,
.Xr umask 2 ,
.Xr fts 3 ,
.Xr symlink 7
.Sh HISTORY
The
.Nm cp
command is expected to be
.St -p1003.2
compatible.
+441
View File
@@ -0,0 +1,441 @@
/*
* Copyright (c) 1988, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* David Hitz of Auspex Systems Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1988, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
#endif /* not lint */
/*
* Cp copies source files to target files.
*
* The global PATH_T structure "to" always contains the path to the
* current target file. Since fts(3) does not change directories,
* this path can be either absolute or dot-realative.
*
* The basic algorithm is to initialize "to" and use fts(3) to traverse
* the file hierarchy rooted in the argument list. A trivial case is the
* case of 'cp file1 file2'. The more interesting case is the case of
* 'cp file1 file2 ... fileN dir' where the hierarchy is traversed and the
* path (relative to the root of the traversal) is appended to dir (stored
* in "to") to form the final target path.
*/
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <fts.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "extern.h"
#define STRIP_TRAILING_SLASH(p) { \
while ((p).p_end > (p).p_path && (p).p_end[-1] == '/') \
*--(p).p_end = 0; \
}
PATH_T to = { to.p_path, "" };
uid_t myuid;
int Rflag, iflag, pflag, rflag;
int myumask;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
int copy __P((char *[], enum op, int));
int mastercmp __P((const FTSENT **, const FTSENT **));
int
main(argc, argv)
int argc;
char *argv[];
{
struct stat to_stat, tmp_stat;
enum op type;
int Hflag, Lflag, Pflag, ch, fts_options, r;
char *target;
Hflag = Lflag = Pflag = Rflag = 0;
while ((ch = getopt(argc, argv, "HLPRfipr")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
Lflag = Pflag = 0;
break;
case 'L':
Lflag = 1;
Hflag = Pflag = 0;
break;
case 'P':
Pflag = 1;
Hflag = Lflag = 0;
break;
case 'R':
Rflag = 1;
break;
case 'f':
iflag = 0;
break;
case 'i':
iflag = isatty(fileno(stdin));
break;
case 'p':
pflag = 1;
break;
case 'r':
rflag = 1;
break;
case '?':
default:
usage();
break;
}
argc -= optind;
argv += optind;
if (argc < 2)
usage();
fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
if (rflag) {
if (Rflag)
errx(1,
"the -R and -r options may not be specified together.");
if (Hflag || Lflag || Pflag)
errx(1,
"the -H, -L, and -P options may not be specified with the -r option.");
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
}
if (Rflag) {
if (Hflag)
fts_options |= FTS_COMFOLLOW;
if (Lflag) {
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
}
} else {
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
}
myuid = getuid();
/* Copy the umask for explicit mode setting. */
myumask = umask(0);
(void)umask(myumask);
/* Save the target base in "to". */
target = argv[--argc];
if (strlen(target) > MAXPATHLEN)
errx(1, "%s: name too long", target);
(void)strcpy(to.p_path, target);
to.p_end = to.p_path + strlen(to.p_path);
if (to.p_path == to.p_end) {
*to.p_end++ = '.';
*to.p_end = 0;
}
STRIP_TRAILING_SLASH(to);
to.target_end = to.p_end;
/* Set end of argument list for fts(3). */
argv[argc] = NULL;
/*
* Cp has two distinct cases:
*
* cp [-R] source target
* cp [-R] source1 ... sourceN directory
*
* In both cases, source can be either a file or a directory.
*
* In (1), the target becomes a copy of the source. That is, if the
* source is a file, the target will be a file, and likewise for
* directories.
*
* In (2), the real target is not directory, but "directory/source".
*/
r = stat(to.p_path, &to_stat);
if (r == -1 && errno != ENOENT)
err(1, "%s", to.p_path);
if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
/*
* Case (1). Target is not a directory.
*/
if (argc > 1) {
usage();
exit(1);
}
/*
* Need to detect the case:
* cp -R dir foo
* Where dir is a directory and foo does not exist, where
* we want pathname concatenations turned on but not for
* the initial mkdir().
*/
if (r == -1) {
if (rflag || (Rflag && (Lflag || Hflag)))
stat(*argv, &tmp_stat);
else
lstat(*argv, &tmp_stat);
if (S_ISDIR(tmp_stat.st_mode) && (Rflag || rflag))
type = DIR_TO_DNE;
else
type = FILE_TO_FILE;
} else
type = FILE_TO_FILE;
} else
/*
* Case (2). Target is a directory.
*/
type = FILE_TO_DIR;
exit (copy(argv, type, fts_options));
}
int
copy(argv, type, fts_options)
char *argv[];
enum op type;
int fts_options;
{
struct stat to_stat;
FTS *ftsp;
FTSENT *curr;
int base, dne, nlen, rval;
char *p;
if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
err(1, NULL);
for (rval = 0; (curr = fts_read(ftsp)) != NULL;) {
switch (curr->fts_info) {
case FTS_NS:
case FTS_ERR:
warnx("%s: %s",
curr->fts_path, strerror(curr->fts_errno));
rval = 1;
continue;
case FTS_DC: /* Warn, continue. */
warnx("%s: directory causes a cycle", curr->fts_path);
rval = 1;
continue;
case FTS_DP: /* Ignore, continue. */
continue;
}
/*
* If we are in case (2) or (3) above, we need to append the
* source name to the target name.
*/
if (type != FILE_TO_FILE) {
if ((curr->fts_namelen +
to.target_end - to.p_path + 1) > MAXPATHLEN) {
warnx("%s/%s: name too long (not copied)",
to.p_path, curr->fts_name);
rval = 1;
continue;
}
/*
* Need to remember the roots of traversals to create
* correct pathnames. If there's a directory being
* copied to a non-existent directory, e.g.
* cp -R a/dir noexist
* the resulting path name should be noexist/foo, not
* noexist/dir/foo (where foo is a file in dir), which
* is the case where the target exists.
*
* Also, check for "..". This is for correct path
* concatentation for paths ending in "..", e.g.
* cp -R .. /tmp
* Paths ending in ".." are changed to ".". This is
* tricky, but seems the easiest way to fix the problem.
*
* XXX
* Since the first level MUST be FTS_ROOTLEVEL, base
* is always initialized.
*/
if (curr->fts_level == FTS_ROOTLEVEL)
if (type != DIR_TO_DNE) {
p = strrchr(curr->fts_path, '/');
base = (p == NULL) ? 0 :
(int)(p - curr->fts_path + 1);
if (!strcmp(&curr->fts_path[base],
".."))
base += 1;
} else
base = curr->fts_pathlen;
if (to.target_end[-1] != '/') {
*to.target_end = '/';
*(to.target_end + 1) = 0;
}
p = &curr->fts_path[base];
nlen = curr->fts_pathlen - base;
(void)strncat(to.target_end + 1, p, nlen);
to.p_end = to.target_end + nlen + 1;
*to.p_end = 0;
STRIP_TRAILING_SLASH(to);
}
/* Not an error but need to remember it happened */
if (stat(to.p_path, &to_stat) == -1)
dne = 1;
else {
if (to_stat.st_dev == curr->fts_statp->st_dev &&
to_stat.st_ino == curr->fts_statp->st_ino) {
warnx("%s and %s are identical (not copied).",
to.p_path, curr->fts_path);
rval = 1;
if (S_ISDIR(curr->fts_statp->st_mode))
(void)fts_set(ftsp, curr, FTS_SKIP);
continue;
}
dne = 0;
}
switch (curr->fts_statp->st_mode & S_IFMT) {
case S_IFLNK:
if (copy_link(curr, !dne))
rval = 1;
break;
case S_IFDIR:
if (!Rflag && !rflag) {
warnx("%s is a directory (not copied).",
curr->fts_path);
(void)fts_set(ftsp, curr, FTS_SKIP);
rval = 1;
break;
}
/*
* If the directory doesn't exist, create the new
* one with the from file mode plus owner RWX bits,
* modified by the umask. Trade-off between being
* able to write the directory (if from directory is
* 555) and not causing a permissions race. If the
* umask blocks owner writes, we fail..
*/
if (dne) {
if (mkdir(to.p_path,
curr->fts_statp->st_mode | S_IRWXU) < 0)
err(1, "%s", to.p_path);
} else if (!S_ISDIR(to_stat.st_mode)) {
errno = ENOTDIR;
err(1, "%s: %s", to.p_path);
}
/*
* If not -p and directory didn't exist, set it to be
* the same as the from directory, umodified by the
* umask; arguably wrong, but it's been that way
* forever.
*/
if (pflag && setfile(curr->fts_statp, 0))
rval = 1;
else if (dne)
(void)chmod(to.p_path,
curr->fts_statp->st_mode);
break;
case S_IFBLK:
case S_IFCHR:
if (Rflag) {
if (copy_special(curr->fts_statp, !dne))
rval = 1;
} else
if (copy_file(curr, dne))
rval = 1;
break;
case S_IFIFO:
if (Rflag)
if (copy_fifo(curr->fts_statp, !dne))
rval = 1;
else
if (copy_file(curr, dne))
rval = 1;
break;
default:
if (copy_file(curr, dne))
rval = 1;
break;
}
}
if (errno)
err(1, "fts_read");
return (rval);
}
/*
* mastercmp --
* The comparison function for the copy order. The order is to copy
* non-directory files before directory files. The reason for this
* is because files tend to be in the same cylinder group as their
* parent directory, whereas directories tend not to be. Copying the
* files first reduces seeking.
*/
int
mastercmp(a, b)
const FTSENT **a, **b;
{
int a_info, b_info;
a_info = (*a)->fts_info;
if (a_info == FTS_ERR || a_info == FTS_NS || a_info == FTS_DNR)
return (0);
b_info = (*b)->fts_info;
if (b_info == FTS_ERR || b_info == FTS_NS || b_info == FTS_DNR)
return (0);
if (a_info == FTS_D)
return (-1);
if (b_info == FTS_D)
return (1);
return (0);
}
+55
View File
@@ -0,0 +1,55 @@
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)extern.h 8.2 (Berkeley) 4/1/94
*/
typedef struct {
char *p_end; /* pointer to NULL at end of path */
char *target_end; /* pointer to end of target base */
char p_path[MAXPATHLEN + 1]; /* pointer to the start of a path */
} PATH_T;
extern PATH_T to;
extern uid_t myuid;
extern int iflag, pflag, myumask;
#include <sys/cdefs.h>
__BEGIN_DECLS
int copy_fifo __P((struct stat *, int));
int copy_file __P((FTSENT *, int));
int copy_link __P((FTSENT *, int));
int copy_special __P((struct stat *, int));
int setfile __P((struct stat *, int));
void usage __P((void));
__END_DECLS
+1
View File
@@ -0,0 +1 @@
/usr/obj/bin/cp
+10
View File
@@ -0,0 +1,10 @@
Mcp cp.c /^main(argc, argv)$/
STRIP_TRAILING_SLASH cp.c /^#define STRIP_TRAILING_SLASH(p) { \\$/
copy cp.c /^copy(argv, type, fts_options)$/
copy_fifo utils.c /^copy_fifo(from_stat, exists)$/
copy_file utils.c /^copy_file(entp, dne)$/
copy_link utils.c /^copy_link(p, exists)$/
copy_special utils.c /^copy_special(from_stat, exists)$/
mastercmp cp.c /^mastercmp(a, b)$/
setfile utils.c /^setfile(fs, fd)$/
usage utils.c /^usage()$/
+285
View File
@@ -0,0 +1,285 @@
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <fts.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "extern.h"
int
copy_file(entp, dne)
FTSENT *entp;
int dne;
{
static char buf[MAXBSIZE];
struct stat to_stat, *fs;
int ch, checkch, from_fd, rcount, rval, to_fd, wcount;
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
char *p;
#endif
if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) {
warn("%s", entp->fts_path);
return (1);
}
fs = entp->fts_statp;
/*
* If the file exists and we're interactive, verify with the user.
* If the file DNE, set the mode to be the from file, minus setuid
* bits, modified by the umask; arguably wrong, but it makes copying
* executables work right and it's been that way forever. (The
* other choice is 666 or'ed with the execute bits on the from file
* modified by the umask.)
*/
if (!dne) {
if (iflag) {
(void)fprintf(stderr, "overwrite %s? ", to.p_path);
checkch = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
if (checkch != 'y') {
(void)close(from_fd);
return (0);
}
}
to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
} else
to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
fs->st_mode & ~(S_ISUID | S_ISGID));
if (to_fd == -1) {
warn("%s", to.p_path);
(void)close(from_fd);
return (1);;
}
rval = 0;
/*
* Mmap and write if less than 8M (the limit is so we don't totally
* trash memory on big files. This is really a minor hack, but it
* wins some CPU back.
*/
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
if (fs->st_size <= 8 * 1048576) {
if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
0, from_fd, (off_t)0)) == (char *)-1) {
warn("%s", entp->fts_path);
rval = 1;
} else {
if (write(to_fd, p, fs->st_size) != fs->st_size) {
warn("%s", to.p_path);
rval = 1;
}
/* Some systems don't unmap on close(2). */
if (munmap(p, fs->st_size) < 0) {
warn("%s", entp->fts_path);
rval = 1;
}
}
} else
#endif
{
while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
wcount = write(to_fd, buf, rcount);
if (rcount != wcount || wcount == -1) {
warn("%s", to.p_path);
rval = 1;
break;
}
}
if (rcount < 0) {
warn("%s", entp->fts_path);
rval = 1;
}
}
/* If the copy went bad, lose the file. */
if (rval == 1) {
(void)unlink(to.p_path);
(void)close(from_fd);
(void)close(to_fd);
return (1);
}
if (pflag && setfile(fs, to_fd))
rval = 1;
/*
* If the source was setuid or setgid, lose the bits unless the
* copy is owned by the same user and group.
*/
#define RETAINBITS \
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
else if (fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid)
if (fstat(to_fd, &to_stat)) {
warn("%s", to.p_path);
rval = 1;
} else if (fs->st_gid == to_stat.st_gid &&
fchmod(to_fd, fs->st_mode & RETAINBITS & ~myumask)) {
warn("%s", to.p_path);
rval = 1;
}
(void)close(from_fd);
if (close(to_fd)) {
warn("%s", to.p_path);
rval = 1;
}
return (rval);
}
int
copy_link(p, exists)
FTSENT *p;
int exists;
{
int len;
char link[MAXPATHLEN];
if ((len = readlink(p->fts_path, link, sizeof(link))) == -1) {
warn("readlink: %s", p->fts_path);
return (1);
}
link[len] = '\0';
if (exists && unlink(to.p_path)) {
warn("unlink: %s", to.p_path);
return (1);
}
if (symlink(link, to.p_path)) {
warn("symlink: %s", link);
return (1);
}
return (0);
}
int
copy_fifo(from_stat, exists)
struct stat *from_stat;
int exists;
{
if (exists && unlink(to.p_path)) {
warn("unlink: %s", to.p_path);
return (1);
}
if (mkfifo(to.p_path, from_stat->st_mode)) {
warn("mkfifo: %s", to.p_path);
return (1);
}
return (pflag ? setfile(from_stat, 0) : 0);
}
int
copy_special(from_stat, exists)
struct stat *from_stat;
int exists;
{
if (exists && unlink(to.p_path)) {
warn("unlink: %s", to.p_path);
return (1);
}
if (mknod(to.p_path, from_stat->st_mode, from_stat->st_rdev)) {
warn("mknod: %s", to.p_path);
return (1);
}
return (pflag ? setfile(from_stat, 0) : 0);
}
int
setfile(fs, fd)
register struct stat *fs;
int fd;
{
static struct timeval tv[2];
int rval;
rval = 0;
fs->st_mode &= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
if (utimes(to.p_path, tv)) {
warn("utimes: %s", to.p_path);
rval = 1;
}
/*
* Changing the ownership probably won't succeed, unless we're root
* or POSIX_CHOWN_RESTRICTED is not set. Set uid/gid before setting
* the mode; current BSD behavior is to remove all setuid bits on
* chown. If chown fails, lose setuid/setgid bits.
*/
if (fd ? fchown(fd, fs->st_uid, fs->st_gid) :
chown(to.p_path, fs->st_uid, fs->st_gid)) {
if (errno != EPERM) {
warn("chown: %s", to.p_path);
rval = 1;
}
fs->st_mode &= ~(S_ISUID | S_ISGID);
}
if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) {
warn("chown: %s", to.p_path);
rval = 1;
}
if (fd ?
fchflags(fd, fs->st_flags) : chflags(to.p_path, fs->st_flags)) {
warn("chflags: %s", to.p_path);
rval = 1;
}
return (rval);
}
void
usage()
{
(void)fprintf(stderr, "%s\n%s\n",
"usage: cp [-R [-H | -L | -P] [-fip] src target",
" cp [-R [-H | -L | -P] [-fip] src1 ... srcN directory");
exit(1);
}
+44
View File
@@ -0,0 +1,44 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
#
# C Shell with process control; VM/UNIX VAX Makefile
# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
#
# To profile, put -DPROF in DEFS and -pg in CFLAGS, and recompile.
PROG= csh
DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
#CFLAGS+=-g
#CFLAGS+=-Wall -ansi -pedantic
CFLAGS+=-I${.CURDIR} -I. ${DFLAGS}
SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \
sem.c set.c str.c time.c
.PATH: ${.CURDIR}/../../usr.bin/printf
MAN1= csh.0
MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \
csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \
csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \
csh.1 stop.1 csh.1 source.1
CLEANFILES+=err.h const.h
const.h: err.h
err.h: err.c
@rm -f $@
@echo '/* Do not edit this file, make creates it. */' > $@
@echo '#ifndef _h_sh_err' >> $@
@echo '#define _h_sh_err' >> $@
egrep 'ERR_' ${.CURDIR}/$*.c | egrep '^#define' >> $@
@echo '#endif /* _h_sh_err */' >> $@
const.h: const.c
@rm -f $@
@echo '/* Do not edit this file, make creates it. */' > $@
${CC} -E ${CFLAGS} ${.CURDIR}/$*.c | egrep 'Char STR' | \
sed -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \
sort >> $@
.depend: const.h err.h
.include <bsd.prog.mk>
+7
View File
@@ -0,0 +1,7 @@
# @(#)Makefile 8.1 (Berkeley) 8/14/93
DIR= usd/04.csh
SRCS= tabs csh.1 csh.2 csh.3 csh.4 csh.a csh.g
MACROS= -ms
.include <bsd.doc.mk>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+650
View File
@@ -0,0 +1,650 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)csh.3 8.1 (Berkeley) 6/8/93
.\"
.nr H1 2
.NH
Shell control structures and command scripts
.NH 2
Introduction
.PP
It is possible to place commands in files and to cause shells to be
invoked to read and execute commands from these files,
which are called
.I "shell scripts."
We here detail those features of the shell useful to the writers of such
scripts.
.NH 2
Make
.PP
It is important to first note what shell scripts are
.I not
useful for.
There is a program called
.I make
which is very useful for maintaining a group of related files
or performing sets of operations on related files.
For instance a large program consisting of one or more files
can have its dependencies described in a
.I makefile
which contains definitions of the commands used to create these
different files when changes occur.
Definitions of the means for printing listings, cleaning up the directory
in which the files reside, and installing the resultant programs
are easily, and most appropriately placed in this
.I makefile.
This format is superior and preferable to maintaining a group of shell
procedures to maintain these files.
.PP
Similarly when working on a document a
.I makefile
may be created which defines how different versions of the document
are to be created and which options of
.I nroff
or
.I troff
are appropriate.
.NH 2
Invocation and the argv variable
.PP
A
.I csh
command script may be interpreted by saying
.DS
% csh script ...
.DE
where
.I script
is the name of the file containing a group of
.I csh
commands and
`\&...' is replaced by a sequence of arguments.
The shell places these arguments in the variable
.I argv
and then begins to read commands from the script.
These parameters are then available through the same mechanisms
which are used to reference any other shell variables.
.PP
If you make the file
`script'
executable by doing
.DS
chmod 755 script
.DE
and place a shell comment at the beginning of the shell script
(i.e. begin the file with a `#' character)
then a `/bin/csh' will automatically be invoked to execute `script' when
you type
.DS
script
.DE
If the file does not begin with a `#' then the standard shell
`/bin/sh' will be used to execute it.
This allows you to convert your older shell scripts to use
.I csh
at your convenience.
.NH 2
Variable substitution
.PP
After each input line is broken into words and history substitutions
are done on it, the input line is parsed into distinct commands.
Before each command is executed a mechanism know as
.I "variable substitution"
is done on these words.
Keyed by the character `$' this substitution replaces the names
of variables by their values.
Thus
.DS
echo $argv
.DE
when placed in a command script would cause the current value of the
variable
.I argv
to be echoed to the output of the shell script.
It is an error for
.I argv
to be unset at this point.
.PP
A number of notations are provided for accessing components and attributes
of variables.
The notation
.DS
$?name
.DE
expands to `1' if name is
.I set
or to `0'
if name is not
.I set.
It is the fundamental mechanism used for checking whether particular
variables have been assigned values.
All other forms of reference to undefined variables cause errors.
.PP
The notation
.DS
$#name
.DE
expands to the number of elements in the variable
.I name.
Thus
.DS
% set argv=(a b c)
% echo $?argv
1
% echo $#argv
3
% unset argv
% echo $?argv
0
% echo $argv
Undefined variable: argv.
%
.DE
.PP
It is also possible to access the components of a variable
which has several values.
Thus
.DS
$argv[1]
.DE
gives the first component of
.I argv
or in the example above `a'.
Similarly
.DS
$argv[$#argv]
.DE
would give `c',
and
.DS
$argv[1\-2]
.DE
would give `a b'. Other notations useful in shell scripts are
.DS
$\fIn\fR
.DE
where
.I n
is an integer as a shorthand for
.DS
$argv[\fIn\fR\|]
.DE
the
.I n\|th
parameter and
.DS
$*
.DE
which is a shorthand for
.DS
$argv
.DE
The form
.DS
$$
.DE
expands to the process number of the current shell.
Since this process number is unique in the system it can
be used in generation of unique temporary file names.
The form
.DS
$<
.DE
is quite special and is replaced by the next line of input read from
the shell's standard input (not the script it is reading). This is
useful for writing shell scripts that are interactive, reading
commands from the terminal, or even writing a shell script that
acts as a filter, reading lines from its input file. Thus the sequence
.DS
echo 'yes or no?\ec'
set a=($<)
.DE
would write out the prompt `yes or no?' without a newline and then
read the answer into the variable `a'. In this case `$#a' would be
`0' if either a blank line or end-of-file (^D) was typed.
.PP
One minor difference between `$\fIn\fR\|' and `$argv[\fIn\fR\|]'
should be noted here.
The form
`$argv[\fIn\fR\|]'
will yield an error if
.I n
is not in the range
`1\-$#argv'
while `$n'
will never yield an out of range subscript error.
This is for compatibility with the way older shells handled parameters.
.PP
Another important point is that it is never an error to give a subrange
of the form `n\-'; if there are less than
.I n
components of the given variable then no words are substituted.
A range of the form `m\-n' likewise returns an empty vector without giving
an error when \fIm\fR exceeds the number of elements of the given variable,
provided the subscript \fIn\fR is in range.
.NH 2
Expressions
.PP
In order for interesting shell scripts to be constructed it
must be possible to evaluate expressions in the shell based on the
values of variables.
In fact, all the arithmetic operations of the language C are available
in the shell
with the same precedence that they have in C.
In particular, the operations `==' and `!=' compare strings
and the operators `&&' and `|\|\||' implement the boolean and/or operations.
The special operators `=~' and `!~' are similar to `==' and `!=' except
that the string on the right side can have pattern matching characters
(like *, ? or []) and the test is whether the string on the left matches
the pattern on the right.
.PP
The shell also allows file enquiries of the form
.DS
\-? filename
.DE
where `?' is replace by a number of single characters.
For instance the expression primitive
.DS
\-e filename
.DE
tell whether the file
`filename'
exists.
Other primitives test for read, write and execute access to the file,
whether it is a directory, or has non-zero length.
.PP
It is possible to test whether a command terminates normally,
by a primitive of the
form `{ command }' which returns true, i.e. `1' if the command
succeeds exiting normally with exit status 0, or `0' if the command
terminates abnormally or with exit status non-zero.
If more detailed information about the execution status of a command
is required, it can be executed and the variable `$status' examined
in the next command.
Since `$status' is set by every command, it is very transient.
It can be saved if it is inconvenient to use it only in the single
immediately following command.
.PP
For a full list of expression components available see the manual
section for the shell.
.NH 2
Sample shell script
.PP
A sample shell script which makes use of the expression mechanism
of the shell and some of its control structure follows:
.DS
% cat copyc
#
# Copyc copies those C programs in the specified list
# to the directory ~/backup if they differ from the files
# already in ~/backup
#
set noglob
foreach i ($argv)
if ($i !~ *.c) continue # not a .c file so do nothing
if (! \-r ~/backup/$i:t) then
echo $i:t not in backup... not cp\e\'ed
continue
endif
cmp \-s $i ~/backup/$i:t # to set $status
if ($status != 0) then
echo new backup of $i
cp $i ~/backup/$i:t
endif
end
.DE
.PP
This script makes use of the
.I foreach
command, which causes the shell to execute the commands between the
.I foreach
and the matching
.I end
for each of the values given between `(' and `)' with the named
variable, in this case `i' set to successive values in the list.
Within this loop we may use the command
.I break
to stop executing the loop
and
.I continue
to prematurely terminate one iteration
and begin the next.
After the
.I foreach
loop the iteration variable
(\fIi\fR in this case)
has the value at the last iteration.
.PP
We set the variable
.I noglob
here to prevent filename expansion of the members of
.I argv.
This is a good idea, in general, if the arguments to a shell script
are filenames which have already been expanded or if the arguments
may contain filename expansion metacharacters.
It is also possible to quote each use of a `$' variable expansion,
but this is harder and less reliable.
.PP
The other control construct used here is a statement of the form
.DS
\fBif\fR ( expression ) \fBthen\fR
command
...
\fBendif\fR
.DE
The placement of the keywords here is
.B not
flexible due to the current implementation of the shell.\(dg
.FS
\(dgThe following two formats are not currently acceptable to the shell:
.sp
.in +5
.nf
\fBif\fR ( expression ) # \fBWon't work!\fR
\fBthen\fR
command
...
\fBendif\fR
.fi
.in -5
.sp
and
.sp
.in +5
.nf
\fBif\fR ( expression ) \fBthen\fR command \fBendif\fR # \fBWon't work\fR
.in -5
.fi
.FE
.PP
The shell does have another form of the if statement of the form
.DS
\fBif\fR ( expression ) \fBcommand\fR
.DE
which can be written
.DS
\fBif\fR ( expression ) \e
command
.DE
Here we have escaped the newline for the sake of appearance.
The command must not involve `\||\|', `&' or `;'
and must not be another control command.
The second form requires the final `\e' to
.B immediately
precede the end-of-line.
.PP
The more general
.I if
statements above also admit a sequence of
.I else\-if
pairs followed by a single
.I else
and an
.I endif,
e.g.:
.DS
\fBif\fR ( expression ) \fBthen\fR
commands
\fBelse\fR \fBif\fR (expression ) \fBthen\fR
commands
\&...
\fBelse\fR
commands
\fBendif\fR
.DE
.PP
Another important mechanism used in shell scripts is the `:' modifier.
We can use the modifier `:r' here to extract a root of a filename or
`:e' to extract the
.I extension.
Thus if the variable
.I i
has the value
`/mnt/foo.bar'
then
.sp
.in +5
.nf
% echo $i $i:r $i:e
/mnt/foo.bar /mnt/foo bar
%
.sp
.in -5
.fi
shows how the `:r' modifier strips off the trailing `.bar' and the
the `:e' modifier leaves only the `bar'.
Other modifiers will take off the last component of a pathname leaving
the head `:h' or all but the last component of a pathname leaving the
tail `:t'.
These modifiers are fully described in the
.I csh
manual pages in the User's Reference Manual.
It is also possible to use the
.I "command substitution"
mechanism described in the next major section to perform modifications
on strings to then reenter the shell's environment.
Since each usage of this mechanism involves the creation of a new process,
it is much more expensive to use than the `:' modification mechanism.\(dd
.FS
\(dd It is also important to note that
the current implementation of the shell limits the number of `:' modifiers
on a `$' substitution to 1.
Thus
.sp
.nf
.in +5
% echo $i $i:h:t
/a/b/c /a/b:t
%
.in -5
.fi
.sp
does not do what one would expect.
.FE
Finally, we note that the character `#' lexically introduces a shell
comment in shell scripts (but not from the terminal).
All subsequent characters on the input line after a `#' are discarded
by the shell.
This character can be quoted using `\'' or `\e' to place it in
an argument word.
.NH 2
Other control structures
.PP
The shell also has control structures
.I while
and
.I switch
similar to those of C.
These take the forms
.DS
\fBwhile\fR ( expression )
commands
\fBend\fR
.DE
and
.DS
\fBswitch\fR ( word )
\fBcase\fR str1:
commands
\fBbreaksw\fR
\& ...
\fBcase\fR strn:
commands
\fBbreaksw\fR
\fBdefault:\fR
commands
\fBbreaksw\fR
\fBendsw\fR
.DE
For details see the manual section for
.I csh.
C programmers should note that we use
.I breaksw
to exit from a
.I switch
while
.I break
exits a
.I while
or
.I foreach
loop.
A common mistake to make in
.I csh
scripts is to use
.I break
rather than
.I breaksw
in switches.
.PP
Finally,
.I csh
allows a
.I goto
statement, with labels looking like they do in C, i.e.:
.DS
loop:
commands
\fBgoto\fR loop
.DE
.NH 2
Supplying input to commands
.PP
Commands run from shell scripts receive by default the standard
input of the shell which is running the script.
This is different from previous shells running
under \s-2UNIX\s0. It allows shell scripts to fully participate
in pipelines, but mandates extra notation for commands which are to take
inline data.
.PP
Thus we need a metanotation for supplying inline data to commands in
shell scripts.
As an example, consider this script which runs the editor to
delete leading blanks from the lines in each argument file:
.DS
% cat deblank
# deblank \-\- remove leading blanks
foreach i ($argv)
ed \- $i << \'EOF\'
1,$s/^[ ]*//
w
q
\&\'EOF\'
end
%
.DE
The notation `<< \'EOF\''
means that the standard input for the
.I ed
command is to come from the text in the shell script file
up to the next line consisting of exactly `\'EOF\''.
The fact that the `EOF' is enclosed in `\'' characters, i.e. quoted,
causes the shell to not perform variable substitution on the
intervening lines.
In general, if any part of the word following the `<<' which the
shell uses to terminate the text to be given to the command is quoted
then these substitutions will not be performed.
In this case since we used the form `1,$' in our editor script
we needed to insure that this `$' was not variable substituted.
We could also have insured this by preceding the `$' here with a `\e',
i.e.:
.DS
1,\e$s/^[ ]*//
.DE
but quoting the `EOF' terminator is a more reliable way of achieving the
same thing.
.NH 2
Catching interrupts
.PP
If our shell script creates temporary files, we may wish to catch
interruptions of the shell script so that we can clean up
these files.
We can then do
.DS
onintr label
.DE
where
.I label
is a label in our program.
If an interrupt is received the shell will do a
`goto label'
and we can remove the temporary files and then do an
.I exit
command (which is built in to the shell)
to exit from the shell script.
If we wish to exit with a non-zero status we can do
.DS
exit(1)
.DE
e.g. to exit with status `1'.
.NH 2
What else?
.PP
There are other features of the shell useful to writers of shell
procedures.
The
.I verbose
and
.I echo
options and the related
.I \-v
and
.I \-x
command line options can be used to help trace the actions of the shell.
The
.I \-n
option causes the shell only to read commands and not to execute
them and may sometimes be of use.
.PP
One other thing to note is that
.I csh
will not execute shell scripts which do not begin with the
character `#', that is shell scripts that do not begin with a comment.
Similarly, the `/bin/sh' on your system may well defer to `csh'
to interpret shell scripts which begin with `#'.
This allows shell scripts for both shells to live in harmony.
.PP
There is also another quotation mechanism using `"' which allows
only some of the expansion mechanisms we have so far discussed to occur
on the quoted string and serves to make this string into a single word
as `\'' does.
.bp
+178
View File
@@ -0,0 +1,178 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)csh.4 8.1 (Berkeley) 6/8/93
.\"
.nr H1 3
.NH
Other, less commonly used, shell features
.NH 2
Loops at the terminal; variables as vectors
.PP
It is occasionally useful to use the
.I foreach
control structure at the terminal to aid in performing a number
of similar commands.
For instance, there were at one point three shells in use on the Cory \s-2UNIX\s0
system at Cory Hall,
`/bin/sh',
`/bin/nsh',
and
`/bin/csh'.
To count the number of persons using each shell one could have issued
the commands
.DS
% grep \-c csh$ /etc/passwd
27
% grep \-c nsh$ /etc/passwd
128
% grep \-c \-v sh$ /etc/passwd
430
%
.DE
Since these commands are very similar we can use
.I foreach
to do this more easily.
.DS
% foreach i (\'sh$\' \'csh$\' \'\-v sh$\')
? grep \-c $i /etc/passwd
? end
27
128
430
%
.DE
Note here that the shell prompts for
input with `? ' when reading the body of the loop.
.PP
Very useful with loops are variables which contain lists of filenames
or other words.
You can, for example, do
.DS
% set a=(\`ls\`)
% echo $a
csh.n csh.rm
% ls
csh.n
csh.rm
% echo $#a
2
%
.DE
The
.I set
command here gave the variable
.I a
a list of all the filenames in the current directory as value.
We can then iterate over these names to perform any chosen function.
.PP
The output of a command within `\`' characters is converted by
the shell to a list of words.
You can also place the `\`' quoted string within `"' characters
to take each (non-empty) line as a component of the variable;
preventing the lines from being split into words at blanks and tabs.
A modifier `:x' exists which can be used later to expand each component
of the variable into another variable splitting it into separate words
at embedded blanks and tabs.
.NH 2
Braces { ... } in argument expansion
.PP
Another form of filename expansion, alluded
to before involves the characters `{' and `}'.
These characters specify that the contained strings, separated by `,'
are to be consecutively substituted into the containing characters
and the results expanded left to right.
Thus
.DS
A{str1,str2,...strn}B
.DE
expands to
.DS
Astr1B Astr2B ... AstrnB
.DE
This expansion occurs before the other filename expansions, and may
be applied recursively (i.e. nested).
The results of each expanded string are sorted separately, left
to right order being preserved.
The resulting filenames are not required to exist if no other expansion
mechanisms are used.
This means that this mechanism can be used to generate arguments which are
not filenames, but which have common parts.
.PP
A typical use of this would be
.DS
mkdir ~/{hdrs,retrofit,csh}
.DE
to make subdirectories `hdrs', `retrofit' and `csh'
in your home directory.
This mechanism is most useful when the common prefix is longer
than in this example, i.e.
.DS
chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
.DE
.NH 2
Command substitution
.PP
A command enclosed in `\`' characters is replaced, just before
filenames are expanded, by the output from that command.
Thus it is possible to do
.DS
set pwd=\`pwd\`
.DE
to save the current directory in the variable
.I pwd
or to do
.DS
ex \`grep \-l TRACE *.c\`
.DE
to run the editor
.I ex
supplying as arguments those files whose names end in `.c'
which have the string `TRACE' in them.*
.FS
*Command expansion also occurs in input redirected with `<<'
and within `"' quotations.
Refer to the shell manual section for full details.
.FE
.NH 2
Other details not covered here
.PP
In particular circumstances it may be necessary to know the exact
nature and order of different substitutions performed by the shell.
The exact meaning of certain combinations of quotations is also
occasionally important.
These are detailed fully in its manual section.
.PP
The shell has a number of command line option flags mostly of use
in writing \s-2UNIX\s0 programs,
and debugging shell scripts.
See the csh(1) manual section for a list of these options.
.bp
+95
View File
@@ -0,0 +1,95 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)csh.a 8.1 (Berkeley) 6/8/93
.\"
.SH
Appendix \- Special characters
.LP
The following table lists the special characters of
.I csh
and the \s-2UNIX\s0 system, giving for each the section(s) in which it
is discussed.
A number of these characters also have special meaning in expressions.
See the
.I csh
manual section
for a complete list.
.ta .75i 1.5i 2.25i
.LP
Syntactic metacharacters
.DS
; 2.4 separates commands to be executed sequentially
| 1.5 separates commands in a pipeline
( ) 2.2,3.6 brackets expressions and variable values
& 2.5 follows commands to be executed without waiting for completion
.DE
.LP
Filename metacharacters
.DS
/ 1.6 separates components of a file's pathname
\. 1.6 separates root parts of a file name from extensions
? 1.6 expansion character matching any single character
* 1.6 expansion character matching any sequence of characters
[ ] 1.6 expansion sequence matching any single character from a set
~ 1.6 used at the beginning of a filename to indicate home directories
{ } 4.2 used to specify groups of arguments with common parts
.DE
.LP
Quotation metacharacters
.DS
\e 1.7 prevents meta-meaning of following single character
\' 1.7 prevents meta-meaning of a group of characters
" 4.3 like \', but allows variable and command expansion
.DE
.LP
Input/output metacharacters
.DS
< 1.5 indicates redirected input
> 1.3 indicates redirected output
.DE
.LP
Expansion/substitution metacharacters
.DS
$ 3.4 indicates variable substitution
! 2.3 indicates history substitution
: 3.6 precedes substitution modifiers
^ 2.3 used in special forms of history substitution
\` 4.3 indicates command substitution
.DE
.LP
Other metacharacters
.DS
# 1.3,3.6 begins scratch file names; indicates shell comments
\- 1.2 prefixes option (flag) arguments to commands
% 2.6 prefixes job name specifications
.DE
.bp
File diff suppressed because it is too large. Load diff
+34
View File
@@ -0,0 +1,34 @@
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)tabs 8.1 (Berkeley) 6/8/93
.\"
.ta 5n 10n 15n 20n 25n 30n 35n 40n 45n 50n 55n 60n 65n 70n 75n 80n
+124
View File
@@ -0,0 +1,124 @@
/*-
* Copyright (c) 1983, 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)alloc.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#if __STDC__
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include "csh.h"
#include "extern.h"
char *memtop = NULL; /* PWP: top of current memory */
char *membot = NULL; /* PWP: bottom of allocatable memory */
ptr_t
Malloc(n)
size_t n;
{
ptr_t ptr;
if (membot == NULL)
memtop = membot = sbrk(0);
if ((ptr = malloc(n)) == (ptr_t) 0) {
child++;
stderror(ERR_NOMEM);
}
return (ptr);
}
ptr_t
Realloc(p, n)
ptr_t p;
size_t n;
{
ptr_t ptr;
if (membot == NULL)
memtop = membot = sbrk(0);
if ((ptr = realloc(p, n)) == (ptr_t) 0) {
child++;
stderror(ERR_NOMEM);
}
return (ptr);
}
ptr_t
Calloc(s, n)
size_t s, n;
{
ptr_t ptr;
if (membot == NULL)
memtop = membot = sbrk(0);
if ((ptr = calloc(s, n)) == (ptr_t) 0) {
child++;
stderror(ERR_NOMEM);
}
return (ptr);
}
void
Free(p)
ptr_t p;
{
if (p)
free(p);
}
/*
* mstats - print out statistics about malloc
*
* Prints two lines of numbers, one showing the length of the free list
* for each size category, the second showing the number of mallocs -
* frees for each size category.
*/
void
/*ARGSUSED*/
showall(v, t)
Char **v;
struct command *t;
{
memtop = (char *) sbrk(0);
(void) fprintf(cshout, "Allocated memory from 0x%lx to 0x%lx (%ld).\n",
(unsigned long) membot, (unsigned long) memtop, memtop - membot);
}
+311
View File
@@ -0,0 +1,311 @@
/*-
* Copyright (c) 1980, 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)char.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
#include "char.h"
unsigned short _cmap[256] = {
/* nul soh stx etx */
_CTR, _CTR, _CTR, _CTR,
/* eot enq ack bel */
_CTR, _CTR, _CTR, _CTR,
/* bs ht nl vt */
_CTR, _CTR|_SP|_META, _CTR|_NL|_META, _CTR,
/* np cr so si */
_CTR, _CTR, _CTR, _CTR,
/* dle dc1 dc2 dc3 */
_CTR, _CTR, _CTR, _CTR,
/* dc4 nak syn etb */
_CTR, _CTR, _CTR, _CTR,
/* can em sub esc */
_CTR, _CTR, _CTR, _CTR,
/* fs gs rs us */
_CTR, _CTR, _CTR, _CTR,
/* sp ! " # */
_SP|_META, 0, _QF, _META,
/* $ % & ' */
_DOL, 0, _META|_CMD, _QF,
/* ( ) * + */
_META|_CMD, _META, _GLOB, 0,
/* , - . / */
0, 0, 0, 0,
/* 0 1 2 3 */
_DIG|_XD, _DIG|_XD, _DIG|_XD, _DIG|_XD,
/* 4 5 6 7 */
_DIG|_XD, _DIG|_XD, _DIG|_XD, _DIG|_XD,
/* 8 9 : ; */
_DIG|_XD, _DIG|_XD, 0, _META|_CMD,
/* < = > ? */
_META, 0, _META, _GLOB,
/* @ A B C */
0, _LET|_UP|_XD, _LET|_UP|_XD, _LET|_UP|_XD,
/* D E F G */
_LET|_UP|_XD, _LET|_UP|_XD, _LET|_UP|_XD, _LET|_UP,
/* H I J K */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* L M N O */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* P Q R S */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* T U V W */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* X Y Z [ */
_LET|_UP, _LET|_UP, _LET|_UP, _GLOB,
/* \ ] ^ _ */
_ESC, 0, 0, 0,
/* ` a b c */
_QB|_GLOB|_META, _LET|_LOW|_XD, _LET|_LOW|_XD, _LET|_LOW|_XD,
/* d e f g */
_LET|_LOW|_XD, _LET|_LOW|_XD, _LET|_LOW|_XD, _LET|_LOW,
/* h i j k */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* l m n o */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* p q r s */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* t u v w */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* x y z { */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _GLOB,
/* | } ~ del */
_META|_CMD, 0, 0, _CTR,
#if defined(SHORT_STRINGS) && !defined(KANJI)
/****************************************************************/
/* 128 - 255 The below is supposedly ISO 8859/1 */
/****************************************************************/
/* (undef) (undef) (undef) (undef) */
_CTR, _CTR, _CTR, _CTR,
/* (undef) (undef) (undef) (undef) */
_CTR, _CTR, _CTR, _CTR,
/* (undef) (undef) (undef) (undef) */
_CTR, _CTR, _CTR, _CTR,
/* (undef) (undef) (undef) (undef) */
_CTR, _CTR, _CTR, _CTR,
/* (undef) (undef) (undef) (undef) */
_CTR, _CTR, _CTR, _CTR,
/* (undef) (undef) (undef) (undef) */
_CTR, _CTR, _CTR, _CTR,
/* (undef) (undef) (undef) (undef) */
_CTR, _CTR, _CTR, _CTR,
/* (undef) (undef) (undef) (undef) */
_CTR, _CTR, _CTR, _CTR,
/* nobreakspace exclamdown cent sterling */
_SP, 0, 0, 0,
/* currency yen brokenbar section */
0, 0, 0, 0,
/* diaeresis copyright ordfeminine guillemotleft */
0, 0, 0, 0,
/* notsign hyphen registered macron */
0, 0, 0, 0,
/* degree plusminus twosuperior threesuperior */
0, 0, 0, 0,
/* acute mu paragraph periodcentered */
0, 0, 0, 0,
/* cedilla onesuperior masculine guillemotright */
0, 0, 0, 0,
/* onequarter onehalf threequarters questiondown */
0, 0, 0, 0,
/* Agrave Aacute Acircumflex Atilde */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* Adiaeresis Aring AE Ccedilla */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* Egrave Eacute Ecircumflex Ediaeresis */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* Igrave Iacute Icircumflex Idiaeresis */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* ETH Ntilde Ograve Oacute */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* Ocircumflex Otilde Odiaeresis multiply */
_LET|_UP, _LET|_UP, _LET|_UP, 0,
/* Ooblique Ugrave Uacute Ucircumflex */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP,
/* Udiaeresis Yacute THORN ssharp */
_LET|_UP, _LET|_UP, _LET|_UP, _LET|_LOW,
/* agrave aacute acircumflex atilde */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* adiaeresis aring ae ccedilla */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* egrave eacute ecircumflex ediaeresis */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* igrave iacute icircumflex idiaeresis */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* eth ntilde ograve oacute */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* ocircumflex otilde odiaeresis division */
_LET|_LOW, _LET|_LOW, _LET|_LOW, 0,
/* oslash ugrave uacute ucircumflex */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
/* udiaeresis yacute thorn ydiaeresis */
_LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW,
#endif /* SHORT_STRINGS && !KANJI */
};
#ifndef NLS
/* _cmap_lower, _cmap_upper for ISO 8859/1 */
unsigned char _cmap_lower[256] = {
0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007,
0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017,
0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027,
0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037,
0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047,
0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057,
0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067,
0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077,
0100, 0141, 0142, 0143, 0144, 0145, 0146, 0147,
0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167,
0170, 0171, 0172, 0133, 0134, 0135, 0136, 0137,
0140, 0141, 0142, 0143, 0144, 0145, 0146, 0147,
0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167,
0170, 0171, 0172, 0173, 0174, 0175, 0176, 0177,
0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,
0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,
0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,
0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,
0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,
0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,
0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,
0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,
0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
0360, 0361, 0362, 0363, 0364, 0365, 0366, 0327,
0370, 0371, 0372, 0373, 0374, 0375, 0376, 0337,
0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,
0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377,
};
unsigned char _cmap_upper[256] = {
0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007,
0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017,
0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027,
0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037,
0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047,
0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057,
0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067,
0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077,
0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,
0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137,
0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,
0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177,
0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,
0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,
0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,
0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,
0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,
0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,
0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,
0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,
0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,
0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,
0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,
0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,
0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,
0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,
0320, 0321, 0322, 0323, 0324, 0325, 0326, 0367,
0330, 0331, 0332, 0333, 0334, 0335, 0336, 0377,
};
#endif /* NLS */
+96
View File
@@ -0,0 +1,96 @@
/*-
* Copyright (c) 1980, 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)char.h 8.1 (Berkeley) 5/31/93
*/
#include <ctype.h>
extern unsigned short _cmap[];
#ifndef NLS
extern unsigned char _cmap_lower[], _cmap_upper[];
#endif
#define _QF 0x0001 /* '" (Forward quotes) */
#define _QB 0x0002 /* ` (Backquote) */
#define _SP 0x0004 /* space and tab */
#define _NL 0x0008 /* \n */
#define _META 0x0010 /* lex meta characters, sp #'`";&<>()|\t\n */
#define _GLOB 0x0020 /* glob characters, *?{[` */
#define _ESC 0x0040 /* \ */
#define _DOL 0x0080 /* $ */
#define _DIG 0x0100 /* 0-9 */
#define _LET 0x0200 /* a-z, A-Z, _ */
#define _UP 0x0400 /* A-Z */
#define _LOW 0x0800 /* a-z */
#define _XD 0x1000 /* 0-9, a-f, A-F */
#define _CMD 0x2000 /* lex end of command chars, ;&(|` */
#define _CTR 0x4000 /* control */
#define cmap(c, bits) \
(((c) & QUOTE) ? 0 : (_cmap[(unsigned char)(c)] & (bits)))
#define isglob(c) cmap(c, _GLOB)
#define isspc(c) cmap(c, _SP)
#define ismeta(c) cmap(c, _META)
#define iscmdmeta(c) cmap(c, _CMD)
#define letter(c) (((c) & QUOTE) ? 0 : \
(isalpha((unsigned char) (c)) || (c) == '_'))
#define alnum(c) (((c) & QUOTE) ? 0 : \
(isalnum((unsigned char) (c)) || (c) == '_'))
#ifdef NLS
#define Isspace(c) (((c) & QUOTE) ? 0 : isspace((unsigned char) (c)))
#define Isdigit(c) (((c) & QUOTE) ? 0 : isdigit((unsigned char) (c)))
#define Isalpha(c) (((c) & QUOTE) ? 0 : isalpha((unsigned char) (c)))
#define Islower(c) (((c) & QUOTE) ? 0 : islower((unsigned char) (c)))
#define Isupper(c) (((c) & QUOTE) ? 0 : isupper((unsigned char) (c)))
#define Tolower(c) (((c) & QUOTE) ? 0 : tolower((unsigned char) (c)))
#define Toupper(c) (((c) & QUOTE) ? 0 : toupper((unsigned char) (c)))
#define Isxdigit(c) (((c) & QUOTE) ? 0 : isxdigit((unsigned char) (c)))
#define Isalnum(c) (((c) & QUOTE) ? 0 : isalnum((unsigned char) (c)))
#define Iscntrl(c) (((c) & QUOTE) ? 0 : iscntrl((unsigned char) (c)))
#define Isprint(c) (((c) & QUOTE) ? 0 : isprint((unsigned char) (c)))
#else
#define Isspace(c) cmap(c, _SP|_NL)
#define Isdigit(c) cmap(c, _DIG)
#define Isalpha(c) (cmap(c,_LET) && !(((c) & META) && AsciiOnly))
#define Islower(c) (cmap(c,_LOW) && !(((c) & META) && AsciiOnly))
#define Isupper(c) (cmap(c, _UP) && !(((c) & META) && AsciiOnly))
#define Tolower(c) (_cmap_lower[(unsigned char)(c)])
#define Toupper(c) (_cmap_upper[(unsigned char)(c)])
#define Isxdigit(c) cmap(c, _XD)
#define Isalnum(c) (cmap(c, _DIG|_LET) && !(((c) & META) && AsciiOnly))
#define Iscntrl(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
#define Isprint(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
#endif
Loaded 100 of 18797 files, more files were not shown because too many files have changed in this diff. Show more