socklog-2.1.1+repack/0000755000000000000000000000000014702065454013122 5ustar rootrootsocklog-2.1.1+repack/doc/0000755000000000000000000000000014702065454013667 5ustar rootrootsocklog-2.1.1+repack/doc/notify.html0000644000000000000000000001000014702065454016054 0ustar rootroot socklog - log events notification G. Pape
socklog

socklog - log events notification


The service socklog-notify provides instant notification of log events. There is an interval in seconds for the creation of notifications to prevent a flood.

Set up the socklog-notify service as described in Configuration to ensure that the named pipe /var/log/socklog/.notify exists. Do not delete this file after creation.

Read disable notifications before stopping the socklog-notify service once it is started.

socklog-notify is handled by the uncat program.


how to configure log events

Choose a log controlled by svlogd to be watched for log events, say /var/log/socklog/main/.

Make sure the account running this log service is member of the socklog group adm. If it isn't, change it now. Make sure that the socklog-notify service is running.

Redirect the standard error output of svlogd to the named pipe socklog-notify is reading from. To do so, insert exec 2> /var/log/socklog/.notify as second line into /var/service/socklog-unix/log/run:

  #!/bin/sh
  exec 2> /var/log/socklog/.notify
  exec setuidgid log svlogd \
    main/main main/auth main/cron main/daemon main/debug main/ftp \
    main/kern main/local main/mail main/news main/syslog main/user
svlogd's error messages are always log events.

To configure additional log events in /var/log/socklog/main/, use the e instruction in the config file of this log, see the svlogd man page. For example, if you want to be notified about all log messages of the priority alert, add a corresponding e instruction to the config file /var/log/socklog/main/config like this:

  s999999
  n10
  e*.alert: *
Then tell the log service to re-read the config files:
  # sv hup socklog-unix/log

how to configure the notification

Per default, socklog-notify injects a mail to a specified address containing the log events, but the behavior is configurable, so you can change it to use instant or short messaging service for example.

To configure the kind of notification, edit /etc/sv/socklog-notify/run and change the prog argument of uncat to your needs. This example uses sms_client to notify:

  #!/bin/sh -e
  PIPE=/var/log/socklog/.notify
  if [ ! -p "$PIPE" ]; then mkfifo -m0620 "$PIPE"; chown log:adm "$PIPE"; fi
  exec <> "$PIPE"
  exec setuidgid log uncat -s49999 -t90 \
    sh -c 'head -c140 | sms_client pager'
Then restart the service:
  # sv restart socklog-notify

Another example using wall:

  exec setuidgid log uncat -vs49999 -t180 sh -c 'head | wall'

Disable log event notifications

You need to disable all log event notifications before stopping the socklog-notify service. To check which services are configured for sending log events, run:
  # grep -F /var/log/socklog/.notify /var/service/*/log/run
For each of these services, edit the corresponding log/run script to remove the exec 2>/var/log/socklog/.notify line and the configured log event(s) and restart its log service:
  # sv restart <service>/log
Now it is safe to stop the socklog-notify service.
Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/doc/benefits.html0000644000000000000000000001147614702065454016365 0ustar rootroot socklog - benefits G. Pape
socklog

socklog - benefits


Log file rotation based on file size
Selecting and de-selecting log entries
Modular, reliable network logging
Sortable logs
Small code size
Most of the benefits described here are actually benefits of svlogd and multilog. But since socklog uses svlogd as its back-end, the benefits apply to syslogging with socklog.

Log file rotation based on file size

svlogd supports automatically rotated logs, there is no need for any other tool running from cron or similar to rotate the logs.

svlogd keeps a specified number of log files with a maximum file size, so it is possible to calculate a log file partition properly.

For example, this log/run file

  #!/bin/sh
  LOGDIR=/var/log/socklog
  exec setuidgid log svlogd ${LOGDIR}/main ${LOGDIR}/debug
with these log config files
  # cat /var/log/socklog/main/config
  s4999999
  n10
  # cat /var/log/socklog/debug/config
  s999999
  n5
  -*
  +*.debug*
causes svlogd to hold maximal 10 log files, each of maximal size 4999999 bytes in /var/log/socklog/main/, and maximal 5 log files, each of maximal size 999999 bytes in /var/log/socklog/debug/.

So the maximal used space for these both logs is less then:

(10 * 5000000) + (5 * 1000000) = 55000000 bytes < 55 MB

If there is any service acting up and filling up your logs rapidly, you will never run into a filled up log partition, causing loss of new log entries, even of other services. You can lose old log entries from this service, but will ever have the recent ones.

Please note that above numbers could change if you use svlogd with a processor.


Selecting and de-selecting log entries

svlogd supports selecting and de-selecting log lines based on pattern matching.

This is much more flexible than the usual syslogd support for selecting log entries by facility and priority. Of course, selecting entries by facility or priority is still possible with socklog and svlogd, just like the default socklog-unix configuration shows.

This line selection feature is also used for socklog's instant Log events notification.


Modular, reliable network logging

The socklog-inet service can be used to replace a syslog network server, receiving log messages on UDP port 514. Usually syslog clients try to transmit their logs to that port using UDP.

socklog does not support this UDP network logging on the client side. socklog provides a different modular, reliable Network logging concept instead. Logs are transmitted through network using a TCP connection in the default configuration, log transmission failures are handled. The modular design of runit and socklog makes it possible to insert encryption, authentication, compression, and more, easily.


Sortable logs

If svlogd is told to prepend log lines with time-stamps, the resulting logs are sortable. So it is possible to merge different logs and sort them chronologically without special effort.

Small code size

One of the socklog project's principles is to keep the code size minimal. As of version 0.8.0 of socklog, the socklog.c source contains only about 400 lines of code; the uncat.c source is about 200 lines of code.

This minimizes the possibility of bugs introduced by programmer's fault, and makes it more easy for security related people to proofread the source code.

Of course this also means that socklog never will evolve to a multi-/over-featured, bloated project.


Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/doc/upgrade.html0000644000000000000000000000624414702065454016212 0ustar rootroot socklog - upgrading from previous versions G. Pape
socklog

socklog - upgrading from previous versions


2.1.0 to 2.1.1

No further action from you is required.

2.0.x to 2.1.0

For new installations, the socklog-conf program now creates the socklog service directories in /etc/sv/ and names them socklog-unix, socklog-klog, ...; you don't necessarily need to adapt existing installations.

Additionally socklog-conf now by default creates a ./check script in the socklog-unix service directory, which is utilized by runit's sv program when starting or checking the service. To update existing installations, you can create the script manually:

 # cd /var/service/socklog-unix
 # cat >check <<EOT
 #!/bin/sh
 exec socklog-check unix /dev/log
 EOT
 # chmod 755 check

1.5.0 to 2.0.x

The tryto program supports a new option -P to run the program given at the command line in a new session, and signal the process group on timeouts.

1.4.1 or 1.4.2 to 1.5.0

This version introduces the socklog-check program which can be used to check for the availability of a syslog service listening on /dev/log or other sockets. The socklog program now understands the -U option in unix mode to create unix domain sockets with permissions other than 777.

1.3.0 or 1.3.1 to 1.4.1 or 1.4.2

No further action from you is required.

1.2.0 to 1.3.0 or 1.3.1

With this version socklog supports old-style syslog network logging through UDP in cooperation with the runit package. The web page about network logging has been updated accordingly.

1.1.0 or 1.1.1 to 1.2.0

The socklog-conf program now creates slightly different run scripts that utilize the new chpst program from the runit package. Please refer to the examples if you want to adapt your current run scripts.

1.0.0 to 1.1.0 or 1.1.1

The socklog package now cooperates with the runit package instead of the daemontools package to provide syslog services. If you don't want to change your current configuration to utilize the programs from the runit package, you don't need to upgrade. If you want to upgrade nonetheless, but still use the programs from the daemontools package, no further action from you but installing the new socklog version is required.

If you want to switch your configuration to utilize the runit package, you need to re-create your service directories using the socklog-conf program.


Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/doc/uncat.1.html0000644000000000000000000000534014702065454016030 0ustar rootroot uncat(1) manual page G. Pape
socklog

Name

uncat - continuously reads stdin, splits up the data either by timeout or number of bytes read to process it

Synopsis

uncat [-vo] [-t seconds] [-s size] prog

Description

uncat continuously reads stdin and repeatedly processes the data either after seconds timeout or maximal number of bytes size read. To process the data, uncat starts prog and feeds the data into prog’s standard input. prog’s standard output is redirected to standard error. uncat never writes to standard output.

prog consist of one or more arguments.

If prog exits non-zero, uncat prints an error message, discards the data and continues to read stdin.

Note that uncat is not crash proof.

uncat is used to run the socklog-notify service.

Options

-v
verbose. Print verbose messages to stderr.
-o
once. Exit on end of input. Normally uncat continues waiting for data on standard input, even on end of file.
-t seconds
timeout. Set the timeout to seconds seconds. Default is 300.
-s size
Set the maximal number of bytes to size. Default is 1024.

Signals

If uncat receives a TERM signal, it starts to process the data in memory and exits as soon as possible.

uncat also does this on end of input if the -o option was given.

Exit Codes

uncat returns 0 after receiving a TERM signal. uncat returns 111 on error.

See Also

socklog(8), socklog-conf(8), sv(8), runsv(8), svlogd(8), tryto(1)

http://smarden.org/socklog/
http://smarden.org/runit/

Author

Gerrit Pape <pape@smarden.org>


Table of Contents

socklog-2.1.1+repack/doc/install.html0000644000000000000000000000277314702065454016234 0ustar rootroot socklog - installation G. Pape
socklog

socklog - installation


Since version 0.3.0, socklog installs into /package.

Check that you have the recent version of runit installed.

Download socklog-2.1.1.tar.gz into /package (sha256sum) and unpack the archive

 # cd /package
 # gunzip socklog-2.1.1.tar
 # tar -xpf socklog-2.1.1.tar
 # rm socklog-2.1.1.tar
 # cd admin/socklog-2.1.1
On solaris read using socklog on solaris before proceeding.

Compile and install the socklog programs

 # package/install
If you want to make the man pages available in the /usr/local/man/ hierarchy, do:
 # package/install-man
To report success:
 # mail pape-socklog-2.1.1@xxiv.smarden.org <compile/sysdeps
If you use socklog regularly, please contribute to the project.

Refer to Configuration for configuring and setting up socklog services.


Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/doc/index.html0000644000000000000000000001234214702065454015666 0ustar rootroot socklog - system and kernel logging services G. Pape

socklog - system and kernel logging services


How to install socklog
Upgrading from previous versions of socklog
How to use dietlibc
Using on solaris

Benefits
Configuration
Examples
Network logging
Log events notification

The socklog-conf program
The socklog program
The tryto program
The uncat program


socklog, in cooperation with the runit package, is a small and secure replacement for syslogd. There are three main features syslogd provides:

socklog provides these features with the help of runit's runsvdir, runsv, and svlogd, provides a different network logging concept, and additionally does log event notification.

svlogd has a built in log file rotation based on file size, so there is no need for any cron jobs or similar to rotate the logs. Log partitions can be calculated properly.

socklog runs on Linux, glibc 2.1.0 or higher, or dietlibc, Open-BSD, and Free-BSD. socklog reportedly runs on Solaris and Net-BSD. If it runs for you on any other operating systems, please let me know.

socklog is small, secure, reliable.


socklog is discussed on the <misc@list.smarden.org> mailing list. To subscribe send an empty email to <misc-subscribe@list.smarden.org>. Send an empty email to <misc-help@list.smarden.org> for more information about this list.

socklog is run under runit's runsv, writing syslog messages it receives from an unix domain socket path ("/dev/log") or an inet udp socket ip:port ("0.0.0.0:514") through a pipe provided by runsv to a svlogd process.

socklog can be run as an ucspi application to listen to an unix domain stream socket and for centralized or more flexible distributed logging (see network logging).

If socklog listens to an udp socket, it prepends ip: ("a.b.c.d: ") to each syslog message it receives, where a.b.c.d is the ip address of the connecting system.

If the environment variables $UID and/or $GID are present, socklog drops permissions to those ids after creating and binding to the socket (not in ucspi mode).

socklog converts syslog facility and priority information to names ("facility.priority") as found in /usr/include/syslog.h at compile time if present, you can use this for svlogd's line selecting by pattern.


A proper run file for runsv is:
  #!/bin/sh
  exec 2>&1
  exec chpst -Unobody socklog unix /dev/log

A proper log/run file for runsv is:

  #!/bin/sh
  exec chpst -ulog svlogd -t main/*

See INSTALL on how to install socklog and Configuration for setting up socklog services.
See http://smarden.org/socklog/ for recent informations.
Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/doc/socklog.8.html0000644000000000000000000001036414702065454016370 0ustar rootroot socklog(8) manual page G. Pape
socklog

Name

socklog - small and secure syslogd replacement for use with runit

Synopsis

socklog [-rRU] [unix] [path]
socklog [-rR] inet [ip] [port]
socklog [-rR] ucspi [args]

Description

socklog is run under runit’s runsv(8), writing syslog messages it receives from unix domain socket path or an inet udp socket ip:port through a pipe provided by runsv(8) to a svlogd(8) process.

socklog can be run as an ucspi application to listen to an unix domain stream socket and for more flexible distributed logging.

If the environment variables $UID and/or $GID are present, socklog drops permissions to those ids after creating and binding the socket (not in ucspi mode).

socklog converts syslog facility and priority information to names (facility.priority:) as found in /usr/include/syslog.h at compile time if present.

On solaris socklog also accepts sun_stream as first argument. Please see the web page for details.

UNIX Socket

socklog [ unix ] [ path ]

Starting socklog with the 1st argument unix, socklog will listen to the unix domain socket path. If path is omitted, the default /dev/log is used.

The 1st argument may be omitted, default is unix.

Inet Socket

socklog inet [ ip ] [ port ]

Starting socklog with the 1st argument inet, socklog will listen to the inet udp socket ip:port.

If ip starts with 0, socklog will bind to all local interfaces.

If port is less or equal 1024, socklog must be run by root.

port may be omitted, default is 514. ip may be omitted, default is 0.

socklog prepends a.b.c.d: to each syslog message it receives, where a.b.c.d is the ip address of the connecting system.

Ucspi Mode

socklog ucspi [ args ]

Starting socklog with the 1st argument ucspi, socklog will run as an ucspi application. Normally socklog will only be started in ucspi mode by an ucspi server tool, such as tcpsvd(8), tcpserver(1) or unixserver.

For each arg, socklog will prepend $arg: to each syslog message, if the environment variable $arg is present (maximum is 8).

Options

-r
raw. Write the raw syslog messages (no conversion of facility and priority) to the pipe, additionally to the log messages with syslog facility and priority converted to names.
-R
raw only. Same as -r above, but write the raw syslog messages only.
-U
respect umask. Don’t set umask to 0 before creating a unix domain socket, but respect the current setting of umask(2). This option only takes effect in unix mode.

See Also

sv(8), runsvdir(8), runsv(8), svlogd(8), tryto(1), uncat(1), socklog-check(8), tcpsvd(8), nc(1)

http://smarden.org/socklog/
http://smarden.org/runit/

Author

Gerrit Pape <pape@smarden.org>


Table of Contents

socklog-2.1.1+repack/doc/socklog-check.8.html0000644000000000000000000000431314702065454017440 0ustar rootroot socklog-check(8) manual page G. Pape
socklog

Name

socklog-check - checks for the availability of a socklog(8) service.

Synopsis

socklog-check [-v] [unix [address]]

Description

socklog-check attempts to connect to a socklog(8) unix service and reports whether the connection attempt succeeded or not.

It connects to the datagram oriented unix domain socket address, and reports success through the return code. If address is not specified, socklog-check attempts to connect to /dev/log.

When running services that use the syslog facility under runit’s service supervision, socklog-check should be added to the top of the service’s run script to ensure that no syslog messages are generated until a syslog service is up and running to process the messages, e.g.:

#!/bin/sh
socklog-check || exit 1
exec service_using_syslog

Options

-v
verbose. Print verbose message to standard error.

Exit Codes

On success socklog-check returns 0.

On error, socklog-check prints a message to standard error and exits 111.

See Also

socklog(8), socklog-conf(8), svlogd(8), tryto(1), uncat(1), sv(8), runsv(8), runsvdir(8)

http://smarden.org/socklog/
http://smarden.org/runit/

Author

Gerrit Pape <pape@smarden.org>


Table of Contents

socklog-2.1.1+repack/doc/examples.html0000644000000000000000000000574614702065454016407 0ustar rootroot socklog - examples G. Pape
socklog

socklog - examples


listening on unix domain dgram socket /dev/log:


listening on udp network socket 0.0.0.0:514:


reading kernel messages from /dev/klog on BSD:


A client for socklog network logging:


log events notification with wall:


Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/doc/network.html0000644000000000000000000001365114702065454016254 0ustar rootroot socklog - network logging G. Pape
socklog

socklog - network logging


Logging through TCP
Logging through UDP
Logging via network connection cannot be made reliable. There is always a possibility for failures. The network connection itself may be down or the receiving machine has crashed for example. So there must be a decision, what to do in such cases.

The socklog network logging concept

There are no restrictions on how to transmit the log data, a separate process of your choice will do the work, e.g. netcat or tcpclient. This modularity lets you easily insert authentication, compression, encryption and other things.

Example setup

Log Server (machine receiving log data)

Setup a socklog-ucspi-tcp service as described in Configuration with the following socklog-ucspi-tcp/run and socklog-ucspi-tcp/log/run scripts:

socklog-ucspi-tcp/run:

  #!/bin/sh
  PORT=10116
  exec 2>&1
  exec tcpsvd -vl0 -unobody 0 "$PORT" socklog ucspi TCPREMOTEIP
socklog-ucspi-tcp/log/run:
  #!/bin/sh
  exec chpst -ulog svlogd -t main/main main/10.0.0.236
and socklog-ucspi-tcp/log/main/10.0.0.236/config
  # cat 10.0.0.236/config
  -*
  +10.0.0.236:*
You will then find all log data from remote hosts that was successfully transmitted in main/main/. Log data from 10.0.0.236 will additionally be saved in main/10.0.0.236/.

Log client (machine sending log data)

Change the socklog configuration to use a processor to transmit the log data:

socklog-unix/log/run:

  #!/bin/sh
  exec chpst -ulog svlogd ./main/main
socklog-unix/log/main/main/config
  s4096
  n20
  !tryto -pv nc 10.0.0.16 10116
and restart the log service:
  # sv restart socklog-unix/log
On each rotation of svlogd's current, the data will be transmitted to 10.0.0.16:10116 using tryto and netcat, failures will be noticed and notified on the next run.

Logging through UDP

Transmitting log messages through UDP should only be used within private networks. Logging through UDP doesn't ensure that the log messages actually reach the log server, and doesn't provide authentication and authorization. It's the old-style UNIX syslog remote logging, and supported by socklog for compatibility reasons.

Example setup

Log Server (machine receiving log data)

Setup a socklog-inet service as described in Configuration with the following socklog-inet/run and socklog-inet/log/run scripts, and the following socklog-inet/log/main/config log configuration:

socklog-inet/run:

  #!/bin/sh
  exec 2>&1
  exec chpst -Unobody socklog inet 0 514
socklog-inet/log/run:
  #!/bin/sh
  exec chpst -ulog svlogd -t main/main main/10.0.0.236
and socklog-inet/log/main/10.0.0.236/config:
  # cat 10.0.0.236/config
  -*
  +10.0.0.236:*
You will then find all log messages from remote hosts that were successfully transmitted in main/main/. Log messages from 10.0.0.236 will additionally be saved in main/10.0.0.236/.

Log client (machine sending log data)

Tell socklog to write raw syslog messages without converting syslog priority and facility to names by adding the -R option:

socklog-unix/run:

  #!/bin/sh
  exec 2>&1
  exec chpst -Unobody socklog -R unix /dev/log
Then change the configuration of socklog's main log directory to tell svlogd to transmit log messages through UDP:

/var/log/socklog/main/config:

  s9999
  n2
  U10.0.0.16:514
Restart the service, and tell the log service to reload its configuration:
  # sv restart socklog-unix
  # sv hup socklog-unix/log
Now each log message will be sent through UDP to 10.0.0.16:514, and not written to the log directory. If svlogd has trouble transmitting data through UDP, and is able to detect an error, it logs an error message followed by the log message to the log directory.

Of course you can configure socklog to log through UDP while keeping local logging enabled, and also select log messages to be transmitted through UDP by pattern. See the documentation of svlogd for details.


Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/doc/tryto.1.html0000644000000000000000000001024614702065454016100 0ustar rootroot tryto(1) manual page G. Pape
socklog

Name

tryto - tries to run a command limited by a timeout or number of tries, can be used to run as svlogd(8) processor.

Synopsis

tryto [-pPv] [-t sec] [-k ksec] [-n tries] prog

Description

prog consist of one or more arguments.

tryto runs and watches prog, feeding its standard input to prog’s standard input. If prog exits with a return code other then 0, tryto runs prog again after sleeping one second.

If the number of retries reaches the maximal number of tries, tryto prints an error message and gives up.

If the timeout sec seconds is reached and prog is still running, tryto sends a TERM signal to prog, waits ksec seconds for prog to terminate, then sends a KILL signal if prog still is there, and exits as soon as possible.

Options

-t sec
timeout. Set the timeout to send TERM to prog to sec seconds. Default is 180.
-k ksec
kill timeout. Set the timeout to send KILL to prog to ksec seconds. Default is 5.
-n tries
Set the maximal number of tries to tries. If prog exited with a return code other that 0, tryto tries to rewind standard input to the beginning using lseek(2) before starting prog again. Default is 5.
-p
processor. Use this option if you run tryto as a svlogd(8) processor (see below).
-P
process group. Run prog in a new session and process group, and send signals on timeout to prog’s process group instead of its pid.
-v
verbose. Print verbose messages to standard error.

Processor

If tryto sees the -p option, tryto runs as a svlogd(8) or multilog(8) processor, making use of filedescriptors 4 and 5:

Before starting prog, tryto moves the filedescriptor 5 to 2, so all error messages from tryto and prog will be saved in svlogd(8)’s state to be processed on the next run of tryto -p.

After starting prog, tryto first feeds all data it reads from filedescriptor 4 into prog’s standard input, then all data from filedescriptor 0.

If prog fails by timeout sec seconds or maximal number of tries, tryto prints all data from standard input to standard output, an error message to standard error, and exits with 0.

Exit Codes

If tryto itself fails, it returns 111.

If tryto runs as a svlogd(8) processor, tryto returns 0 in all other cases.

If prog was run successfully, tryto returns 0.

If prog failed by timeout, tryto returns 100.

If prog failed by maximal number of tries, tryto returns the last return code from prog.

See Also

socklog(8), uncat(1), svlogd(8), multilog(8), lseek(2)

http://smarden.org/socklog/
http://smarden.org/runit/

Author

Gerrit Pape <pape@smarden.org>


Table of Contents

socklog-2.1.1+repack/doc/configuration.html0000644000000000000000000002143514702065454017431 0ustar rootroot socklog - configuration G. Pape
socklog

socklog - configuration


The socklog-unix service listens on the unix domain socket /dev/log. Usually this service replaces the syslogd system log daemon.

The socklog-inet service listens on the UDP port 0.0.0.0:514. Usually this service replaces syslogd's support for remote logging.

The socklog-klog service reads kernel messages from /proc/kmsg on Linux or /dev/klog on BSD. Usually this service replaces klogd on Linux or syslogd on BSD.

The socklog-ucspi-tcp service listens on the TCP port 0.0.0.0:10116, this is a server for socklog network logging, a different remote logging concept.

The socklog-notify handles log event notification, scheduled notification of specified log entries.


How to configure the socklog services

The socklog-unix service
The socklog-inet service
The socklog-klog service
The socklog-ucspi-tcp service
The socklog-notify service

Removing socklog services

The socklog-unix service

Before starting the socklog-unix service, you will have to make two decisions: Create the service directory and log directories by running the socklog-conf program:
  # socklog-conf unix nobody log
If you are replacing another service providing system logging through the socket /dev/log, such as syslogd, stop this service now and ensure that it will not be restarted on runlevel change or system reboot.

Tell runsvdir about the new service:

  # ln -s /etc/sv/socklog-unix /var/service/
Wait five seconds for the service to start and then check the log directories, e.g.:
  # less /var/log/socklog/main/current
Optionally configure the socklog-unix service by editing the corresponding run scripts and config files:

The socklog-inet service

Before starting the socklog-inet service, you will have to make two decisions: Create the service directory and log directories by running the socklog-conf program:
  # socklog-conf inet nobody log
If you are replacing another service providing system logging through the syslog UDP port 514, such as syslogd, stop this service now and ensure that it will not be restarted on runlevel change or system reboot.

Tell runsvdir about the new service:

  # ln -s /etc/sv/socklog-inet /var/service/
Wait five seconds for the service to start and then check the log directory:
  # less /var/log/socklog-inet/main/current
Optionally configure the socklog-inet service by editing the corresponding run scripts and config file:

The socklog-klog service

Before starting the socklog-klog service, you will have to make two decisions: Create the service directory and log directories by running the socklog-conf program:
  # socklog-conf klog nobody log
If you are replacing another service providing kernel logging, such as klogd on Linux or syslogd on BSD, stop this service now and ensure that it will not be restarted on runlevel change or system reboot.

Tell runsvdir about the new service:

  # ln -s /etc/sv/socklog-klog /var/service/
Wait five seconds for the service to start and then check the log directory:
  # less /var/log/socklog-klog/main/current
Optionally configure the socklog-klog service by editing the corresponding run scripts and config file:

The socklog-ucspi-tcp service

Before starting the socklog-ucspi-tcp service, you will have to make two decisions: Make sure that you have the ipsvd package installed. Then create the service directory and log directories by running the socklog-conf program:
  # socklog-conf ucspi-tcp nobody log
Tell runsvdir about the new service:
  # ln -s /etc/sv/socklog-ucspi-tcp /var/service/
Wait five seconds for the service to start and then check the log directory:
  # less /var/log/socklog-ucspi-tcp/main/current
Optionally configure the socklog-ucspi-tcp service by editing the corresponding run scripts and config file: Refer to Network logging for setting up clients.

The socklog-notify service

Before starting the socklog-notify service, you will have to make two decisions: Create the service directory by running the socklog-conf program:
  # socklog-conf notify log adm
Tell runsvdir about the new service:
  # ln -s /etc/sv/socklog-notify /var/service/
Wait five seconds for the service to start, you can test the service with:
  # echo test | tai64n > /var/log/socklog/.notify
Optionally configure the socklog-notify service by editing the corresponding run script: Read Log events notification before disabling this service and for configuring arbitrary log services to notify events.
Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/doc/socklog-conf.8.html0000644000000000000000000001375514702065454017322 0ustar rootroot socklog-conf(8) manual page G. Pape
socklog

Name

socklog-conf - sets up a socklog(8) service.

Synopsis

socklog-conf unix|inet|klog|ucspi-tcp acct logacct
socklog-conf notify acct grp

Description

socklog-conf creates /etc/sv if necessary and a subdirectory that runs the unix, inet, ucspi-tcp or notify service (see below for each service). Except for the notify service, socklog-conf also creates a log directory with subdirectories.

acct, logacct and grp must not contain any special characters.

UNIX Service

socklog-conf unix acct logacct

Running socklog-conf with the 1st argument unix, socklog-conf creates the service directory /etc/sv/socklog-unix and the log directory /var/log/socklog.

socklog-conf arranges for socklog(8) to run under the uid and gid of acct and to listen for syslog messages on /dev/log.

It also creates automatically rotated log directories in /var/log/socklog. The logs are owned by logacct. The corresponding svlogd(8) process runs under the uid and gid of logacct.

You can run the service under runsvdir(8) by creating a symbolic link in the service directory:

ln -s /etc/sv/socklog-unix /var/service/

Inet Service

socklog-conf inet acct logacct

Running socklog-conf with the 1st argument inet, socklog-conf creates the service directory /etc/sv/socklog-inet and the log directory /var/log/socklog-inet.

socklog-conf arranges for socklog(8) to run under the uid and gid of acct and to listen for syslog messages on the UDP socket 0.0.0.0:514.

It also creates automatically rotated log directories in /var/log/socklog-inet. The logs are owned by logacct. The corresponding svlogd(8) process runs under the uid and gid of logacct.

You can run the service under runsvdir(8) by creating a symbolic link in the service directory:

ln -s /etc/sv/socklog-inet /var/service/

Klog Service

socklog-conf klog acct logacct

Running socklog-conf with the 1st argument klog, socklog-conf creates the service directory /etc/sv/socklog-klog and the log directory /var/log/socklog-klog.

socklog-conf arranges for socklog(8) to run under the uid and gid of acct and to read kernel messages from /proc/kmsg on Linux, or /dev/socklog-klog on BSD.

It also creates automatically rotated log directories in /var/log/socklog-klog. The logs are owned by logacct. The corresponding svlogd(8) process runs under the uid and gid of logacct.

You can run the service under runsvdir(8) by creating a symbolic link in the service directory:

ln -s /etc/sv/socklog-klog /var/service/

Ucspi-tcp Service

socklog-conf ucspi-tcp acct logacct

Running socklog-conf with the 1st argument ucspi-tcp, socklog-conf creates the service directory /etc/sv/socklog-ucspi-tcp and the log directory /var/log/socklog-ucspi-tcp.

socklog-conf arranges for tcpsvd(1) to run socklog(8) under the uid and gid of acct and to listen on the TCP socket 0.0.0.0:10116.

It also creates automatically rotated log directories in /var/log/socklog-ucspi-tcp. The logs are owned by logacct. The corresponding svlogd(8) process runs under the uid and gid of logacct.

You can run the service under runsvdir(8) by creating a symbolic link in the service directory:

ln -s /etc/sv/socklog-ucspi-tcp /var/service/

Notify Service

socklog-conf notify acct grp

Running socklog-conf with the 1st argument notify, socklog-conf creates the service directory /etc/sv/socklog-notify.

socklog-conf arranges for uncat(1) to run under the uid and gid of acct and to listen on the named pipe /var/log/socklog/.notify. The named pipe will have mode 0620, the uid of acct and the gid of grp.

All uids running a log service that is configured to push log events to the socklog-notify service must be member of the group grp.

You can run the service under runsvdir(8) by creating a symbolic link in the service directory:

ln -s /etc/sv/socklog-notify /var/service/

See Also

socklog(8), svlogd(8), nc(1), tryto(1), uncat(1), socklog-check(8), tcpsvd(8), sv(8), runsv(8), runsvdir(8)

http://smarden.org/socklog/
http://smarden.org/runit/

Author

Gerrit Pape <pape@smarden.org>


Table of Contents

socklog-2.1.1+repack/doc/readme.solaris.html0000644000000000000000000001172514702065454017473 0ustar rootroot socklog - on Solaris G. Pape
socklog

socklog - on Solaris


Logging on Solaris

Solaris uses a STREAMS file, usually /dev/log to route locally generated syslog messages. See the log(7d) driver manual page for more information. Starting with SunOS 5.6 (Solaris 2.5.1) the syslog(3) library contains support for "doors", a superfast and multithreaded IPC mechanism provided by the Solaris Operating Environment. Using a door file - /etc/.syslog_door up to SunOS 5.7, /var/run/syslog_door on SunOS 5.8 and later, the process listening on the syslog_door gets immediate notification upon receipt of a log message.

Format of Solaris syslog messages

Starting with Solaris 8, Sun introduced a new log message format containing so called message IDs (See syslogd(1) and msgid(1)).
 [ID msgid facility.priority]

  Jul  9 10:13:06 u5 pseudo: [ID 129642 kern.info] pseudo-device: tod0
  Jul  9 16:14:51 u5 login: [ID 644210 auth.notice] ROOT LOGIN /dev/console
All Solaris versions up to Solaris 7 use the well known, good old syslog messages:
  Jul 10 16:24:21 u5 login: ROOT LOGIN /dev/console
  Jul 10 16:35:19 u5 unix: se0 is /pci@1f,0/pci@1,1/ebus@1/se@14,400000
The format is configurable. The log(7d) driver configuration file is /kernel/drv/log.conf. Set the variable "msgid" to either 1 or 0, to en- or disable message ID generation. Note: you must reboot to activate the changes.

socklog does prepend the formated 'facility.priority: ' to every log message, whether message IDs are used or not. This makes it easier to write svlogd or multilog filters. So this is how a log message processed by socklog will look like:

without message IDs:

  auth.info: Jul 15 21:40:52 sshd[1576]: Accepted publickey for root from 195.71.100.159 port 36621 ssh2
with message IDs enabled (default on Solaris 8 and later):
  auth.info: Jul 11 14:10:53 sshd[382]: [ID 800047 auth.info] Accepted rsa for ROOT from 195.71.100.159 port 36177
I prefer the first method, because it's much less visual clutter, and I don't need message IDs anyway.

Kernel messages

Solaris has no such thing as /proc/kmsg, or /dev/klog. Kernel log messages are provided by the same STREAMS device (/dev/log) as normal log messages. All kernel messages are logged with a facility of "kern":
  kern.info: unix: avail mem = 250077184
  kern.info: unix: root nexus = Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz)
  kern.info: unix: pcipsy0 at root: UPA 0x1f 0x0
The kernel messages do not contain timestamps. It seems that syslog does automatically prepend timestamps to kernel messages, so I might implement this in socklog as well.

dmesg will not work any longer, since it is just a sh shell script which prints out the last 200 lines from /var/adm/messages. If you need dmesg, you can easily write your own version :-).

Note that if message IDs are enabled, kernel log messages contain the name of the loadable module or driver instead of just "unix:".

  kern.info: m64: [ID 308573 kern.info] m64#0: 1280x1024, 4M mappable, rev 4750.7c
  kern.info: hme: [ID 517527 kern.info] SUNW,hme0 : PCI IO 2.0 (Rev Id = c1) Found
Be sure to enable message IDs to get these.

How to compile socklog on Solaris

You'll have to decide if you want "door" support or not.

1. With syslog_door support

  echo "gcc -O2 -Wall -DWANT_SUN_DOOR" > src/conf-cc
  echo "gcc -s -ldoor -lthread" > src/conf-ld

2. Without syslog_door support (default) Just run package/install. Then follow the standard installation instructions.

How to configure socklog for the STREAMS log driver

  $ socklog-conf unix acct logacct [/rundir] [/logdir]
This will create the following run script:
  #!/bin/sh
  exec 2>&1
  exec chpst -Uacct socklog sun_stream /dev/log /var/run/syslog_door
It is possible to run multiple socklog instances, but only one socklog can listen on the door file. If another process is in charge of the door file, socklog will exit immediately with exit code 100. Simply remove the last argument (path to door file), to start socklog without door support. This way you can run syslogd and socklog parallel, to test your socklog setup.

Support

If you have problems, questions or suggestions regarding the Solaris support, email me: Lars Uffmann <lu@cachescrubber.org>, or post to the <misc@list.smarden.org> mailing list.
Lars Uffmann, <lu@cachescrubber.org>
socklog-2.1.1+repack/doc/usedietlibc.html0000644000000000000000000000165214702065454017055 0ustar rootroot socklog - use dietlibc G. Pape
socklog

socklog - use dietlibc


To recompile the socklog programs with the diet libc, check that you have the recent version of dietlibc installed.

Change to the package directory of socklog:

  # cd /package/admin/socklog/
Change the conf-cc and conf-ld to use diet:
  # echo 'diet -Os gcc -O2 -Wall' >src/conf-cc
  # echo 'diet -Os gcc -s -Os -pipe' >src/conf-ld
Rebuild and install the socklog programs:
  # package/install

Gerrit Pape <pape@smarden.org>
socklog-2.1.1+repack/package/0000755000000000000000000000000014702065454014515 5ustar rootrootsocklog-2.1.1+repack/package/versions0000644000000000000000000000024414702065454016310 0ustar rootroot0.4.0 0.4.1 0.5.1 0.6.0 0.6.1 0.7.0 0.8.1 0.8.2 0.9.0 0.9.1 0.10.0 0.10.1 1.0.0 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.4.1 1.4.2 1.5.0 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 socklog-2.1.1+repack/package/upgrade0000755000000000000000000000140214702065454016067 0ustar rootroot#!/bin/sh -e umask 022 test -d package || sh -cx '! : Wrong working directory.' test -d src || sh -cx '! : Wrong working directory.' here=`env - PATH=$PATH pwd` parent=`dirname $here` echo 'Creating symlink socklog -> socklog-2.1.1...' rm -f socklog ln -s socklog-2.1.1 socklog mv -f socklog .. echo 'Making command links in /command...' mkdir -p /command for i in `cat package/commands`; do rm -f /command/$i'{new}' ln -s $parent/socklog/command/$i /command/$i'{new}' mv -f /command/$i'{new}' /command/$i done echo 'Making compatibility links in /usr/local/bin...' mkdir -p /usr/local/bin for i in `cat package/commands`; do rm -f /usr/local/bin/$i'{new}' ln -s /command/$i /usr/local/bin/$i'{new}' mv -f /usr/local/bin/$i'{new}' /usr/local/bin/$i done socklog-2.1.1+repack/package/CHANGES0000644000000000000000000002632414702065454015517 0ustar rootrootsocklog 2.1.1 Fri, 11 Oct 2024 00:00:17 +0000 * doc/install.html: add link to sha256sum.asc. * doc/install.html: change mail address. * doc/index.html: remove reference to socklog 2.0.x. * doc/*.html: remove $Id$. * debian/: remove; obsolete. * pathexec.h, pathexec_env.c, pathexec_run.c, seek_set.c, sgetopt.c, sgetopt.h, socklog-check.c, socklog-conf.c, socklog.c, subgetopt.c, subgetopt.h, trycpp.c, tryflock.c, trypoll.c, trysgact.c, trysgprm.c, tryto.c, tryulong64.c, trywaitp.c, uncat.c, x86cpuid.c: incorporate lib changes from runit-2.2.0 and adapt socklog programs to properly build with modern toolchains (thx Gentoo, Debian, Void Linux). * prot.c, prot.h, chkshsgr.c, tryshsgr.c, hasshsgr.h?, warn-shsgr: remove; obsolete. * Makefile, TARGETS: no longer check for "shortsetgroups" (thx Leah Neukirchen). * socklog.c: replace prot_gid() with setgroups() and prot_uid() with setuid(). socklog 2.1.0 Mon, 06 Mar 2006 12:59:33 +0000 * socklog-conf, man/socklog-conf.8: create service directories /etc/sv/socklog-* instead of /etc/socklog/*; create ./check script for socklog-unix service. * doc/configuration.html, doc/install.html, doc/network.html, doc/notify.html: adapt to new path to service directories; utilize runit's sv program instead of runsvctrl. * man/socklog-check.8, man/socklog-conf.8, man/socklog.8, man/uncat.1: see also sv(8). socklog 2.0.3 Sun, 26 Feb 2006 13:29:17 +0000 * doc/index.html: minor. * socklog-check.c: change EDESTADDRREQ to ECONNREFUSED if defined and set by connect(). * tryto: fix a race with child terminating immediatly (thx Alex Efros); catch SIGCHLD while waiting ktimeout seconds before sending KILL. * man/tryto.1: remove reference to timelimit(8) (thx Alex Efros). * socklog.check, socklog.dist: don't check usage output with -V as it differs on solaris (thx Asif Iqbal). socklog 2.0.2 Sun, 10 Apr 2005 07:21:30 +0000 * doc/readme.solaris.html: add -ldoor -lthread to src/conf-ld (thx Lars Kellogg-Stedman); update log/run script, mailing list address. * man/socklog.8: remove double entries in SEE ALSO. socklog 2.0.1 Thu, 10 Feb 2005 10:05:55 +0000 * Makefile: add linker options detected by trysocketlib.c to targets check-socklog-inet, check-socklog-inet (fixes test failure on solaris, thx Uffe Jakobsen). socklog 2.0.0 Sun, 06 Feb 2005 19:57:04 +0000 * socklog-check.check: tweak timing in program test. * tryto.c: new option -P: run prog in new session, and signal process group. * man/tryto.1: adapt; cleanup. * man/socklog-check.8: add hint about runit services using syslog facility; cleanup. * man/socklog-conf.8, man/socklog.8, man/uncat.1: cleanup. * doc/index.html: new stable release. * doc/network.html: typo. socklog 1.5.0 Sat, 26 Jun 2004 11:28:33 +0000 * socklog-check, man/socklog-check.8: new; check for the availability of a socklog service. * socklog-check.check, socklog-check.dist: new; program test. * byte_zero.c: new. * socklog.c, man/socklog.8: new option -U: don't override umask when creating domain socket. * package/check, package/compile, package/install-man, package/upgrade: minor cleanup. * Makefile, man/socklog-conf.8: adapt. socklog 1.4.2 Tue, 23 Mar 2004 18:16:17 +0000 * doc/index.html, doc/install.html: minor. * socklog.c: fix sigterm handling in ucspi mode. * uncat.check: tweak timing in program test. * Makefile: don't run target check by default. * package/check: new; run checks on programs. * package/install: run package/check. socklog 1.4.1 Sat, 28 Feb 2004 17:47:13 +0000 * socklog.c: handle sigterm on other platforms as accurately as already done on solaris. * tryto.c, uncat.c: minor cleanup. * check-diff, check-dist, check-local: new; run checks on programs. * socklog-conf.check, socklog.check, tryto.check, uncat.check, check-socklog-inet.c, check-socklog-unix.c: new; check program. * socklog-conf.dist, socklog.dist, tryto.dist, uncat.dist: new; dist check program output. * package/COPYING: 2004. * package/compile, package/install-man, package/upgrade: minor. socklog 1.3.1 Mon, 19 Jan 2004 18:39:01 +0000 * trysocketlib.c: new; check for libraries needed for socket() on some systems (solaris, thx Uffe Jakobsen). * Makefile: adapt. * socklog.c, socklog-conf.c: add defines automatically detecting solaris systems; now builds on solaris out-of-the-box (thx Uffe Jakobsen, Lars Uffmann). * doc/readme.solaris.html: adapt (thx Lars Uffmann). * print-cc.sh, print-ld.sh: head -1 -> head -n1. socklog 1.3.0 Mon, 12 Jan 2004 19:06:56 +0000 * socklog.c: add getopt-style command line options -r, -R for logging raw syslog messages without priority, facility conversion. * man/socklog.8: adapt. * doc/network.html: document old-style syslog network logging through UDP. * doc/index.html: change short description. * package/compile, package/install-man, package/upgrade: exit 1 on sub-shell failures. socklog 1.2.0 Sat, 09 Aug 2003 18:08:20 +0200 * socklog-conf.c: fix run file for socklog-unix service on solaris; use runit's chpst instead of setuidgid. * doc/install.html: remove obsolete note about setuidgid replacement. * doc/examples.html: adapt. * doc/index.html: adapt examples. * doc/benefits.html: minor. socklog 1.1.1 Mon, 07 Jul 2003 09:59:08 +0200 * socklog-conf.c: fix typos (thx Hleil Liu); use mail -s instead of mailsubj for the notify service. socklog 1.1.0 Thu, 19 Jun 2003 15:40:52 +0200 * man/socklog-conf.8, man/socklog.8, man/tryto.1: typos. * doc/benefits.html, doc/configuration.html, doc/examples.html, doc/index.html, doc/network.html, doc/notify.html, doc/readme.solaris.html, man/socklog-conf.8, man/socklog.8, man/tryto.1, man/uncat.1: utilize runit package instead of daemontools package. * socklog-conf.c: create service directories for the use with the runit package. socklog 1.0.0 Thu, 30 Jan 2003 13:32:24 +0100 * doc/configuration.html, doc/examples.html: remove description for socklog-ucspi-unix service. * doc/benefits.html, doc/network.html, doc/readme.solaris.html, doc/usedietlibc.html, man/socklog-conf.8: typos. * error.h: include . * tryto.c: catch possible error in write() to child; minor cleanup. * doc/index.html: add NetBSD to supported systems. socklog 0.10.1 Thu, 08 Aug 2002 22:55:35 +0200 * package/versions: new. * doc/network.html: typos. * doc/usedietlibc.html: fix path to conf-cc, conf-ld. socklog 0.10.0 Thu, 18 Jul 2002 15:45:58 +0200 * solaris support rewrite (thx Lars Uffmann): * socklog.c: new option sun_stream; new optional option door; rewrite solaris related code. * socklog-conf.c: option unix: create special run script on solaris. * doc/readme.solaris.html: new. * (thx Lars Uffmann). * documentation adapted. socklog 0.9.1 Wed, 26 Jun 2002 15:54:06 +0200 * Makefile: enable target sysdeps. socklog 0.9.0 Fri, 31 May 2002 14:07:11 +0200 * new service socklog-klog doing kernel logging. * socklog.c: fix facility and priority decoding in ucspi mode. * socklog-conf.c: creates socklog-klog's service directories. * doc/configuration.html, doc/examples.html, man/socklog-conf.8: document socklog-klog service. socklog 0.8.2 Sat, 18 May 2002 15:08:09 +0200 * src/: include public domain sources to build byte.a, unix.a, time.a: socklog builds without having daemontools' sources installed. * doc/usedietlibc.html: how to use dietlibc. socklog 0.8.1 Sun, 28 Apr 2002 10:32:28 +0200 * tryto.c: change return value on child timeout to 100, add FATAL prefix to error message on child timeout/crash. socklog 0.8.0 Tue, 16 Apr 2002 14:11:34 +0200 * doc/network.html: fix quoting bug, network client sample was not working properly. * doc/benefits.html: add more descriptions of benefits. * no code changes at all. socklog 0.7.0 Mon, 4 Feb 2002 11:37:13 +0100 * install-man: symlinks now point into the correct directory: /package/admin/socklog/man/ (thx Mike Forster). * socklog.c: complete revision: dropped fdbuffer.o, switched to unix.a, byte.a support libraries (now in the Public domain). * socklog-conf.c: support log dir with cross device link; optional logdir option must start with /. * Makefile: sysdeps. * doc: revised. * (thx Gary Gendel, support for solaris) socklog 0.6.1 Thu, 17 Jan 2002 11:43:36 +0100 * bug: socklog.c: error in recvfrom() was not catched (thx Liviu Daia) socklog 0.6.0 Sat, 12 Jan 2002 14:18:57 +0100 * uncat: redirect prog's stdout to stderr; never writes to stdout * socklog-conf notify: redirects uncat's stdout to the pipe: 'exec <> $PIPE', fixes wrong timeout handling seen in some configurations. * new: package/install-man for installing manpage links * doc: adapted * socklog.c,socklog-conf.c,uncat.c: code cleanup * doc: install.html: typos socklog 0.5.4 Sun, 30 Dec 2001 19:18:29 +0100 * uncat: new option -o: once, exit on eof * uncat: manpage adapted * doc: minor changes * socklog: trim 0-characters * Makefile: use ./support/compile, ./support/load socklog 0.5.1 Tue, 20 Nov 2001 11:36:23 +0100 * package socklog moved to smarden.org socklog 0.5.0 Fri, 16 Nov 2001 15:53:07 +0100 * minor beautification * deb: reorganized debian/rules socklog 0.4.6 Sun, 11 Nov 2001 15:08:22 +0100 * socklog: changed undocumented option -v to -V * Makefile: does not require gnu make (thx Jordan Krushen) * socklog-conf added * run socklog with softlimit * socklog-group mandatory, notify pipe mode 0620 * doc: upgrade.html, socklog-conf.8.html, socklog-conf.8 added * doc: adapted socklog 0.4.1 Fri, 12 Oct 2001 11:04:29 +0200 * uncat: continue; on error_again, fixes wrong timeouts * uncat: more verbose on -v * deb: moved to unofficial, fhs failures * socklog-notify: use mailsubj * doc: improved configuration.html * doc: how to disable log event notifications socklog 0.4.0 Fri, 21 Sep 2001 17:43:09 +0200 * changed to new primary email address * BSD license * doc: minor changes socklog 0.3.6 Mon, 17 Sep 2001 18:26:12 +0200 * doc: updated socklog 0.3.5 Sun, 16 Sep 2001 20:12:01 +0200 * new: tryto, uncat * new: network logging concept * new: log event notification * deb: cleaner binary package (rm -rf (socklog/{compile,etc,doc,man}) socklog 0.3.0 Tue, 14 Aug 2001 12:26:02 +0200 * installs into /package (see http://cr.yp.to/slashpackage.html) * no code changes socklog 0.2.2 Fri, 22 Jun 2001 11:59:10 +0200 * LDFLAGS for solaris in Makefile * doc: benefits.html added, describing logfile rotation based on file size socklog 0.2.1 Tue, 19 Jun 2001 11:48:28 +0200 * support for solaris (thx Gary Gendel) * deb: provides: system-log-daemon (thx ska) socklog 0.2.0 Mon, 11 Jun 2001 13:31:42 +0200 * ucspi mode added. * use setgroups() before setgid() (thx ari) * buffering output (thx ari) * doc: Examples added (thx Eduardo Augusto Alvarenga, Paul Jarc) * compiles on openbsd 2.9 (thx clemensF) socklog 0.1.2 Fri, 1 Jun 2001 10:50:36 +0200 * doc: improved socklog 0.1.1 Tue, 29 May 2001 13:26:24 +0200 * deb: provides log directories for default log/run files * deb: add user 'log' in postinst * doc: improved socklog 0.1.0 Mon, 28 May 2001 11:39:36 +0200 * initial release socklog-2.1.1+repack/package/sharing0000644000000000000000000000004314702065454016070 0ustar rootrootcommand:syst package:dist src:dist socklog-2.1.1+repack/package/compile0000755000000000000000000000123314702065454016072 0ustar rootroot#!/bin/sh -e umask 022 test -d package || sh -cx '! : Wrong working directory.' test -d src || sh -cx '! : Wrong working directory.' here=`env - PATH=$PATH pwd` mkdir -p compile command test -r compile/home || echo $here >compile/home test -h compile/src || ln -s $here/src compile/src echo 'Linking ./src/* into ./compile...' for i in `ls src`; do test -h compile/$i || ln -s src/$i compile/$i done echo 'Compiling everything in ./compile...' sh -cxe 'cd compile; exec make' echo 'Copying commands into ./command...' for i in `cat package/commands`; do rm -f command/$i'{new}' cp -p compile/$i command/$i'{new}' mv -f command/$i'{new}' command/$i done socklog-2.1.1+repack/package/install0000755000000000000000000000007414702065454016112 0ustar rootroot#!/bin/sh -e package/compile package/check package/upgrade socklog-2.1.1+repack/package/README0000644000000000000000000000007014702065454015372 0ustar rootrootCopyright 2001-2005 G. Pape http://smarden.org/socklog/ socklog-2.1.1+repack/package/check0000755000000000000000000000033214702065454015516 0ustar rootroot#!/bin/sh -e umask 022 test -d package || sh -cx '! : Wrong working directory.' test -d compile || sh -cx '! : Wrong working directory.' echo 'Checking commands in ./command...' sh -cxe 'cd compile; exec make check' socklog-2.1.1+repack/package/COPYING0000644000000000000000000000261214702065454015551 0ustar rootrootCopyright (c) 2001-2005, Gerrit Pape 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. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. socklog-2.1.1+repack/package/commands0000644000000000000000000000005714702065454016243 0ustar rootrootsocklog socklog-check socklog-conf tryto uncat socklog-2.1.1+repack/package/install-man0000755000000000000000000000112714702065454016663 0ustar rootroot#!/bin/sh -e umask 022 test -d package || sh -cx '! : Wrong working directory.' test -d man || sh -cx '! : Wrong working directory.' here=`env - PATH=$PATH pwd` parent=`dirname $here` echo 'Compressing manpages...' for i in man/*.[1-8]; do gzip -c $i >${i}.gz done echo 'Making manpage links in /usr/local/man...' cd man for i in 1 8; do mkdir -p /usr/local/man/man$i for j in *.$i; do rm -f /usr/local/man/man$i/$j.gz'{new}' ln -s $parent/socklog/man/$j.gz /usr/local/man/man$i/$j.gz'{new}' mv -f /usr/local/man/man$i/$j.gz'{new}' /usr/local/man/man$i/$j.gz done done cd .. socklog-2.1.1+repack/src/0000755000000000000000000000000014702065454013711 5ustar rootrootsocklog-2.1.1+repack/src/taia_less.c0000644000000000000000000000046714702065454016030 0ustar rootroot/* Public domain. */ #include "taia.h" /* XXX: breaks tai encapsulation */ int taia_less(const struct taia *t,const struct taia *u) { if (t->sec.x < u->sec.x) return 1; if (t->sec.x > u->sec.x) return 0; if (t->nano < u->nano) return 1; if (t->nano > u->nano) return 0; return t->atto < u->atto; } socklog-2.1.1+repack/src/uncat.dist0000644000000000000000000000151714702065454015714 0ustar rootrootusage: uncat [-vo] [-t timeout] [-s size] prog 1 $Id$ usage: uncat [-vo] [-t timeout] [-s size] prog 1 uncat: warning: starting. uncat: warning: end of input. uncat: warning: starting child. foo bar uncat: warning: child exited. uncat: warning: exit. 0 uncat: warning: starting. uncat: warning: timeout reached. uncat: warning: starting child. foo uncat: warning: child exited. uncat: warning: end of input. uncat: warning: starting child. bar uncat: warning: child exited. uncat: warning: exit. 0 uncat: warning: starting. uncat: warning: max size reached. uncat: warning: starting child. foo uncat: warning: child exited. uncat: warning: max size reached. uncat: warning: starting child. bar uncat: warning: child exited. uncat: warning: end of input. uncat: warning: starting child. baz uncat: warning: child exited. uncat: warning: exit. 0 socklog-2.1.1+repack/src/socklog.dist0000644000000000000000000000020314702065454016232 0ustar rootrootlistening on socklog.check.socket, starting. foo 0 listening on 127.0.0.1:12614, starting. 127.0.0.1: foo 0 U: foo U: bar U: baz 0 socklog-2.1.1+repack/src/Makefile0000644000000000000000000002612214702065454015354 0ustar rootrootIT=socklog socklog-check socklog-conf tryto uncat default: sysdeps $(IT) check: default check-socklog-unix check-socklog-inet ./check-local $(IT) socklog-conf: load socklog-conf.o unix.a byte.a ./load socklog-conf unix.a byte.a socklog: load socklog.o unix.a byte.a socket.lib ./load socklog unix.a byte.a `cat socket.lib` socklog-check: load socklog-check.o unix.a byte.a socket.lib ./load socklog-check unix.a byte.a `cat socket.lib` tryto: load tryto.o unix.a byte.a time.a ./load tryto unix.a byte.a time.a uncat: load uncat.o unix.a byte.a time.a ./load uncat unix.a byte.a time.a check-socklog-inet: load check-socklog-inet.o unix.a byte.a socket.lib ./load check-socklog-inet unix.a byte.a `cat socket.lib` check-socklog-unix: load check-socklog-unix.o unix.a byte.a socket.lib ./load check-socklog-unix unix.a byte.a `cat socket.lib` socklog-conf.o: compile socklog-conf.c ./compile socklog-conf.c socklog.o: compile socklog.c ./compile socklog.c socklog-check.o: compile socklog-check.c ./compile socklog-check.c tryto.o: compile tryto.c iopause.h uint64.h ./compile tryto.c uncat.o: compile uncat.c iopause.h uint64.h ./compile uncat.c check-socklog-inet.o: compile check-socklog-inet.c ./compile check-socklog-inet.c check-socklog-unix.o: compile check-socklog-unix.c ./compile check-socklog-unix.c socket.lib: compile load trysocketlib.c ./compile trysocketlib.c ( ./load trysocketlib >/dev/null 2>&1 || \ ( ./load trysocketlib -lxnet >/dev/null 2>&1 && echo '-lxnet' ) || \ ( ./load trysocketlib -lsocket -lnsl >/dev/null 2>&1 && \ echo '-lsocket -lnsl' ) \ ) >socket.lib rm -f trysocketlib.o trysocketlib clean: find . -name \*~ -exec rm -f {} \; find . -name .??*~ -exec rm -f {} \; find . -name \#?* -exec rm -f {} \; rm -f `cat TARGETS` alloc.o: alloc.c alloc.h compile error.h ./compile alloc.c alloc_re.o: alloc.h alloc_re.c byte.h compile ./compile alloc_re.c buffer.o: buffer.c buffer.h compile ./compile buffer.c buffer_0.o: buffer.h buffer_0.c compile ./compile buffer_0.c buffer_1.o: buffer.h buffer_1.c compile ./compile buffer_1.c buffer_2.o: buffer.h buffer_2.c compile ./compile buffer_2.c buffer_get.o: buffer.h buffer_get.c byte.h compile error.h ./compile buffer_get.c buffer_put.o: buffer.h buffer_put.c byte.h compile error.h str.h ./compile buffer_put.c buffer_read.o: buffer.h buffer_read.c compile ./compile buffer_read.c buffer_write.o: buffer.h buffer_write.c compile ./compile buffer_write.c byte.a: byte_chr.o byte_copy.o byte_cr.o byte_diff.o byte_rchr.o byte_zero.o \ fmt_uint.o fmt_uint0.o fmt_ulong.o makelib scan_ulong.o str_chr.o \ str_diff.o str_len.o str_start.o ./makelib byte.a byte_chr.o byte_copy.o byte_cr.o byte_diff.o \ byte_rchr.o byte_zero.o fmt_uint.o fmt_uint0.o fmt_ulong.o \ scan_ulong.o str_chr.o str_diff.o str_len.o str_start.o byte_chr.o: byte.h byte_chr.c compile ./compile byte_chr.c byte_copy.o: byte.h byte_copy.c compile ./compile byte_copy.c byte_cr.o: byte.h byte_cr.c compile ./compile byte_cr.c byte_diff.o: byte.h byte_diff.c compile ./compile byte_diff.c byte_rchr.o: byte.h byte_rchr.c compile ./compile byte_rchr.c byte_zero.o: byte.h byte_zero.c compile ./compile byte_zero.c choose: choose.sh warn-auto.sh rm -f choose cat warn-auto.sh choose.sh \ > choose chmod 555 choose coe.o: coe.c coe.h compile ./compile coe.c compile: conf-cc print-cc.sh systype warn-auto.sh rm -f compile sh print-cc.sh > compile chmod 555 compile direntry.h: choose compile direntry.h1 direntry.h2 trydrent.c ./choose c trydrent direntry.h1 direntry.h2 > direntry.h env.o: compile env.c env.h str.h ./compile env.c error.o: compile error.c error.h ./compile error.c error_str.o: compile error.h error_str.c ./compile error_str.c fd_copy.o: compile fd.h fd_copy.c ./compile fd_copy.c fd_move.o: compile fd.h fd_move.c ./compile fd_move.c fifo.o: compile fifo.c fifo.h hasmkffo.h ./compile fifo.c fmt_uint.o: compile fmt.h fmt_uint.c ./compile fmt_uint.c fmt_uint0.o: compile fmt.h fmt_uint0.c ./compile fmt_uint0.c fmt_ulong.o: compile fmt.h fmt_ulong.c ./compile fmt_ulong.c hasflock.h: choose compile hasflock.h1 hasflock.h2 load tryflock.c ./choose cl tryflock hasflock.h1 hasflock.h2 > hasflock.h hasmkffo.h: choose compile hasmkffo.h1 hasmkffo.h2 load trymkffo.c ./choose cl trymkffo hasmkffo.h1 hasmkffo.h2 > hasmkffo.h hassgact.h: choose compile hassgact.h1 hassgact.h2 load trysgact.c ./choose cl trysgact hassgact.h1 hassgact.h2 > hassgact.h hassgprm.h: choose compile hassgprm.h1 hassgprm.h2 load trysgprm.c ./choose cl trysgprm hassgprm.h1 hassgprm.h2 > hassgprm.h haswaitp.h: choose compile haswaitp.h1 haswaitp.h2 load trywaitp.c ./choose cl trywaitp haswaitp.h1 haswaitp.h2 > haswaitp.h iopause.h: choose compile iopause.h1 iopause.h2 load trypoll.c ./choose clr trypoll iopause.h1 iopause.h2 > iopause.h iopause.o: compile iopause.c iopause.h select.h tai.h taia.h uint64.h ./compile iopause.c load: conf-ld print-ld.sh systype warn-auto.sh rm -f load sh print-ld.sh > load chmod 555 load lock_ex.o: compile hasflock.h lock.h lock_ex.c ./compile lock_ex.c lock_exnb.o: compile hasflock.h lock.h lock_exnb.c ./compile lock_exnb.c makelib: print-ar.sh systype warn-auto.sh rm -f makelib sh print-ar.sh > makelib chmod 555 makelib ndelay_off.o: compile ndelay.h ndelay_off.c ./compile ndelay_off.c ndelay_on.o: compile ndelay.h ndelay_on.c ./compile ndelay_on.c open_append.o: compile open.h open_append.c ./compile open_append.c open_read.o: compile open.h open_read.c ./compile open_read.c open_trunc.o: compile open.h open_trunc.c ./compile open_trunc.c open_write.o: compile open.h open_write.c ./compile open_write.c openreadclose.o: compile error.h gen_alloc.h open.h openreadclose.c \ openreadclose.h readclose.h stralloc.h ./compile openreadclose.c pathexec_env.o: alloc.h byte.h compile env.h gen_alloc.h pathexec.h \ pathexec_env.c str.h stralloc.h ./compile pathexec_env.c pathexec_run.o: compile env.h error.h gen_alloc.h pathexec.h \ pathexec_run.c str.h stralloc.h ./compile pathexec_run.c readclose.o: compile error.h gen_alloc.h readclose.c readclose.h \ stralloc.h ./compile readclose.c scan_ulong.o: compile scan.h scan_ulong.c ./compile scan_ulong.c seek_set.o: compile seek.h seek_set.c ./compile seek_set.c select.h: choose compile select.h1 select.h2 trysysel.c ./choose c trysysel select.h1 select.h2 > select.h sgetopt.o: buffer.h compile sgetopt.c sgetopt.h subgetopt.h ./compile sgetopt.c sig.o: compile sig.c sig.h ./compile sig.c sig_block.o: compile hassgprm.h sig.h sig_block.c ./compile sig_block.c sig_catch.o: compile hassgact.h sig.h sig_catch.c ./compile sig_catch.c sig_pause.o: compile hassgprm.h sig.h sig_pause.c ./compile sig_pause.c str_chr.o: compile str.h str_chr.c ./compile str_chr.c str_diff.o: compile str.h str_diff.c ./compile str_diff.c str_len.o: compile str.h str_len.c ./compile str_len.c str_start.o: compile str.h str_start.c ./compile str_start.c stralloc_cat.o: byte.h compile gen_alloc.h stralloc.h stralloc_cat.c ./compile stralloc_cat.c stralloc_catb.o: byte.h compile gen_alloc.h stralloc.h \ stralloc_catb.c ./compile stralloc_catb.c stralloc_cats.o: byte.h compile gen_alloc.h str.h stralloc.h \ stralloc_cats.c ./compile stralloc_cats.c stralloc_eady.o: alloc.h compile gen_alloc.h gen_allocdefs.h \ stralloc.h stralloc_eady.c ./compile stralloc_eady.c stralloc_opyb.o: byte.h compile gen_alloc.h stralloc.h \ stralloc_opyb.c ./compile stralloc_opyb.c stralloc_opys.o: byte.h compile gen_alloc.h str.h stralloc.h \ stralloc_opys.c ./compile stralloc_opys.c stralloc_pend.o: alloc.h compile gen_alloc.h gen_allocdefs.h \ stralloc.h stralloc_pend.c ./compile stralloc_pend.c strerr_die.o: buffer.h compile strerr.h strerr_die.c ./compile strerr_die.c strerr_sys.o: compile error.h strerr.h strerr_sys.c ./compile strerr_sys.c subgetopt.o: compile subgetopt.c subgetopt.h ./compile subgetopt.c sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \ hassgprm.h haswaitp.h iopause.h load select.h systype \ uint64.h rm -f sysdeps cat systype compile load >> sysdeps grep sysdep direntry.h >> sysdeps grep sysdep haswaitp.h >> sysdeps grep sysdep hassgact.h >> sysdeps grep sysdep hassgprm.h >> sysdeps grep sysdep select.h >> sysdeps grep sysdep uint64.h >> sysdeps grep sysdep iopause.h >> sysdeps grep sysdep hasmkffo.h >> sysdeps grep sysdep hasflock.h >> sysdeps cat sysdeps systype: find-systype.sh trycpp.c x86cpuid.c sh find-systype.sh > systype tai_now.o: compile tai.h tai_now.c uint64.h ./compile tai_now.c tai_pack.o: compile tai.h tai_pack.c uint64.h ./compile tai_pack.c tai_sub.o: compile tai.h tai_sub.c uint64.h ./compile tai_sub.c tai_unpack.o: compile tai.h tai_unpack.c uint64.h ./compile tai_unpack.c taia_add.o: compile tai.h taia.h taia_add.c uint64.h ./compile taia_add.c taia_approx.o: compile tai.h taia.h taia_approx.c uint64.h ./compile taia_approx.c taia_frac.o: compile tai.h taia.h taia_frac.c uint64.h ./compile taia_frac.c taia_less.o: compile tai.h taia.h taia_less.c uint64.h ./compile taia_less.c taia_now.o: compile tai.h taia.h taia_now.c uint64.h ./compile taia_now.c taia_pack.o: compile tai.h taia.h taia_pack.c uint64.h ./compile taia_pack.c taia_sub.o: compile tai.h taia.h taia_sub.c uint64.h ./compile taia_sub.c taia_uint.o: compile tai.h taia.h taia_uint.c uint64.h ./compile taia_uint.c time.a: iopause.o makelib tai_now.o tai_pack.o tai_sub.o tai_unpack.o \ taia_add.o taia_approx.o taia_frac.o taia_less.o taia_now.o \ taia_pack.o taia_sub.o taia_uint.o ./makelib time.a iopause.o tai_now.o tai_pack.o tai_sub.o \ tai_unpack.o taia_add.o taia_approx.o taia_frac.o taia_less.o \ taia_now.o taia_pack.o taia_sub.o taia_uint.o uint64.h: choose compile load tryulong64.c uint64.h1 uint64.h2 ./choose clr tryulong64 uint64.h1 uint64.h2 > uint64.h unix.a: alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o buffer_2.o \ buffer_get.o buffer_put.o buffer_read.o buffer_write.o coe.o env.o \ error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o lock_exnb.o \ makelib ndelay_off.o ndelay_on.o open_append.o open_read.o \ open_trunc.o open_write.o openreadclose.o pathexec_env.o \ pathexec_run.o readclose.o seek_set.o sgetopt.o sig.o \ sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \ stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \ stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o \ wait_pid.o ./makelib unix.a alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o \ buffer_2.o buffer_get.o buffer_put.o buffer_read.o buffer_write.o \ coe.o env.o error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o \ lock_exnb.o ndelay_off.o ndelay_on.o open_append.o open_read.o \ open_trunc.o open_write.o openreadclose.o pathexec_env.o \ pathexec_run.o readclose.o seek_set.o sgetopt.o sig.o \ sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \ stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \ stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o \ wait_pid.o wait_nohang.o: compile haswaitp.h wait_nohang.c ./compile wait_nohang.c wait_pid.o: compile error.h haswaitp.h wait_pid.c ./compile wait_pid.c socklog-2.1.1+repack/src/byte_rchr.c0000644000000000000000000000070714702065454016042 0ustar rootroot/* Public domain. */ #include "byte.h" unsigned int byte_rchr(s,n,c) char *s; register unsigned int n; int c; { register char ch; register char *t; register char *u; ch = c; t = s; u = 0; for (;;) { if (!n) break; if (*t == ch) u = t; ++t; --n; if (!n) break; if (*t == ch) u = t; ++t; --n; if (!n) break; if (*t == ch) u = t; ++t; --n; if (!n) break; if (*t == ch) u = t; ++t; --n; } if (!u) u = t; return u - s; } socklog-2.1.1+repack/src/taia_approx.c0000644000000000000000000000020314702065454016357 0ustar rootroot/* Public domain. */ #include "taia.h" double taia_approx(const struct taia *t) { return tai_approx(&t->sec) + taia_frac(t); } socklog-2.1.1+repack/src/str_len.c0000644000000000000000000000040514702065454015522 0ustar rootroot/* Public domain. */ #include "str.h" unsigned int str_len(const char *s) { register const char *t; t = s; for (;;) { if (!*t) return t - s; ++t; if (!*t) return t - s; ++t; if (!*t) return t - s; ++t; if (!*t) return t - s; ++t; } } socklog-2.1.1+repack/src/stralloc_opys.c0000644000000000000000000000025514702065454016754 0ustar rootroot/* Public domain. */ #include "byte.h" #include "str.h" #include "stralloc.h" int stralloc_copys(stralloc *sa,const char *s) { return stralloc_copyb(sa,s,str_len(s)); } socklog-2.1.1+repack/src/sig_block.c0000644000000000000000000000122314702065454016007 0ustar rootroot/* Public domain. */ #include #include "sig.h" #include "hassgprm.h" void sig_block(int sig) { #ifdef HASSIGPROCMASK sigset_t ss; sigemptyset(&ss); sigaddset(&ss,sig); sigprocmask(SIG_BLOCK,&ss,(sigset_t *) 0); #else sigblock(1 << (sig - 1)); #endif } void sig_unblock(int sig) { #ifdef HASSIGPROCMASK sigset_t ss; sigemptyset(&ss); sigaddset(&ss,sig); sigprocmask(SIG_UNBLOCK,&ss,(sigset_t *) 0); #else sigsetmask(sigsetmask(~0) & ~(1 << (sig - 1))); #endif } void sig_blocknone(void) { #ifdef HASSIGPROCMASK sigset_t ss; sigemptyset(&ss); sigprocmask(SIG_SETMASK,&ss,(sigset_t *) 0); #else sigsetmask(0); #endif } socklog-2.1.1+repack/src/open.h0000644000000000000000000000036514702065454015027 0ustar rootroot/* Public domain. */ #ifndef OPEN_H #define OPEN_H extern int open_read(const char *); extern int open_excl(const char *); extern int open_append(const char *); extern int open_trunc(const char *); extern int open_write(const char *); #endif socklog-2.1.1+repack/src/hasmkffo.h20000644000000000000000000000010014702065454015731 0ustar rootroot/* Public domain. */ /* sysdep: +mkfifo */ #define HASMKFIFO 1 socklog-2.1.1+repack/src/conf-ld0000644000000000000000000000007714702065454015162 0ustar rootrootgcc -s This will be used to link .o files into an executable. socklog-2.1.1+repack/src/trymkffo.c0000644000000000000000000000016114702065454015714 0ustar rootroot/* Public domain. */ #include #include void main() { mkfifo("temp-trymkffo",0); } socklog-2.1.1+repack/src/select.h20000644000000000000000000000026514702065454015426 0ustar rootroot/* Public domain. */ #ifndef SELECT_H #define SELECT_H /* sysdep: +sysselect */ #include #include #include extern int select(); #endif socklog-2.1.1+repack/src/TODO0000644000000000000000000000000014702065454014367 0ustar rootrootsocklog-2.1.1+repack/src/ndelay_off.c0000644000000000000000000000034514702065454016165 0ustar rootroot/* Public domain. */ #include #include #include "ndelay.h" #ifndef O_NONBLOCK #define O_NONBLOCK O_NDELAY #endif int ndelay_off(int fd) { return fcntl(fd,F_SETFL,fcntl(fd,F_GETFL,0) & ~O_NONBLOCK); } socklog-2.1.1+repack/src/hassgact.h20000644000000000000000000000010614702065454015736 0ustar rootroot/* Public domain. */ /* sysdep: +sigaction */ #define HASSIGACTION 1 socklog-2.1.1+repack/src/trysgprm.c0000644000000000000000000000025014702065454015741 0ustar rootroot/* Public domain. */ #include int main() { sigset_t ss; sigemptyset(&ss); sigaddset(&ss,SIGCHLD); sigprocmask(SIG_SETMASK,&ss,(sigset_t *) 0); } socklog-2.1.1+repack/src/taia_now.c0000644000000000000000000000044114702065454015655 0ustar rootroot/* Public domain. */ #include #include #include #include "taia.h" void taia_now(struct taia *t) { struct timeval now; gettimeofday(&now,(struct timezone *) 0); tai_unix(&t->sec,now.tv_sec); t->nano = 1000 * now.tv_usec + 500; t->atto = 0; } socklog-2.1.1+repack/src/socklog-check.check0000755000000000000000000000043514702065454017431 0ustar rootroot#!/bin/sh socklog-check -V echo $? socklog unix socklog.check.socket & pid=$! sleep 1 socklog-check unix socklog.check.socket echo $? socklog-check -v unix socklog.check.socket echo $? kill -TERM "$pid" wait socklog-check unix socklog.check.socket echo $? rm -f socklog.check.socket socklog-2.1.1+repack/src/haswaitp.h20000644000000000000000000000010214702065454015755 0ustar rootroot/* Public domain. */ /* sysdep: +waitpid */ #define HASWAITPID 1 socklog-2.1.1+repack/src/lock_ex.c0000644000000000000000000000037414702065454015505 0ustar rootroot/* Public domain. */ #include #include #include #include "hasflock.h" #include "lock.h" #ifdef HASFLOCK int lock_ex(int fd) { return flock(fd,LOCK_EX); } #else int lock_ex(int fd) { return lockf(fd,1,0); } #endif socklog-2.1.1+repack/src/scan.h0000644000000000000000000000260514702065454015011 0ustar rootroot/* Public domain. */ #ifndef SCAN_H #define SCAN_H extern unsigned int scan_uint(const char *,unsigned int *); extern unsigned int scan_xint(const char *,unsigned int *); extern unsigned int scan_nbbint(const char *,unsigned int,unsigned int,unsigned int,unsigned int *); extern unsigned int scan_ushort(const char *,unsigned short *); extern unsigned int scan_xshort(const char *,unsigned short *); extern unsigned int scan_nbbshort(const char *,unsigned int,unsigned int,unsigned int,unsigned short *); extern unsigned int scan_ulong(const char *,unsigned long *); extern unsigned int scan_xlong(const char *,unsigned long *); extern unsigned int scan_nbblong(const char *,unsigned int,unsigned int,unsigned int,unsigned long *); extern unsigned int scan_plusminus(const char *,int *); extern unsigned int scan_0x(const char *,unsigned int *); extern unsigned int scan_whitenskip(const char *,unsigned int); extern unsigned int scan_nonwhitenskip(const char *,unsigned int); extern unsigned int scan_charsetnskip(const char *,const char *,unsigned int); extern unsigned int scan_noncharsetnskip(const char *,const char *,unsigned int); extern unsigned int scan_strncmp(const char *,const char *,unsigned int); extern unsigned int scan_memcmp(const char *,const char *,unsigned int); extern unsigned int scan_long(const char *,long *); extern unsigned int scan_8long(const char *,unsigned long *); #endif socklog-2.1.1+repack/src/fmt_ulong.c0000644000000000000000000000052014702065454016044 0ustar rootroot/* Public domain. */ #include "fmt.h" unsigned int fmt_ulong(register char *s,register unsigned long u) { register unsigned int len; register unsigned long q; len = 1; q = u; while (q > 9) { ++len; q /= 10; } if (s) { s += len; do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */ } return len; } socklog-2.1.1+repack/src/seek_set.c0000644000000000000000000000031614702065454015657 0ustar rootroot/* Public domain. */ #include #include #include "seek.h" #define SET 0 /* sigh */ int seek_set(int fd,seek_pos pos) { if (lseek(fd,(off_t) pos,SET) == -1) return -1; return 0; } socklog-2.1.1+repack/src/open_trunc.c0000644000000000000000000000026414702065454016233 0ustar rootroot/* Public domain. */ #include #include #include "open.h" int open_trunc(const char *fn) { return open(fn,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644); } socklog-2.1.1+repack/src/wait_pid.c0000644000000000000000000000133314702065454015655 0ustar rootroot/* Public domain. */ #include #include #include "error.h" #include "haswaitp.h" #ifdef HASWAITPID int wait_pid(wstat,pid) int *wstat; int pid; { int r; do r = waitpid(pid,wstat,0); while ((r == -1) && (errno == error_intr)); return r; } #else /* XXX untested */ /* XXX breaks down with more than two children */ static int oldpid = 0; static int oldwstat; /* defined if(oldpid) */ int wait_pid(wstat,pid) int *wstat; int pid; { int r; if (pid == oldpid) { *wstat = oldwstat; oldpid = 0; return pid; } do { r = wait(wstat); if ((r != pid) && (r != -1)) { oldwstat = *wstat; oldpid = r; continue; } } while ((r == -1) && (errno == error_intr)); return r; } #endif socklog-2.1.1+repack/src/trysocketlib.c0000644000000000000000000000031214702065454016567 0ustar rootroot#include #include #include #include #include int main(void) { int s; s =socket(AF_INET, SOCK_STREAM, 0); return(close(s)); } socklog-2.1.1+repack/src/TARGETS0000644000000000000000000000250014702065454014742 0ustar rootrootsocklog socklog.o socklog-check socklog-check.o socklog-conf socklog-conf.o tryto tryto.o uncat uncat.o check-socklog-inet check-socklog-inet.o check-socklog-unix check-socklog-unix.o socket.lib trysocketlib trysocketlib.o alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o buffer_2.o buffer_get.o buffer_put.o buffer_read.o buffer_write.o byte.a byte_chr.o byte_copy.o byte_cr.o byte_diff.o byte_rchr.o byte_zero.o choose coe.o compile direntry.h env.o error.o error_str.o fd_copy.o fd_move.o fifo.o fmt_uint.o fmt_uint0.o fmt_ulong.o hasflock.h hasmkffo.h hassgact.h hassgprm.h haswaitp.h iopause.h iopause.o load lock_ex.o lock_exnb.o makelib ndelay_off.o ndelay_on.o open_append.o open_read.o open_trunc.o open_write.o openreadclose.o pathexec_env.o pathexec_run.o prot.o readclose.o scan_ulong.o seek_set.o select.h sgetopt.o sig.o sig_block.o sig_catch.o sig_pause.o str_chr.o str_diff.o str_len.o str_start.o stralloc_cat.o stralloc_catb.o stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o sysdeps systype tai_now.o tai_pack.o tai_sub.o tai_unpack.o taia_add.o taia_approx.o taia_frac.o taia_less.o taia_now.o taia_pack.o taia_sub.o taia_uint.o time.a uint64.h unix.a wait_nohang.o wait_pid.o socklog.local socklog-check.local socklog-conf.local tryto.local uncat.local socklog-2.1.1+repack/src/fd_move.c0000644000000000000000000000027414702065454015477 0ustar rootroot/* Public domain. */ #include #include "fd.h" int fd_move(int to,int from) { if (to == from) return 0; if (fd_copy(to,from) == -1) return -1; close(from); return 0; } socklog-2.1.1+repack/src/buffer_read.c0000644000000000000000000000022514702065454016320 0ustar rootroot/* Public domain. */ #include #include "buffer.h" int buffer_unixread(int fd,char *buf,unsigned int len) { return read(fd,buf,len); } socklog-2.1.1+repack/src/ndelay.h0000644000000000000000000000017014702065454015334 0ustar rootroot/* Public domain. */ #ifndef NDELAY_H #define NDELAY_H extern int ndelay_on(int); extern int ndelay_off(int); #endif socklog-2.1.1+repack/src/ndelay_on.c0000644000000000000000000000034314702065454016025 0ustar rootroot/* Public domain. */ #include #include #include "ndelay.h" #ifndef O_NONBLOCK #define O_NONBLOCK O_NDELAY #endif int ndelay_on(int fd) { return fcntl(fd,F_SETFL,fcntl(fd,F_GETFL,0) | O_NONBLOCK); } socklog-2.1.1+repack/src/sig_pause.c0000644000000000000000000000032314702065454016032 0ustar rootroot/* Public domain. */ #include #include "sig.h" #include "hassgprm.h" void sig_pause(void) { #ifdef HASSIGPROCMASK sigset_t ss; sigemptyset(&ss); sigsuspend(&ss); #else sigpause(0); #endif } socklog-2.1.1+repack/src/socklog-conf.check0000755000000000000000000000067214702065454017304 0ustar rootroot#!/bin/sh rm -rf "${ctmp}" socklog-conf echo $? socklog-conf -V echo $? mkdir -p "${ctmp}" user=`whoami` socklog-conf unix "${user}" "${user}" "${ctmp}"/socklog "${ctmp}"/unix echo $? socklog-conf inet "${user}" "${user}" "${ctmp}"/socklog "${ctmp}"/inet echo $? socklog-conf klog "${user}" "${user}" "${ctmp}"/socklog "${ctmp}"/klog echo $? socklog-conf ucspi "${user}" "${user}" "${ctmp}"/socklog "${ctmp}"/ucspi echo $? rm -rf "${ctmp}" socklog-2.1.1+repack/src/haswaitp.h10000644000000000000000000000005514702065454015763 0ustar rootroot/* Public domain. */ /* sysdep: -waitpid */ socklog-2.1.1+repack/src/error_str.c0000644000000000000000000001257614702065454016111 0ustar rootroot/* Public domain. */ #include #include "error.h" #define X(e,s) if (i == e) return s; const char *error_str(int i) { X(0,"no error") X(error_intr,"interrupted system call") X(error_nomem,"out of memory") X(error_noent,"file does not exist") X(error_txtbsy,"text busy") X(error_io,"input/output error") X(error_exist,"file already exists") X(error_timeout,"timed out") X(error_inprogress,"operation in progress") X(error_again,"temporary failure") X(error_wouldblock,"input/output would block") X(error_pipe,"broken pipe") X(error_perm,"permission denied") X(error_acces,"access denied") X(error_nodevice,"device not configured") X(error_proto,"protocol error") X(error_isdir,"is a directory") X(error_connrefused,"connection refused") X(error_notdir,"not a directory") #ifdef ESRCH X(ESRCH,"no such process") #endif #ifdef E2BIG X(E2BIG,"argument list too long") #endif #ifdef ENOEXEC X(ENOEXEC,"exec format error") #endif #ifdef EBADF X(EBADF,"file descriptor not open") #endif #ifdef ECHILD X(ECHILD,"no child processes") #endif #ifdef EDEADLK X(EDEADLK,"operation would cause deadlock") #endif #ifdef EFAULT X(EFAULT,"bad address") #endif #ifdef ENOTBLK X(ENOTBLK,"not a block device") #endif #ifdef EBUSY X(EBUSY,"device busy") #endif #ifdef EXDEV X(EXDEV,"cross-device link") #endif #ifdef ENODEV X(ENODEV,"device does not support operation") #endif #ifdef EINVAL X(EINVAL,"invalid argument") #endif #ifdef ENFILE X(ENFILE,"system cannot open more files") #endif #ifdef EMFILE X(EMFILE,"process cannot open more files") #endif #ifdef ENOTTY X(ENOTTY,"not a tty") #endif #ifdef EFBIG X(EFBIG,"file too big") #endif #ifdef ENOSPC X(ENOSPC,"out of disk space") #endif #ifdef ESPIPE X(ESPIPE,"unseekable descriptor") #endif #ifdef EROFS X(EROFS,"read-only file system") #endif #ifdef EMLINK X(EMLINK,"too many links") #endif #ifdef EDOM X(EDOM,"input out of range") #endif #ifdef ERANGE X(ERANGE,"output out of range") #endif #ifdef EALREADY X(EALREADY,"operation already in progress") #endif #ifdef ENOTSOCK X(ENOTSOCK,"not a socket") #endif #ifdef EDESTADDRREQ X(EDESTADDRREQ,"destination address required") #endif #ifdef EMSGSIZE X(EMSGSIZE,"message too long") #endif #ifdef EPROTOTYPE X(EPROTOTYPE,"incorrect protocol type") #endif #ifdef ENOPROTOOPT X(ENOPROTOOPT,"protocol not available") #endif #ifdef EPROTONOSUPPORT X(EPROTONOSUPPORT,"protocol not supported") #endif #ifdef ESOCKTNOSUPPORT X(ESOCKTNOSUPPORT,"socket type not supported") #endif #ifdef EOPNOTSUPP X(EOPNOTSUPP,"operation not supported") #endif #ifdef EPFNOSUPPORT X(EPFNOSUPPORT,"protocol family not supported") #endif #ifdef EAFNOSUPPORT X(EAFNOSUPPORT,"address family not supported") #endif #ifdef EADDRINUSE X(EADDRINUSE,"address already used") #endif #ifdef EADDRNOTAVAIL X(EADDRNOTAVAIL,"address not available") #endif #ifdef ENETDOWN X(ENETDOWN,"network down") #endif #ifdef ENETUNREACH X(ENETUNREACH,"network unreachable") #endif #ifdef ENETRESET X(ENETRESET,"network reset") #endif #ifdef ECONNABORTED X(ECONNABORTED,"connection aborted") #endif #ifdef ECONNRESET X(ECONNRESET,"connection reset") #endif #ifdef ENOBUFS X(ENOBUFS,"out of buffer space") #endif #ifdef EISCONN X(EISCONN,"already connected") #endif #ifdef ENOTCONN X(ENOTCONN,"not connected") #endif #ifdef ESHUTDOWN X(ESHUTDOWN,"socket shut down") #endif #ifdef ETOOMANYREFS X(ETOOMANYREFS,"too many references") #endif #ifdef ELOOP X(ELOOP,"symbolic link loop") #endif #ifdef ENAMETOOLONG X(ENAMETOOLONG,"file name too long") #endif #ifdef EHOSTDOWN X(EHOSTDOWN,"host down") #endif #ifdef EHOSTUNREACH X(EHOSTUNREACH,"host unreachable") #endif #ifdef ENOTEMPTY X(ENOTEMPTY,"directory not empty") #endif #ifdef EPROCLIM X(EPROCLIM,"too many processes") #endif #ifdef EUSERS X(EUSERS,"too many users") #endif #ifdef EDQUOT X(EDQUOT,"disk quota exceeded") #endif #ifdef ESTALE X(ESTALE,"stale NFS file handle") #endif #ifdef EREMOTE X(EREMOTE,"too many levels of remote in path") #endif #ifdef EBADRPC X(EBADRPC,"RPC structure is bad") #endif #ifdef ERPCMISMATCH X(ERPCMISMATCH,"RPC version mismatch") #endif #ifdef EPROGUNAVAIL X(EPROGUNAVAIL,"RPC program unavailable") #endif #ifdef EPROGMISMATCH X(EPROGMISMATCH,"program version mismatch") #endif #ifdef EPROCUNAVAIL X(EPROCUNAVAIL,"bad procedure for program") #endif #ifdef ENOLCK X(ENOLCK,"no locks available") #endif #ifdef ENOSYS X(ENOSYS,"system call not available") #endif #ifdef EFTYPE X(EFTYPE,"bad file type") #endif #ifdef EAUTH X(EAUTH,"authentication error") #endif #ifdef ENEEDAUTH X(ENEEDAUTH,"not authenticated") #endif #ifdef ENOSTR X(ENOSTR,"not a stream device") #endif #ifdef ETIME X(ETIME,"timer expired") #endif #ifdef ENOSR X(ENOSR,"out of stream resources") #endif #ifdef ENOMSG X(ENOMSG,"no message of desired type") #endif #ifdef EBADMSG X(EBADMSG,"bad message type") #endif #ifdef EIDRM X(EIDRM,"identifier removed") #endif #ifdef ENONET X(ENONET,"machine not on network") #endif #ifdef ERREMOTE X(ERREMOTE,"object not local") #endif #ifdef ENOLINK X(ENOLINK,"link severed") #endif #ifdef EADV X(EADV,"advertise error") #endif #ifdef ESRMNT X(ESRMNT,"srmount error") #endif #ifdef ECOMM X(ECOMM,"communication error") #endif #ifdef EMULTIHOP X(EMULTIHOP,"multihop attempted") #endif #ifdef EREMCHG X(EREMCHG,"remote address changed") #endif return "unknown error"; } socklog-2.1.1+repack/src/stralloc_cat.c0000644000000000000000000000025714702065454016533 0ustar rootroot/* Public domain. */ #include "byte.h" #include "stralloc.h" int stralloc_cat(stralloc *sato,const stralloc *safrom) { return stralloc_catb(sato,safrom->s,safrom->len); } socklog-2.1.1+repack/src/tai_sub.c0000644000000000000000000000020614702065454015501 0ustar rootroot/* Public domain. */ #include "tai.h" void tai_sub(struct tai *t,const struct tai *u,const struct tai *v) { t->x = u->x - v->x; } socklog-2.1.1+repack/src/iopause.h10000644000000000000000000000046214702065454015612 0ustar rootroot/* Public domain. */ #ifndef IOPAUSE_H #define IOPAUSE_H /* sysdep: -poll */ typedef struct { int fd; short events; short revents; } iopause_fd; #define IOPAUSE_READ 1 #define IOPAUSE_WRITE 4 #include "taia.h" extern void iopause(iopause_fd *,unsigned int,struct taia *,struct taia *); #endif socklog-2.1.1+repack/src/strerr_die.c0000644000000000000000000000155414702065454016224 0ustar rootroot/* Public domain. */ #include #include "buffer.h" #include "strerr.h" void strerr_warn(const char *x1,const char *x2,const char *x3,const char *x4,const char *x5,const char *x6,const struct strerr *se) { strerr_sysinit(); if (x1) buffer_puts(buffer_2,x1); if (x2) buffer_puts(buffer_2,x2); if (x3) buffer_puts(buffer_2,x3); if (x4) buffer_puts(buffer_2,x4); if (x5) buffer_puts(buffer_2,x5); if (x6) buffer_puts(buffer_2,x6); while(se) { if (se->x) buffer_puts(buffer_2,se->x); if (se->y) buffer_puts(buffer_2,se->y); if (se->z) buffer_puts(buffer_2,se->z); se = se->who; } buffer_puts(buffer_2,"\n"); buffer_flush(buffer_2); } void strerr_die(int e,const char *x1,const char *x2,const char *x3,const char *x4,const char *x5,const char *x6,const struct strerr *se) { strerr_warn(x1,x2,x3,x4,x5,x6,se); _exit(e); } socklog-2.1.1+repack/src/trypoll.c0000644000000000000000000000057214702065454015566 0ustar rootroot/* Public domain. */ #include #include #include #include int main() { struct pollfd x; x.fd = open("trypoll.c",O_RDONLY); if (x.fd == -1) _exit(111); x.events = POLLIN; if (poll(&x,1,10) == -1) _exit(1); if (x.revents != POLLIN) _exit(1); /* XXX: try to detect and avoid poll() imitation libraries */ _exit(0); } socklog-2.1.1+repack/src/iopause.c0000644000000000000000000000321414702065454015522 0ustar rootroot/* Public domain. */ #include "taia.h" #include "select.h" #include "iopause.h" void iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *stamp) { struct taia t; int millisecs; double d; int i; if (taia_less(deadline,stamp)) millisecs = 0; else { t = *stamp; taia_sub(&t,deadline,&t); d = taia_approx(&t); if (d > 1000.0) d = 1000.0; millisecs = d * 1000.0 + 20.0; } for (i = 0;i < len;++i) x[i].revents = 0; #ifdef IOPAUSE_POLL poll(x,len,millisecs); /* XXX: some kernels apparently need x[0] even if len is 0 */ /* XXX: how to handle EAGAIN? are kernels really this dumb? */ /* XXX: how to handle EINVAL? when exactly can this happen? */ #else { struct timeval tv; fd_set rfds; fd_set wfds; int nfds; int fd; FD_ZERO(&rfds); FD_ZERO(&wfds); nfds = 1; for (i = 0;i < len;++i) { fd = x[i].fd; if (fd < 0) continue; if (fd >= 8 * sizeof(fd_set)) continue; /*XXX*/ if (fd >= nfds) nfds = fd + 1; if (x[i].events & IOPAUSE_READ) FD_SET(fd,&rfds); if (x[i].events & IOPAUSE_WRITE) FD_SET(fd,&wfds); } tv.tv_sec = millisecs / 1000; tv.tv_usec = 1000 * (millisecs % 1000); if (select(nfds,&rfds,&wfds,(fd_set *) 0,&tv) <= 0) return; /* XXX: for EBADF, could seek out and destroy the bad descriptor */ for (i = 0;i < len;++i) { fd = x[i].fd; if (fd < 0) continue; if (fd >= 8 * sizeof(fd_set)) continue; /*XXX*/ if (x[i].events & IOPAUSE_READ) if (FD_ISSET(fd,&rfds)) x[i].revents |= IOPAUSE_READ; if (x[i].events & IOPAUSE_WRITE) if (FD_ISSET(fd,&wfds)) x[i].revents |= IOPAUSE_WRITE; } } #endif } socklog-2.1.1+repack/src/choose.sh0000644000000000000000000000040214702065454015521 0ustar rootroot result="$4" case "$1" in *c*) ./compile $2.c >/dev/null 2>&1 || result="$3" ;; esac case "$1" in *l*) ./load $2 >/dev/null 2>&1 || result="$3" ;; esac case "$1" in *r*) ./$2 >/dev/null 2>&1 || result="$3" ;; esac rm -f $2.o $2 exec cat "$result" socklog-2.1.1+repack/src/subgetopt.h0000644000000000000000000000111014702065454016067 0ustar rootroot/* Public domain. */ #ifndef SUBGETOPT_H #define SUBGETOPT_H #ifndef SUBGETOPTNOSHORT #define sgopt subgetopt #define sgoptarg subgetoptarg #define sgoptind subgetoptind #define sgoptpos subgetoptpos #define sgoptproblem subgetoptproblem #define sgoptprogname subgetoptprogname #define sgoptdone subgetoptdone #endif #define SUBGETOPTDONE -1 extern int subgetopt(int,char *const *,const char *); extern const char *subgetoptarg; extern int subgetoptind; extern int subgetoptpos; extern int subgetoptproblem; extern const char *subgetoptprogname; extern int subgetoptdone; #endif socklog-2.1.1+repack/src/check-local0000755000000000000000000000035014702065454016002 0ustar rootroot#!/bin/sh PATH=`pwd`:$PATH for i in ${1+"$@"}; do echo "Checking $i..." env - PATH="$PATH" ctmp="`pwd`/check-tmp" $i.check 2>&1 |cat -v >$i.local ./check-diff $i || ( cat $i.local; echo "$i failed."; exit 1 ) || exit 1 done socklog-2.1.1+repack/src/fd.h0000644000000000000000000000016314702065454014453 0ustar rootroot/* Public domain. */ #ifndef FD_H #define FD_H extern int fd_copy(int,int); extern int fd_move(int,int); #endif socklog-2.1.1+repack/src/print-ar.sh0000644000000000000000000000037114702065454016002 0ustar rootrootcat warn-auto.sh echo 'main="$1"; shift' echo 'rm -f "$main"' echo 'ar cr "$main" ${1+"$@"}' case "`cat systype`" in sunos-5.*) ;; unix_sv*) ;; irix64-*) ;; irix-*) ;; dgux-*) ;; hp-ux-*) ;; sco*) ;; *) echo 'ranlib "$main"' ;; esac socklog-2.1.1+repack/src/fmt.h0000644000000000000000000000212414702065454014647 0ustar rootroot/* Public domain. */ #ifndef FMT_H #define FMT_H #define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */ #define FMT_LEN ((char *) 0) /* convenient abbreviation */ extern unsigned int fmt_uint(char *,unsigned int); extern unsigned int fmt_uint0(char *,unsigned int,unsigned int); extern unsigned int fmt_xint(char *,unsigned int); extern unsigned int fmt_nbbint(char *,unsigned int,unsigned int,unsigned int,unsigned int); extern unsigned int fmt_ushort(char *,unsigned short); extern unsigned int fmt_xshort(char *,unsigned short); extern unsigned int fmt_nbbshort(char *,unsigned int,unsigned int,unsigned int,unsigned short); extern unsigned int fmt_ulong(char *,unsigned long); extern unsigned int fmt_xlong(char *,unsigned long); extern unsigned int fmt_nbblong(char *,unsigned int,unsigned int,unsigned int,unsigned long); extern unsigned int fmt_plusminus(char *,int); extern unsigned int fmt_minus(char *,int); extern unsigned int fmt_0x(char *,int); extern unsigned int fmt_str(char *,const char *); extern unsigned int fmt_strn(char *,const char *,unsigned int); #endif socklog-2.1.1+repack/src/strerr_sys.c0000644000000000000000000000033214702065454016272 0ustar rootroot/* Public domain. */ #include "error.h" #include "strerr.h" struct strerr strerr_sys; void strerr_sysinit(void) { strerr_sys.who = 0; strerr_sys.x = error_str(errno); strerr_sys.y = ""; strerr_sys.z = ""; } socklog-2.1.1+repack/src/socklog.check0000755000000000000000000000047314702065454016360 0ustar rootroot#!/bin/sh socklog unix socklog.check.socket & pid=$! sleep 1 check-socklog-unix sleep 2 kill -TERM $pid wait echo $? rm -f socklog.check.socket socklog inet 127.0.0.1 12614 & pid=$! sleep 1 check-socklog-inet sleep 2 kill -TERM $pid wait echo $? ( echo foo; echo bar; echo baz ) |env u=U socklog ucspi u echo $? socklog-2.1.1+repack/src/tryto.c0000644000000000000000000001426314702065454015244 0ustar rootroot#include #include #include "strerr.h" #include "pathexec.h" #include "iopause.h" #include "taia.h" #include "wait.h" #include "sig.h" #include "coe.h" #include "ndelay.h" #include "fd.h" #include "buffer.h" #include "error.h" #include "sgetopt.h" #include "scan.h" /* defaults */ #define TIMEOUT 180 #define KTIMEOUT 5 #define TRYMAX 5 #define USAGE " [-vp] [-t seconds] [-k kseconds] [-n tries] prog" #define WARNING "tryto: warning: " #define FATAL "tryto: fatal: " const char *progname; int selfpipe[2]; int try =0; void sig_child_handler(void) { try++; write(selfpipe[1], "", 1); } void usage () { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } int main (int argc, char * const *argv, char * const *envp) { int opt; struct taia now, deadline; iopause_fd x[2]; int pid; int rc =111; unsigned long timeout =TIMEOUT; unsigned long ktimeout =KTIMEOUT; unsigned long trymax =TRYMAX; int verbose =0; char ch; int processor =0; unsigned int pgroup =0; int cpipe[2]; progname =*argv; while ((opt =getopt(argc,argv,"t:k:n:pPvV")) != opteof) { switch(opt) { case 'V': strerr_warn1("$Id$\n", 0); case '?': usage(); case 't': scan_ulong(optarg, &timeout); if (timeout <= 0) timeout =TIMEOUT; break; case 'k': scan_ulong(optarg, &ktimeout); if (ktimeout <= 0) ktimeout =KTIMEOUT; break; case 'n': scan_ulong(optarg, &trymax); break; case 'p': processor =1; break; case 'P': pgroup =1; break; case 'v': verbose =1; break; } } argv +=optind; if (!*argv) usage(); /* create selfpipe */ if (pipe(selfpipe) == -1) { strerr_die2sys(111, FATAL, "unable to create selfpipe: "); } coe(selfpipe[0]); coe(selfpipe[1]); ndelay_on(selfpipe[0]); ndelay_on(selfpipe[1]); ndelay_on(0); if (processor) ndelay_on(4); sig_block(sig_pipe); sig_block(sig_child); sig_catch(sig_child, sig_child_handler); /* set timeout */ taia_now(&now); taia_uint(&deadline, timeout); taia_add(&deadline, &now, &deadline); timeout =0; for (;;) { int iopausefds; char buffer_x_space[BUFFER_INSIZE]; buffer buffer_x; if (processor) { buffer_init(&buffer_x, buffer_unixread, 4, buffer_x_space, sizeof buffer_x_space); } else { buffer_init(&buffer_x, buffer_unixread, 0, buffer_x_space, sizeof buffer_x_space); } /* start real processor */ if (pipe(cpipe) == -1) { strerr_die2sys(111, FATAL, "unable to create pipe for child: "); } while ((pid =fork()) == -1) { strerr_warn4(WARNING, "unable to fork for \"", *argv, "\" pausing: ", &strerr_sys); sleep(5); } if (!pid) { /* child */ sig_unblock(sig_pipe); sig_unblock(sig_child); sig_uncatch(sig_child); close(cpipe[1]); fd_move(0, cpipe[0]); if (processor) { fd_move(2, 5); close(4); } if (pgroup) setsid(); pathexec_run(*argv, argv, envp); strerr_die2sys(111, FATAL, "unable to start child: "); } close(cpipe[0]); x[0].fd =selfpipe[0]; x[0].events =IOPAUSE_READ; if (processor) { fd_move(2, 5); x[1].fd =4; } else { x[1].fd =0; } x[1].events =IOPAUSE_READ; iopausefds =2; /* feed + watch child */ for (;;) { int r; int i; char *s; sig_unblock(sig_child); iopause(x, iopausefds, &deadline, &now); sig_block(sig_child); while (read(selfpipe[0], &ch, 1) == 1) {} taia_now(&now); if ((timeout =taia_less(&deadline, &now))) break; if (wait_nohang(&rc) == pid) break; rc =111; r = buffer_feed(&buffer_x); if (r < 0) { if ((errno == error_intr) || (errno == error_again)) continue; } if (r == 0) { if (processor && (buffer_x.fd == 4)) { x[1].fd =0; buffer_init(&buffer_x, buffer_unixread, 0, buffer_x_space, sizeof buffer_x_space); continue; } if (iopausefds == 2) { close(cpipe[1]); iopausefds =1; } continue; } s =buffer_peek(&buffer_x); i =write(cpipe[1], s, r); if (i == -1) strerr_die2sys(111, FATAL, "unable to write to child: "); if (i < r) strerr_die2x(111, FATAL, "unable to write to child: partial write"); buffer_seek(&buffer_x, r); } close(cpipe[1]); if (timeout) { if (wait_nohang(&rc) == pid) break; /* child not finished */ strerr_warn4(WARNING, "child \"", *argv, "\" timed out. sending TERM...", 0); kill(pgroup ? -pid : pid, SIGTERM); /* ktimeout sec timeout */ taia_now(&now); taia_uint(&deadline, ktimeout); taia_add(&deadline, &now, &deadline); ktimeout =0; for (;;) { sig_unblock(sig_child); iopause(x, 1, &deadline, &now); sig_block(sig_child); while (read(selfpipe[0], &ch, 1) == 1) {} if (wait_nohang(&rc) == pid) { strerr_warn2(WARNING, "child terminated.", 0); break; } rc =111; taia_now(&now); if ((ktimeout =taia_less(&deadline, &now))) break; } if (ktimeout) { strerr_warn4(WARNING, "child \"", *argv, "\" not terminated. sending KILL...", 0); kill(pgroup ? -pid : pid, SIGKILL); } break; } if (rc == 0) break; if (verbose) strerr_warn2(WARNING, "child crashed.", 0); if (lseek(0, 0, SEEK_SET) != 0) if (verbose) strerr_warn2(WARNING, "unable to lseek fd 0: ", &strerr_sys); if (try >= trymax) break; sleep(1); } if (processor && (rc != 0)) { for (;;) { int r; char *s; r = buffer_feed(buffer_0); if (r < 0) { if ((errno == error_intr) || (errno == error_again)) continue; } if (r == 0) { break; } s =buffer_peek(buffer_0); buffer_putflush(buffer_1, s, r); buffer_seek(buffer_0, r); } } if (timeout) { if (processor) strerr_die2x(0, FATAL, "child timed out, giving up."); strerr_die2x(100, FATAL, "child timed out, giving up."); } if (try >= trymax) { if (processor) strerr_die2x(0, FATAL, "child crashed, giving up."); strerr_die2x(rc >> 8, FATAL, "child crashed, giving up."); } _exit(0); } socklog-2.1.1+repack/src/env.c0000644000000000000000000000047214702065454014650 0ustar rootroot/* Public domain. */ #include "str.h" #include "env.h" extern /*@null@*/char *env_get(const char *s) { int i; unsigned int len; if (!s) return 0; len = str_len(s); for (i = 0;environ[i];++i) if (str_start(environ[i],s) && (environ[i][len] == '=')) return environ[i] + len + 1; return 0; } socklog-2.1.1+repack/src/subgetopt.c0000644000000000000000000000260514702065454016074 0ustar rootroot/* Public domain. */ #define SUBGETOPTNOSHORT #include "subgetopt.h" #define sgopt subgetopt #define optind subgetoptind #define optpos subgetoptpos #define optarg subgetoptarg #define optproblem subgetoptproblem #define optdone subgetoptdone int optind = 1; int optpos = 0; const char *optarg = 0; int optproblem = 0; int optdone = SUBGETOPTDONE; int sgopt(int argc,char *const *argv,const char *opts) { int c; const char *s; optarg = 0; if (!argv || (optind >= argc) || !argv[optind]) return optdone; if (optpos && !argv[optind][optpos]) { ++optind; optpos = 0; if ((optind >= argc) || !argv[optind]) return optdone; } if (!optpos) { if (argv[optind][0] != '-') return optdone; ++optpos; c = argv[optind][1]; if ((c == '-') || (c == 0)) { if (c) ++optind; optpos = 0; return optdone; } /* otherwise c is reassigned below */ } c = argv[optind][optpos]; ++optpos; s = opts; while (*s) { if (c == *s) { if (s[1] == ':') { optarg = argv[optind] + optpos; ++optind; optpos = 0; if (!*optarg) { optarg = argv[optind]; if ((optind >= argc) || !optarg) { /* argument past end */ optproblem = c; return '?'; } ++optind; } } return c; } ++s; if (*s == ':') ++s; } optproblem = c; return '?'; } socklog-2.1.1+repack/src/uncat.c0000644000000000000000000000764514702065454015203 0ustar rootroot#include #include "strerr.h" #include "error.h" #include "sgetopt.h" #include "scan.h" #include "stralloc.h" #include "buffer.h" #include "pathexec.h" #include "fd.h" #include "wait.h" #include "taia.h" #include "iopause.h" #include "ndelay.h" #include "sig.h" /* defaults */ #define TIMEOUT 300 #define SIZEMAX 1024 #define USAGE " [-vo] [-t timeout] [-s size] prog" #define WARNING "uncat: warning: " #define FATAL "uncat: fatal: " const char *progname; int exitasap =0; void exit_asap() { exitasap =1; } void usage () { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } int main (int argc, char * const *argv, char * const *envp) { int opt; unsigned long timeout =TIMEOUT; unsigned long sizemax =SIZEMAX; int verbose =0; int once =0; static stralloc sa; int eof =0; progname =*argv; sig_block(sig_term); sig_catch(sig_term, exit_asap); while ((opt =getopt(argc, argv, "t:s:voV")) != opteof) { switch(opt) { case 'V': strerr_warn1("$Id$\n", 0); case '?': usage(); case 't': scan_ulong(optarg, &timeout); if (timeout <= 0) timeout =TIMEOUT; break; case 's': scan_ulong(optarg, &sizemax); if (sizemax <= 0) sizemax =SIZEMAX; break; case 'v': verbose =1; break; case 'o': once =1; break; } } argv +=optind; if (!*argv) usage(); if (verbose) strerr_warn2(WARNING, "starting.", 0); ndelay_on(0); for (;;) { struct taia now, deadline; int cpipe[2]; int pid; int wstat; stralloc_copys(&sa, ""); /* set timeout */ taia_now(&now); taia_uint(&deadline, timeout); taia_add(&deadline, &now, &deadline); /* read fd 0, stop at maxsize bytes or timeout */ for (;;) { int r; char *s; iopause_fd iofd; taia_now(&now); if (taia_less(&deadline, &now)) { if (verbose && sa.len) strerr_warn2(WARNING, "timeout reached.", 0); break; } iofd.fd =0; iofd.events =IOPAUSE_READ; sig_unblock(sig_term); iopause(&iofd, 1, &deadline, &now); sig_block(sig_term); if (exitasap) { if (verbose) strerr_warn2(WARNING, "got sigterm.", 0); break; } r =buffer_feed(buffer_0); if (r < 0) { if (errno == error_again) continue; strerr_die2sys(111, FATAL, "unable to read fd 0: "); } if (r == 0) { if (verbose) strerr_warn2(WARNING, "end of input.", 0); if (! once) continue; eof++; break; } if (r >= sizemax) r =sizemax; if ((sa.len +r) > sizemax) { if (verbose) strerr_warn2(WARNING, "max size reached.", 0); break; } s =buffer_peek(buffer_0); if (! stralloc_catb(&sa, s, r)) { strerr_die2sys(111, FATAL, "out of memory: "); } buffer_seek(buffer_0, r); } if (sa.len) { /* run prog to process sa.s */ if (pipe(cpipe) == -1) { strerr_die2sys(111, FATAL, "unable to create pipe for child: "); } while ((pid =fork()) == -1) { strerr_warn4(WARNING, "unable to fork for \"", *argv, "\" pausing: ", &strerr_sys); sleep(5); } if (!pid) { /* child */ sig_uncatch(sig_term); sig_unblock(sig_term); close(cpipe[1]); fd_move(0, cpipe[0]); fd_copy(1, 2); if (verbose) strerr_warn2(WARNING, "starting child.", 0); pathexec_run(*argv, argv, envp); strerr_die2sys(111, FATAL, "unable to start child: "); } close(cpipe[0]); if (write(cpipe[1], sa.s, sa.len) < sa.len) { strerr_warn2(WARNING, "unable to write to child: ", &strerr_sys); } close(cpipe[1]); if (wait_pid(&wstat, pid) != pid) { strerr_die2sys(111, FATAL, "wait_pid: "); } if (wait_crashed(wstat)) { strerr_warn2(WARNING, "child crashed.", 0); } else { if (verbose) strerr_warn2(WARNING, "child exited.", 0); } } if (exitasap || eof) break; } if (verbose) strerr_warn2(WARNING, "exit.", 0); _exit(0); } socklog-2.1.1+repack/src/socklog-check.dist0000644000000000000000000000040714702065454017313 0ustar rootroot$Id$ usage: socklog-check [-v] [unix [address]] 1 listening on socklog.check.socket, starting. 0 socklog-check: info: successfully connected to socklog.check.socket 0 socklog-check: warning: unable to connect socket: socklog.check.socket: connection refused 111 socklog-2.1.1+repack/src/tai_now.c0000644000000000000000000000017414702065454015517 0ustar rootroot/* Public domain. */ #include #include "tai.h" void tai_now(struct tai *t) { tai_unix(t,time((time_t *) 0)); } socklog-2.1.1+repack/src/tai_unpack.c0000644000000000000000000000063014702065454016172 0ustar rootroot/* Public domain. */ #include "tai.h" void tai_unpack(const char *s,struct tai *t) { uint64 x; x = (unsigned char) s[0]; x <<= 8; x += (unsigned char) s[1]; x <<= 8; x += (unsigned char) s[2]; x <<= 8; x += (unsigned char) s[3]; x <<= 8; x += (unsigned char) s[4]; x <<= 8; x += (unsigned char) s[5]; x <<= 8; x += (unsigned char) s[6]; x <<= 8; x += (unsigned char) s[7]; t->x = x; } socklog-2.1.1+repack/src/uint64.h10000644000000000000000000000017414702065454015276 0ustar rootroot/* Public domain. */ #ifndef UINT64_H #define UINT64_H /* sysdep: -ulong64 */ typedef unsigned long long uint64; #endif socklog-2.1.1+repack/src/conf-cc0000644000000000000000000000026114702065454015143 0ustar rootrootgcc -O2 -Wall gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings This will be used to compile .c files. socklog-2.1.1+repack/src/taia_sub.c0000644000000000000000000000071614702065454015650 0ustar rootroot/* Public domain. */ #include "taia.h" /* XXX: breaks tai encapsulation */ void taia_sub(struct taia *t,const struct taia *u,const struct taia *v) { unsigned long unano = u->nano; unsigned long uatto = u->atto; t->sec.x = u->sec.x - v->sec.x; t->nano = unano - v->nano; t->atto = uatto - v->atto; if (t->atto > uatto) { t->atto += 1000000000UL; --t->nano; } if (t->nano > unano) { t->nano += 1000000000UL; --t->sec.x; } } socklog-2.1.1+repack/src/strerr.h0000644000000000000000000000532214702065454015405 0ustar rootroot/* Public domain. */ #ifndef STRERR_H #define STRERR_H struct strerr { struct strerr *who; const char *x; const char *y; const char *z; } ; extern struct strerr strerr_sys; extern void strerr_sysinit(void); extern const char *strerr(const struct strerr *); extern void strerr_warn(const char *,const char *,const char *,const char *,const char *,const char *,const struct strerr *); extern void strerr_die(int,const char *,const char *,const char *,const char *,const char *,const char *,const struct strerr *); #define STRERR(r,se,a) \ { se.who = 0; se.x = a; se.y = 0; se.z = 0; return r; } #define STRERR_SYS(r,se,a) \ { se.who = &strerr_sys; se.x = a; se.y = 0; se.z = 0; return r; } #define STRERR_SYS3(r,se,a,b,c) \ { se.who = &strerr_sys; se.x = a; se.y = b; se.z = c; return r; } #define strerr_warn6(x1,x2,x3,x4,x5,x6,se) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(se)) #define strerr_warn5(x1,x2,x3,x4,x5,se) \ strerr_warn((x1),(x2),(x3),(x4),(x5),0,(se)) #define strerr_warn4(x1,x2,x3,x4,se) \ strerr_warn((x1),(x2),(x3),(x4),0,0,(se)) #define strerr_warn3(x1,x2,x3,se) \ strerr_warn((x1),(x2),(x3),0,0,0,(se)) #define strerr_warn2(x1,x2,se) \ strerr_warn((x1),(x2),0,0,0,0,(se)) #define strerr_warn1(x1,se) \ strerr_warn((x1),0,0,0,0,0,(se)) #define strerr_die6(e,x1,x2,x3,x4,x5,x6,se) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),(se)) #define strerr_die5(e,x1,x2,x3,x4,x5,se) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),0,(se)) #define strerr_die4(e,x1,x2,x3,x4,se) \ strerr_die((e),(x1),(x2),(x3),(x4),0,0,(se)) #define strerr_die3(e,x1,x2,x3,se) \ strerr_die((e),(x1),(x2),(x3),0,0,0,(se)) #define strerr_die2(e,x1,x2,se) \ strerr_die((e),(x1),(x2),0,0,0,0,(se)) #define strerr_die1(e,x1,se) \ strerr_die((e),(x1),0,0,0,0,0,(se)) #define strerr_die6sys(e,x1,x2,x3,x4,x5,x6) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),&strerr_sys) #define strerr_die5sys(e,x1,x2,x3,x4,x5) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),0,&strerr_sys) #define strerr_die4sys(e,x1,x2,x3,x4) \ strerr_die((e),(x1),(x2),(x3),(x4),0,0,&strerr_sys) #define strerr_die3sys(e,x1,x2,x3) \ strerr_die((e),(x1),(x2),(x3),0,0,0,&strerr_sys) #define strerr_die2sys(e,x1,x2) \ strerr_die((e),(x1),(x2),0,0,0,0,&strerr_sys) #define strerr_die1sys(e,x1) \ strerr_die((e),(x1),0,0,0,0,0,&strerr_sys) #define strerr_die6x(e,x1,x2,x3,x4,x5,x6) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),0) #define strerr_die5x(e,x1,x2,x3,x4,x5) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),0,0) #define strerr_die4x(e,x1,x2,x3,x4) \ strerr_die((e),(x1),(x2),(x3),(x4),0,0,0) #define strerr_die3x(e,x1,x2,x3) \ strerr_die((e),(x1),(x2),(x3),0,0,0,0) #define strerr_die2x(e,x1,x2) \ strerr_die((e),(x1),(x2),0,0,0,0,0) #define strerr_die1x(e,x1) \ strerr_die((e),(x1),0,0,0,0,0,0) #endif socklog-2.1.1+repack/src/lock_exnb.c0000644000000000000000000000041214702065454016016 0ustar rootroot/* Public domain. */ #include #include #include #include "hasflock.h" #include "lock.h" #ifdef HASFLOCK int lock_exnb(int fd) { return flock(fd,LOCK_EX | LOCK_NB); } #else int lock_exnb(int fd) { return lockf(fd,2,0); } #endif socklog-2.1.1+repack/src/str.h0000644000000000000000000000070414702065454014673 0ustar rootroot/* Public domain. */ #ifndef STR_H #define STR_H extern unsigned int str_copy(char *,const char *); extern int str_diff(const char *,const char *); extern int str_diffn(const char *,const char *,unsigned int); extern unsigned int str_len(const char *); extern unsigned int str_chr(const char *,int); extern unsigned int str_rchr(const char *,int); extern int str_start(const char *,const char *); #define str_equal(s,t) (!str_diff((s),(t))) #endif socklog-2.1.1+repack/src/error.c0000644000000000000000000000232114702065454015204 0ustar rootroot/* Public domain. */ #include #include "error.h" /* warning: as coverage improves here, should update error_{str,temp} */ int error_intr = #ifdef EINTR EINTR; #else -1; #endif int error_nomem = #ifdef ENOMEM ENOMEM; #else -2; #endif int error_noent = #ifdef ENOENT ENOENT; #else -3; #endif int error_txtbsy = #ifdef ETXTBSY ETXTBSY; #else -4; #endif int error_io = #ifdef EIO EIO; #else -5; #endif int error_exist = #ifdef EEXIST EEXIST; #else -6; #endif int error_timeout = #ifdef ETIMEDOUT ETIMEDOUT; #else -7; #endif int error_inprogress = #ifdef EINPROGRESS EINPROGRESS; #else -8; #endif int error_wouldblock = #ifdef EWOULDBLOCK EWOULDBLOCK; #else -9; #endif int error_again = #ifdef EAGAIN EAGAIN; #else -10; #endif int error_pipe = #ifdef EPIPE EPIPE; #else -11; #endif int error_perm = #ifdef EPERM EPERM; #else -12; #endif int error_acces = #ifdef EACCES EACCES; #else -13; #endif int error_nodevice = #ifdef ENXIO ENXIO; #else -14; #endif int error_proto = #ifdef EPROTO EPROTO; #else -15; #endif int error_isdir = #ifdef EISDIR EISDIR; #else -16; #endif int error_connrefused = #ifdef ECONNREFUSED ECONNREFUSED; #else -17; #endif int error_notdir = #ifdef ENOTDIR ENOTDIR; #else -18; #endif socklog-2.1.1+repack/src/str_start.c0000644000000000000000000000056214702065454016105 0ustar rootroot/* Public domain. */ #include "str.h" int str_start(register const char *s,register const char *t) { register char x; for (;;) { x = *t++; if (!x) return 1; if (x != *s++) return 0; x = *t++; if (!x) return 1; if (x != *s++) return 0; x = *t++; if (!x) return 1; if (x != *s++) return 0; x = *t++; if (!x) return 1; if (x != *s++) return 0; } } socklog-2.1.1+repack/src/trysgact.c0000644000000000000000000000030014702065454015706 0ustar rootroot/* Public domain. */ #include int main() { struct sigaction sa; sa.sa_handler = 0; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(0,&sa,(struct sigaction *) 0); } socklog-2.1.1+repack/src/fmt_uint.c0000644000000000000000000000020514702065454015677 0ustar rootroot/* Public domain. */ #include "fmt.h" unsigned int fmt_uint(register char *s,register unsigned int u) { return fmt_ulong(s,u); } socklog-2.1.1+repack/src/hasflock.h20000644000000000000000000000007614702065454015741 0ustar rootroot/* Public domain. */ /* sysdep: +flock */ #define HASFLOCK 1 socklog-2.1.1+repack/src/readclose.h0000644000000000000000000000031314702065454016020 0ustar rootroot/* Public domain. */ #ifndef READCLOSE_H #define READCLOSE_H #include "stralloc.h" extern int readclose_append(int,stralloc *,unsigned int); extern int readclose(int,stralloc *,unsigned int); #endif socklog-2.1.1+repack/src/tryulong64.c0000644000000000000000000000057614702065454016122 0ustar rootroot/* Public domain. */ #include int main() { unsigned long u; u = 1; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; if (!u) _exit(1); _exit(0); } socklog-2.1.1+repack/src/buffer_2.c0000644000000000000000000000026614702065454015553 0ustar rootroot/* Public domain. */ #include "buffer.h" char buffer_2_space[256]; static buffer it = BUFFER_INIT(buffer_unixwrite,2,buffer_2_space,sizeof buffer_2_space); buffer *buffer_2 = ⁢ socklog-2.1.1+repack/src/check-dist0000755000000000000000000000026514702065454015660 0ustar rootroot#!/bin/sh PATH=`pwd`:$PATH for i in `cat ../package/commands`; do echo "Creating new $i.dist..." env - PATH="$PATH" ctmp="`pwd`/check-tmp" $i.check 2>&1 |cat -v >$i.dist done socklog-2.1.1+repack/src/tryto.dist0000644000000000000000000000103214702065454015753 0ustar rootrootusage: tryto [-vp] [-t seconds] [-k kseconds] [-n tries] prog 1 $Id$ usage: tryto [-vp] [-t seconds] [-k kseconds] [-n tries] prog 1 0 tryto: warning: child crashed. tryto: warning: child crashed. tryto: fatal: child crashed, giving up. 1 tryto: warning: child "sleep" timed out. sending TERM... tryto: warning: child terminated. tryto: fatal: child timed out, giving up. 100 tryto: warning: child "sh" timed out. sending TERM... tryto: warning: child "sh" not terminated. sending KILL... tryto: fatal: child timed out, giving up. 100 socklog-2.1.1+repack/src/coe.h0000644000000000000000000000012014702065454014621 0ustar rootroot/* Public domain. */ #ifndef COE_H #define COE_H extern int coe(int); #endif socklog-2.1.1+repack/src/tai.h0000644000000000000000000000116214702065454014637 0ustar rootroot/* Public domain. */ #ifndef TAI_H #define TAI_H #include "uint64.h" struct tai { uint64 x; } ; #define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64) (u))) extern void tai_now(struct tai *); #define tai_approx(t) ((double) ((t)->x)) extern void tai_add(struct tai *,const struct tai *,const struct tai *); extern void tai_sub(struct tai *,const struct tai *,const struct tai *); #define tai_less(t,u) ((t)->x < (u)->x) #define TAI_PACK 8 extern void tai_pack(char *,const struct tai *); extern void tai_unpack(const char *,struct tai *); extern void tai_uint(struct tai *,unsigned int); #endif socklog-2.1.1+repack/src/stralloc.h0000644000000000000000000000222714702065454015710 0ustar rootroot/* Public domain. */ #ifndef STRALLOC_H #define STRALLOC_H #include "gen_alloc.h" GEN_ALLOC_typedef(stralloc,char,s,len,a) extern int stralloc_ready(stralloc *,unsigned int); extern int stralloc_readyplus(stralloc *,unsigned int); extern int stralloc_copy(stralloc *,const stralloc *); extern int stralloc_cat(stralloc *,const stralloc *); extern int stralloc_copys(stralloc *,const char *); extern int stralloc_cats(stralloc *,const char *); extern int stralloc_copyb(stralloc *,const char *,unsigned int); extern int stralloc_catb(stralloc *,const char *,unsigned int); extern int stralloc_append(stralloc *,const char *); /* beware: this takes a pointer to 1 char */ extern int stralloc_starts(stralloc *,const char *); #define stralloc_0(sa) stralloc_append(sa,"") extern int stralloc_catulong0(stralloc *,unsigned long,unsigned int); extern int stralloc_catlong0(stralloc *,long,unsigned int); #define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0)) #define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n))) #define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(i),(n))) #define stralloc_catint(sa,i) (stralloc_catlong0((sa),(i),0)) #endif socklog-2.1.1+repack/src/env.h0000644000000000000000000000020114702065454014643 0ustar rootroot/* Public domain. */ #ifndef ENV_H #define ENV_H extern char **environ; extern /*@null@*/char *env_get(const char *); #endif socklog-2.1.1+repack/src/trydrent.c0000644000000000000000000000016114702065454015726 0ustar rootroot/* Public domain. */ #include #include void foo() { DIR *dir; struct dirent *d; } socklog-2.1.1+repack/src/open_append.c0000644000000000000000000000026614702065454016351 0ustar rootroot/* Public domain. */ #include #include #include "open.h" int open_append(const char *fn) { return open(fn,O_WRONLY | O_NDELAY | O_APPEND | O_CREAT,0600); } socklog-2.1.1+repack/src/sgetopt.c0000644000000000000000000000241714702065454015546 0ustar rootroot/* Public domain. */ /* sgetopt.c, sgetopt.h: (yet another) improved getopt clone, outer layer D. J. Bernstein, djb@pobox.com. Depends on subgetopt.h, buffer.h. No system requirements. 19991219: Switched to buffer.h. 19970208: Cleanups. 931201: Baseline. No known patent problems. Documentation in sgetopt.3. */ #include "buffer.h" #define SGETOPTNOSHORT #include "sgetopt.h" #define SUBGETOPTNOSHORT #include "subgetopt.h" #define getopt sgetoptmine #define optind subgetoptind #define opterr sgetopterr #define optproblem subgetoptproblem #define optprogname sgetoptprogname int opterr = 1; const char *optprogname = 0; int getopt(int argc,char *const *argv,const char *opts) { int c; const char *s; if (!optprogname) { optprogname = *argv; if (!optprogname) optprogname = ""; for (s = optprogname;*s;++s) if (*s == '/') optprogname = s + 1; } c = subgetopt(argc,argv,opts); if (opterr) if (c == '?') { char chp[2]; chp[0] = optproblem; chp[1] = '\n'; buffer_puts(buffer_2,optprogname); if (argv[optind] && (optind < argc)) buffer_puts(buffer_2,": illegal option -- "); else buffer_puts(buffer_2,": option requires an argument -- "); buffer_put(buffer_2,chp,2); buffer_flush(buffer_2); } return c; } socklog-2.1.1+repack/src/error.h0000644000000000000000000000125114702065454015212 0ustar rootroot/* Public domain. */ #ifndef ERROR_H #define ERROR_H /* 20030126: include -upcoming glibc changes */ #include /* extern int errno; */ extern int error_intr; extern int error_nomem; extern int error_noent; extern int error_txtbsy; extern int error_io; extern int error_exist; extern int error_timeout; extern int error_inprogress; extern int error_wouldblock; extern int error_again; extern int error_pipe; extern int error_perm; extern int error_acces; extern int error_nodevice; extern int error_proto; extern int error_isdir; extern int error_connrefused; extern int error_notdir; extern const char *error_str(int); extern int error_temp(int); #endif socklog-2.1.1+repack/src/hassgprm.h20000644000000000000000000000011214702065454015762 0ustar rootroot/* Public domain. */ /* sysdep: +sigprocmask */ #define HASSIGPROCMASK 1 socklog-2.1.1+repack/src/str_diff.c0000644000000000000000000000072314702065454015657 0ustar rootroot/* Public domain. */ #include "str.h" int str_diff(register const char *s,register const char *t) { register char x; for (;;) { x = *s; if (x != *t) break; if (!x) break; ++s; ++t; x = *s; if (x != *t) break; if (!x) break; ++s; ++t; x = *s; if (x != *t) break; if (!x) break; ++s; ++t; x = *s; if (x != *t) break; if (!x) break; ++s; ++t; } return ((int)(unsigned int)(unsigned char) x) - ((int)(unsigned int)(unsigned char) *t); } socklog-2.1.1+repack/src/sig_catch.c0000644000000000000000000000055314702065454016004 0ustar rootroot/* Public domain. */ #include #include "sig.h" #include "hassgact.h" void sig_catch(int sig,void (*f)()) { #ifdef HASSIGACTION struct sigaction sa; sa.sa_handler = f; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(sig,&sa,(struct sigaction *) 0); #else signal(sig,f); /* won't work under System V, even nowadays---dorks */ #endif } socklog-2.1.1+repack/src/stralloc_opyb.c0000644000000000000000000000042114702065454016726 0ustar rootroot/* Public domain. */ #include "stralloc.h" #include "byte.h" int stralloc_copyb(stralloc *sa,const char *s,unsigned int n) { if (!stralloc_ready(sa,n + 1)) return 0; byte_copy(sa->s,n,s); sa->len = n; sa->s[n] = 'Z'; /* ``offensive programming'' */ return 1; } socklog-2.1.1+repack/src/uint64.h20000644000000000000000000000016714702065454015301 0ustar rootroot/* Public domain. */ #ifndef UINT64_H #define UINT64_H /* sysdep: +ulong64 */ typedef unsigned long uint64; #endif socklog-2.1.1+repack/src/open_write.c0000644000000000000000000000023314702065454016226 0ustar rootroot/* Public domain. */ #include #include #include "open.h" int open_write(const char *fn) { return open(fn,O_WRONLY | O_NDELAY); } socklog-2.1.1+repack/src/direntry.h10000644000000000000000000000024714702065454016006 0ustar rootroot/* Public domain. */ #ifndef DIRENTRY_H #define DIRENTRY_H /* sysdep: -dirent */ #include #include #define direntry struct direct #endif socklog-2.1.1+repack/src/pathexec.h0000644000000000000000000000034514702065454015665 0ustar rootroot/* Public domain. */ #ifndef PATHEXEC_H #define PATHEXEC_H extern void pathexec_run(const char *,char * const *,char * const *); extern int pathexec_env(const char *,const char *); extern void pathexec(char * const *); #endif socklog-2.1.1+repack/src/sig.c0000644000000000000000000000046514702065454014644 0ustar rootroot/* Public domain. */ #include #include "sig.h" int sig_alarm = SIGALRM; int sig_child = SIGCHLD; int sig_cont = SIGCONT; int sig_hangup = SIGHUP; int sig_int = SIGINT; int sig_pipe = SIGPIPE; int sig_term = SIGTERM; void (*sig_defaulthandler)() = SIG_DFL; void (*sig_ignorehandler)() = SIG_IGN; socklog-2.1.1+repack/src/iopause.h20000644000000000000000000000052314702065454015611 0ustar rootroot/* Public domain. */ #ifndef IOPAUSE_H #define IOPAUSE_H /* sysdep: +poll */ #define IOPAUSE_POLL #include #include typedef struct pollfd iopause_fd; #define IOPAUSE_READ POLLIN #define IOPAUSE_WRITE POLLOUT #include "taia.h" extern void iopause(iopause_fd *,unsigned int,struct taia *,struct taia *); #endif socklog-2.1.1+repack/src/buffer_1.c0000644000000000000000000000030114702065454015540 0ustar rootroot/* Public domain. */ #include "buffer.h" char buffer_1_space[BUFFER_OUTSIZE]; static buffer it = BUFFER_INIT(buffer_unixwrite,1,buffer_1_space,sizeof buffer_1_space); buffer *buffer_1 = ⁢ socklog-2.1.1+repack/src/coe.c0000644000000000000000000000015514702065454014624 0ustar rootroot/* Public domain. */ #include #include "coe.h" int coe(int fd) { return fcntl(fd,F_SETFD,1); } socklog-2.1.1+repack/src/x86cpuid.c0000644000000000000000000000132014702065454015523 0ustar rootroot/* Public domain. */ #include #include #include void nope() { exit(1); } int main() { unsigned long x[4]; unsigned long y[4]; int i; int j; char c; signal(SIGILL,nope); x[0] = y[0] = 0; x[1] = y[1] = 0; x[2] = y[2] = 0; x[3] = y[3] = 0; asm volatile(".byte 15;.byte 162" : "=a"(x[0]),"=b"(x[1]),"=c"(x[3]),"=d"(x[2]) : "0"(0) ); if (!x[0]) return 0; asm volatile(".byte 15;.byte 162" : "=a"(y[0]),"=b"(y[1]),"=c"(y[2]),"=d"(y[3]) : "0"(1) ); for (i = 1;i < 4;++i) for (j = 0;j < 4;++j) { c = x[i] >> (8 * j); if (c < 32) c = 32; if (c > 126) c = 126; putchar(c); } printf("-%08lx-%08lx\n",y[0],y[3]); return 0; } socklog-2.1.1+repack/src/byte_copy.c0000644000000000000000000000050114702065454016046 0ustar rootroot/* Public domain. */ #include "byte.h" void byte_copy(to,n,from) register char *to; register unsigned int n; register char *from; { for (;;) { if (!n) return; *to++ = *from++; --n; if (!n) return; *to++ = *from++; --n; if (!n) return; *to++ = *from++; --n; if (!n) return; *to++ = *from++; --n; } } socklog-2.1.1+repack/src/stralloc_cats.c0000644000000000000000000000025314702065454016712 0ustar rootroot/* Public domain. */ #include "byte.h" #include "str.h" #include "stralloc.h" int stralloc_cats(stralloc *sa,const char *s) { return stralloc_catb(sa,s,str_len(s)); } socklog-2.1.1+repack/src/sig.h0000644000000000000000000000111314702065454014640 0ustar rootroot/* Public domain. */ #ifndef SIG_H #define SIG_H extern int sig_alarm; extern int sig_child; extern int sig_cont; extern int sig_hangup; extern int sig_int; extern int sig_pipe; extern int sig_term; extern void (*sig_defaulthandler)(); extern void (*sig_ignorehandler)(); extern void sig_catch(int,void (*)()); #define sig_ignore(s) (sig_catch((s),sig_ignorehandler)) #define sig_uncatch(s) (sig_catch((s),sig_defaulthandler)) extern void sig_block(int); extern void sig_unblock(int); extern void sig_blocknone(void); extern void sig_pause(void); extern void sig_dfl(int); #endif socklog-2.1.1+repack/src/stralloc_eady.c0000644000000000000000000000034114702065454016700 0ustar rootroot/* Public domain. */ #include "alloc.h" #include "stralloc.h" #include "gen_allocdefs.h" GEN_ALLOC_ready(stralloc,char,s,len,a,i,n,x,30,stralloc_ready) GEN_ALLOC_readyplus(stralloc,char,s,len,a,i,n,x,30,stralloc_readyplus) socklog-2.1.1+repack/src/tryto.check0000755000000000000000000000033714702065454016077 0ustar rootroot#!/bin/sh exec sec.x = u->sec.x + v->sec.x; t->nano = u->nano + v->nano; t->atto = u->atto + v->atto; if (t->atto > 999999999UL) { t->atto -= 1000000000UL; ++t->nano; } if (t->nano > 999999999UL) { t->nano -= 1000000000UL; ++t->sec.x; } } socklog-2.1.1+repack/src/trycpp.c0000644000000000000000000000024114702065454015373 0ustar rootroot/* Public domain. */ #include #include int main() { #ifdef NeXT printf("nextstep\n"); exit(0); #endif printf("unknown\n"); exit(0); } socklog-2.1.1+repack/src/socklog-check.c0000644000000000000000000000270314702065454016573 0ustar rootroot#include #include #include #include #include #include "strerr.h" #include "byte.h" #include "sgetopt.h" #define FATAL "socklog-check: fatal: " #define WARNING "socklog-check: warning: " #define INFO "socklog-check: info: " #define VERSION "$Id$" #define USAGE " [-v] [unix [address]]" const char *progname; void usage() { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } int s; struct sockaddr_un sa; const char *address ="/dev/log"; unsigned int verbose =0; int main(int argc, char **argv) { int opt; progname =*argv; while ((opt =getopt(argc, argv, "vV")) != opteof) { switch(opt) { case 'v': verbose =1; break; case 'V': strerr_warn1(VERSION, 0); case '?': usage(); } } argv +=optind; if (argv && *argv) { if (**argv != 'u') usage(); if (++argv && *argv) address =*argv; } if ((s =socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) strerr_die4sys(111, FATAL, "unable to create socket: ", address, ": "); byte_zero(&sa, sizeof(sa)); sa.sun_family =AF_UNIX; strncpy(sa.sun_path, address, sizeof(sa.sun_path)); if (connect(s, (struct sockaddr *)&sa, sizeof(sa)) == -1) { close(s); #ifdef EDESTADDRREQ if (errno == EDESTADDRREQ) errno =error_connrefused; #endif strerr_die4sys(111, WARNING, "unable to connect socket: ", address, ": "); } close(s); if (verbose) strerr_die3x(0, INFO, "successfully connected to ", address); return(0); } socklog-2.1.1+repack/src/buffer_put.c0000644000000000000000000000341514702065454016221 0ustar rootroot/* Public domain. */ #include "buffer.h" #include "str.h" #include "byte.h" #include "error.h" static int allwrite(int (*op)(),int fd,const char *buf,unsigned int len) { int w; while (len) { w = op(fd,buf,len); if (w == -1) { if (errno == error_intr) continue; return -1; /* note that some data may have been written */ } if (w == 0) ; /* luser's fault */ buf += w; len -= w; } return 0; } int buffer_flush(buffer *s) { int p; p = s->p; if (!p) return 0; s->p = 0; return allwrite(s->op,s->fd,s->x,p); } int buffer_putalign(buffer *s,const char *buf,unsigned int len) { unsigned int n; while (len > (n = s->n - s->p)) { byte_copy(s->x + s->p,n,buf); s->p += n; buf += n; len -= n; if (buffer_flush(s) == -1) return -1; } /* now len <= s->n - s->p */ byte_copy(s->x + s->p,len,buf); s->p += len; return 0; } int buffer_put(buffer *s,const char *buf,unsigned int len) { unsigned int n; n = s->n; if (len > n - s->p) { if (buffer_flush(s) == -1) return -1; /* now s->p == 0 */ if (n < BUFFER_OUTSIZE) n = BUFFER_OUTSIZE; while (len > s->n) { if (n > len) n = len; if (allwrite(s->op,s->fd,buf,n) == -1) return -1; buf += n; len -= n; } } /* now len <= s->n - s->p */ byte_copy(s->x + s->p,len,buf); s->p += len; return 0; } int buffer_putflush(buffer *s,const char *buf,unsigned int len) { if (buffer_flush(s) == -1) return -1; return allwrite(s->op,s->fd,buf,len); } int buffer_putsalign(buffer *s,const char *buf) { return buffer_putalign(s,buf,str_len(buf)); } int buffer_puts(buffer *s,const char *buf) { return buffer_put(s,buf,str_len(buf)); } int buffer_putsflush(buffer *s,const char *buf) { return buffer_putflush(s,buf,str_len(buf)); } socklog-2.1.1+repack/src/hasflock.h10000644000000000000000000000005314702065454015733 0ustar rootroot/* Public domain. */ /* sysdep: -flock */ socklog-2.1.1+repack/src/check-socklog-unix.c0000644000000000000000000000126214702065454017553 0ustar rootroot#include #include #include #include #include #include #include "error.h" #include "strerr.h" #include "byte.h" int s; struct sockaddr_un sa; int main() { s =socket(AF_UNIX, SOCK_DGRAM, 0); if (s == -1) strerr_die1sys(111, "fatal: unable to create socket: "); byte_zero(&sa, sizeof(sa)); sa.sun_family =AF_UNIX; strcpy(sa.sun_path, "socklog.check.socket"); if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) == -1) strerr_die1sys(111, "fatal: unable to connect socket: "); if (write(s, "foo\n", 4) != 4) strerr_die1sys(111, "fatal: unable to write to socket: "); close(s); return(0); } socklog-2.1.1+repack/src/alloc.c0000644000000000000000000000150014702065454015143 0ustar rootroot/* Public domain. */ #include #include "alloc.h" #include "error.h" #define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */ #define SPACE 2048 /* must be multiple of ALIGNMENT */ typedef union { char irrelevant[ALIGNMENT]; double d; } aligned; static aligned realspace[SPACE / ALIGNMENT]; #define space ((char *) realspace) static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */ /*@null@*//*@out@*/char *alloc(n) unsigned int n; { char *x; n = ALIGNMENT + n - (n & (ALIGNMENT - 1)); /* XXX: could overflow */ if (n <= avail) { avail -= n; return space + avail; } x = malloc(n); if (!x) errno = error_nomem; return x; } void alloc_free(x) char *x; { if (x >= space) if (x < space + SPACE) return; /* XXX: assuming that pointers are flat */ free(x); } socklog-2.1.1+repack/src/byte_cr.c0000644000000000000000000000053214702065454015504 0ustar rootroot/* Public domain. */ #include "byte.h" void byte_copyr(to,n,from) register char *to; register unsigned int n; register char *from; { to += n; from += n; for (;;) { if (!n) return; *--to = *--from; --n; if (!n) return; *--to = *--from; --n; if (!n) return; *--to = *--from; --n; if (!n) return; *--to = *--from; --n; } } socklog-2.1.1+repack/src/alloc.h0000644000000000000000000000023114702065454015150 0ustar rootroot/* Public domain. */ #ifndef ALLOC_H #define ALLOC_H extern /*@null@*//*@out@*/char *alloc(); extern void alloc_free(); extern int alloc_re(); #endif socklog-2.1.1+repack/src/print-ld.sh0000644000000000000000000000021314702065454015772 0ustar rootrootld="`head -n1 conf-ld`" systype="`cat systype`" cat warn-auto.sh echo 'main="$1"; shift' echo exec "$ld" '-o "$main" "$main".o ${1+"$@"}' socklog-2.1.1+repack/src/uncat.check0000755000000000000000000000033014702065454016021 0ustar rootroot#!/bin/sh uncat echo $? uncat -V echo $? ( echo foo; sleep 1; echo bar ) |uncat -vot14 cat echo $? ( echo foo; sleep 3; echo bar ) |uncat -vot2 cat echo $? ( echo foo; echo bar; echo baz ) |uncat -vos4 cat echo $? socklog-2.1.1+repack/src/socklog-conf.c0000644000000000000000000002354714702065454016454 0ustar rootroot#include #include #include #include #include #include #include "error.h" #include "strerr.h" #include "open.h" #include "buffer.h" #if defined(__sun__) && defined(__sparc__) && defined(__unix__) && defined(__svr4__) #define SOLARIS #include #include "scan.h" #endif #ifndef SOLARIS #include #endif #ifndef _PATH_KLOG #define _PATH_KLOG "/dev/klog" #endif #define USAGE1 " unix|inet|klog|ucspi acct logacct [/etc/sv] [/logdir]" #define USAGE2 " notify acct grp [/etc/sv] [pipe]" #define VERSION "$Id$" #define WARNING "socklog-conf: warning: " #define FATAL "socklog-conf: fatal: " #define CONF_DIR "/etc/sv" #define LOG_DIR_UNIX "/var/log/socklog" #define LOG_DIR_INET "/var/log/socklog-inet" #define LOG_DIR_UCSPI_TCP "/var/log/socklog-ucspi-tcp" #define LOG_DIR_KLOG "/var/log/socklog-klog" #define PATH_NOTIFY "/var/log/socklog/.notify" #define CONF_UNIX 0 #define CONF_INET 1 #define CONF_UCSPI_TCP 2 #define CONF_NOTIFY 3 #define CONF_KLOG 4 const char *progname; void usage() { strerr_warn3("usage: ", progname, USAGE1, 0); strerr_die4x(1, "usage: ", progname, USAGE2, "\n"); } const char *dir; const char *fn; char buf[1024]; int fd; buffer b; char *user; char *loguser; const char *path; struct passwd *upw, *pw; struct group *gr; void fail() { if (fn[0] == '/') strerr_die4sys(111, FATAL, "unable to create ", fn, ": "); else strerr_die6sys(111, FATAL, "unable to create ", dir, "/", fn, ": "); } void start(const char *s) { fn = s; fd = open_trunc(fn); if (fd == -1) fail(); buffer_init(&b, buffer_unixwrite, fd, buf, sizeof buf); } void outs(const char *s) { if (buffer_puts(&b, s) == -1) fail(); } void finish(void) { if (buffer_flush(&b) == -1) fail(); if (fsync(fd) == -1) fail(); close(fd); } void perm(int mode) { if (chmod(fn, mode) == -1) fail(); } void mkfile(const char *f, const char *s) { start(f); outs(s); outs("\n"); finish(); } void makedir(const char *s) { fn =s; if (mkdir(fn, 0750) == -1) fail(); } void makechdir(const char *s) { makedir(s); if (chown(s, pw->pw_uid, pw->pw_gid) == -1) strerr_die6sys(111, FATAL, "unable to set owner of ", dir, "/", s, ": "); } void conf_unix() { #ifdef SOLARIS #if WANT_SUN_DOOR struct utsname u; unsigned long sunos_version; uname(&u); scan_ulong(u.release+strlen(u.release)-1, &sunos_version); #endif #endif makedir("socklog-unix"); perm(0750); makedir("socklog-unix/log"); perm(0755); makechdir(path); if (symlink(path, "socklog-unix/log/main") == -1) strerr_die4sys(111, FATAL, "unable to link ", path, ": "); makechdir("socklog-unix/log/main/auth"); mkfile("socklog-unix/log/main/auth/config", "s999999\nn5\n-*\n+auth.*\n+authpriv.*"); makechdir("socklog-unix/log/main/cron"); mkfile("socklog-unix/log/main/cron/config", "s999999\nn5\n-*\n+cron.*"); makechdir("socklog-unix/log/main/daemon"); mkfile("socklog-unix/log/main/daemon/config", "s999999\nn5\n-*\n+daemon.*"); makechdir("socklog-unix/log/main/debug"); mkfile("socklog-unix/log/main/debug/config", "s999999\nn5\n-*\n+*.debug*"); makechdir("socklog-unix/log/main/ftp"); mkfile("socklog-unix/log/main/ftp/config", "s999999\nn5\n-*\n+ftp.*"); makechdir("socklog-unix/log/main/kern"); mkfile("socklog-unix/log/main/kern/config", "s999999\nn5\n-*\n+kern.*"); makechdir("socklog-unix/log/main/local"); mkfile("socklog-unix/log/main/local/config", "s999999\nn5\n-*\n+local.*"); makechdir("socklog-unix/log/main/mail"); mkfile("socklog-unix/log/main/mail/config", "s999999\nn5\n-*\n+mail.*"); makechdir("socklog-unix/log/main/main"); mkfile("socklog-unix/log/main/main/config", "s999999\nn10"); makechdir("socklog-unix/log/main/news"); mkfile("socklog-unix/log/main/news/config", "s999999\nn5\n-*\n+news.*"); makechdir("socklog-unix/log/main/syslog"); mkfile("socklog-unix/log/main/syslog/config", "s999999\nn5\n-*\n+syslog.*"); makechdir("socklog-unix/log/main/user"); mkfile("socklog-unix/log/main/user/config", "s999999\nn5\n-*\n+user.*"); start("socklog-unix/run"); outs("#!/bin/sh\n"); outs("exec 2>&1\n"); #ifndef SOLARIS outs("exec chpst -U"); outs(user); outs(" socklog unix /dev/log\n"); #else outs("exec chpst -U"); outs(user); outs(" socklog sun_stream /dev/log"); #if WANT_SUN_DOOR if (sunos_version == 7) outs(" /etc/.syslog_door"); if (sunos_version >= 8) outs(" /var/run/syslog_door"); #endif outs("\n"); #endif finish(); perm(0750); start("socklog-unix/check"); outs("#!/bin/sh\n"); outs("exec 2>/dev/null\n"); outs("exec socklog-check unix /dev/log\n"); finish(); perm(0755); start("socklog-unix/log/run"); outs("#!/bin/sh\n"); outs("exec chpst -u"); outs(loguser); outs(" svlogd \\\n"); outs(" main/main main/auth main/cron main/daemon main/debug main/ftp \\\n"); outs(" main/kern main/local main/mail main/news main/syslog main/user\n"); finish(); perm(0750); } void conf_inet() { makedir("socklog-inet"); perm(0750); makedir("socklog-inet/log"); perm(0755); makechdir(path); if (symlink(path, "socklog-inet/log/main") == -1) strerr_die4sys(111, FATAL, "unable to link ", path, ": "); makechdir("socklog-inet/log/main/main"); mkfile("socklog-inet/log/main/main/config", "s999999\nn10"); start("socklog-inet/run"); outs("#!/bin/sh\n"); outs("exec 2>&1\n"); outs("exec chpst -U"); outs(user); outs(" socklog inet 0 514\n"); finish(); perm(0750); start("socklog-inet/log/run"); outs("#!/bin/sh\n"); outs("exec chpst -u"); outs(loguser); outs(" svlogd -t main/main\n"); finish(); perm(0750); } void conf_ucspi_tcp() { makedir("socklog-ucspi-tcp"); perm(0750); makedir("socklog-ucspi-tcp/log"); perm(0755); makechdir(path); if (symlink(path, "socklog-ucspi-tcp/log/main") == -1) strerr_die4sys(111, FATAL, "unable to link ", path, ": "); makechdir("socklog-ucspi-tcp/log/main/main"); mkfile("socklog-ucspi-tcp/log/main/main/config", "s999999\nn10"); start("socklog-ucspi-tcp/run"); outs("#!/bin/sh\n"); outs("PORT=10116\n"); outs("exec 2>&1\n"); outs("exec tcpsvd -vllogserver -u"); outs(user); outs(" 0 \"$PORT\" socklog ucspi TCPREMOTEIP\n"); finish(); perm(0750); start("socklog-ucspi-tcp/log/run"); outs("#!/bin/sh\n"); outs("exec chpst -u"); outs(loguser); outs(" svlogd -t main/main\n"); finish(); perm(0750); } void conf_klog() { makedir("socklog-klog"); perm(0750); makedir("socklog-klog/log"); perm(0755); makechdir(path); if (symlink(path, "socklog-klog/log/main") == -1) strerr_die4sys(111, FATAL, "unable to link ", path, ": "); makechdir("socklog-klog/log/main/main"); mkfile("socklog-klog/log/main/main/config", "s999999\nn10"); start("socklog-klog/run"); outs("#!/bin/sh\n"); outs("exec <"); outs(_PATH_KLOG); outs("\n"); outs("exec 2>&1\n"); outs("exec chpst -u"); outs(user); outs(" socklog ucspi\n"); finish(); perm(0750); start("socklog-klog/log/run"); outs("#!/bin/sh\n"); outs("exec chpst -u"); outs(loguser); outs(" svlogd -t main/main\n"); finish(); perm(0750); } void conf_notify() { makedir("socklog-notify"); perm(0755); umask(007); if (mkfifo(path, 0620) == -1) strerr_die4sys(111, FATAL, "unable to create \"", path, "\": "); umask(022); if (chown(path, upw->pw_uid, gr->gr_gid) == -1) strerr_die4sys(111, FATAL, "unable to set owner of ", path, ": "); start("socklog-notify/run"); outs("#!/bin/sh -e\n"); outs("MAILTO=root\n"); outs("PIPE="); outs(path); outs("\n\n"); outs("if [ ! -p \"$PIPE\" ]; then mkfifo -m0620 \"$PIPE\"; chown "); outs(user); outs(":"); outs(loguser); outs(" \"$PIPE\"; fi\n"); outs("exec <> \"$PIPE\"\n"); outs("exec chpst -u"); outs(user); outs(" uncat -s49999 -t180 \\\n"); outs(" env MAILUSER=log MAILNAME='socklog notify' \\\n"); outs(" mail -s socklog-notify $MAILTO\n"); finish(); perm(0750); } int main(int argc, char **argv) { int mode =0; progname =*argv++; umask(022); if (! *argv) usage(); switch (**argv) { case 'u': if (! *(++*argv)) usage(); switch (**argv) { case 'n': mode =CONF_UNIX; break; case 'c': mode =CONF_UCSPI_TCP; break; default: usage(); } break; case 'i': mode =CONF_INET; break; case 'n': mode =CONF_NOTIFY; break; case 'k': mode =CONF_KLOG; break; case '-': if ((*argv)[1] && (*argv)[1] == 'V') { strerr_warn2(VERSION, "\n", 0); } default: usage(); } argv++; user =*argv++; if (!user) usage(); loguser =*argv++; if (!loguser) usage(); dir =*argv++; if (!dir) { dir =CONF_DIR; } else { if (dir[0] != '/') usage(); if (*argv) { path =*argv; if (path[0] != '/') usage(); } } upw =getpwnam(user); if (!upw) strerr_die3x(111, FATAL, "unknown account ", user); if (mode != CONF_NOTIFY) { pw =getpwnam(loguser); if (!pw) strerr_die3x(111, FATAL, "unknown account ", loguser); } else { gr =getgrnam(loguser); if (!gr) strerr_die3x(111, FATAL, "unknown group ", loguser); } if (chdir(dir) == -1) { if (errno != error_noent) strerr_die4sys(111, FATAL, "unable to switch to ", dir, ": "); if (mkdir(dir, 0700) == -1) strerr_die4sys(111, FATAL, "unable to create ", dir, ": "); if (chmod(dir, 0750) == -1) strerr_die4sys(111, FATAL, "unable to set mode of ", dir, ": "); if (chdir(dir) == -1) strerr_die4sys(111, FATAL, "unable to switch to ", dir, ": "); } switch(mode) { case CONF_UNIX: if (!path) path =LOG_DIR_UNIX; conf_unix(); break; case CONF_INET: if (!path) path =LOG_DIR_INET; conf_inet(); break; case CONF_UCSPI_TCP: if (!path) path =LOG_DIR_UCSPI_TCP; conf_ucspi_tcp(); break; case CONF_KLOG: if (!path) path =LOG_DIR_KLOG; conf_klog(); break; case CONF_NOTIFY: if (!path) path =PATH_NOTIFY; conf_notify(); break; } return(0); } socklog-2.1.1+repack/src/check-socklog-inet.c0000644000000000000000000000162614702065454017533 0ustar rootroot#include #include #include #include #include #include #include "error.h" #include "strerr.h" #include "byte.h" char ip[4]; int s; struct sockaddr_in sa; int main() { ip[0] =127; ip[1] =0; ip[2] =0; ip[3] =1; s =socket(AF_INET,SOCK_DGRAM,0); if (s == -1) strerr_die1sys(111, "fatal: unable to create socket: "); memset(&sa, 0, sizeof(sa)); sa.sin_family =AF_INET; sa.sin_port =htons(0); byte_copy((char *) &sa.sin_addr, 4, ip); if (bind(s, (struct sockaddr *) &sa, sizeof sa) == -1) strerr_die1sys(111, "fatal: unable to bind socket: "); memset(&sa, 0, sizeof(sa)); sa.sin_family =AF_INET; sa.sin_port =htons(12614); byte_copy((char *)&sa.sin_addr, 4, ip); if (sendto(s, "foo\n", 4, 0, (struct sockaddr *)&sa, sizeof(sa)) != 4) strerr_die1sys(111, "fatal: unable to send: "); close(s); return(0); } socklog-2.1.1+repack/src/pathexec_env.c0000644000000000000000000000243114702065454016526 0ustar rootroot/* Public domain. */ #include "stralloc.h" #include "alloc.h" #include "str.h" #include "byte.h" #include "env.h" #include "pathexec.h" static stralloc plus; static stralloc tmp; int pathexec_env(const char *s,const char *t) { if (!s) return 1; if (!stralloc_copys(&tmp,s)) return 0; if (t) { if (!stralloc_cats(&tmp,"=")) return 0; if (!stralloc_cats(&tmp,t)) return 0; } if (!stralloc_0(&tmp)) return 0; return stralloc_cat(&plus,&tmp); } void pathexec(char *const *argv) { char **e; unsigned int elen; unsigned int i; unsigned int j; unsigned int split; unsigned int t; if (!stralloc_cats(&plus,"")) return; elen = 0; for (i = 0;environ[i];++i) ++elen; for (i = 0;i < plus.len;++i) if (!plus.s[i]) ++elen; e = (char **) alloc((elen + 1) * sizeof(char *)); if (!e) return; elen = 0; for (i = 0;environ[i];++i) e[elen++] = environ[i]; j = 0; for (i = 0;i < plus.len;++i) if (!plus.s[i]) { split = str_chr(plus.s + j,'='); for (t = 0;t < elen;++t) if (byte_equal(plus.s + j,split,e[t])) if (e[t][split] == '=') { --elen; e[t] = e[elen]; break; } if (plus.s[j + split]) e[elen++] = plus.s + j; j = i + 1; } e[elen] = 0; pathexec_run(*argv,argv,e); alloc_free(e); } socklog-2.1.1+repack/src/fmt_uint0.c0000644000000000000000000000036114702065454015762 0ustar rootroot/* Public domain. */ #include "fmt.h" unsigned int fmt_uint0(char *s,unsigned int u,unsigned int n) { unsigned int len; len = fmt_uint(FMT_LEN,u); while (len < n) { if (s) *s++ = '0'; ++len; } if (s) fmt_uint(s,u); return len; } socklog-2.1.1+repack/src/print-cc.sh0000644000000000000000000000014114702065454015760 0ustar rootrootcc="`head -n1 conf-cc`" systype="`cat systype`" cat warn-auto.sh echo exec "$cc" '-c ${1+"$@"}' socklog-2.1.1+repack/src/hasmkffo.h10000644000000000000000000000005414702065454015740 0ustar rootroot/* Public domain. */ /* sysdep: -mkfifo */ socklog-2.1.1+repack/src/tai_pack.c0000644000000000000000000000047114702065454015632 0ustar rootroot/* Public domain. */ #include "tai.h" void tai_pack(char *s,const struct tai *t) { uint64 x; x = t->x; s[7] = x & 255; x >>= 8; s[6] = x & 255; x >>= 8; s[5] = x & 255; x >>= 8; s[4] = x & 255; x >>= 8; s[3] = x & 255; x >>= 8; s[2] = x & 255; x >>= 8; s[1] = x & 255; x >>= 8; s[0] = x; } socklog-2.1.1+repack/src/byte_diff.c0000644000000000000000000000073314702065454016013 0ustar rootroot/* Public domain. */ #include "byte.h" int byte_diff(s,n,t) register char *s; register unsigned int n; register char *t; { for (;;) { if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; } return ((int)(unsigned int)(unsigned char) *s) - ((int)(unsigned int)(unsigned char) *t); } socklog-2.1.1+repack/src/pathexec_run.c0000644000000000000000000000203014702065454016535 0ustar rootroot/* Public domain. */ #include #include "error.h" #include "stralloc.h" #include "str.h" #include "env.h" #include "pathexec.h" static stralloc tmp; void pathexec_run(const char *file,char * const *argv,char * const *envp) { const char *path; unsigned int split; int savederrno; if (file[str_chr(file,'/')]) { execve(file,argv,envp); return; } path = env_get("PATH"); if (!path) path = "/bin:/usr/bin"; savederrno = 0; for (;;) { split = str_chr(path,':'); if (!stralloc_copyb(&tmp,path,split)) return; if (!split) if (!stralloc_cats(&tmp,".")) return; if (!stralloc_cats(&tmp,"/")) return; if (!stralloc_cats(&tmp,file)) return; if (!stralloc_0(&tmp)) return; execve(tmp.s,argv,envp); if (errno != error_noent) { savederrno = errno; if ((errno != error_acces) && (errno != error_perm) && (errno != error_isdir)) return; } if (!path[split]) { if (savederrno) errno = savederrno; return; } path += split; path += 1; } } socklog-2.1.1+repack/src/gen_allocdefs.h0000644000000000000000000000227414702065454016654 0ustar rootroot/* Public domain. */ #ifndef GEN_ALLOC_DEFS_H #define GEN_ALLOC_DEFS_H #define GEN_ALLOC_ready(ta,type,field,len,a,i,n,x,base,ta_ready) \ int ta_ready(register ta *x,register unsigned int n) \ { register unsigned int i; \ if (x->field) { \ i = x->a; \ if (n > i) { \ x->a = base + n + (n >> 3); \ if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \ x->a = i; return 0; } \ return 1; } \ x->len = 0; \ return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); } #define GEN_ALLOC_readyplus(ta,type,field,len,a,i,n,x,base,ta_rplus) \ int ta_rplus(register ta *x,register unsigned int n) \ { register unsigned int i; \ if (x->field) { \ i = x->a; n += x->len; \ if (n > i) { \ x->a = base + n + (n >> 3); \ if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \ x->a = i; return 0; } \ return 1; } \ x->len = 0; \ return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); } #define GEN_ALLOC_append(ta,type,field,len,a,i,n,x,base,ta_rplus,ta_append) \ int ta_append(register ta *x,register const type *i) \ { if (!ta_rplus(x,1)) return 0; x->field[x->len++] = *i; return 1; } #endif socklog-2.1.1+repack/src/select.h10000644000000000000000000000023514702065454015422 0ustar rootroot/* Public domain. */ #ifndef SELECT_H #define SELECT_H /* sysdep: -sysselect */ #include #include extern int select(); #endif socklog-2.1.1+repack/src/wait_nohang.c0000644000000000000000000000036714702065454016361 0ustar rootroot/* Public domain. */ #include #include #include "haswaitp.h" int wait_nohang(wstat) int *wstat; { #ifdef HASWAITPID return waitpid(-1,wstat,WNOHANG); #else return wait3(wstat,WNOHANG,(struct rusage *) 0); #endif } socklog-2.1.1+repack/src/wait.h0000644000000000000000000000047514702065454015034 0ustar rootroot/* Public domain. */ #ifndef WAIT_H #define WAIT_H extern int wait_pid(); extern int wait_nohang(); extern int wait_stop(); extern int wait_stopnohang(); #define wait_crashed(w) ((w) & 127) #define wait_exitcode(w) ((w) >> 8) #define wait_stopsig(w) ((w) >> 8) #define wait_stopped(w) (((w) & 127) == 127) #endif socklog-2.1.1+repack/src/buffer_write.c0000644000000000000000000000023514702065454016540 0ustar rootroot/* Public domain. */ #include #include "buffer.h" int buffer_unixwrite(int fd,const char *buf,unsigned int len) { return write(fd,buf,len); } socklog-2.1.1+repack/src/open_read.c0000644000000000000000000000023214702065454016006 0ustar rootroot/* Public domain. */ #include #include #include "open.h" int open_read(const char *fn) { return open(fn,O_RDONLY | O_NDELAY); } socklog-2.1.1+repack/src/taia_pack.c0000644000000000000000000000055014702065454015771 0ustar rootroot/* Public domain. */ #include "taia.h" void taia_pack(char *s,const struct taia *t) { unsigned long x; tai_pack(s,&t->sec); s += 8; x = t->atto; s[7] = x & 255; x >>= 8; s[6] = x & 255; x >>= 8; s[5] = x & 255; x >>= 8; s[4] = x; x = t->nano; s[3] = x & 255; x >>= 8; s[2] = x & 255; x >>= 8; s[1] = x & 255; x >>= 8; s[0] = x; } socklog-2.1.1+repack/src/fifo.c0000644000000000000000000000043314702065454015000 0ustar rootroot/* Public domain. */ #include #include #include "hasmkffo.h" #include "fifo.h" #ifdef HASMKFIFO int fifo_make(const char *fn,int mode) { return mkfifo(fn,mode); } #else int fifo_make(const char *fn,int mode) { return mknod(fn,S_IFIFO | mode,0); } #endif socklog-2.1.1+repack/src/gen_alloc.h0000644000000000000000000000030314702065454016001 0ustar rootroot/* Public domain. */ #ifndef GEN_ALLOC_H #define GEN_ALLOC_H #define GEN_ALLOC_typedef(ta,type,field,len,a) \ typedef struct ta { type *field; unsigned int len; unsigned int a; } ta; #endif socklog-2.1.1+repack/src/taia_frac.c0000644000000000000000000000021614702065454015765 0ustar rootroot/* Public domain. */ #include "taia.h" double taia_frac(const struct taia *t) { return (t->atto * 0.000000001 + t->nano) * 0.000000001; } socklog-2.1.1+repack/src/buffer.h0000644000000000000000000000315014702065454015332 0ustar rootroot/* Public domain. */ #ifndef BUFFER_H #define BUFFER_H typedef struct buffer { char *x; unsigned int p; unsigned int n; int fd; int (*op)(); } buffer; #define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) } #define BUFFER_INSIZE 8192 #define BUFFER_OUTSIZE 8192 extern void buffer_init(buffer *,int (*)(),int,char *,unsigned int); extern int buffer_flush(buffer *); extern int buffer_put(buffer *,const char *,unsigned int); extern int buffer_putalign(buffer *,const char *,unsigned int); extern int buffer_putflush(buffer *,const char *,unsigned int); extern int buffer_puts(buffer *,const char *); extern int buffer_putsalign(buffer *,const char *); extern int buffer_putsflush(buffer *,const char *); #define buffer_PUTC(s,c) \ ( ((s)->n != (s)->p) \ ? ( (s)->x[(s)->p++] = (c), 0 ) \ : buffer_put((s),&(c),1) \ ) extern int buffer_get(buffer *,char *,unsigned int); extern int buffer_bget(buffer *,char *,unsigned int); extern int buffer_feed(buffer *); extern char *buffer_peek(buffer *); extern void buffer_seek(buffer *,unsigned int); #define buffer_PEEK(s) ( (s)->x + (s)->n ) #define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) ) #define buffer_GETC(s,c) \ ( ((s)->p > 0) \ ? ( *(c) = (s)->x[(s)->n], buffer_SEEK((s),1), 1 ) \ : buffer_get((s),(c),1) \ ) extern int buffer_copy(buffer *,buffer *); extern int buffer_unixread(int,char *,unsigned int); extern int buffer_unixwrite(int,const char *,unsigned int); extern buffer *buffer_0; extern buffer *buffer_0small; extern buffer *buffer_1; extern buffer *buffer_1small; extern buffer *buffer_2; #endif socklog-2.1.1+repack/src/buffer.c0000644000000000000000000000027514702065454015332 0ustar rootroot/* Public domain. */ #include "buffer.h" void buffer_init(buffer *s,int (*op)(),int fd,char *buf,unsigned int len) { s->x = buf; s->fd = fd; s->op = op; s->p = 0; s->n = len; } socklog-2.1.1+repack/src/tryflock.c0000644000000000000000000000021614702065454015711 0ustar rootroot/* Public domain. */ #include #include #include int main() { flock(0,LOCK_EX | LOCK_UN | LOCK_NB); } socklog-2.1.1+repack/src/lock.h0000644000000000000000000000021214702065454015005 0ustar rootroot/* Public domain. */ #ifndef LOCK_H #define LOCK_H extern int lock_ex(int); extern int lock_un(int); extern int lock_exnb(int); #endif socklog-2.1.1+repack/src/warn-auto.sh0000644000000000000000000000010014702065454016151 0ustar rootroot#!/bin/sh # WARNING: This file was auto-generated. Do not edit! socklog-2.1.1+repack/src/byte.h0000644000000000000000000000042714702065454015030 0ustar rootroot/* Public domain. */ #ifndef BYTE_H #define BYTE_H extern unsigned int byte_chr(); extern unsigned int byte_rchr(); extern void byte_copy(); extern void byte_copyr(); extern int byte_diff(); extern void byte_zero(); #define byte_equal(s,n,t) (!byte_diff((s),(n),(t))) #endif socklog-2.1.1+repack/src/socklog-conf.dist0000644000000000000000000000042214702065454017160 0ustar rootrootusage: socklog-conf unix|inet|klog|ucspi acct logacct [/etc/sv] [/logdir] usage: socklog-conf notify acct grp [/etc/sv] [pipe] 1 $Id$ usage: socklog-conf unix|inet|klog|ucspi acct logacct [/etc/sv] [/logdir] usage: socklog-conf notify acct grp [/etc/sv] [pipe] 1 0 0 0 0 socklog-2.1.1+repack/src/buffer_get.c0000644000000000000000000000236714702065454016175 0ustar rootroot/* Public domain. */ #include "buffer.h" #include "byte.h" #include "error.h" static int oneread(int (*op)(),int fd,char *buf,unsigned int len) { int r; for (;;) { r = op(fd,buf,len); if (r == -1) if (errno == error_intr) continue; return r; } } static int getthis(buffer *s,char *buf,unsigned int len) { if (len > s->p) len = s->p; s->p -= len; byte_copy(buf,len,s->x + s->n); s->n += len; return len; } int buffer_feed(buffer *s) { int r; if (s->p) return s->p; r = oneread(s->op,s->fd,s->x,s->n); if (r <= 0) return r; s->p = r; s->n -= r; if (s->n > 0) byte_copyr(s->x + s->n,r,s->x); return r; } int buffer_bget(buffer *s,char *buf,unsigned int len) { int r; if (s->p > 0) return getthis(s,buf,len); if (s->n <= len) return oneread(s->op,s->fd,buf,s->n); r = buffer_feed(s); if (r <= 0) return r; return getthis(s,buf,len); } int buffer_get(buffer *s,char *buf,unsigned int len) { int r; if (s->p > 0) return getthis(s,buf,len); if (s->n <= len) return oneread(s->op,s->fd,buf,len); r = buffer_feed(s); if (r <= 0) return r; return getthis(s,buf,len); } char *buffer_peek(buffer *s) { return s->x + s->n; } void buffer_seek(buffer *s,unsigned int len) { s->n += len; s->p -= len; } socklog-2.1.1+repack/src/alloc_re.c0000644000000000000000000000035414702065454015637 0ustar rootroot/* Public domain. */ #include "alloc.h" #include "byte.h" int alloc_re(x,m,n) char **x; unsigned int m; unsigned int n; { char *y; y = alloc(n); if (!y) return 0; byte_copy(y,m,*x); alloc_free(*x); *x = y; return 1; } socklog-2.1.1+repack/src/openreadclose.c0000644000000000000000000000054014702065454016677 0ustar rootroot/* Public domain. */ #include "error.h" #include "open.h" #include "readclose.h" #include "openreadclose.h" int openreadclose(const char *fn,stralloc *sa,unsigned int bufsize) { int fd; fd = open_read(fn); if (fd == -1) { if (errno == error_noent) return 0; return -1; } if (readclose(fd,sa,bufsize) == -1) return -1; return 1; } socklog-2.1.1+repack/src/readclose.c0000644000000000000000000000105514702065454016017 0ustar rootroot/* Public domain. */ #include #include "error.h" #include "readclose.h" int readclose_append(int fd,stralloc *sa,unsigned int bufsize) { int r; for (;;) { if (!stralloc_readyplus(sa,bufsize)) { close(fd); return -1; } r = read(fd,sa->s + sa->len,bufsize); if (r == -1) if (errno == error_intr) continue; if (r <= 0) { close(fd); return r; } sa->len += r; } } int readclose(int fd,stralloc *sa,unsigned int bufsize) { if (!stralloc_copys(sa,"")) { close(fd); return -1; } return readclose_append(fd,sa,bufsize); } socklog-2.1.1+repack/src/fifo.h0000644000000000000000000000014514702065454015005 0ustar rootroot/* Public domain. */ #ifndef FIFO_H #define FIFO_H extern int fifo_make(const char *,int); #endif socklog-2.1.1+repack/src/syslognames.h0000644000000000000000000000272514702065454016434 0ustar rootroot#define LOG_PRI(p) ((p) & LOG_PRIMASK) #define LOG_MAKEPRI(fac, pri) (((fac) <<3) | (pri)) #define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ #define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) /* mark "facility" */ typedef struct _code { char *c_name; int c_val; } CODE; #define LOG_AUTHPRIV (10 <<3) #define LOG_FTP (11 <<3) CODE prioritynames[] = { { "alert", LOG_ALERT }, { "crit", LOG_CRIT }, { "debug", LOG_DEBUG }, { "emerg", LOG_EMERG }, { "err", LOG_ERR }, { "error", LOG_ERR }, /* DEPRECATED */ { "info", LOG_INFO }, { "none", INTERNAL_NOPRI }, /* INTERNAL */ { "notice", LOG_NOTICE }, { "panic", LOG_EMERG }, /* DEPRECATED */ { "warn", LOG_WARNING }, /* DEPRECATED */ { "warning", LOG_WARNING }, { NULL, -1 } }; #define LOG_FAC(p) (((p) & LOG_FACMASK) >>3) /* facility of pri */ CODE facilitynames[] = { { "auth", LOG_AUTH }, { "authpriv", LOG_AUTHPRIV }, { "cron", LOG_CRON }, { "daemon", LOG_DAEMON }, { "ftp", LOG_FTP }, { "kern", LOG_KERN }, { "lpr", LOG_LPR }, { "mail", LOG_MAIL }, { "mark", INTERNAL_MARK }, /* INTERNAL */ { "news", LOG_NEWS }, { "security", LOG_AUTH }, /* DEPRECATED */ { "syslog", LOG_SYSLOG }, { "user", LOG_USER }, { "uucp", LOG_UUCP }, { "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 }, { "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 }, { "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 }, { "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 }, { NULL, -1 } }; socklog-2.1.1+repack/src/socklog.c0000644000000000000000000002514214702065454015522 0ustar rootroot#include #include #include #include #include #include #include #include #include #include #include "byte.h" #include "buffer.h" #include "error.h" #include "strerr.h" #include "scan.h" #include "env.h" #include "sig.h" #include "open.h" #include "sgetopt.h" #define SYSLOG_NAMES #include #if defined(__sun__) && defined(__sparc__) && defined(__unix__) && defined(__svr4__) #define SOLARIS # include # include # include # include "syslognames.h" #if WANT_SUN_DOOR # include #endif #endif /* #define WARNING "socklog: warning: " */ #define FATAL "socklog: fatal: " #ifdef SOLARIS #define USAGE " [-rRU] [unix|inet|ucspi|sun_stream] [args]" #else #define USAGE " [-rRU] [unix|inet|ucspi] [args]" #endif #define VERSION "$Id$" #define DEFAULTINET "0" #define DEFAULTPORT "514" #define DEFAULTUNIX "/dev/log" const char *progname; #define LINEC 1024 #define MODE_UNIX 0 #define MODE_INET 1 #define MODE_UCSPI 2 #ifdef SOLARIS #define MODE_SUN_STREAM 3 #endif int mode =MODE_UNIX; char line[LINEC]; const char *address =NULL; char *uid, *gid; unsigned int lograw =0; unsigned int noumask =0; int flag_exitasap = 0; void sig_term_catch(void) { flag_exitasap = 1; } void usage() { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } void out(const char *s1, const char *s2) { if (s1) buffer_puts(buffer_1, s1); if (s2) buffer_puts(buffer_1, s2); } void err(const char *s1, const char *s2, const char *s3) { if (s1) buffer_puts(buffer_2, s1); if (s2) buffer_puts(buffer_2, s2); if (s3) buffer_puts(buffer_2, s3); } void setuidgid() { /* drop permissions */ if ((gid = env_get("GID")) != NULL) { unsigned long g; scan_ulong(gid, &g); err("gid=", gid, ", "); if (setgroups(1,(gid_t *)&g) == -1) strerr_die2sys(111, FATAL, "unable to setgroups: "); } if ((uid = env_get("UID")) != NULL) { unsigned long u; scan_ulong(uid, &u); err("uid=", uid, ", "); if (setuid(u) == -1) strerr_die2sys(111, FATAL, "unable to setuid: "); } } int print_syslog_names(int fpr, buffer *buf) { int fp =LOG_FAC(fpr) <<3; CODE *p; int rc =1; for (p =facilitynames; p->c_name; p++) { if (p->c_val == fp) { buffer_puts(buf, p->c_name); buffer_puts(buf, "."); break; } } if (! p->c_name) { buffer_puts(buf, "unknown."); rc =0; } fp =LOG_PRI(fpr); for (p =prioritynames; p->c_name; p++) { if (p->c_val == fp) { buffer_puts(buf, p->c_name); buffer_puts(buf, ": "); break; } } if (! p->c_name) { buffer_puts(buf, "unknown: "); rc =0; } return(rc); } int scan_syslog_names (char *l, int lc, buffer *buf) { int i; int ok =0; int fpr =0; if (l[0] != '<') return(0); for (i =1; (i < 5) && (i < lc); i++) { if (l[i] == '>') { ok =1; break; } if (('0' <= l[i]) && (l[i] <= '9')) { fpr =10 *fpr + l[i] -'0'; } else { return(0); } } if (!ok || !fpr) return(0); return(print_syslog_names(fpr, buf) ? ++i : 0); } void remote_info (struct sockaddr_in *sa) { char *host; host =inet_ntoa(sa->sin_addr); out(host, ": "); } int socket_unix (const char* f) { int s; struct sockaddr_un sa; if ((s =socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) strerr_die2sys(111, FATAL, "socket(): "); byte_zero(&sa, sizeof(sa)); sa.sun_family =AF_UNIX; strncpy(sa.sun_path, f, sizeof(sa.sun_path)); unlink(f); if (! noumask) umask(0); if (bind(s, (struct sockaddr*) &sa, sizeof sa) == -1) strerr_die2sys(111, FATAL, "bind(): "); err("listening on ", f, ", "); return(s); } int socket_inet (const char* ip, const char* port) { int s; unsigned long p; struct sockaddr_in sa; byte_zero(&sa, sizeof(sa)); if (ip[0] == '0') { sa.sin_addr.s_addr =INADDR_ANY; } else { #ifndef SOLARIS if (inet_aton(ip, &sa.sin_addr) == 0) { strerr_die2sys(111, FATAL, "inet_aton(): "); } #else sa.sin_addr.s_addr =inet_addr(ip); #endif } if ((s =socket(AF_INET, SOCK_DGRAM, 0)) == -1) strerr_die2sys(111, FATAL, "socket(): "); if (scan_ulong(port, &p) == 0) strerr_die3x(111, FATAL, "bad port number: ", port); sa.sin_family =AF_INET; sa.sin_port =htons(p); if (bind(s, (struct sockaddr*) &sa, sizeof sa) == -1) strerr_die2sys(111, FATAL, "bind(): "); ip =inet_ntoa(sa.sin_addr); err("listening on ", ip, 0); err(":", port, ", "); return(s); } int read_socket (int s) { sig_catch(sig_term, sig_term_catch); sig_catch(sig_int, sig_term_catch); /* drop permissions */ setuidgid(); buffer_putsflush(buffer_2, "starting.\n"); for(;;) { struct sockaddr_in saf; int dummy =sizeof saf; int linec; int os; linec =recvfrom(s, line, LINEC, 0, (struct sockaddr *) &saf, &dummy); if (linec == -1) { if (errno != error_intr) strerr_die2sys(111, FATAL, "recvfrom(): "); else linec =0; } if (flag_exitasap) break; while (linec && (line[linec -1] == 0)) linec--; if (linec == 0) continue; if (lograw) { buffer_put(buffer_1, line, linec); if (line[linec -1] != '\n') { if (linec == LINEC) out("...", 0); out("\n", 0); } if (lograw == 2) { buffer_flush(buffer_1); continue; } } if (mode == MODE_INET) remote_info(&saf); os =scan_syslog_names(line, linec, buffer_1); buffer_put(buffer_1, line +os, linec -os); if (line[linec -1] != '\n') { if (linec == LINEC) out("...", 0); out("\n", 0); } buffer_flush(buffer_1); } return(0); } int read_ucspi (int fd, char **vars) { char *envs[9]; int flageol =1; int i; for (i =0; *vars && (i < 8); vars++) { if ((envs[i] =env_get(*vars)) != NULL) i++; } envs[i] =NULL; for(;;) { int linec; char *l, *p; linec =buffer_get(buffer_0, line, LINEC); if (linec == -1) strerr_die2sys(111, FATAL, "read(): "); if (linec == 0) { if (! flageol) err("\n", 0, 0); buffer_flush(buffer_2); return(0); } for (l =p =line; l -line < linec; l++) { if (flageol) { if (! *l || (*l == '\n')) continue; for (i =0; envs[i]; i++) { err(envs[i], ": ", 0); } /* could fail on eg <13\0>user.notice: ... */ l += scan_syslog_names(l, line -l +linec, buffer_2); p =l; flageol =0; } if (! *l || (*l == '\n')) { buffer_put(buffer_2, p, l -p); buffer_putsflush(buffer_2, "\n"); flageol =1; } } if (!flageol) buffer_putflush(buffer_2, p, l -p); } } #ifdef SOLARIS #if WANT_SUN_DOOR static void door_proc(void *cookie, char *argp, size_t arg_size, door_desc_t *dp, uint_t ndesc) { door_return(NULL, 0, NULL, 0); return; } static int door_setup(const char *door) { int dfd; struct door_info di; if ( (dfd = open_trunc(door)) == -1) strerr_die2sys(111, FATAL, "open_trunc(): "); if (door_info(dfd, &di) == -1) { if (errno != EBADF) strerr_die2sys(111, FATAL, "door_info(): "); } else { /*XXX: could log the pid of the door owner. */ if (di.di_target != -1) strerr_die4x(100, FATAL, "door ", door, " allready in use."); } close(dfd); fdetach(door); /* highjack the door file */ if ((dfd =door_create(door_proc, NULL, 0)) == -1) strerr_die2sys(111, FATAL, "door_create(): "); if (fattach(dfd, door) == -1) strerr_die2sys(111, FATAL, "fattach(): "); err("door path is ", door, ", "); return(dfd); } #endif /*WANT_SUN_DOOR*/ static int stream_sun(const char *address) { int sfd; struct strioctl sc; if ((sfd = open(address, O_RDONLY | O_NOCTTY)) == -1) strerr_die2sys(111, FATAL, "open(): "); memset(&sc, 0, sizeof(sc)); sc.ic_cmd =I_CONSLOG; if (ioctl(sfd, I_STR, &sc) < 0) strerr_die2sys(111, FATAL, "ioctl(): "); err("sun_stream is ", address, ", "); return(sfd); } static void read_stream_sun(int fd) { struct strbuf ctl, data; struct log_ctl logctl; int flags; ctl.maxlen =ctl.len =sizeof(logctl); ctl.buf =(char *) &logctl; data.maxlen =LINEC; data.len =0; data.buf =line; flags =0; sig_catch(sig_term, sig_term_catch); sig_catch(sig_int, sig_term_catch); setuidgid(); buffer_putsflush(buffer_2, "starting.\n"); /* read the messages */ for (;;) { if ((getmsg(fd, &ctl, &data, &flags) & MORECTL) && (errno != error_intr)) strerr_die2sys(111, FATAL, "getmsg(): "); if (flag_exitasap) return; if (data.len) { int shorten =data.len; if (!line[shorten-1]) shorten--; while (line[shorten-1] == '\n') shorten--; (void) print_syslog_names(logctl.pri, buffer_1); buffer_put(buffer_1, line, shorten); if (data.len == LINEC) out("...", 0); out("\n", 0); buffer_flush(buffer_1); } } } #endif int main(int argc, char **argv) { int opt; int s =0; progname =*argv; while ((opt =getopt(argc, argv, "rRUV")) != opteof) { switch(opt) { case 'r': lograw =1; break; case 'R': lograw =2; break; case 'U': noumask =1; break; case 'V': err(VERSION, 0, 0); buffer_putsflush(buffer_2, "\n\n"); case '?': usage(); } } argv +=optind; if (*argv) { switch (**argv) { case 'u': if (! *(++*argv)) usage(); switch (**argv) { case 'n': mode =MODE_UNIX; break; case 'c': mode =MODE_UCSPI; argv--; break; default: usage(); } break; case 'i': mode =MODE_INET; break; #ifdef SOLARIS case 's': mode =MODE_SUN_STREAM; break; #endif default: usage(); } argv++; } if (*argv) address =*argv++; switch (mode) { case MODE_INET: { const char* port =NULL; if (*argv) port =*argv++; if (*argv) usage(); if (!address) address =DEFAULTINET; if (!port) port =DEFAULTPORT; s =socket_inet(address, port); return(read_socket(s)); } case MODE_UNIX: { if (*argv) usage(); if (!address) address =DEFAULTUNIX; s =socket_unix(address); return(read_socket(s)); } #ifdef SOLARIS case MODE_SUN_STREAM: { #if WANT_SUN_DOOR const char *door =NULL; int dfd =-1; if (*argv) door =*argv++; #endif if (!address) address =DEFAULTUNIX; if (*argv) usage(); s =stream_sun(address); #if WANT_SUN_DOOR if (door) dfd = door_setup(door); #endif read_stream_sun(s); #if WANT_SUN_DOOR if (dfd != -1) door_revoke(dfd); /* ** syslogd does unlink() the door file, but we can't, since we droped ** all privs before. */ #endif return 0; } #endif /*SOLARIS*/ case MODE_UCSPI: s =0; return(read_ucspi(0, argv)); } /* not reached */ return(1); } socklog-2.1.1+repack/src/check-diff0000755000000000000000000000024614702065454015624 0ustar rootroot#!/bin/sh test -r "$1".dist || exit 1 test -r "$1".local || exit 1 while read i; do read j 0<&7 || exit 1 test "$i" = "$j" || exit 1 done 7<"$1".dist <"$1".local socklog-2.1.1+repack/src/seek.h0000644000000000000000000000042714702065454015014 0ustar rootroot/* Public domain. */ #ifndef SEEK_H #define SEEK_H typedef unsigned long seek_pos; extern seek_pos seek_cur(int); extern int seek_set(int,seek_pos); extern int seek_end(int); extern int seek_trunc(int,seek_pos); #define seek_begin(fd) (seek_set((fd),(seek_pos) 0)) #endif socklog-2.1.1+repack/src/taia_uint.c0000644000000000000000000000025614702065454016035 0ustar rootroot/* Public domain. */ #include "taia.h" /* XXX: breaks tai encapsulation */ void taia_uint(struct taia *t,unsigned int s) { t->sec.x = s; t->nano = 0; t->atto = 0; } socklog-2.1.1+repack/src/trysysel.c0000644000000000000000000000022614702065454015753 0ustar rootroot/* Public domain. */ #include #include #include #include /* SVR4 silliness */ void foo() { ; } socklog-2.1.1+repack/src/stralloc_pend.c0000644000000000000000000000025714702065454016712 0ustar rootroot/* Public domain. */ #include "alloc.h" #include "stralloc.h" #include "gen_allocdefs.h" GEN_ALLOC_append(stralloc,char,s,len,a,i,n,x,30,stralloc_readyplus,stralloc_append) socklog-2.1.1+repack/src/hassgact.h10000644000000000000000000000005714702065454015742 0ustar rootroot/* Public domain. */ /* sysdep: -sigaction */ socklog-2.1.1+repack/src/trywaitp.c0000644000000000000000000000014514702065454015740 0ustar rootroot/* Public domain. */ #include #include int main() { waitpid(0,0,0); } socklog-2.1.1+repack/src/fd_copy.c0000644000000000000000000000040114702065454015473 0ustar rootroot/* Public domain. */ #include #include #include "fd.h" int fd_copy(int to,int from) { if (to == from) return 0; if (fcntl(from,F_GETFL,0) == -1) return -1; close(to); if (fcntl(from,F_DUPFD,to) == -1) return -1; return 0; } socklog-2.1.1+repack/src/openreadclose.h0000644000000000000000000000024614702065454016707 0ustar rootroot/* Public domain. */ #ifndef OPENREADCLOSE_H #define OPENREADCLOSE_H #include "stralloc.h" extern int openreadclose(const char *,stralloc *,unsigned int); #endif socklog-2.1.1+repack/src/taia.h0000644000000000000000000000174214702065454015004 0ustar rootroot/* Public domain. */ #ifndef TAIA_H #define TAIA_H #include "tai.h" struct taia { struct tai sec; unsigned long nano; /* 0...999999999 */ unsigned long atto; /* 0...999999999 */ } ; extern void taia_tai(const struct taia *,struct tai *); extern void taia_now(struct taia *); extern double taia_approx(const struct taia *); extern double taia_frac(const struct taia *); extern void taia_add(struct taia *,const struct taia *,const struct taia *); extern void taia_addsec(struct taia *,const struct taia *,int); extern void taia_sub(struct taia *,const struct taia *,const struct taia *); extern void taia_half(struct taia *,const struct taia *); extern int taia_less(const struct taia *,const struct taia *); #define TAIA_PACK 16 extern void taia_pack(char *,const struct taia *); extern void taia_unpack(const char *,struct taia *); #define TAIA_FMTFRAC 19 extern unsigned int taia_fmtfrac(char *,const struct taia *); extern void taia_uint(struct taia *,unsigned int); #endif socklog-2.1.1+repack/src/byte_zero.c0000644000000000000000000000034614702065454016062 0ustar rootroot#include "byte.h" void byte_zero(s,n) char *s; register unsigned int n; { for (;;) { if (!n) break; *s++ = 0; --n; if (!n) break; *s++ = 0; --n; if (!n) break; *s++ = 0; --n; if (!n) break; *s++ = 0; --n; } } socklog-2.1.1+repack/src/byte_chr.c0000644000000000000000000000063014702065454015653 0ustar rootroot/* Public domain. */ #include "byte.h" unsigned int byte_chr(s,n,c) char *s; register unsigned int n; int c; { register char ch; register char *t; ch = c; t = s; for (;;) { if (!n) break; if (*t == ch) break; ++t; --n; if (!n) break; if (*t == ch) break; ++t; --n; if (!n) break; if (*t == ch) break; ++t; --n; if (!n) break; if (*t == ch) break; ++t; --n; } return t - s; } socklog-2.1.1+repack/src/stralloc_catb.c0000644000000000000000000000052214702065454016670 0ustar rootroot/* Public domain. */ #include "stralloc.h" #include "byte.h" int stralloc_catb(stralloc *sa,const char *s,unsigned int n) { if (!sa->s) return stralloc_copyb(sa,s,n); if (!stralloc_readyplus(sa,n + 1)) return 0; byte_copy(sa->s + sa->len,n,s); sa->len += n; sa->s[sa->len] = 'Z'; /* ``offensive programming'' */ return 1; } socklog-2.1.1+repack/src/direntry.h20000644000000000000000000000024614702065454016006 0ustar rootroot/* Public domain. */ #ifndef DIRENTRY_H #define DIRENTRY_H /* sysdep: +dirent */ #include #include #define direntry struct dirent #endif socklog-2.1.1+repack/src/find-systype.sh0000644000000000000000000000640414702065454016707 0ustar rootroot# oper-:arch-:syst-:chip-:kern- # oper = operating system type; e.g., sunos-4.1.4 # arch = machine language; e.g., sparc # syst = which binaries can run; e.g., sun4 # chip = chip model; e.g., micro-2-80 # kern = kernel version; e.g., sun4m # dependence: arch --- chip # \ \ # oper --- syst --- kern # so, for example, syst is interpreted in light of oper, but chip is not. # anyway, no slashes, no extra colons, no uppercase letters. # the point of the extra -'s is to ease parsing: can add hierarchies later. # e.g., *:i386-*:*:pentium-*:* would handle pentium-100 as well as pentium, # and i386-486 (486s do have more instructions, you know) as well as i386. # the idea here is to include ALL useful available information. exec 2>/dev/null sys="`uname -s | tr '/:[A-Z]' '..[a-z]'`" if [ x"$sys" != x ] then unamer="`uname -r | tr /: ..`" unamem="`uname -m | tr /: ..`" unamev="`uname -v | tr /: ..`" case "$sys" in bsd.os|freebsd|netbsd|openbsd) # in bsd 4.4, uname -v does not have useful info. # in bsd 4.4, uname -m is arch, not chip. oper="$sys-$unamer" arch="$unamem" syst="" chip="`sysctl -n hw.model`" # hopefully kern="" ;; linux) # as in bsd 4.4, uname -v does not have useful info. oper="$sys-$unamer" syst="" chip="$unamem" kern="" case "$chip" in i386|i486|i586|i686) arch="i386" ;; alpha) arch="alpha" ;; esac ;; aix) # naturally IBM has to get uname -r and uname -v backwards. dorks. oper="$sys-$unamev-$unamer" arch="`arch | tr /: ..`" syst="" chip="$unamem" kern="" ;; sunos) oper="$sys-$unamer-$unamev" arch="`(uname -p || mach) | tr /: ..`" syst="`arch | tr /: ..`" chip="$unamem" # this is wrong; is there any way to get the real info? kern="`arch -k | tr /: ..`" ;; unix_sv) oper="$sys-$unamer-$unamev" arch="`uname -m`" syst="" chip="$unamem" kern="" ;; *) oper="$sys-$unamer-$unamev" arch="`arch | tr /: ..`" syst="" chip="$unamem" kern="" ;; esac else gcc -c trycpp.c gcc -o trycpp trycpp.o case `./trycpp` in nextstep) oper="nextstep-`hostinfo | sed -n 's/^[ ]*NeXT Mach \([^:]*\):.*$/\1/p'`" arch="`hostinfo | sed -n 's/^Processor type: \(.*\) (.*)$/\1/p' | tr /: ..`" syst="" chip="`hostinfo | sed -n 's/^Processor type: .* (\(.*\))$/\1/p' | tr ' /:' '...'`" kern="" ;; *) oper="unknown" arch="" syst="" chip="" kern="" ;; esac rm -f trycpp.o trycpp fi case "$chip" in 80486) # let's try to be consistent here. (BSD/OS) chip=i486 ;; i486DX) # respect the hyphen hierarchy. (FreeBSD) chip=i486-dx ;; i486.DX2) # respect the hyphen hierarchy. (FreeBSD) chip=i486-dx2 ;; Intel.586) # no, you nitwits, there is no such chip. (NeXTStep) chip=pentium ;; i586) # no, you nitwits, there is no such chip. (Linux) chip=pentium ;; i686) # STOP SAYING THAT! (Linux) chip=ppro esac if gcc -c x86cpuid.c then if gcc -o x86cpuid x86cpuid.o then x86cpuid="`./x86cpuid | tr /: ..`" case "$x86cpuid" in ?*) chip="$x86cpuid" ;; esac fi fi rm -f x86cpuid x86cpuid.o echo "$oper-:$arch-:$syst-:$chip-:$kern-" | tr ' [A-Z]' '.[a-z]' socklog-2.1.1+repack/src/hassgprm.h10000644000000000000000000000006114702065454015764 0ustar rootroot/* Public domain. */ /* sysdep: -sigprocmask */ socklog-2.1.1+repack/man/0000755000000000000000000000000014702065454013675 5ustar rootrootsocklog-2.1.1+repack/man/uncat.10000644000000000000000000000316214702065454015073 0ustar rootroot.TH uncat 1 .SH NAME uncat \- continuously reads stdin, splits up the data either by timeout or number of bytes read to process it .SH SYNOPSIS .B uncat [\-vo] [\-t .IR seconds ] [\-s .IR size ] .I prog .SH DESCRIPTION .B uncat continuously reads stdin and repeatedly processes the data either after .I seconds timeout or maximal number of bytes .I size read. To process the data, .B uncat starts .I prog and feeds the data into .IR prog 's standard input. .IR prog 's standard output is redirected to standard error. .B uncat never writes to standard output. .LP .I prog consist of one or more arguments. .LP If .I prog exits non-zero, .B uncat prints an error message, discards the data and continues to read stdin. .LP Note that .B uncat is not crash proof. .LP .B uncat is used to run the .I socklog-notify service. .SH OPTIONS .TP .B \-v verbose. Print verbose messages to stderr. .TP .B \-o once. Exit on end of input. Normally .B uncat continues waiting for data on standard input, even on end of file. .TP .B \-t \fIseconds timeout. Set the timeout to .I seconds seconds. Default is 300. .TP .B \-s \fIsize Set the maximal number of bytes to .IR size . Default is 1024. .SH SIGNALS If .B uncat receives a TERM signal, it starts to process the data in memory and exits as soon as possible. .LP .B uncat also does this on end of input if the .B \-o option was given. .SH EXIT CODES .B uncat returns 0 after receiving a TERM signal. .B uncat returns 111 on error. .SH SEE ALSO socklog(8), socklog-conf(8), sv(8), runsv(8), svlogd(8), tryto(1) .LP http://smarden.org/socklog/ http://smarden.org/runit/ .SH AUTHOR Gerrit Pape socklog-2.1.1+repack/man/tryto.10000644000000000000000000000553114702065454015144 0ustar rootroot.TH tryto 1 .SH NAME tryto \- tries to run a command limited by a timeout or number of tries, can be used to run as svlogd(8) processor. .SH SYNOPSIS .B tryto [\-pPv] [\-t .IR sec ] [\-k .IR ksec ] [\-n .IR tries ] .I prog .SH DESCRIPTION .I prog consist of one or more arguments. .LP .B tryto runs and watches .IR prog , feeding its standard input to .IR prog 's standard input. If .I prog exits with a return code other then 0, .B tryto runs .I prog again after sleeping one second. .LP If the number of retries reaches the maximal number of .IR tries , .B tryto prints an error message and gives up. .LP If the timeout .I sec seconds is reached and .I prog is still running, .B tryto sends a TERM signal to .IR prog , waits .I ksec seconds for .I prog to terminate, then sends a KILL signal if .I prog still is there, and exits as soon as possible. .SH OPTIONS .TP .B \-t \fIsec timeout. Set the timeout to send TERM to .I prog to .I sec seconds. Default is 180. .TP .B \-k \fIksec kill timeout. Set the timeout to send KILL to .I prog to .I ksec seconds. Default is 5. .TP .B \-n \fItries Set the maximal number of tries to .IR tries . If .I prog exited with a return code other that 0, .B tryto tries to rewind standard input to the beginning using .BR lseek (2) before starting .I prog again. Default is 5. .TP .B \-p processor. Use this option if you run .B tryto as a .BR svlogd (8) processor (see below). .TP .B \-P process group. Run .I prog in a new session and process group, and send signals on timeout to .IR prog 's process group instead of its pid. .TP .B \-v verbose. Print verbose messages to standard error. .SH PROCESSOR If .B tryto sees the .B \-p option, .B tryto runs as a .BR svlogd (8) or .BR multilog (8) processor, making use of filedescriptors 4 and 5: .LP Before starting .IR prog , .B tryto moves the filedescriptor 5 to 2, so all error messages from .B tryto and .I prog will be saved in .BR svlogd (8)'s .I state to be processed on the next run of .B tryto .BR \-p . .LP After starting .IR prog , .B tryto first feeds all data it reads from filedescriptor 4 into .IR prog 's standard input, then all data from filedescriptor 0. .LP If .I prog fails by timeout .I sec seconds or maximal number of .IR tries , .B tryto prints all data from standard input to standard output, an error message to standard error, and exits with 0. .SH EXIT CODES If .B tryto itself fails, it returns 111. .LP If .B tryto runs as a .BR svlogd (8) processor, .B tryto returns 0 in all other cases. .LP If .I prog was run successfully, .B tryto returns 0. .LP If .I prog failed by timeout, .B tryto returns 100. .LP If .I prog failed by maximal number of .IR tries , .B tryto returns the last return code from .IR prog . .LP .SH SEE ALSO socklog(8), uncat(1), svlogd(8), multilog(8), lseek(2) .LP http://smarden.org/socklog/ http://smarden.org/runit/ .SH AUTHOR Gerrit Pape socklog-2.1.1+repack/man/socklog-conf.80000644000000000000000000001072414702065454016356 0ustar rootroot.TH socklog-conf 8 .SH NAME socklog-conf \- sets up a socklog(8) service. .SH SYNOPSIS .B socklog-conf unix|inet|klog|ucspi-tcp .I acct .I logacct .br .B socklog-conf notify .I acct .I grp .SH DESCRIPTION .B socklog-conf creates .I /etc/sv if necessary and a subdirectory that runs the .BR unix , .BR inet , .B ucspi-tcp or .B notify service (see below for each service). Except for the notify service, .B socklog-conf also creates a log directory with subdirectories. .LP .IR acct , .I logacct and .I grp must not contain any special characters. .SH UNIX SERVICE .B socklog-conf unix .I acct .I logacct .LP Running .B socklog-conf with the 1st argument .IR unix , .B socklog-conf creates the service directory .I /etc/sv/socklog-unix and the log directory .IR /var/log/socklog . .LP .B socklog-conf arranges for .BR socklog (8) to run under the uid and gid of .I acct and to listen for syslog messages on .IR /dev/log . .LP It also creates automatically rotated log directories in .IR /var/log/socklog . The logs are owned by .IR logacct . The corresponding .BR svlogd (8) process runs under the uid and gid of .IR logacct . .LP You can run the service under .BR runsvdir (8) by creating a symbolic link in the service directory: .LP ln \-s /etc/sv/socklog-unix /var/service/ .LP .SH INET SERVICE .B socklog-conf inet .I acct .I logacct .LP Running .B socklog-conf with the 1st argument .IR inet , .B socklog-conf creates the service directory .I /etc/sv/socklog-inet and the log directory .IR /var/log/socklog-inet . .LP .B socklog-conf arranges for .BR socklog (8) to run under the uid and gid of .I acct and to listen for syslog messages on the UDP socket .IR 0.0.0.0:514 . .LP It also creates automatically rotated log directories in .IR /var/log/socklog-inet . The logs are owned by .IR logacct . The corresponding .BR svlogd (8) process runs under the uid and gid of .IR logacct . .LP You can run the service under .BR runsvdir (8) by creating a symbolic link in the service directory: .LP ln \-s /etc/sv/socklog-inet /var/service/ .LP .SH KLOG SERVICE .B socklog-conf klog .I acct .I logacct .LP Running .B socklog-conf with the 1st argument .IR klog , .B socklog-conf creates the service directory .I /etc/sv/socklog-klog and the log directory .IR /var/log/socklog-klog . .LP .B socklog-conf arranges for .BR socklog (8) to run under the uid and gid of .I acct and to read kernel messages from .I /proc/kmsg on Linux, or .I /dev/socklog-klog on BSD. .LP It also creates automatically rotated log directories in .IR /var/log/socklog-klog . The logs are owned by .IR logacct . The corresponding .BR svlogd (8) process runs under the uid and gid of .IR logacct . .LP You can run the service under .BR runsvdir (8) by creating a symbolic link in the service directory: .LP ln \-s /etc/sv/socklog-klog /var/service/ .LP .SH UCSPI-TCP SERVICE .B socklog-conf ucspi-tcp .I acct .I logacct .LP Running .B socklog-conf with the 1st argument .IR ucspi-tcp , .B socklog-conf creates the service directory .I /etc/sv/socklog-ucspi-tcp and the log directory .IR /var/log/socklog-ucspi-tcp . .LP .B socklog-conf arranges for .BR tcpsvd (1) to run .BR socklog (8) under the uid and gid of .I acct and to listen on the TCP socket .IR 0.0.0.0:10116 . .LP It also creates automatically rotated log directories in .IR /var/log/socklog-ucspi-tcp . The logs are owned by .IR logacct . The corresponding .BR svlogd (8) process runs under the uid and gid of .IR logacct . .LP You can run the service under .BR runsvdir (8) by creating a symbolic link in the service directory: .LP ln \-s /etc/sv/socklog-ucspi-tcp /var/service/ .LP .SH NOTIFY SERVICE .B socklog-conf notify .I acct .I grp .LP Running .B socklog-conf with the 1st argument .IR notify , .B socklog-conf creates the service directory .IR /etc/sv/socklog-notify . .LP .B socklog-conf arranges for .BR uncat (1) to run under the uid and gid of .I acct and to listen on the named pipe .IR /var/log/socklog/.notify . The named pipe will have mode 0620, the uid of .I acct and the gid of .IR grp . .LP All uids running a log service that is configured to push log events to the socklog-notify service must be member of the group .IR grp . .LP You can run the service under .BR runsvdir (8) by creating a symbolic link in the service directory: .LP ln \-s /etc/sv/socklog-notify /var/service/ .LP .SH SEE ALSO socklog(8), svlogd(8), nc(1), tryto(1), uncat(1), socklog-check(8), tcpsvd(8), sv(8), runsv(8), runsvdir(8) .LP http://smarden.org/socklog/ http://smarden.org/runit/ .SH AUTHOR Gerrit Pape socklog-2.1.1+repack/man/socklog.80000644000000000000000000000566014702065454015436 0ustar rootroot.TH socklog 8 .SH NAME socklog \- small and secure syslogd replacement for use with runit .SH SYNOPSIS .B socklog [\-rRU] [unix] .RI [ path\fR] .br .B socklog [\-rR] inet .RI [ ip\fR] .RI [ port\fR] .br .B socklog [\-rR] ucspi .RI [ args\fR] .SH DESCRIPTION .B socklog is run under runit's .BR runsv (8), writing syslog messages it receives from unix domain socket .I path or an inet udp socket .I ip\fR:\fIport\fR through a pipe provided by .BR runsv (8) to a .BR svlogd (8) process. .LP .B socklog can be run as an ucspi application to listen to an unix domain stream socket and for more flexible distributed logging. .LP If the environment variables $UID and/or $GID are present, .B socklog drops permissions to those ids after creating and binding the socket (not in .I ucspi mode). .LP .B socklog converts syslog facility and priority information to names (\fIfacility\fR.\fIpriority\fR:) as found in .I /usr/include/syslog.h at compile time if present. .LP On solaris .B socklog also accepts .I sun_stream as first argument. Please see the web page for details. .SH UNIX SOCKET .B socklog [ unix ] [ .I path ] .LP Starting .B socklog with the 1st argument .IR unix , .B socklog will listen to the unix domain socket .IR path . If .I path is omitted, the default .I /dev/log is used. .LP The 1st argument may be omitted, default is .IR unix . .SH INET SOCKET .B socklog inet [ .I ip ] [ .I port ] .LP Starting .B socklog with the 1st argument .IR inet , .B socklog will listen to the inet udp socket .I ip\fR:\fIport\fR. .LP If .I ip starts with 0, .B socklog will bind to all local interfaces. .LP If .I port is less or equal 1024, .B socklog must be run by root. .LP .I port may be omitted, default is 514. .I ip may be omitted, default is 0. .LP .B socklog prepends .I a.b.c.d: to each syslog message it receives, where .I a.b.c.d is the ip address of the connecting system. .SH UCSPI MODE .B socklog ucspi [ .I args ] .LP Starting .B socklog with the 1st argument .IR ucspi , .B socklog will run as an ucspi application. Normally .B socklog will only be started in .I ucspi mode by an ucspi server tool, such as .BR tcpsvd (8), .BR tcpserver (1) or .BR unixserver . .LP For each .IR arg , .B socklog will prepend $\fIarg\fR: to each syslog message, if the environment variable .RI $ arg is present (maximum is 8). .SH OPTIONS .TP .B \-r raw. Write the raw syslog messages (no conversion of facility and priority) to the pipe, additionally to the log messages with syslog facility and priority converted to names. .TP .B \-R raw only. Same as \-r above, but write the raw syslog messages only. .TP .B \-U respect umask. Don't set umask to 0 before creating a unix domain socket, but respect the current setting of .BR umask (2). This option only takes effect in unix mode. .SH SEE ALSO sv(8), runsvdir(8), runsv(8), svlogd(8), tryto(1), uncat(1), socklog-check(8), tcpsvd(8), nc(1) .LP http://smarden.org/socklog/ http://smarden.org/runit/ .SH AUTHOR Gerrit Pape socklog-2.1.1+repack/man/socklog-check.80000644000000000000000000000237014702065454016504 0ustar rootroot.TH socklog-check 8 .SH NAME socklog-check \- checks for the availability of a socklog(8) service. .SH SYNOPSIS .B socklog-check [\-v] [unix .RI [ address\fR]] .SH DESCRIPTION .B socklog-check attempts to connect to a .BR socklog (8) unix service and reports whether the connection attempt succeeded or not. .P It connects to the datagram oriented unix domain socket .IR address , and reports success through the return code. If .I address is not specified, .B socklog-check attempts to connect to .IR /dev/log . .P When running services that use the syslog facility under runit's service supervision, .B socklog-check should be added to the top of the service's run script to ensure that no syslog messages are generated until a syslog service is up and running to process the messages, e.g.: .P #!/bin/sh socklog-check || exit 1 exec service_using_syslog .SH OPTIONS .TP .B \-v verbose. Print verbose message to standard error. .SH EXIT CODES On success .B socklog-check returns 0. .P On error, .B socklog-check prints a message to standard error and exits 111. .SH SEE ALSO socklog(8), socklog-conf(8), svlogd(8), tryto(1), uncat(1), sv(8), runsv(8), runsvdir(8) .LP http://smarden.org/socklog/ http://smarden.org/runit/ .SH AUTHOR Gerrit Pape