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

Function sys_setaudit

freebsd/security/audit/audit_syscalls.c:673–713  ·  view source on GitHub ↗

ARGSUSED */

Source from the content-addressed store, hash-verified

671
672/* ARGSUSED */
673int
674sys_setaudit(struct thread *td, struct setaudit_args *uap)
675{
676 struct ucred *newcred, *oldcred;
677 struct auditinfo ai;
678 int error;
679
680 if (jailed(td->td_ucred))
681 return (ENOSYS);
682 error = copyin(uap->auditinfo, &ai, sizeof(ai));
683 if (error)
684 return (error);
685 audit_arg_auditinfo(&ai);
686 newcred = crget();
687 PROC_LOCK(td->td_proc);
688 oldcred = td->td_proc->p_ucred;
689 crcopy(newcred, oldcred);
690#ifdef MAC
691 error = mac_cred_check_setaudit(oldcred, &ai);
692 if (error)
693 goto fail;
694#endif
695 error = priv_check_cred(oldcred, PRIV_AUDIT_SETAUDIT);
696 if (error)
697 goto fail;
698 bzero(&newcred->cr_audit, sizeof(newcred->cr_audit));
699 newcred->cr_audit.ai_auid = ai.ai_auid;
700 newcred->cr_audit.ai_mask = ai.ai_mask;
701 newcred->cr_audit.ai_asid = ai.ai_asid;
702 newcred->cr_audit.ai_termid.at_addr[0] = ai.ai_termid.machine;
703 newcred->cr_audit.ai_termid.at_port = ai.ai_termid.port;
704 newcred->cr_audit.ai_termid.at_type = AU_IPv4;
705 proc_set_cred(td->td_proc, newcred);
706 PROC_UNLOCK(td->td_proc);
707 crfree(oldcred);
708 return (0);
709fail:
710 PROC_UNLOCK(td->td_proc);
711 crfree(newcred);
712 return (error);
713}
714
715/* ARGSUSED */
716int

Callers

nothing calls this directly

Calls 10

jailedFunction · 0.85
audit_arg_auditinfoFunction · 0.85
crcopyFunction · 0.85
mac_cred_check_setauditFunction · 0.85
bzeroFunction · 0.85
proc_set_credFunction · 0.85
copyinFunction · 0.50
crgetFunction · 0.50
priv_check_credFunction · 0.50
crfreeFunction · 0.50

Tested by

no test coverage detected