Project

General

Profile

Feature #5822 » bsnmpd-descr-ifAlias.diff

patch to freebsd 10.2; back porting ifAlias to also(optionally) making bsnmpd to pick it up. - Dirk-Willem van Gulik, 01/28/2016 10:04 AM

View differences:

contrib/bsnmp/lib/asn1.c
652 652
			err = ASN_ERR_RANGE;
653 653
		}
654 654
		if (oid->subs[0] > 2 ||
655
		    (oid->subs[0] < 2 && oid->subs[1] >= 40)) {
655
		    (oid->subs[0] < 2 && oid->subs[0] >= 40)) {
656 656
			asn_error(NULL, "oid out of range (%u,%u)",
657 657
			    oid->subs[0], oid->subs[1]);
658 658
			err = ASN_ERR_RANGE;
contrib/bsnmp/lib/snmp.c
288 288
	memset(buf, 0, 256);
289 289
	tb.asn_ptr = buf;
290 290
	tb.asn_len = 256;
291
	u_int len;
292 291

  
293
	if (asn_get_octetstring(b, buf, &len) != ASN_ERR_OK) {
292
	if (asn_get_octetstring(b, buf, &tb.asn_len) != ASN_ERR_OK) {
294 293
		snmp_error("cannot parse usm header");
295 294
		return (ASN_ERR_FAILED);
296 295
	}
297
	tb.asn_len = len;
298 296

  
299 297
	if (asn_get_sequence(&tb, &octs_len) != ASN_ERR_OK) {
300 298
		snmp_error("cannot decode usm header");
......
866 864
			return (SNMP_CODE_FAILED);
867 865

  
868 866
		pdu->scoped_len = b->asn_ptr - pdu->scoped_ptr;
869
		if (snmp_pdu_fix_padd(b, pdu) != ASN_ERR_OK)
867
		if ((code = snmp_pdu_fix_padd(b, pdu))!= ASN_ERR_OK)
870 868
			return (SNMP_CODE_FAILED);
871 869

  
872 870
		if (pdu->security_model != SNMP_SECMODEL_USM)
......
999 997
	if ((err = snmp_pdu_encode_header(resp_b, pdu)) != SNMP_CODE_OK)
1000 998
		return (err);
1001 999
	for (idx = 0; idx < pdu->nbindings; idx++)
1002
		if (snmp_binding_encode(resp_b, &pdu->bindings[idx])
1000
		if ((err = snmp_binding_encode(resp_b, &pdu->bindings[idx]))
1003 1001
		    != ASN_ERR_OK)
1004 1002
			return (SNMP_CODE_FAILED);
1005 1003

  
contrib/bsnmp/lib/snmp.h
182 182

  
183 183
	/* fixes for encoding */
184 184
	size_t			outer_len;
185
	asn_len_t		scoped_len;
185
	size_t			scoped_len;
186 186
	u_char			*outer_ptr;
187 187
	u_char			*digest_ptr;
188 188
	u_char			*encrypted_ptr;
contrib/bsnmp/lib/snmpagent.c
166 166
}
167 167

  
168 168
static void
169
snmp_pdu_create_response(const struct snmp_pdu *pdu, struct snmp_pdu *resp)
169
snmp_pdu_create_response(struct snmp_pdu *pdu, struct snmp_pdu *resp)
170 170
{
171 171
	memset(resp, 0, sizeof(*resp));
172 172
	strcpy(resp->community, pdu->community);
......
276 276
		}
277 277
	}
278 278

  
279
	if (snmp_fix_encoding(resp_b, resp) != SNMP_CODE_OK) {
280
		snmp_debug("get: failed to encode PDU");
281
		return (SNMP_RET_ERR);
282
	}
283

  
284
	return (SNMP_RET_OK);
279
	return (snmp_fix_encoding(resp_b, resp));
285 280
}
286 281

  
287 282
static struct snmp_node *
......
443 438
			return (SNMP_RET_ERR);
444 439
		}
445 440
	}
446

  
447
	if (snmp_fix_encoding(resp_b, resp) != SNMP_CODE_OK) {
448
		snmp_debug("getnext: failed to encode PDU");
449
		return (SNMP_RET_ERR);
450
	}
451

  
452
	return (SNMP_RET_OK);
441
	return (snmp_fix_encoding(resp_b, resp));
453 442
}
454 443

  
455 444
enum snmp_ret
......
553 542
	}
554 543

  
555 544
  done:
556
	if (snmp_fix_encoding(resp_b, resp) != SNMP_CODE_OK) {
557
		snmp_debug("getnext: failed to encode PDU");
558
		return (SNMP_RET_ERR);
559
	}
560

  
561
	return (SNMP_RET_OK);
545
	return (snmp_fix_encoding(resp_b, resp));
562 546
}
563 547

  
564 548
/*
......
973 957
snmp_make_errresp(const struct snmp_pdu *pdu, struct asn_buf *pdu_b,
974 958
    struct asn_buf *resp_b)
975 959
{
976
	u_char type;
977 960
	asn_len_t len;
978 961
	struct snmp_pdu resp;
979 962
	enum asn_err err;
980 963
	enum snmp_code code;
981 964

  
982
	snmp_pdu_create_response(pdu, &resp);
983

  
965
	memset(&resp, 0, sizeof(resp));
984 966
	if ((code = snmp_pdu_decode_header(pdu_b, &resp)) != SNMP_CODE_OK)
985 967
		return (SNMP_RET_IGN);
986 968

  
987
	if (pdu->version == SNMP_V3) {
988
		if (resp.user.priv_proto != SNMP_PRIV_NOPRIV &&
989
		   (asn_get_header(pdu_b, &type, &resp.scoped_len) != ASN_ERR_OK
990
		   || type != ASN_TYPE_OCTETSTRING)) {
991
			snmp_error("cannot decode encrypted pdu");
992
			return (SNMP_RET_IGN);
993
		}
994

  
995
		if (asn_get_sequence(pdu_b, &len) != ASN_ERR_OK) {
996
			snmp_error("cannot decode scoped pdu header");
997
			return (SNMP_RET_IGN);
998
		}
999

  
1000
		len = SNMP_ENGINE_ID_SIZ;
1001
		if (asn_get_octetstring(pdu_b, (u_char *)resp.context_engine,
1002
		    &len) != ASN_ERR_OK) {
1003
			snmp_error("cannot decode msg context engine");
1004
			return (SNMP_RET_IGN);
1005
		}
1006
		resp.context_engine_len = len;
1007
		len = SNMP_CONTEXT_NAME_SIZ;
1008
		if (asn_get_octetstring(pdu_b, (u_char *)resp.context_name,
1009
		    &len) != ASN_ERR_OK) {
1010
			snmp_error("cannot decode msg context name");
1011
			return (SNMP_RET_IGN);
1012
		}
1013
		resp.context_name[len] = '\0';
1014
	}
1015

  
1016

  
1017
	if (asn_get_header(pdu_b, &type, &len) != ASN_ERR_OK) {
1018
		snmp_error("cannot get pdu header");
1019
		return (SNMP_RET_IGN);
1020
	}
1021

  
1022
	if ((type & ~ASN_TYPE_MASK) !=
1023
	    (ASN_TYPE_CONSTRUCTED | ASN_CLASS_CONTEXT)) {
1024
		snmp_error("bad pdu header tag");
969
	if (pdu_b->asn_len < len)
1025 970
		return (SNMP_RET_IGN);
1026
	}
971
	pdu_b->asn_len = len;
1027 972

  
1028 973
	err = snmp_parse_pdus_hdr(pdu_b, &resp, &len);
1029 974
	if (ASN_ERR_STOPPED(err))
contrib/bsnmp/snmp_mibII/mibII.c
443 443
	size_t len;
444 444
	void *newmib;
445 445
	struct ifmibdata oldmib = ifp->mib;
446
	struct ifreq irr;
447 446

  
448 447
	if (fetch_generic_mib(ifp, &oldmib) == -1)
449 448
		return (-1);
......
515 514
	}
516 515

  
517 516
  out:
518
	strncpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name));
519
	irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias;
520
	irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias);
521
	if (ioctl(mib_netsock, SIOCGIFDESCR, &irr) == -1) {
522
		MIBIF_PRIV(ifp)->alias[0] = 0;
523
		if (errno != ENOMSG)
524
			syslog(LOG_WARNING, "SIOCGIFDESCR (%s): %m", ifp->name);
525
	} else if (irr.ifr_buffer.buffer == NULL) {
526
		MIBIF_PRIV(ifp)->alias[0] = 0;
527
		syslog(LOG_WARNING, "SIOCGIFDESCR (%s): too long (%zu)",
528
		    ifp->name, irr.ifr_buffer.length);
529
	}
530 517
	ifp->mibtick = get_ticks();
531 518
	return (0);
532 519
}
contrib/bsnmp/snmp_mibII/mibII.h
57 57
#include "snmp_mibII.h"
58 58
#include "mibII_tree.h"
59 59

  
60
/* maximum size of the interface alias */
61
#define	MIBIF_ALIAS_SIZE	(64 + 1)
62

  
63 60
/*
64 61
 * Interface list and flags.
65 62
 */
......
80 77
	uint64_t	hc_opackets;
81 78
	uint64_t	hc_imcasts;
82 79
	uint64_t	hc_ipackets;
83

  
84
	/* this should be made public */
85
	char		alias[MIBIF_ALIAS_SIZE];
86 80
};
87 81
#define	MIBIF_PRIV(IFP) ((struct mibif_private *)((IFP)->private))
88 82

  
contrib/bsnmp/snmp_mibII/mibII_interfaces.c
528 528
		break;
529 529

  
530 530
	  case LEAF_ifAlias:
531
		ret = string_get(value, MIBIF_PRIV(ifp)->alias, -1);
531
		ret = string_get(value, "", -1);
532 532
		break;
533 533

  
534 534
	  case LEAF_ifCounterDiscontinuityTime:
contrib/bsnmp/snmp_mibII/mibII_ip.c
151 151
op_ip(struct snmp_context *ctx, struct snmp_value *value,
152 152
    u_int sub, u_int idx __unused, enum snmp_op op)
153 153
{
154
	int old = 0;
154
	int old;
155 155

  
156 156
	switch (op) {
157 157

  
contrib/bsnmp/snmp_mibII/mibII_tcp.c
45 45
};
46 46

  
47 47
static uint64_t tcp_tick;
48
static uint64_t tcp_stats_tick;
49 48
static struct tcpstat tcpstat;
50 49
static struct xinpgen *xinpgen;
51 50
static size_t xinpgen_len;
51
static u_int tcp_count;
52 52
static u_int tcp_total;
53 53

  
54 54
static u_int oidnum;
......
64 64
}
65 65

  
66 66
static int
67
fetch_tcp_stats(void)
67
fetch_tcp(void)
68 68
{
69 69
	size_t len;
70
	struct xinpgen *ptr;
71
	struct xtcpcb *tp;
72
	struct tcp_index *oid;
73
	in_addr_t inaddr;
70 74

  
71 75
	len = sizeof(tcpstat);
72 76
	if (sysctlbyname("net.inet.tcp.stats", &tcpstat, &len, NULL, 0) == -1) {
......
78 82
		return (-1);
79 83
	}
80 84

  
81
	tcp_stats_tick = get_ticks();
82

  
83
	return (0);
84
}
85

  
86
static int
87
fetch_tcp(void)
88
{
89
	size_t len;
90
	struct xinpgen *ptr;
91
	struct xtcpcb *tp;
92
	struct tcp_index *oid;
93
	in_addr_t inaddr;
94

  
95 85
	len = 0;
96 86
	if (sysctlbyname("net.inet.tcp.pcblist", NULL, &len, NULL, 0) == -1) {
97 87
		syslog(LOG_ERR, "net.inet.tcp.pcblist: %m");
......
112 102

  
113 103
	tcp_tick = get_ticks();
114 104

  
105
	tcp_count = 0;
115 106
	tcp_total = 0;
116 107
	for (ptr = (struct xinpgen *)(void *)((char *)xinpgen + xinpgen->xig_len);
117 108
	     ptr->xig_len > sizeof(struct xinpgen);
......
123 114

  
124 115
		if (tp->xt_inp.inp_vflag & INP_IPV4)
125 116
			tcp_total++;
117

  
118
		if (tp->xt_tp.t_state == TCPS_ESTABLISHED ||
119
		    tp->xt_tp.t_state == TCPS_CLOSE_WAIT)
120
			tcp_count++;
126 121
	}
127 122

  
128 123
	if (oidnum < tcp_total) {
......
189 184
		abort();
190 185
	}
191 186

  
192
	if (tcp_stats_tick < this_tick)
193
		if (fetch_tcp_stats() == -1)
187
	if (tcp_tick < this_tick)
188
		if (fetch_tcp() == -1)
194 189
			return (SNMP_ERR_GENERR);
195 190

  
196 191
	switch (value->var.subs[sub - 1]) {
......
231 226
		break;
232 227

  
233 228
	  case LEAF_tcpCurrEstab:
234
#if __FreeBSD_version > 1003000
235
		value->v.uint32 = tcpstat.tcps_states[TCPS_ESTABLISHED] +
236
		    tcpstat.tcps_states[TCPS_CLOSE_WAIT];
237
#else
238
		value->v.uint32 = (uint32_t) -1;
239
#endif
229
		value->v.uint32 = tcp_count;
240 230
		break;
241 231

  
242 232
	  case LEAF_tcpInSegs:
contrib/bsnmp/snmp_target/target_snmp.c
301 301
		default:
302 302
			break;	
303 303
		}
304
		return (SNMP_ERR_NOERROR);
305 304

  
306 305
	default:
307 306
		abort();
......
626 625
		default:
627 626
			break;
628 627
		}
629
		return (SNMP_ERR_NOERROR);
630 628

  
631 629
	default:
632 630
		abort();
......
665 663
static int
666 664
target_decode_index(const struct asn_oid *oid, uint sub, char *name)
667 665
{
668
	uint32_t i;
666
	uint32_t i, len;
669 667

  
670
	if (oid->len - sub != oid->subs[sub] + 1 || oid->subs[sub] >=
671
	    SNMP_ADM_STR32_SIZ)
668
	if ((len = oid->len - sub) >= SNMP_ADM_STR32_SIZ)
672 669
		return (-1);
673 670

  
674
	for (i = 0; i < oid->subs[sub]; i++)
675
		name[i] = oid->subs[sub + i + 1];
671
	for (i = 0; i < len; i++)
672
		name[i] = oid->subs[sub + i];
676 673
	name[i] = '\0';
677 674

  
678 675
	return (0);
etc/netstart
34 34
# the network by hand, this script will do it for you).
35 35
#
36 36

  
37
. /etc/rc.subr
38

  
39
load_rc_config 'XXX'
40 37
_start=quietstart
41 38

  
42 39
/etc/rc.d/devd ${_start}
etc/periodic/daily/400.status-disks
16 16
	echo ""
17 17
	echo "Disk status:"
18 18

  
19
	df $daily_status_disks_df_flags && rc=1 || rc=3
19
	if [ -n "${daily_status_disks_ignore}" ] ; then
20
		ignore="egrep -v ${daily_status_disks_ignore}"
21
	else
22
		ignore="cat"
23
	fi
24
	(df $daily_status_disks_df_flags | ${ignore}) && rc=1 || rc=3
20 25

  
21 26
	# display which filesystems need backing up
22 27
	if [ -s /etc/dumpdates ]; then
etc/rc.d/local_unbound
30 30
: ${local_unbound_config:=${local_unbound_workdir}/unbound.conf}
31 31
: ${local_unbound_flags:="-c ${local_unbound_config}"}
32 32
: ${local_unbound_forwardconf:=${local_unbound_workdir}/forward.conf}
33
: ${local_unbound_controlconf:=${local_unbound_workdir}/control.conf}
33 34
: ${local_unbound_anchor:=${local_unbound_workdir}/root.key}
34 35
: ${local_unbound_forwarders:=}
35 36

  
......
68 69
	    -w ${local_unbound_workdir} \
69 70
	    -c ${local_unbound_config} \
70 71
	    -f ${local_unbound_forwardconf} \
72
	    -o ${local_unbound_controlconf} \
71 73
	    -a ${local_unbound_anchor} \
72 74
	    ${local_unbound_forwarders}
73 75
}
etc/rc.d/othermta
10 10
#
11 11
. /etc/rc.subr
12 12

  
13
load_rc_config 'XXX'
13
load_rc_config
14 14

  
15 15
if [ -n "${mta_start_script}" ]; then
16 16
	[ "${mta_start_script}" != "/etc/rc.sendmail" ] && \
etc/rc.shutdown
45 45

  
46 46
. /etc/rc.subr
47 47

  
48
load_rc_config 'XXX'
48
load_rc_config
49 49

  
50 50
# reverse_list list
51 51
#	print the list in reverse order
lib/libc/net/sctp_sys_calls.c
700 700
#ifdef SYS_sctp_generic_sendmsg
701 701
	if (addrcnt == 1) {
702 702
		socklen_t l;
703
		ssize_t ret;
703 704

  
704 705
		/*
705 706
		 * Quick way, we don't need to do a connectx so lets use the
706 707
		 * syscall directly.
707 708
		 */
708 709
		l = addrs->sa_len;
709
		return (syscall(SYS_sctp_generic_sendmsg, sd,
710
		    msg, msg_len, addrs, l, sinfo, flags));
710
		ret = syscall(SYS_sctp_generic_sendmsg, sd,
711
		    msg, msg_len, addrs, l, sinfo, flags);
712
		if ((ret >= 0) && (sinfo != NULL)) {
713
			sinfo->sinfo_assoc_id = sctp_getassocid(sd, addrs);
714
		}
715
		return (ret);
711 716
	}
712 717
#endif
713 718

  
......
984 989
	struct sockaddr *addr;
985 990
	struct sockaddr_in *addr_in;
986 991
	struct sockaddr_in6 *addr_in6;
992
	sctp_assoc_t *assoc_id;
987 993

  
988 994
	if ((addrcnt < 0) ||
989 995
	    (iovcnt < 0) ||
......
1002 1008
		errno = ENOMEM;
1003 1009
		return (-1);
1004 1010
	}
1011
	assoc_id = NULL;
1005 1012
	msg.msg_control = cmsgbuf;
1006 1013
	msg.msg_controllen = 0;
1007 1014
	cmsg = (struct cmsghdr *)cmsgbuf;
......
1025 1032
		memcpy(CMSG_DATA(cmsg), info, sizeof(struct sctp_sndinfo));
1026 1033
		msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo));
1027 1034
		cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo)));
1035
		assoc_id = &(((struct sctp_sndinfo *)info)->snd_assoc_id);
1028 1036
		break;
1029 1037
	case SCTP_SENDV_PRINFO:
1030 1038
		if ((info == NULL) || (infolen < sizeof(struct sctp_prinfo))) {
......
1066 1074
			memcpy(CMSG_DATA(cmsg), &spa_info->sendv_sndinfo, sizeof(struct sctp_sndinfo));
1067 1075
			msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo));
1068 1076
			cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo)));
1077
			assoc_id = &(spa_info->sendv_sndinfo.snd_assoc_id);
1069 1078
		}
1070 1079
		if (spa_info->sendv_flags & SCTP_SEND_PRINFO_VALID) {
1071 1080
			cmsg->cmsg_level = IPPROTO_SCTP;
......
1164 1173
	msg.msg_flags = 0;
1165 1174
	ret = sendmsg(sd, &msg, flags);
1166 1175
	free(cmsgbuf);
1176
	if ((ret >= 0) && (addrs != NULL) && (assoc_id != NULL)) {
1177
		*assoc_id = sctp_getassocid(sd, addrs);
1178
	}
1167 1179
	return (ret);
1168 1180
}
1169 1181

  
lib/libc/stdio/fopen.3
120 120
.St -isoC
121 121
and has effect only for
122 122
.Fn fmemopen
123
; otherwise the ``b'' is ignored.
123
; otherwise
124
.Dq Li b
125
is ignored.
124 126
.Pp
125 127
Any created files will have mode
126 128
.Do Dv S_IRUSR
......
230 232
.Fa size
231 233
bytes of memory. This buffer is automatically freed when the
232 234
stream is closed. Buffers can be opened in text-mode (default) or binary-mode
233
(if ``b'' is present in the second or third position of the
235
(if
236
.Dq Li b
237
is present in the second or third position of the
234 238
.Fa mode
235 239
argument). Buffers opened in text-mode make sure that writes are terminated with
236 240
a NULL byte, if the last write hasn't filled up the whole buffer. Buffers
......
343 347
function
344 348
conforms to
345 349
.St -p1003.1-2008 .
346
The ``b'' mode does not conform to any standard
350
The
351
.Dq Li b
352
mode does not conform to any standard
347 353
but is also supported by glibc.
lib/libc/stdlib/tdelete.c
1
/*	$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $	*/
1
/*	$NetBSD: tdelete.c,v 1.8 2016/01/20 20:47:41 christos Exp $	*/
2 2

  
3 3
/*
4 4
 * Tree search generalized from Knuth (6.2.2) Algorithm T just like
......
14 14
#include <sys/cdefs.h>
15 15
#if 0
16 16
#if defined(LIBC_SCCS) && !defined(lint)
17
__RCSID("$NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
17
__RCSID("$NetBSD: tdelete.c,v 1.8 2016/01/20 20:47:41 christos Exp $");
18 18
#endif /* LIBC_SCCS and not lint */
19 19
#endif
20 20
__FBSDID("$FreeBSD$");
......
25 25

  
26 26

  
27 27
/*
28
 * find a node with given key
28
 * delete node with given key
29 29
 *
30
 * vkey:   key to be found
30
 * vkey:   key to be deleted
31 31
 * vrootp: address of the root of the tree
32 32
 * compar: function to carry out node comparisons
33 33
 */
......
65 65
			q->rlink = (*rootp)->rlink;
66 66
		}
67 67
	}
68
	if (p != *rootp)
69
		free(*rootp);			/* D4: Free node */
68
	free(*rootp);				/* D4: Free node */
70 69
	*rootp = q;				/* link parent to new node */
71 70
	return p;
72 71
}
lib/libdpv/dpv.c
36 36
#include <dialog.h>
37 37
#include <err.h>
38 38
#include <limits.h>
39
#include <locale.h>
39 40
#include <stdio.h>
40 41
#include <stdlib.h>
41 42
#include <string.h>
......
482 483
		/* Reads: label_size pbar_size pprompt aprompt dpv_nfiles */
483 484
		/* Inits: dheight and dwidth */
484 485

  
486
	/* Default localeconv(3) settings for dialog(3) status */
487
	setlocale(LC_NUMERIC,
488
		getenv("LC_ALL") == NULL && getenv("LC_NUMERIC") == NULL ?
489
		LC_NUMERIC_DEFAULT : "");
490

  
485 491
	if (!debug) {
486 492
		/* Internally create the initial `--gauge' prompt text */
487 493
		dprompt_recreate(file_list, (struct dpv_file_node *)NULL, 0);
lib/libdpv/dpv.h
38 38
#define FALSE 0
39 39
#endif
40 40

  
41
/* localeconv(3) */
42
#define LC_NUMERIC_DEFAULT	"en_US.ISO8859-1"
43

  
41 44
/* Data to process */
42 45
extern long long dpv_overall_read;
43 46

  
release/doc/share/xml/security.xml
107 107
	<entry><para><application>OpenSSH</application> client
108 108
	    information leak</para></entry>
109 109
      </row>
110

  
111
      <row>
112
	<entry><link
113
	    xlink:href="&security.url;/FreeBSD-SA-16:09.ntp.asc">FreeBSD-SA-16:09.ntp</link></entry>
114
	<entry>27&nbsp;January&nbsp;2016</entry>
115
	<entry><para>Multiple vulnerabilities.</para></entry>
116
      </row>
117

  
118
      <row>
119
	<entry><link
120
	    xlink:href="&security.url;/FreeBSD-SA-16:10.linux.asc">FreeBSD-SA-16:10.linux</link></entry>
121
	<entry>27&nbsp;January&nbsp;2016</entry>
122
	<entry><para>&man.issetugid.2; system call
123
	    vulnerability.</para></entry>
124
      </row>
110 125
    </tbody>
111 126
  </tgroup>
112 127
</informaltable>
sbin/pfctl/pfctl.c
834 834
			printf("  [ Inserted: pid %u "
835 835
			    "State Creations: %-6ju]\n",
836 836
			    (unsigned)rule->cpid,
837
			    (uintmax_t)rule->states_tot);
837
			    (uintmax_t)rule->u_states_tot);
838 838
#endif
839 839
	}
840 840
}
share/dtrace/Makefile
12 12
_toolkit=	toolkit
13 13
.endif
14 14

  
15
SCRIPTS=	nfsclienttime hotopen
15
SCRIPTS=	nfsclienttime hotopen \
16
		watch_execve \
17
		watch_kill \
18
		watch_vop_remove
16 19

  
17 20
SCRIPTSDIR= ${SHAREDIR}/dtrace
18 21

  
share/dtrace/watch_execve
1
#!/usr/sbin/dtrace -s
2
/* -
3
 * Copyright (c) 2014 Devin Teske <dteske@FreeBSD.org>
4
 * All rights reserved.
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 *
26
 * $Title: dtrace(1) script to log process(es) entering syscall::execve $
27
 * $FreeBSD$
28
 */
29

  
30
#pragma D option quiet
31
#pragma D option dynvarsize=16m
32
#pragma D option switchrate=10hz
33

  
34
/*********************************************************/
35

  
36
syscall::execve:entry /* probe ID 1 */
37
{
38
	this->caller_execname = execname;
39
}
40

  
41
/*********************************************************/
42

  
43
syscall::execve:return /execname != this->caller_execname/ /* probe ID 2 */
44
{
45
	/*
46
	 * Examine process, parent process, and grandparent process details
47
	 */
48

  
49
	/******************* CURPROC *******************/
50

  
51
	this->proc = curthread->td_proc;
52
	this->pid0 = this->proc->p_pid;
53
	this->uid0 = this->proc->p_ucred->cr_uid;
54
	this->gid0 = this->proc->p_ucred->cr_rgid;
55
	this->p_args = this->proc->p_args;
56
	this->ar_length = this->p_args ? this->p_args->ar_length : 0;
57
	this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
58

  
59
	this->arg0_0 = this->ar_length > 0 ?
60
		this->ar_args : stringof(this->proc->p_comm);
61
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
62
	this->ar_args += this->len;
63
	this->ar_length -= this->len;
64

  
65
	this->arg0_1 = this->ar_length > 0 ? this->ar_args : "";
66
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
67
	this->ar_args += this->len;
68
	this->ar_length -= this->len;
69

  
70
	this->arg0_2 = this->ar_length > 0 ? this->ar_args : "";
71
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
72
	this->ar_args += this->len;
73
	this->ar_length -= this->len;
74

  
75
	this->arg0_3 = this->ar_length > 0 ? this->ar_args : "";
76
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
77
	this->ar_args += this->len;
78
	this->ar_length -= this->len;
79

  
80
	this->arg0_4 = this->ar_length > 0 ? "..." : "";
81

  
82
	/******************* PPARENT *******************/
83

  
84
	this->proc = this->proc->p_pptr;
85
	this->pid1 = this->proc->p_pid;
86
	this->uid1 = this->proc->p_ucred->cr_uid;
87
	this->gid1 = this->proc->p_ucred->cr_rgid;
88
	this->p_args = this->proc ? this->proc->p_args : 0;
89
	this->ar_length = this->p_args ? this->p_args->ar_length : 0;
90
	this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
91

  
92
	this->arg1_0 = this->ar_length > 0 ?
93
		this->ar_args : stringof(this->proc->p_comm);
94
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
95
	this->ar_args += this->len;
96
	this->ar_length -= this->len;
97

  
98
	this->arg1_1 = this->ar_length > 0 ? this->ar_args : "";
99
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
100
	this->ar_args += this->len;
101
	this->ar_length -= this->len;
102

  
103
	this->arg1_2 = this->ar_length > 0 ? this->ar_args : "";
104
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
105
	this->ar_args += this->len;
106
	this->ar_length -= this->len;
107

  
108
	this->arg1_3 = this->ar_length > 0 ? this->ar_args : "";
109
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
110
	this->ar_args += this->len;
111
	this->ar_length -= this->len;
112

  
113
	this->arg1_4 = this->ar_length > 0 ? "..." : "";
114

  
115
	/******************* GPARENT *******************/
116

  
117
	this->proc = this->proc->p_pptr;
118
	this->pid2 = this->proc->p_pid;
119
	this->uid2 = this->proc->p_ucred->cr_uid;
120
	this->gid2 = this->proc->p_ucred->cr_rgid;
121
	this->p_args = this->proc ? this->proc->p_args : 0;
122
	this->ar_length = this->p_args ? this->p_args->ar_length : 0;
123
	this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
124

  
125
	this->arg2_0 = this->ar_length > 0 ?
126
		this->ar_args : stringof(this->proc->p_comm);
127
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
128
	this->ar_args += this->len;
129
	this->ar_length -= this->len;
130

  
131
	this->arg2_1 = this->ar_length > 0 ? this->ar_args : "";
132
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
133
	this->ar_args += this->len;
134
	this->ar_length -= this->len;
135

  
136
	this->arg2_2 = this->ar_length > 0 ? this->ar_args : "";
137
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
138
	this->ar_args += this->len;
139
	this->ar_length -= this->len;
140

  
141
	this->arg2_3 = this->ar_length > 0 ? this->ar_args : "";
142
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
143
	this->ar_args += this->len;
144
	this->ar_length -= this->len;
145

  
146
	this->arg2_4 = this->ar_length > 0 ? "..." : "";
147

  
148
	/******************* APARENT *******************/
149

  
150
	this->proc = this->proc->p_pptr;
151
	this->pid3 = this->proc->p_pid;
152
	this->uid3 = this->proc->p_ucred->cr_uid;
153
	this->gid3 = this->proc->p_ucred->cr_rgid;
154
	this->p_args = this->proc ? this->proc->p_args : 0;
155
	this->ar_length = this->p_args ? this->p_args->ar_length : 0;
156
	this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
157

  
158
	this->arg3_0 = this->ar_length > 0 ?
159
		this->ar_args : stringof(this->proc->p_comm);
160
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
161
	this->ar_args += this->len;
162
	this->ar_length -= this->len;
163

  
164
	this->arg3_1 = this->ar_length > 0 ? this->ar_args : "";
165
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
166
	this->ar_args += this->len;
167
	this->ar_length -= this->len;
168

  
169
	this->arg3_2 = this->ar_length > 0 ? this->ar_args : "";
170
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
171
	this->ar_args += this->len;
172
	this->ar_length -= this->len;
173

  
174
	this->arg3_3 = this->ar_length > 0 ? this->ar_args : "";
175
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
176
	this->ar_args += this->len;
177
	this->ar_length -= this->len;
178

  
179
	this->arg3_4 = this->ar_length > 0 ? "..." : "";
180

  
181
	/***********************************************/
182

  
183
	/*
184
	 * Print process, parent, and grandparent details
185
	 */
186

  
187
	printf("%Y %s[%d]: ", timestamp + 1406598400000000000,
188
		this->caller_execname, this->pid1);
189
	printf("%s", this->arg0_0);
190
	printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
191
	printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
192
	printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
193
	printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
194
	printf("\n");
195

  
196
	printf(" -+= %05d %d.%d %s",
197
		this->pid3, this->uid3, this->gid3, this->arg3_0);
198
	printf("%s%s", this->arg3_1 != "" ? " " : "", this->arg3_1);
199
	printf("%s%s", this->arg3_2 != "" ? " " : "", this->arg3_2);
200
	printf("%s%s", this->arg3_3 != "" ? " " : "", this->arg3_3);
201
	printf("%s%s", this->arg3_4 != "" ? " " : "", this->arg3_4);
202
	printf("%s", this->arg3_0 != "" ? "\n" : "");
203

  
204
	printf("  \-+= %05d %d.%d %s",
205
		this->pid2, this->uid2, this->gid2, this->arg2_0);
206
	printf("%s%s", this->arg2_1 != "" ? " " : "", this->arg2_1);
207
	printf("%s%s", this->arg2_2 != "" ? " " : "", this->arg2_2);
208
	printf("%s%s", this->arg2_3 != "" ? " " : "", this->arg2_3);
209
	printf("%s%s", this->arg2_4 != "" ? " " : "", this->arg2_4);
210
	printf("%s", this->arg2_0 != "" ? "\n" : "");
211

  
212
	printf("    \-+= %05d %d.%d %s",
213
		this->pid1, this->uid1, this->gid1, this->arg1_0);
214
	printf("%s%s", this->arg1_1 != "" ? " " : "", this->arg1_1);
215
	printf("%s%s", this->arg1_2 != "" ? " " : "", this->arg1_2);
216
	printf("%s%s", this->arg1_3 != "" ? " " : "", this->arg1_3);
217
	printf("%s%s", this->arg1_4 != "" ? " " : "", this->arg1_4);
218
	printf("%s", this->arg1_0 != "" ? "\n" : "");
219

  
220
	printf("      \-+= %05d %d.%d %s",
221
		this->pid0, this->uid0, this->gid0, this->arg0_0);
222
	printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
223
	printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
224
	printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
225
	printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
226
	printf("%s", this->arg0_0 != "" ? "\n" : "");
227
}
share/dtrace/watch_kill
1
#!/usr/sbin/dtrace -s
2
/* -
3
 * Copyright (c) 2014-2016 Devin Teske <dteske@FreeBSD.org>
4
 * All rights reserved.
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 *
26
 * $Title: dtrace(1) script to log process(es) entering syscall::kill $
27
 * $FreeBSD$
28
 */
29

  
30
#pragma D option quiet
31
#pragma D option dynvarsize=16m
32
#pragma D option switchrate=10hz
33

  
34
/*********************************************************/
35

  
36
syscall::execve:entry /* probe ID 1 */
37
{
38
	this->caller_execname = execname;
39
}
40

  
41
/*********************************************************/
42

  
43
syscall::kill:entry /* probe ID 2 */
44
{
45
	this->pid_to_kill = (pid_t)arg0;
46
	this->kill_signal = (int)arg1;
47

  
48
	/*
49
	 * Examine process, parent process, and grandparent process details
50
	 */
51

  
52
	/******************* CURPROC *******************/
53

  
54
	this->proc = curthread->td_proc;
55
	this->pid0 = this->proc->p_pid;
56
	this->uid0 = this->proc->p_ucred->cr_uid;
57
	this->gid0 = this->proc->p_ucred->cr_rgid;
58
	this->p_args = this->proc->p_args;
59
	this->ar_length = this->p_args ? this->p_args->ar_length : 0;
60
	this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
61

  
62
	this->arg0_0 = this->ar_length > 0 ?
63
		this->ar_args : stringof(this->proc->p_comm);
64
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
65
	this->ar_args += this->len;
66
	this->ar_length -= this->len;
67

  
68
	this->arg0_1 = this->ar_length > 0 ? this->ar_args : "";
69
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
70
	this->ar_args += this->len;
71
	this->ar_length -= this->len;
72

  
73
	this->arg0_2 = this->ar_length > 0 ? this->ar_args : "";
74
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
75
	this->ar_args += this->len;
76
	this->ar_length -= this->len;
77

  
78
	this->arg0_3 = this->ar_length > 0 ? this->ar_args : "";
79
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
80
	this->ar_args += this->len;
81
	this->ar_length -= this->len;
82

  
83
	this->arg0_4 = this->ar_length > 0 ? "..." : "";
84

  
85
	/******************* PPARENT *******************/
86

  
87
	this->proc = this->proc->p_pptr;
88
	this->pid1 = this->proc->p_pid;
89
	this->uid1 = this->proc->p_ucred->cr_uid;
90
	this->gid1 = this->proc->p_ucred->cr_rgid;
91
	this->p_args = this->proc ? this->proc->p_args : 0;
92
	this->ar_length = this->p_args ? this->p_args->ar_length : 0;
93
	this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
94

  
95
	this->arg1_0 = this->ar_length > 0 ?
96
		this->ar_args : stringof(this->proc->p_comm);
97
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
98
	this->ar_args += this->len;
99
	this->ar_length -= this->len;
100

  
101
	this->arg1_1 = this->ar_length > 0 ? this->ar_args : "";
102
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
103
	this->ar_args += this->len;
104
	this->ar_length -= this->len;
105

  
106
	this->arg1_2 = this->ar_length > 0 ? this->ar_args : "";
107
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
108
	this->ar_args += this->len;
109
	this->ar_length -= this->len;
110

  
111
	this->arg1_3 = this->ar_length > 0 ? this->ar_args : "";
112
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
113
	this->ar_args += this->len;
114
	this->ar_length -= this->len;
115

  
116
	this->arg1_4 = this->ar_length > 0 ? "..." : "";
117

  
118
	/******************* GPARENT *******************/
119

  
120
	this->proc = this->proc->p_pptr;
121
	this->pid2 = this->proc->p_pid;
122
	this->uid2 = this->proc->p_ucred->cr_uid;
123
	this->gid2 = this->proc->p_ucred->cr_rgid;
124
	this->p_args = this->proc ? this->proc->p_args : 0;
125
	this->ar_length = this->p_args ? this->p_args->ar_length : 0;
126
	this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
127

  
128
	this->arg2_0 = this->ar_length > 0 ?
129
		this->ar_args : stringof(this->proc->p_comm);
130
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
131
	this->ar_args += this->len;
132
	this->ar_length -= this->len;
133

  
134
	this->arg2_1 = this->ar_length > 0 ? this->ar_args : "";
135
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
136
	this->ar_args += this->len;
137
	this->ar_length -= this->len;
138

  
139
	this->arg2_2 = this->ar_length > 0 ? this->ar_args : "";
140
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
141
	this->ar_args += this->len;
142
	this->ar_length -= this->len;
143

  
144
	this->arg2_3 = this->ar_length > 0 ? this->ar_args : "";
145
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
146
	this->ar_args += this->len;
147
	this->ar_length -= this->len;
148

  
149
	this->arg2_4 = this->ar_length > 0 ? "..." : "";
150

  
151
	/******************* APARENT *******************/
152

  
153
	this->proc = this->proc->p_pptr;
154
	this->pid3 = this->proc->p_pid;
155
	this->uid3 = this->proc->p_ucred->cr_uid;
156
	this->gid3 = this->proc->p_ucred->cr_rgid;
157
	this->p_args = this->proc ? this->proc->p_args : 0;
158
	this->ar_length = this->p_args ? this->p_args->ar_length : 0;
159
	this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
160

  
161
	this->arg3_0 = this->ar_length > 0 ?
162
		this->ar_args : stringof(this->proc->p_comm);
163
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
164
	this->ar_args += this->len;
165
	this->ar_length -= this->len;
166

  
167
	this->arg3_1 = this->ar_length > 0 ? this->ar_args : "";
168
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
169
	this->ar_args += this->len;
170
	this->ar_length -= this->len;
171

  
172
	this->arg3_2 = this->ar_length > 0 ? this->ar_args : "";
173
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
174
	this->ar_args += this->len;
175
	this->ar_length -= this->len;
176

  
177
	this->arg3_3 = this->ar_length > 0 ? this->ar_args : "";
178
	this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
179
	this->ar_args += this->len;
180
	this->ar_length -= this->len;
181

  
182
	this->arg3_4 = this->ar_length > 0 ? "..." : "";
183

  
184
	/***********************************************/
185

  
186
	/*
187
	 * Print process, parent, and grandparent details
188
	 */
189

  
190
	printf("%Y %s[%d]: ", timestamp + 1406598400000000000,
191
		this->caller_execname, this->pid1);
192
	printf("%s", this->arg0_0);
193
	printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
194
	printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
195
	printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
196
	printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
197
	printf(" (sending signal %u to pid %u)",
198
		this->kill_signal, this->pid_to_kill);
199
	printf("\n");
200

  
201
	printf(" -+= %05d %d.%d %s",
202
		this->pid3, this->uid3, this->gid3, this->arg3_0);
203
	printf("%s%s", this->arg3_1 != "" ? " " : "", this->arg3_1);
204
	printf("%s%s", this->arg3_2 != "" ? " " : "", this->arg3_2);
205
	printf("%s%s", this->arg3_3 != "" ? " " : "", this->arg3_3);
206
	printf("%s%s", this->arg3_4 != "" ? " " : "", this->arg3_4);
207
	printf("%s", this->arg3_0 != "" ? "\n" : "");
208

  
209
	printf("  \-+= %05d %d.%d %s",
210
		this->pid2, this->uid2, this->gid2, this->arg2_0);
211
	printf("%s%s", this->arg2_1 != "" ? " " : "", this->arg2_1);
212
	printf("%s%s", this->arg2_2 != "" ? " " : "", this->arg2_2);
213
	printf("%s%s", this->arg2_3 != "" ? " " : "", this->arg2_3);
214
	printf("%s%s", this->arg2_4 != "" ? " " : "", this->arg2_4);
215
	printf("%s", this->arg2_0 != "" ? "\n" : "");
216

  
217
	printf("    \-+= %05d %d.%d %s",
218
		this->pid1, this->uid1, this->gid1, this->arg1_0);
219
	printf("%s%s", this->arg1_1 != "" ? " " : "", this->arg1_1);
220
	printf("%s%s", this->arg1_2 != "" ? " " : "", this->arg1_2);
221
	printf("%s%s", this->arg1_3 != "" ? " " : "", this->arg1_3);
222
	printf("%s%s", this->arg1_4 != "" ? " " : "", this->arg1_4);
223
	printf("%s", this->arg1_0 != "" ? "\n" : "");
224

  
225
	printf("      \-+= %05d %d.%d %s",
226
		this->pid0, this->uid0, this->gid0, this->arg0_0);
227
	printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
228
	printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
229
	printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
230
	printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
231
	printf("%s", this->arg0_0 != "" ? "\n" : "");
232
}
share/dtrace/watch_vop_remove
1
#!/usr/sbin/dtrace -s
2
/* -
3
 * Copyright (c) 2014 Devin Teske <dteske@FreeBSD.org>
4
 * All rights reserved.
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 *
26
 * $Title: dtrace(1) script to log process(es) entering vfs::vop_remove $
27
 * $FreeBSD$
28
 */
29

  
30
#pragma D option quiet
31
#pragma D option dynvarsize=16m
32
#pragma D option switchrate=10hz
33

  
34
/*********************************************************/
35

  
36
vfs::vop_remove:entry /* probe ID 1 */
37
{
38
	this->vp = (struct vnode *)arg0;
39
	this->ncp = &(this->vp->v_cache_dst) != NULL ?
40
		this->vp->v_cache_dst.tqh_first : 0;
41
        this->fi_name = args[1] ? (
42
		args[1]->a_cnp != NULL ?
43
			stringof(args[1]->a_cnp->cn_nameptr) : ""
44
	) : "";
45
	this->mount = this->vp->v_mount; /* ptr to vfs we are in */
46
	this->fi_fs = this->mount != 0 ?
47
		stringof(this->mount->mnt_stat.f_fstypename) : "";
48
	this->fi_mount = this->mount != 0 ?
49
		stringof(this->mount->mnt_stat.f_mntonname) : "";
50
	this->d_name = args[0]->v_cache_dd != NULL ?
51
		stringof(args[0]->v_cache_dd->nc_name) : "";
52
}
53

  
54
vfs::vop_remove:entry /this->vp == 0 || this->fi_fs == 0 ||
55
	this->fi_fs == "devfs" || this->fi_fs == "" ||
56
	this->fi_name == ""/ /* probe ID 2 */
57
{
58
	this->ncp = 0;
59
}
60

  
61
/*********************************************************/
62

  
63
vfs::vop_remove:entry /this->ncp/ /* probe ID 3 (depth 1) */
64
{
65
	this->dvp = this->ncp->nc_dvp != NULL ? (
66
		&(this->ncp->nc_dvp->v_cache_dst) != NULL ?
67
			this->ncp->nc_dvp->v_cache_dst.tqh_first : 0
68
	) : 0;
69
	this->name1 = this->dvp != 0 ? (
70
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
71
	) : "";
72
}
73

  
74
vfs::vop_remove:entry /this->name1 == 0 || this->fi_fs == 0 ||
75
	this->fi_fs == "devfs" || this->fi_fs == "" ||
76
	this->name1 == "/" || this->name1 == ""/ /* probe ID 4 */
77
{
78
	this->dvp = 0;
79
}
80

  
81
/*********************************************************/
82

  
83
/*
84
 * BEGIN Pathname-depth iterators (copy/paste as many times as-desired)
85
 */
86

  
87
vfs::vop_remove:entry /this->dvp/ /* probe ID 5 (depth 2) */
88
{
89
	this->dvp = this->dvp->nc_dvp != NULL ? (
90
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
91
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
92
	) : 0;
93
	this->name2 = this->dvp != 0 ? (
94
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
95
	) : "";
96
}
97

  
98
vfs::vop_remove:entry /this->dvp/ /* probe ID 6 (depth 3) */
99
{
100
	this->dvp = this->dvp->nc_dvp != NULL ? (
101
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
102
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
103
	) : 0;
104
	this->name3 = this->dvp != 0 ? (
105
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
106
	) : "";
107
}
108

  
109
vfs::vop_remove:entry /this->dvp/ /* probe ID 7 (depth 4) */
110
{
111
	this->dvp = this->dvp->nc_dvp != NULL ? (
112
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
113
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
114
	) : 0;
115
	this->name4 = this->dvp != 0 ? (
116
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
117
	) : "";
118
}
119

  
120
vfs::vop_remove:entry /this->dvp/ /* probe ID 8 (depth 5) */
121
{
122
	this->dvp = this->dvp->nc_dvp != NULL ? (
123
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
124
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
125
	) : 0;
126
	this->name5 = this->dvp != 0 ? (
127
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
128
	) : "";
129
}
130

  
131
vfs::vop_remove:entry /this->dvp/ /* probe ID 9 (depth 6) */
132
{
133
	this->dvp = this->dvp->nc_dvp != NULL ? (
134
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
135
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
136
	) : 0;
137
	this->name6 = this->dvp != 0 ? (
138
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
139
	) : "";
140
}
141

  
142
vfs::vop_remove:entry /this->dvp/ /* probe ID 10 (depth 7) */
143
{
144
	this->dvp = this->dvp->nc_dvp != NULL ? (
145
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
146
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
147
	) : 0;
148
	this->name7 = this->dvp != 0 ? (
149
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
150
	) : "";
151
}
152

  
153
vfs::vop_remove:entry /this->dvp/ /* probe ID 11 (depth 8) */
154
{
155
	this->dvp = this->dvp->nc_dvp != NULL ? (
156
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
157
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
158
	) : 0;
159
	this->name8 = this->dvp != 0 ? (
160
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
161
	) : "";
162
}
163

  
164
vfs::vop_remove:entry /this->dvp/ /* probe ID 12 (depth 9) */
165
{
166
	this->dvp = this->dvp->nc_dvp != NULL ? (
167
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
168
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
169
	) : 0;
170
	this->name9 = this->dvp != 0 ? (
171
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
172
	) : "";
173
}
174

  
175
vfs::vop_remove:entry /this->dvp/ /* probe ID 13 (depth 10) */
176
{
177
	this->dvp = this->dvp->nc_dvp != NULL ? (
178
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
179
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
180
	) : 0;
181
	this->name10 = this->dvp != 0 ? (
182
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
183
	) : "";
184
}
185

  
186
vfs::vop_remove:entry /this->dvp/ /* probe ID 14 (depth 11) */
187
{
188
	this->dvp = this->dvp->nc_dvp != NULL ? (
189
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
190
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
191
	) : 0;
192
	this->name11 = this->dvp != 0 ? (
193
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
194
	) : "";
195
}
196

  
197
vfs::vop_remove:entry /this->dvp/ /* probe ID 15 (depth 12) */
198
{
199
	this->dvp = this->dvp->nc_dvp != NULL ? (
200
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
201
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
202
	) : 0;
203
	this->name12 = this->dvp != 0 ? (
204
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
205
	) : "";
206
}
207

  
208
vfs::vop_remove:entry /this->dvp/ /* probe ID 16 (depth 13) */
209
{
210
	this->dvp = this->dvp->nc_dvp != NULL ? (
211
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
212
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
213
	) : 0;
214
	this->name13 = this->dvp != 0 ? (
215
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
216
	) : "";
217
}
218

  
219
vfs::vop_remove:entry /this->dvp/ /* probe ID 17 (depth 14) */
220
{
221
	this->dvp = this->dvp->nc_dvp != NULL ? (
222
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
223
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
224
	) : 0;
225
	this->name14 = this->dvp != 0 ? (
226
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
227
	) : "";
228
}
229

  
230
vfs::vop_remove:entry /this->dvp/ /* probe ID 18 (depth 15) */
231
{
232
	this->dvp = this->dvp->nc_dvp != NULL ? (
233
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
234
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
235
	) : 0;
236
	this->name15 = this->dvp != 0 ? (
237
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
238
	) : "";
239
}
240

  
241
vfs::vop_remove:entry /this->dvp/ /* probe ID 19 (depth 16) */
242
{
243
	this->dvp = this->dvp->nc_dvp != NULL ? (
244
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
245
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
246
	) : 0;
247
	this->name16 = this->dvp != 0 ? (
248
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
249
	) : "";
250
}
251

  
252
vfs::vop_remove:entry /this->dvp/ /* probe ID 20 (depth 17) */
253
{
254
	this->dvp = this->dvp->nc_dvp != NULL ? (
255
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
256
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
257
	) : 0;
258
	this->name17 = this->dvp != 0 ? (
259
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
260
	) : "";
261
}
262

  
263
vfs::vop_remove:entry /this->dvp/ /* probe ID 21 (depth 18) */
264
{
265
	this->dvp = this->dvp->nc_dvp != NULL ? (
266
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
267
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
268
	) : 0;
269
	this->name18 = this->dvp != 0 ? (
270
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
271
	) : "";
272
}
273

  
274
vfs::vop_remove:entry /this->dvp/ /* probe ID 22 (depth 19) */
275
{
276
	this->dvp = this->dvp->nc_dvp != NULL ? (
277
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
278
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
279
	) : 0;
280
	this->name19 = this->dvp != 0 ? (
281
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
282
	) : "";
283
}
284

  
285
vfs::vop_remove:entry /this->dvp/ /* probe ID 23 (depth 20) */
286
{
287
	this->dvp = this->dvp->nc_dvp != NULL ? (
288
		&(this->dvp->nc_dvp->v_cache_dst) != NULL ?
289
			this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
290
	) : 0;
291
	this->name20 = this->dvp != 0 ? (
292
		this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
293
	) : "";
294
}
295

  
296
/*
297
 * END Pathname-depth iterators
298
 */
299

  
300
/*********************************************************/
301

  
302
vfs::vop_remove:entry /this->fi_mount != 0/ /* probe ID 24 */
303
{
304
	printf("%Y %s[%d]: ", timestamp + 1406598400000000000, execname, pid);
305

  
306
	/*
307
	 * Print full path of file to delete
308
	 * NB: Up-to but not including the parent directory (printed below)
309
	 */
310
	printf("%s%s", this->fi_mount, this->fi_mount != 0 ? (
311
		this->fi_mount == "/" ? "" : "/"
312
	) : "/");
313
	printf("%s%s", this->name = this->name20, this->name != "" ? "/" : "");
... This diff was truncated because it exceeds the maximum size that can be displayed.
(2-2/2)