summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/syslogd/args-hostname.pl
blob: 25a663815180d8e6e5a25ccd29d425ef18d4deaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# The client writes messages with various methods.
# The syslogd writes them into a file and through a pipe and to tty.
# The syslogd is run with -h, adds a hostname, and passes them to loghost.
# The server receives the messages on its UDP socket.
# Find the message in client, file, pipe, console, user, syslogd, server log.
# Check that the hostname in file and server log is correct.

use strict;
use warnings;
use Socket;
use Sys::Hostname;

(my $host = hostname()) =~ s/\..*//;

our %args = (
    client => {
	redo => [
	    { connect => {
		proto  => "udp",
		domain => AF_INET,
		addr   => "127.0.0.1",
		port   => 514,
	    }},
	    { connect => {
		proto  => "tcp",
		domain => AF_INET,
		addr   => "127.0.0.1",
		port   => 514,
	    }},
	    { connect => {
		proto  => "tls",
		domain => AF_INET,
		addr   => "127.0.0.1",
		port   => 6514,
	    }},
	    { logsock => {
		type  => "native",
	    }},
	    { logsock => {
		type  => "unix",
	    }},
	    { logsock => {
		type  => "udp",
		host => "127.0.0.1",
		port => 514,
	    }},
	    { logsock => {
		type  => "tcp",
		host => "127.0.0.1",
		port => 514,
	    }},
	],
	func => sub { redo_connect( shift, sub {
	    my $self = shift;
	    write_message($self, "client connect proto: ".
		$self->{connectproto}) if $self->{connectproto};
	    write_message($self, "client logsock type: ".
		$self->{logsock}{type}) if $self->{logsock};
	})},
    },
    syslogd => {
	options => [qw(-h -n -rr
	    -U 127.0.0.1:514 -T 127.0.0.1:514 -S 127.0.0.1:6514)],
    },
    server => {
	loggrep => {
	    qr/ client connect / => 3,
	    qr/:\d\d $host client connect proto: udp$/ => 1,
	    qr/:\d\d $host client connect proto: tcp$/ => 1,
	    qr/:\d\d $host client connect proto: tls$/ => 1,
	    qr/ client logsock / => 4,
	    qr/:\d\d $host syslogd-.*: client logsock type: native/ => 1,
	    qr/:\d\d $host syslogd-.*: client logsock type: unix/ => 1,
	    qr/:\d\d $host syslogd-.*: client logsock type: udp/ => 1,
	    qr/:\d\d $host syslogd-.*: client logsock type: tcp/ => 1,
	},
    },
    file => {
	loggrep => {
	    qr/ client connect / => 3,
	    qr/:\d\d 127.0.0.1 client connect proto: udp$/ => 1,
	    qr/:\d\d 127.0.0.1 client connect proto: tcp$/ => 1,
	    qr/:\d\d 127.0.0.1 client connect proto: tls$/ => 1,
	    qr/ client logsock / => 4,
	    qr/:\d\d $host syslogd-.*: client logsock type: native/ => 1,
	    qr/:\d\d $host syslogd-.*: client logsock type: unix/ => 1,
	    qr/:\d\d 127.0.0.1 syslogd-.*: client logsock type: udp/ => 1,
	    qr/:\d\d 127.0.0.1 syslogd-.*: client logsock type: tcp/ => 1,
	},
    },
);

1;