lecture
in color
limit command)
proactive strategy: prevent resource misuse.
reactive strategy: charge for resource abuses/kick people off after they transgress.
rm an open file, it persists.
/usr/sbin/acct/accton /var/adm/pacct
/usr/sbin/acct/accton
/usr/sbin/acct/acctprc1 </var/adm/pacct | more
/usr/sbin/acct/acctprc1 </var/adm/pacct | /usr/sbin/acct/acctprc2 >tacct
/usr/sbin/acct/prtacct tacct
acctmerge.
/usr/sbin/acct/acctcon1 </var/adm/wtmp: connect time accounting
syslogd.
contents of logging/syslog.cc...
#include <syslog.h>
// void openlog(const char *ident, int logopt, int facility);
// void syslog(int priority, const char *message);
// void closelog(void);
main() {
openlog("foo", 0, LOG_USER);
syslog(LOG_INFO, "hi there, I'm me");
closelog();
}
...end of logging/syslog.cc
This produces the following log entry:
Apr 28 14:37:28 sunfire06 foo: [ID 301932 user.info] hi there, I'm me
^^^^^^^^^^^^^^^^ message
^^^^ priority
^^^^ facility
^^^^^^^^^ process identifier
^^^ identifier in logopen call
^^^^^^^^^ machine
^^^^^^^^^^^^^^^ date
man syslog) LOG_KERN: Messages generated by the kernel. These cannot be gen-
erated by any user processes.
LOG_USER: Messages generated by random user processes. This is
the default facility identifier if none is specified.
LOG_MAIL: The mail system.
LOG_DAEMON: System daemons, such as in.ftpd(1M).
LOG_AUTH: The authorization system: login(1), su(1M), getty(1M).
LOG_LPR: The line printer spooling system: lpr(1B), lpc(1B).
LOG_NEWS: Reserved for the USENET network news system.
LOG_UUCP: Reserved for the UUCP system; it never used syslog.
LOG_CRON: The cron/at facility; crontab(1), at(1), cron(1M).
LOG_LOCAL0: Reserved for local use.
man syslog)
LOG_EMERG: A panic condition. This is normally broadcast to all users.
LOG_ALERT: A condition that should be corrected immediately, such
as a corrupted system database.
LOG_CRIT: Critical conditions, such as hard device errors.
LOG_ERR: Errors.
LOG_WARN: Warning messages.
LOG_NOTICE: Conditions that are not error conditions, but that may
require special handling.
LOG_INFO: Informational messages.
LOG_DEBUG: Messages that contain information normally of use only
when debugging a program.
logger -p daemon.notice "9 o'clock and all is well"
daemon: the facility to which the log entry applies.
notice: how important is this message?
LOGHOST: a machine that you've designated to
collect all log information.
syslogd.conf.
#ident "@(#)syslog.conf 1.5 98/12/14 SMI" /* SunOS 5.0 */ # # Copyright (c) 1991-1998 by Sun Microsystems, Inc. # All rights reserved. # # syslog configuration file. # # This file is processed by m4 so be careful to quote (`') names # that match m4 reserved words. Also, within ifdef's, arguments # containing commas must be quoted. # *.err;kern.debug;daemon.notice;mail.crit /var/adm/messages *.alert;kern.err;daemon.err operator *.alert root *.emerg * # if a non-loghost machine chooses to have authentication messages # sent to the loghost machine, un-comment out the following line: #auth.notice ifdef(`LOGHOST', /var/log/authlog, @loghost) mail.debug ifdef(`LOGHOST', /var/log/syslog, @loghost) # # non-loghost machines will use the following lines to cause "user" # log messages to be logged locally. # ifdef(`LOGHOST', , user.err /dev/sysmsg user.err /var/adm/messages user.alert `root, operator' user.emerg * ) user.info /var/opt/SUNWut/log/messages local1.info /var/opt/SUNWut/log/admin_log
swatch
peep
swatchwatchfor /{pattern}/ - watch for a particular pattern
ignore /{pattern}/ - ignore this pattern if it comes up.
mail addresses={user-list};subject={subject} - mail users if this happens.
pipe {program-name} - print matching lines on input of given program.
exec {program-name} - execute given program
threshold {events}:{seconds} - do one action per {events} matches in {seconds} seconds.
watchfor /ssh.*denied/ threshold 100:60 mail addresses:couch@cs.tufts.edu;subject='dictionary attack in progress'
/var/log/messages => /var/log/messages.1 => /var/log/messages.2 => /var/log/messages.3 => /var/log/messages.4 => discarded!
10 3 * * * /usr/sbin/logadmEvery day, at 3:10 am, run /usr/sbin/logadm. This rotates the logs, as above.
limit command: (man csh)limit resource my-limit
limit coredumpsize 1M
/bin/login (hard limits)
using the ulimit system call (man 3 ulimit)
In this case, user can't override limits.
# more /etc/fstab
/dev/rz0a / ufs rw 1 1
/proc /proc procfs rw 0 0
/dev/rz1c /usr ufs rw 1 2
/dev/rz2c /var ufs rw 1 2
/dev/rz0b swap1 ufs sw 0 2
/dev/rz5c /export/0 ufs rw 1 3
/dev/rz6c /export/1 ufs rw,userquota 1 4
# quotacheck /dev/rz6c # figures out who's been naughty or nice
# quota -v couch
Disk quotas for user couch (uid 30):
Filesystem blocks quota limit grace files quota limit grace
/ 0 0 0 0 0 0
/usr 0 0 0 0 0 0
/var 0 0 0 0 0 0
swap1 0 0 0 0 0 0
/export/0 0 0 0 0 0 0
/export/1 646 50000 100000 97 50000 100000
# edquota couch
# quota -v couch
Quotas for user couch:
/export/1: blocks in use: 646, limits (soft = 50000, hard = 100000)
inodes in use: 97, limits (soft = 50000, hard = 100000)
# edquota -p couch comp150 # sets quotas for couch to those for comp150
lecture
in color