Date: Wed, 26 Jan 2005 04:31:07 GMT From: Wayne Salamon <wsalamon@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 69749 for review Message-ID: <200501260431.j0Q4V7An003983@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=69749 Change 69749 by wsalamon@rickenbacker on 2005/01/26 04:30:42 Change include paths; remove use of syscall() and use audit system calls directly. Affected files ... .. //depot/projects/trustedbsd/audit3/tools/regression/audit/test/syscall/tauditon.c#2 edit .. //depot/projects/trustedbsd/audit3/tools/regression/audit/test/syscall/tauditon_cond.c#2 edit .. //depot/projects/trustedbsd/audit3/tools/regression/audit/test/syscall/tsysaudit.c#2 edit .. //depot/projects/trustedbsd/audit3/tools/regression/audit/test/syscall/tsyscall.c#2 edit Differences ... ==== //depot/projects/trustedbsd/audit3/tools/regression/audit/test/syscall/tauditon.c#2 (text+ko) ==== @@ -25,12 +25,10 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include <audittest.h> #include <fcntl.h> -#include <sys/syscall.h> -#include <sys/audit.h> -#include <sys/bsm_kevents.h> -#include <sys/bsm_uevents.h> -#include <audittest.h> +#include <bsm/audit.h> +#include <bsm/audit_uevents.h> /* * Test the auditon() system call, execpt for the A_GETCOND/A_SETCOND @@ -55,7 +53,7 @@ AUT_INIT(); flags = 0; - ret = syscall(SYS_auditon, A_GETPOLICY, &flags, sizeof(long)); + ret = auditon(A_GETPOLICY, &flags, sizeof(long)); if (ret == 0) AUT_PRINTF("Current policy flags are 0x%08x\n", flags); else @@ -64,13 +62,12 @@ flags = AUDIT_CNT | AUDIT_TRAIL; AUT_PRINTF("Setting policy flags to 0x%08x\n", flags); - ret = syscall(SYS_auditon, A_SETPOLICY, &flags, sizeof(long)); + ret = auditon(A_SETPOLICY, &flags, sizeof(long)); if (ret) AUT_PERROR("A_SETPOLICY"); aut_assert(AUE_AUDITON_SPOLICY); - ret = syscall(SYS_auditon, A_GETKMASK, &mask, sizeof(au_mask_t)); -ret = syscall(SYS_auditon, A_GETKMASK, &mask, -1); + ret = auditon(A_GETKMASK, &mask, sizeof(au_mask_t)); if (ret == 0) AUT_PRINTF("GETKMASK: success[0x%08x], failure[0x%08x]\n", mask.am_success, mask.am_failure); @@ -82,12 +79,12 @@ mask.am_failure = AU_ALL; AUT_PRINTF("A_SETKMASK: success[0x%08x], failure[0x%08x]\n", mask.am_success, mask.am_failure); - ret = syscall(SYS_auditon, A_SETKMASK, &mask, sizeof(au_mask_t)); + ret = auditon(A_SETKMASK, &mask, sizeof(au_mask_t)); if (ret) AUT_PERROR("A_SETKMASK"); aut_assert(AUE_AUDITON_SETKMASK); - ret = syscall(SYS_auditon, A_GETQCTRL, &qctrl, sizeof(au_qctrl_t)); + ret = auditon(A_GETQCTRL, &qctrl, sizeof(au_qctrl_t)); if (ret == 0) AUT_PRINTF("A_GETQCTRL: hiwater[%d], lowater[%d], bufsz[%d], delay[%d], minfree[%d]\n", qctrl.aq_hiwater, qctrl.aq_lowater, qctrl.aq_bufsz, qctrl.aq_delay, qctrl.aq_minfree); @@ -102,33 +99,33 @@ qctrl.aq_minfree = 10; AUT_PRINTF("A_SETQCTRL: hiwater[%d], lowater[%d], bufsz[%d], delay[%d], minfree[%d]\n", qctrl.aq_hiwater, qctrl.aq_lowater, qctrl.aq_bufsz, qctrl.aq_delay, qctrl.aq_minfree); - ret = syscall(SYS_auditon, A_SETQCTRL, &qctrl, sizeof(au_qctrl_t)); + ret = auditon(A_SETQCTRL, &qctrl, sizeof(au_qctrl_t)); if (ret) AUT_PERROR("A_SETQCTRL"); aut_assert(AUE_AUDITON_SQCTRL); bzero(&qctrl, sizeof(qctrl)); - ret = syscall(SYS_auditon, A_GETQCTRL, &qctrl, sizeof(au_qctrl_t)); + ret = auditon(A_GETQCTRL, &qctrl, sizeof(au_qctrl_t)); if (ret == 0) AUT_PRINTF("A_GETQCTRL: hiwater[%d], lowater[%d], bufsz[%d], delay[%d], minfree[%d]\n", qctrl.aq_hiwater, qctrl.aq_lowater, qctrl.aq_bufsz, qctrl.aq_delay, qctrl.aq_minfree); else AUT_PERROR("A_GETQCTRL"); - ret = syscall(SYS_auditon, A_GETCWD, path, MAXPATHLEN); + ret = auditon(A_GETCWD, path, MAXPATHLEN); if (ret == 0) AUT_PRINTF("A_GETCWD: path[%s]\n", path); else AUT_PERROR("A_GETCWD"); aut_assert(AUE_AUDITON_GETCWD); - ret = syscall(SYS_auditon, A_GETCAR, path, MAXPATHLEN); + ret = auditon(A_GETCAR, path, MAXPATHLEN); if (ret == 0) AUT_PRINTF("A_GETCAR: path[%s]\n", path); else AUT_PERROR("A_GETCAR"); aut_assert(AUE_AUDITON_GETCAR); - ret = syscall(SYS_auditon, A_GETSTAT, &stat, sizeof(au_stat_t)); + ret = auditon(A_GETSTAT, &stat, sizeof(au_stat_t)); if (ret == 0) { AUT_PRINTF("A_GETSTAT: version[%u], numevent[%u], generated[%d] ", stat.as_version, stat.as_numevent, stat.as_generated); @@ -144,7 +141,7 @@ aut_assert(AUE_AUDITON_GETSTAT); bzero((void *)&stat, sizeof(au_stat_t)); - ret = syscall(SYS_auditon, A_SETSTAT, &stat, sizeof(au_stat_t)); + ret = auditon(A_SETSTAT, &stat, sizeof(au_stat_t)); if (ret) AUT_PERROR("A_SETSTAT"); @@ -153,19 +150,19 @@ info.ai_mask.am_success = AU_NET | AU_FREAD; info.ai_mask.am_failure = AU_ALL; info.ai_asid = 0; - ret = syscall(SYS_auditon, A_SETUMASK, &info, sizeof(auditinfo_t)); + ret = auditon(A_SETUMASK, &info, sizeof(auditinfo_t)); if (ret) AUT_PERROR("A_SETUMASK"); aut_assert(AUE_AUDITON_SETUMASK); - ret = syscall(SYS_auditon, A_SETSMASK, &info, sizeof(auditinfo_t)); + ret = auditon(A_SETSMASK, &info, sizeof(auditinfo_t)); if (ret) AUT_PERROR("A_SETSMASK"); aut_assert(AUE_AUDITON_SETSMASK); classmap.ec_number = AUE_AUDIT; classmap.ec_class = 0; - ret = syscall(SYS_auditon, A_GETCLASS, &classmap, + ret = auditon(A_GETCLASS, &classmap, sizeof(au_evclass_map_t)); if (ret == 0) AUT_PRINTF("A_GETCLASS: Event %d maps to class mask 0x%08x\n", @@ -178,14 +175,14 @@ classmap.ec_class = AU_LOGIN; AUT_PRINTF("A_SETCLASS: Mapping event %d to class mask 0x%08x\n", classmap.ec_number, classmap.ec_class); - ret = syscall(SYS_auditon, A_SETCLASS, &classmap, + ret = auditon(A_SETCLASS, &classmap, sizeof(au_evclass_map_t)); if (ret) AUT_PERROR("A_SETCLASS"); aut_assert(AUE_AUDITON_SETCLASS); classmap.ec_class = 0; - ret = syscall(SYS_auditon, A_GETCLASS, &classmap, + ret = auditon(A_GETCLASS, &classmap, sizeof(au_evclass_map_t)); if (ret == 0) AUT_PRINTF("A_GETCLASS: Event %d maps to class mask 0x%08x\n", @@ -194,7 +191,7 @@ AUT_PERROR("A_GETCLASS(AUE_telenet"); pinfo.ap_pid = getpid(); - ret = syscall(SYS_auditon, A_GETPINFO, &pinfo, sizeof(auditpinfo_t)); + ret = auditon(A_GETPINFO, &pinfo, sizeof(auditpinfo_t)); if (ret == 0) { AUT_PRINTF("A_GETPINFO: pid[%d], auid[%d] ", pinfo.ap_pid, pinfo.ap_auid); @@ -212,38 +209,38 @@ */ /* Failure auditon() */ pinfo.ap_pid = 0; - syscall(SYS_auditon, A_SETPMASK, &pinfo, sizeof(auditpinfo_t)); + auditon(A_SETPMASK, &pinfo, sizeof(auditpinfo_t)); /* Success auditon() */ pinfo.ap_pid = getpid(); - ret = syscall(SYS_auditon, A_SETPMASK, &pinfo, sizeof(auditpinfo_t)); + ret = auditon(A_SETPMASK, &pinfo, sizeof(auditpinfo_t)); if (ret) AUT_PERROR("A_SETPMASK"); - ret = syscall(SYS_auditon, A_SETFSIZE, &fstat, sizeof(au_fstat_t)); + ret = auditon(A_SETFSIZE, &fstat, sizeof(au_fstat_t)); if (ret) AUT_PERROR("A_SETFSIZE"); - ret = syscall(SYS_auditon, A_GETFSIZE, &fstat, sizeof(au_fstat_t)); + ret = auditon(A_GETFSIZE, &fstat, sizeof(au_fstat_t)); if (ret == 0) ; else AUT_PERROR("A_GETFSIZE"); - ret = syscall(SYS_auditon, A_GETPINFO_ADDR, &pinfo_addr, + ret = auditon(A_GETPINFO_ADDR, &pinfo_addr, sizeof(auditpinfo_addr_t)); if (ret == 0) ; else AUT_PERROR("A_GETPINFO_ADDR"); - ret = syscall(SYS_auditon, A_GETKAUDIT, NULL, 0); + ret = auditon(A_GETKAUDIT, NULL, 0); if (ret == 0) ; else AUT_PERROR("A_GETKAUDIT"); - ret = syscall(SYS_auditon, A_SETKAUDIT, NULL, 0); + ret = auditon(A_SETKAUDIT, NULL, 0); if (ret) AUT_PERROR("A_SETKAUDIT"); ==== //depot/projects/trustedbsd/audit3/tools/regression/audit/test/syscall/tauditon_cond.c#2 (text+ko) ==== @@ -25,13 +25,10 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include <audittest.h> #include <fcntl.h> #include <stdio.h> -#include <sys/syscall.h> -#include <sys/audit.h> -#include <sys/bsm_kevents.h> -#include <sys/bsm_uevents.h> -#include <audittest.h> +#include <bsm/audit.h> /* * Test the A_GETCOND and A_SETCOND commands of the auditon() system call. @@ -46,7 +43,7 @@ AUT_INIT(); - ret = syscall(SYS_auditon, A_GETCOND, &cond, sizeof(long)); + ret = auditon(A_GETCOND, &cond, sizeof(long)); if (ret == 0) AUT_PRINTF("A_GETCOND: cond is %s\n", aut_condstr(cond)); else @@ -63,7 +60,7 @@ */ cond = AUC_AUDITING; AUT_PRINTF("First A_SETCOND: %s\n", aut_condstr(cond)); - ret = syscall(SYS_auditon, A_SETCOND, &cond, sizeof(long)); + ret = auditon(A_SETCOND, &cond, sizeof(long)); if (ret) { AUT_PRINTF("%s ", aut_condstr(cond)); AUT_PERROR("A_SETCOND"); @@ -72,7 +69,7 @@ cond = AUC_NOAUDIT; AUT_PRINTF("Second A_SETCOND: %s\n", aut_condstr(cond)); - ret = syscall(SYS_auditon, A_SETCOND, &cond, sizeof(long)); + ret = auditon(A_SETCOND, &cond, sizeof(long)); if (ret) { AUT_PRINTF("%s ", aut_condstr(cond)); AUT_PERROR("A_SETCOND"); @@ -84,7 +81,7 @@ cond = AUC_AUDITING; AUT_PRINTF("Third A_SETCOND: %s\n", aut_condstr(cond)); - ret = syscall(SYS_auditon, A_SETCOND, &cond, sizeof(long)); + ret = auditon(A_SETCOND, &cond, sizeof(long)); if (ret) { AUT_PRINTF("%s ", aut_condstr(cond)); AUT_PERROR("A_SETCOND"); @@ -101,7 +98,7 @@ */ cond = AUC_DISABLED; AUT_PRINTF("A_SETCOND: %s\n", aut_condstr(cond)); - ret = syscall(SYS_auditon, A_SETCOND, &cond, sizeof(long)); + ret = auditon(A_SETCOND, &cond, sizeof(long)); if (ret) { AUT_PRINTF("%s ", aut_condstr(cond)); AUT_PERROR("A_SETCOND"); ==== //depot/projects/trustedbsd/audit3/tools/regression/audit/test/syscall/tsysaudit.c#2 (text+ko) ==== @@ -25,14 +25,11 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include <audittest.h> #include <fcntl.h> -#include <sys/syscall.h> +#include <bsm/audit.h> +#include <bsm/libbsm.h> #include <sys/types.h> -#include <sys/stat.h> -#include <sys/audit.h> -#include <sys/bsm_token.h> -#include <libbsm.h> -#include <audittest.h> /* * Test the audit() system call. ==== //depot/projects/trustedbsd/audit3/tools/regression/audit/test/syscall/tsyscall.c#2 (text+ko) ==== @@ -25,84 +25,11 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include <fcntl.h> -#include <sys/syscall.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/audit.h> -#include <sys/bsm_token.h> #include <audittest.h> - -/* - * Test some of the audit information system calls. - * These calls should generate audit records because we set the preselection - * mask for the process before making the call. - */ -int main(int argc, char **argv) { - -#define AUDIT_CLASSES (AU_ADMIN) - - int ret; - uid_t auid; - struct auditinfo ret_auinfo; - au_evclass_map_t classmap; - caddr_t rec; - - AUT_INIT(); - - auid = 777; - ret = syscall(SYS_setauid, &auid); - if (ret != 0) - AUT_PERROR("setauid() failed: "); - aut_assert(AUE_SETAUID); - - auid = -1; - ret = syscall(SYS_getauid, &auid); - if (ret != 0) - AUT_PERROR("getauid() failed: "); - else - AUT_PRINTF("Audit ID returned by getauid() is %d\n", auid); - aut_assert(AUE_GETAUID); - - /* Assign the GETAUDIT and SETAUDIT events to the AU_ADMIN class */ - classmap.ec_number = AUE_GETAUDIT; - classmap.ec_class = AU_ADMIN; - ret = syscall(SYS_auditon, A_SETCLASS, &classmap, - sizeof(au_evclass_map_t)); - classmap.ec_number = AUE_SETAUDIT; - ret = syscall(SYS_auditon, A_SETCLASS, &classmap, - sizeof(au_evclass_map_t)); - ret = syscall(SYS_getaudit, &ret_auinfo); - if (ret != 0) - AUT_PERROR("getaudit() failed: "); - else { - AUT_PRINTF("Audit ID returned is %d\n", ret_auinfo.ai_auid); - AUT_PRINTF("Session ID returned is %d\n", ret_auinfo.ai_asid); - AUT_PRINTF("Terminal ID returned is %d:%d\n", - ret_auinfo.ai_termid.port, - ret_auinfo.ai_termid.machine); - AUT_PRINTF("Audit masks returned are 0x%08x:0x%08x\n", - ret_auinfo.ai_mask.am_success, - ret_auinfo.ai_mask.am_failure); - } - aut_assert(AUE_GETAUDIT); - - ret = syscall(SYS_setaudit, &ret_auinfo); - if (ret != 0) - AUT_PERROR("setaudit() failed: "); - aut_assert(AUE_SETAUDIT); - - aut_shutdown(); - exit(0); -} - #include <fcntl.h> -#include <sys/syscall.h> +#include <bsm/audit.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/audit.h> -#include <sys/bsm_token.h> -#include <audittest.h> /* * Test some of the audit information system calls. @@ -122,13 +49,13 @@ AUT_INIT(); auid = 777; - ret = syscall(SYS_setauid, &auid); + ret = setauid(&auid); if (ret != 0) AUT_PERROR("setauid() failed: "); aut_assert(AUE_SETAUID); auid = -1; - ret = syscall(SYS_getauid, &auid); + ret = getauid(&auid); if (ret != 0) AUT_PERROR("getauid() failed: "); else @@ -138,12 +65,12 @@ /* Assign the GETAUDIT and SETAUDIT events to the AU_ADMIN class */ classmap.ec_number = AUE_GETAUDIT; classmap.ec_class = AU_ADMIN; - ret = syscall(SYS_auditon, A_SETCLASS, &classmap, + ret = auditon(A_SETCLASS, &classmap, sizeof(au_evclass_map_t)); classmap.ec_number = AUE_SETAUDIT; - ret = syscall(SYS_auditon, A_SETCLASS, &classmap, + ret = auditon(A_SETCLASS, &classmap, sizeof(au_evclass_map_t)); - ret = syscall(SYS_getaudit, &ret_auinfo); + ret = getaudit(&ret_auinfo); if (ret != 0) AUT_PERROR("getaudit() failed: "); else { @@ -158,7 +85,7 @@ } aut_assert(AUE_GETAUDIT); - ret = syscall(SYS_setaudit, &ret_auinfo); + ret = setaudit(&ret_auinfo); if (ret != 0) AUT_PERROR("setaudit() failed: "); aut_assert(AUE_SETAUDIT);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200501260431.j0Q4V7An003983>