MCPcopy Create free account
hub / github.com/F-Stack/f-stack / audit_pipe_alloc

Function audit_pipe_alloc

freebsd/security/audit/audit_pipe.c:567–604  ·  view source on GitHub ↗

* Allocate a new audit pipe. Connects the pipe, on success, to the global * list and updates statistics. */

Source from the content-addressed store, hash-verified

565 * list and updates statistics.
566 */
567static struct audit_pipe *
568audit_pipe_alloc(void)
569{
570 struct audit_pipe *ap;
571
572 ap = malloc(sizeof(*ap), M_AUDIT_PIPE, M_NOWAIT | M_ZERO);
573 if (ap == NULL)
574 return (NULL);
575 ap->ap_qlimit = AUDIT_PIPE_QLIMIT_DEFAULT;
576 TAILQ_INIT(&ap->ap_queue);
577 knlist_init_mtx(&ap->ap_selinfo.si_note, AUDIT_PIPE_MTX(ap));
578 AUDIT_PIPE_LOCK_INIT(ap);
579 AUDIT_PIPE_SX_LOCK_INIT(ap);
580 cv_init(&ap->ap_cv, "audit_pipe");
581
582 /*
583 * Default flags, naflags, and auid-specific preselection settings to
584 * 0. Initialize the mode to the global trail so that if praudit(1)
585 * is run on /dev/auditpipe, it sees events associated with the
586 * default trail. Pipe-aware application can clear the flag, set
587 * custom masks, and flush the pipe as needed.
588 */
589 bzero(&ap->ap_preselect_flags, sizeof(ap->ap_preselect_flags));
590 bzero(&ap->ap_preselect_naflags, sizeof(ap->ap_preselect_naflags));
591 TAILQ_INIT(&ap->ap_preselect_list);
592 ap->ap_preselect_mode = AUDITPIPE_PRESELECT_MODE_TRAIL;
593
594 /*
595 * Add to global list and update global statistics.
596 */
597 AUDIT_PIPE_LIST_WLOCK();
598 TAILQ_INSERT_HEAD(&audit_pipe_list, ap, ap_list);
599 audit_pipe_count++;
600 audit_pipe_ever++;
601 AUDIT_PIPE_LIST_WUNLOCK();
602
603 return (ap);
604}
605
606/*
607 * Flush all records currently present in an audit pipe; assume mutex is held.

Callers 1

audit_pipe_openFunction · 0.85

Calls 4

mallocFunction · 0.85
knlist_init_mtxFunction · 0.85
bzeroFunction · 0.85
cv_initFunction · 0.50

Tested by

no test coverage detected