├── .gitignore ├── Android-NDK.mk ├── Android.mk ├── Application.mk ├── LICENSE ├── README.md ├── android.h ├── config.h ├── etc ├── auditd.conf └── auditd.rules ├── kernel └── linux │ └── audit.h ├── lib ├── actiontabs.h ├── armeb_table.h ├── armeb_tables.h ├── audit_logging.c ├── deprecated.c ├── errormsg.h ├── errtabs.h ├── ev.h ├── ev_vars.h ├── ev_wrap.h ├── event.h ├── fieldtab.h ├── fieldtabs.h ├── flagtabs.h ├── ftypetabs.h ├── gen_tables.h ├── i386_tables.h ├── ia64_tables.h ├── libaudit.c ├── libaudit.h ├── lookup_table.c ├── machinetab.h ├── machinetabs.h ├── message.c ├── msg_typetab.h ├── msg_typetabs.h ├── netlink.c ├── optabs.h ├── ppc_tables.h ├── private.h ├── s390_tables.h ├── s390x_tables.h └── x86_64_tables.h ├── libc ├── stpcpy.c ├── stpcpy.h └── stpcpytest.c ├── patches ├── android-kernel-goldfish-2.6.29-audit.patch ├── android-kernel-omap-tuna-3.0-jb-pre1-audit.patch └── jellybean │ ├── audit_permission.patch │ ├── audit_systemcore_fsinit.4.2.1.rc1.patch │ └── audit_systemcore_fsinit.patch ├── prebuilt ├── maguro-audit-arm-kernel ├── qemu-audit-arm-kernel └── qemu-audit-x86-kernel ├── scripts ├── makeARMvmtarball.sh ├── makeX86vmtarball.sh ├── makegalaxynexustarball.sh ├── startARMvm.sh ├── startX86vm.sh └── startaudit.sh └── src ├── auditctl-llist.c ├── auditctl-llist.h ├── auditctl.c ├── auditd-config.c ├── auditd-config.h ├── auditd-event.c ├── auditd-event.h ├── auditd-listen.c ├── auditd-listen.h ├── auditd-parse.c ├── auditd-parse.h ├── auditd-reconfig.c ├── auditd-sendmail.c ├── auditd.c ├── delete_all.c ├── ev.c ├── ev_epoll.c ├── ev_poll.c ├── ev_select.c ├── event.c └── spadeLinuxAudit.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /Android-NDK.mk: -------------------------------------------------------------------------------- 1 | # Build the auditctl binary 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | ETC_DIR := $(TARGET_OUT)/etc/audit 7 | 8 | LOCAL_MODULE := auditctl 9 | LOCAL_MODULE_TAGS := eng 10 | LOCAL_SRC_FILES:= lib/libaudit.c \ 11 | lib/message.c \ 12 | lib/netlink.c \ 13 | lib/lookup_table.c \ 14 | lib/audit_logging.c \ 15 | lib/deprecated.c \ 16 | src/auditctl.c \ 17 | src/auditctl-llist.c \ 18 | src/delete_all.c 19 | 20 | 21 | LOCAL_C_INCLUDES := ./ \ 22 | ./lib \ 23 | ./libc \ 24 | ./kernel \ 25 | ./src 26 | 27 | LOCAL_CFLAGS := -fPIE -DPIE -g -D_GNU_SOURCE -fno-strict-aliasing 28 | 29 | LOCAL_SHARED_LIBRARIES := libc libcutils 30 | LOCAL_LDLIBS := -llog 31 | 32 | include $(BUILD_EXECUTABLE) 33 | 34 | 35 | # Build the auditd binary 36 | include $(CLEAR_VARS) 37 | 38 | MY_ROOT_PATH := external/android_audit 39 | 40 | LOCAL_MODULE := auditd 41 | LOCAL_MODULE_TAGS := eng 42 | LOCAL_SRC_FILES:= lib/libaudit.c \ 43 | lib/message.c \ 44 | lib/netlink.c \ 45 | lib/lookup_table.c \ 46 | lib/audit_logging.c \ 47 | lib/deprecated.c \ 48 | src/auditd.c \ 49 | src/auditd-event.c \ 50 | src/auditd-config.c \ 51 | src/auditd-reconfig.c \ 52 | src/auditd-sendmail.c \ 53 | src/auditd-listen.c \ 54 | src/auditd-parse.c \ 55 | src/ev.c \ 56 | src/event.c 57 | 58 | 59 | LOCAL_C_INCLUDES := ./ \ 60 | ./lib \ 61 | ./libc \ 62 | ./kernel \ 63 | ./src 64 | 65 | LOCAL_CFLAGS := -fPIE -DPIE -g -D_GNU_SOURCE -fno-strict-aliasing 66 | 67 | LOCAL_SHARED_LIBRARIES := libc libcutils 68 | LOCAL_LDLIBS := -llog 69 | 70 | include $(BUILD_EXECUTABLE) 71 | 72 | #spade-audit utility build 73 | include $(CLEAR_VARS) 74 | 75 | LOCAL_MODULE := spade-audit 76 | LOCAL_MODULE_TAGS := eng 77 | LOCAL_SRC_FILES:= src/spadeLinuxAudit.c 78 | LOCAL_CFLAGS := -fPIE -DPIE -g -D_GNU_SOURCE -fno-strict-aliasing 79 | LOCAL_SHARED_LIBRARIES := libc libcutils 80 | 81 | include $(BUILD_EXECUTABLE) 82 | 83 | # Start copying configuration files 84 | include $(CLEAR_VARS) 85 | LOCAL_MODULE := auditd.conf 86 | LOCAL_MODULE_TAGS := eng 87 | LOCAL_MODULE_CLASS := ETC 88 | LOCAL_MODULE_PATH := $(ETC_DIR) 89 | LOCAL_SRC_FILES := etc/auditd.conf 90 | include $(BUILD_PREBUILT) 91 | 92 | 93 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | # Build the auditctl binary 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | MY_ROOT_PATH := external/android_audit 7 | ETC_DIR := $(TARGET_OUT)/etc/audit 8 | 9 | LOCAL_MODULE := auditctl 10 | LOCAL_MODULE_TAGS := optional 11 | LOCAL_SRC_FILES:= lib/libaudit.c \ 12 | lib/message.c \ 13 | lib/netlink.c \ 14 | lib/lookup_table.c \ 15 | lib/audit_logging.c \ 16 | lib/deprecated.c \ 17 | src/auditctl.c \ 18 | src/auditctl-llist.c \ 19 | src/delete_all.c 20 | 21 | 22 | LOCAL_C_INCLUDES := $(MY_ROOT_PATH) \ 23 | $(MY_ROOT_PATH)/lib \ 24 | $(MY_ROOT_PATH)/libc \ 25 | $(MY_ROOT_PATH)/kernel \ 26 | $(MY_ROOT_PATH)/src 27 | 28 | LOCAL_SHARED_LIBRARIES := libc libcutils 29 | 30 | include $(BUILD_EXECUTABLE) 31 | 32 | 33 | # Build the auditd binary 34 | include $(CLEAR_VARS) 35 | 36 | MY_ROOT_PATH := external/android_audit 37 | 38 | LOCAL_MODULE := auditd 39 | LOCAL_MODULE_TAGS := optional 40 | LOCAL_SRC_FILES:= lib/libaudit.c \ 41 | lib/message.c \ 42 | lib/netlink.c \ 43 | lib/lookup_table.c \ 44 | lib/audit_logging.c \ 45 | lib/deprecated.c \ 46 | src/auditd.c \ 47 | src/auditd-event.c \ 48 | src/auditd-config.c \ 49 | src/auditd-reconfig.c \ 50 | src/auditd-sendmail.c \ 51 | src/auditd-listen.c \ 52 | src/auditd-parse.c \ 53 | src/ev.c \ 54 | src/event.c 55 | 56 | 57 | LOCAL_C_INCLUDES := $(MY_ROOT_PATH) \ 58 | $(MY_ROOT_PATH)/lib \ 59 | $(MY_ROOT_PATH)/libc \ 60 | $(MY_ROOT_PATH)/kernel \ 61 | $(MY_ROOT_PATH)/src 62 | 63 | LOCAL_SHARED_LIBRARIES := libc libcutils 64 | 65 | include $(BUILD_EXECUTABLE) 66 | 67 | #spade-audit utility build 68 | include $(CLEAR_VARS) 69 | 70 | LOCAL_MODULE := spade-audit 71 | LOCAL_MODULE_TAGS := optional 72 | LOCAL_SRC_FILES:= src/spadeLinuxAudit.c 73 | LOCAL_CFLAGS := -fPIE -DPIE -g -D_GNU_SOURCE -fno-strict-aliasing 74 | LOCAL_LDLIBS := -lm -lpthread -lc 75 | 76 | include $(BUILD_EXECUTABLE) 77 | 78 | # Start copying configuration files 79 | include $(CLEAR_VARS) 80 | LOCAL_MODULE := auditd.conf 81 | LOCAL_MODULE_TAGS := optional 82 | LOCAL_MODULE_CLASS := ETC 83 | LOCAL_MODULE_PATH := $(ETC_DIR) 84 | LOCAL_SRC_FILES := etc/auditd.conf 85 | include $(BUILD_PREBUILT) 86 | 87 | include $(CLEAR_VARS) 88 | LOCAL_MODULE := auditd.rules 89 | LOCAL_MODULE_TAGS := optional 90 | LOCAL_MODULE_CLASS := ETC 91 | LOCAL_MODULE_PATH := $(ETC_DIR) 92 | LOCAL_SRC_FILES := etc/auditd.rules 93 | include $(BUILD_PREBUILT) 94 | 95 | -------------------------------------------------------------------------------- /Application.mk: -------------------------------------------------------------------------------- 1 | # The Application.mk is used with the NDK to get things to 2 | # build properly without using the default Google paths. Required 3 | # because forcing people to build in an arbitrary path structure 4 | # is stupid. I deny your ontology and replace it with my own. 5 | 6 | # Set the root project directory (where the Android.mk will be) 7 | APP_PROJECT_PATH := ./ 8 | 9 | # Target Gingerbread 10 | APP_PLATFORM := android-9 11 | 12 | # Set our build script because it's not in ./jni 13 | APP_BUILD_SCRIPT := ./Android-NDK.mk 14 | 15 | # Use the debug level of optimizations for now. You can uncomment the 16 | # release line and comment the debug line if needed. 17 | APP_OPTIM := debug 18 | #APP_OPTIM := release 19 | 20 | # We have no CPP Flags, but just in case. These are also used as CFlags. 21 | APP_CPPFLAGS := 22 | 23 | # We starget the x86 ABI for now 24 | APP_ABI := armeabi 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AuditD on Android # 2 | 3 | ## Introduction ## 4 | Our goal is to port a minimal set of userland tools from the GNU/Linux userland to the bionic/Linux userland of Android. We've stripped out most the functionality inherent in the Linux software including audisp, ausearch, and auparse. The audit stream is not sent directly to an AF_Unix socket (/dev/audit) by auditd. While not as elegant or robust as the Linux code, our goal is to provide access to the audit stream for Android applications with minimal overhead. Our choice for stripping down Audit is partly due to the fact bionic is horribly GNU incompatible, but also the smartphone platform should be treated than the traditional server/desktop due to resource and runtime constraints. 5 | 6 | ## Requirements ## 7 | 1. A rooted Android system. 8 | 2. Running the 2.6.29 or higher x86 kernel with CONFIG_AUDITSYSCALL=y 9 | * For the ARM platform, the kernel must be patched (See section "Custom Kernel"). 10 | * We needed to copy over the audit.h kernel header because Google uses clean headers. Their utilities to clean headers are unusable by those not blessed with the power of Google (i.e., the documentation is minimal and the ixd is horrible). More details in the directory structure section. 11 | 3. The Google NDK (API Level 10) or the AOSP source code (Tested on 4.0.3 and 4.1.1) 12 | 13 | ## Compiling ## 14 | 15 | ### NDK ### 16 | From inside this directory run the following command: 17 | 18 | `ndk-build NDK_APPLICATION_MK=./Application.mk NDK_PROJECT_PATH=./` 19 | 20 | The obj and libs directory will contain the final output. 21 | 22 | Currently the NDK's build script targets Android's API level 10 (Gingerbread). Anything before this doesn't work. 23 | 24 | The binaries can be tried in an emulator or similarly on a device by following steps: 25 | 26 | * In a new directory copy system.img, userdata.img and ramdisk.img from your platform's system images; copy startvm.sh from scripts directory and copy a custom kernel (See section "Custom kernel"). 27 | * The system's init.rc needs to be patched according to the patch audit_systemcore_fsinit.patch in patches directory. To update init.rc, you need to unpack ramdisk.img, edit the file and repack. See [Modifying .IMG FILES](http://omappedia.org/wiki/Android_eMMC_Booting#Modifying_.IMG_Files) for further assistance. 28 | * The compiled binaries need to be placed in /system/bin and files in AuditAndroid's etc directory need to be placed in /system/etc/audit/. Since the /system directory is mapped in system.img you can place files by unpacking and re-packing sytem.img using [unyaffs](http://code.google.com/p/unyaffs/), [remounting or sim2img](http://omappedia.org/wiki/Android_eMMC_Booting#Modifying_.IMG_Files). 29 | * Run the startvm.sh script to run the emulator. 30 | 31 | ### AOSP ### 32 | Copy this directory in to the /external directory. Compile Android normally. Then, within your compilation terminal type 'mmm external/' to compile in the audit subsystem. Finally, type 'make snod' to rebuild your system image. 33 | 34 | If you are building for a physical device, you will need to build a custom kernel before building AOSP. For instructions on building custom kernels, please refer to the AOSP Documentation here: http://source.android.com/source/building-kernels.html. 35 | 36 | ### Custom kernel ### 37 | You must have a kernel running with CONFIG_AUDIT=y and CONFIG_AUDITSYSCALL=y in the configuration. Instructions on building a kernel for Android can be found at source.android.com and various other sources on the Internet. We include patches for the goldfish ARM platform and the maguro ARM platform to enable systemcall auditing. These patches are included in the 'patches' directory. 38 | 39 | ### Patching AOSP ### 40 | We provide a set of patches for AOSP's 4.1.1_r1 branch under the 'patches/jellybean' directory. These patches enable auditd to start on boot and enable the android.permission.AUDIT so that audit can be controlled from the userland. Currently there is a plan to write a script to perform this patching for the user. Right now, each patch refers to a specific git project under the AOSP source tree. Patching is left as an exercise to the user at this time but here is a helpful guide: http://jungels.net/articles/diff-patch-ten-minutes.html. 41 | 42 | If you use these patches you will also have to run "make update-api" in order to make the modified Framework API. 43 | 44 | ## Directory Structure ## 45 | 46 | ### Special Directories ### 47 | 48 | There are two nonstandard, special, directories in this repository. 49 | 50 | The 'kernel' directory includes kernel headers that are not present in Google's cleaned headers. While I have attempted to clean a new set of headers, I've found the scripts about as usable as writing the next great American novel in 'ed'. This header is from the 2.6.29 kernel. So this is a horribly fragile process until Google starts including the audit.h header, or in a perfect world, a complete set of kernel headers. 51 | 52 | The 'libc' directory includes headers and source files that define functions not included in Google's non-POSIX compliant libc implementation. 53 | 54 | ### Other Directories (That aren't as special) ### 55 | 56 | The 'src' directory contains binary source for individual applications. The 'lib' directory contains source code shared between each application that was originally part of libaudit or libev. The 'etc' directory contains configuration specific files. 57 | 58 | The 'prebuilt' directory contains precompiled binaries used for this program. As of right now it only contains the pre-compiled 2.6.29 kernel used with QEMU. 59 | 60 | The 'scripts' directory contains helper scripts that can be used to aid testing the code, installing code on the system, and building vm tarballs. They're more utility glue than polished products. 61 | 62 | The 'patches' directory contains patches that enable certain advanced functionalities in the AOSP build. For example, it would enable the creation of an AUDIT permission that could be used by userland applications. Any patches that modify AOSP are in a folder specific to the Android release they target. Kernel patches to specific Android device kernels are included in the top level directory. 63 | 64 | ## Modifications of the original Audit configuration ## 65 | 66 | Our port uses the log_file specified in the configuration as a socket for communicating with clients. This log_file will be unlinked whenever auditd starts up so that the socket can be bound. Our version of audit currently does not write out to a log file. This functionality might be added back at a later date. 67 | 68 | __Disclaimer__: The source code requires some serious refactoring after the modifications of the original audit code. Code cleanup of commented out and orphaned code is also needed. 69 | 70 | ## TODOs ## 71 | 72 | - REFACTORING TO DO 73 | - Remove syslog dependency and switch to Android's logcat infrastructure. 74 | - Figure out how to get the old logging code up and running with the new 75 | AF_UNIX socket code in case people want to write audit logs to the 76 | sdcard for whatever reason. 77 | 78 | - CLEANUP TO DO 79 | - Remove GSSAPI related networking 80 | - Remove TCP related networking -- TCPWrappers etc. 81 | -------------------------------------------------------------------------------- /android.h: -------------------------------------------------------------------------------- 1 | /* android.h -- 2 | * Copyright 2004-2012 SRI International 3 | * All Rights Reserved. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Nathaniel Husted 21 | */ 22 | 23 | /** 24 | * @brief Android specific includes 25 | * 26 | * */ 27 | 28 | // Android does not implement stpcpy 29 | #include 30 | 31 | #define fgets_unlocked(x,y,z) fgets(x,y,z) 32 | 33 | #define _POSIX_HOST_NAME_MAX 255 34 | 35 | // This needs to be commented out for Android 4.2.1+ 36 | //#define O_DSYNC O_SYNC 37 | 38 | typedef long fd_mask; 39 | -------------------------------------------------------------------------------- /config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the `clock_gettime' function. */ 5 | /* #undef HAVE_CLOCK_GETTIME */ 6 | 7 | /* Define to 1 to use the syscall interface for clock_gettime */ 8 | #define HAVE_CLOCK_SYSCALL 1 9 | 10 | /* Define to 1 if you have the declaration of `MS_DIRSYNC', and to 0 if you 11 | don't. */ 12 | #define HAVE_DECL_MS_DIRSYNC 0 13 | 14 | /* Define to 1 if you have the header file. */ 15 | #define HAVE_DLFCN_H 1 16 | 17 | /* Define to 1 if you have the `epoll_ctl' function. */ 18 | #define HAVE_EPOLL_CTL 1 19 | 20 | /* Define to 1 if you have the `eventfd' function. */ 21 | #define HAVE_EVENTFD 1 22 | 23 | /* Define to 1 if the floor function is available */ 24 | #define HAVE_FLOOR 1 25 | 26 | /* Define to 1 if you have the `inotify_init' function. */ 27 | #define HAVE_INOTIFY_INIT 1 28 | 29 | /* Define to 1 if you have the header file. */ 30 | #define HAVE_INTTYPES_H 1 31 | 32 | /* Define to 1 if you have the `kqueue' function. */ 33 | /* #undef HAVE_KQUEUE */ 34 | 35 | /* libcap-ng support */ 36 | /* #undef HAVE_LIBCAP_NG */ 37 | 38 | /* Define to 1 if you have the `rt' library (-lrt). */ 39 | /* #undef HAVE_LIBRT */ 40 | 41 | /* Define if tcp_wrappers support is enabled */ 42 | /* #undef HAVE_LIBWRAP */ 43 | 44 | /* Define to 1 if you have the header file. */ 45 | #define HAVE_MEMORY_H 1 46 | 47 | /* Define to 1 if you have the `nanosleep' function. */ 48 | #define HAVE_NANOSLEEP 1 49 | 50 | /* Define to 1 if you have the `poll' function. */ 51 | #define HAVE_POLL 1 52 | 53 | /* Define to 1 if you have the header file. */ 54 | #define HAVE_POLL_H 1 55 | 56 | /* Define to 1 if you have the `port_create' function. */ 57 | /* #undef HAVE_PORT_CREATE */ 58 | 59 | /* Define to 1 if you have the header file. */ 60 | /* #undef HAVE_PORT_H */ 61 | 62 | /* Define to 1 if you have the `select' function. */ 63 | #define HAVE_SELECT 1 64 | 65 | /* Define to 1 if you have the `signalfd' function. */ 66 | #define HAVE_SIGNALFD 1 67 | 68 | /* Define to 1 if you have the header file. */ 69 | #define HAVE_STDINT_H 1 70 | 71 | /* Define to 1 if you have the header file. */ 72 | #define HAVE_STDLIB_H 1 73 | 74 | /* Define to 1 if you have the header file. */ 75 | #define HAVE_STRINGS_H 1 76 | 77 | /* Define to 1 if you have the header file. */ 78 | #define HAVE_STRING_H 1 79 | 80 | /* Define to 1 if you have the header file. */ 81 | #define HAVE_SYS_EPOLL_H 1 82 | 83 | /* Define to 1 if you have the header file. */ 84 | #define HAVE_SYS_EVENTFD_H 1 85 | 86 | /* Define to 1 if you have the header file. */ 87 | /* #undef HAVE_SYS_EVENT_H */ 88 | 89 | /* Define to 1 if you have the header file. */ 90 | #define HAVE_SYS_INOTIFY_H 1 91 | 92 | /* Define to 1 if you have the header file. */ 93 | #define HAVE_SYS_SELECT_H 1 94 | 95 | /* Define to 1 if you have the header file. */ 96 | #define HAVE_SYS_SIGNALFD_H 1 97 | 98 | /* Define to 1 if you have the header file. */ 99 | #define HAVE_SYS_STAT_H 1 100 | 101 | /* Define to 1 if you have the header file. */ 102 | #define HAVE_SYS_TYPES_H 1 103 | 104 | /* Define to 1 if you have the header file. */ 105 | #define HAVE_UNISTD_H 1 106 | 107 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 108 | */ 109 | #define LT_OBJDIR ".libs/" 110 | 111 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */ 112 | /* #undef NO_MINUS_C_MINUS_O */ 113 | 114 | /* Name of package */ 115 | #define PACKAGE "audit" 116 | 117 | /* Define to the address where bug reports for this package should be sent. */ 118 | #define PACKAGE_BUGREPORT "" 119 | 120 | /* Define to the full name of this package. */ 121 | #define PACKAGE_NAME "audit" 122 | 123 | /* Define to the full name and version of this package. */ 124 | #define PACKAGE_STRING "audit 2.2.1" 125 | 126 | /* Define to the one symbol short name of this package. */ 127 | #define PACKAGE_TARNAME "audit" 128 | 129 | /* Define to the home page for this package. */ 130 | #define PACKAGE_URL "" 131 | 132 | /* Define to the version of this package. */ 133 | #define PACKAGE_VERSION "2.2.1" 134 | 135 | /* The size of `unsigned int', as computed by sizeof. */ 136 | #define SIZEOF_UNSIGNED_INT 4 137 | 138 | /* The size of `unsigned long', as computed by sizeof. */ 139 | #define SIZEOF_UNSIGNED_LONG 8 140 | 141 | /* Define to 1 if you have the ANSI C header files. */ 142 | #define STDC_HEADERS 1 143 | 144 | /* Define to 1 if you can safely include both and . */ 145 | #define TIME_WITH_SYS_TIME 1 146 | 147 | /* Define if you want to use GSSAPI */ 148 | /* #undef USE_GSSAPI */ 149 | 150 | /* Version number of package */ 151 | #define VERSION "2.2.1" 152 | 153 | /* Define if you want to enable Alpha processor support. */ 154 | /* #undef WITH_ALPHA */ 155 | 156 | /* Define if you want to enable AppArmor events. */ 157 | /* #undef WITH_APPARMOR */ 158 | 159 | /* Define if you want to enable Arm eabi processor support. */ 160 | /* #undef WITH_ARMEB */ 161 | 162 | /* Define to empty if `const' does not conform to ANSI C. */ 163 | /* #undef const */ 164 | 165 | /* Define to `__inline__' or `__inline' if that's what the C compiler 166 | calls it, or to nothing if 'inline' is not supported under any name. */ 167 | #ifndef __cplusplus 168 | /* #undef inline */ 169 | #endif 170 | -------------------------------------------------------------------------------- /etc/auditd.conf: -------------------------------------------------------------------------------- 1 | # 2 | # This file controls the configuration of the audit daemon 3 | # 4 | 5 | socket_file = /dev/audit 6 | log_format = RAW 7 | log_group = root 8 | priority_boost = 4 9 | flush = INCREMENTAL 10 | freq = 20 11 | #num_logs = 5 12 | disp_qos = lossy 13 | #dispatcher = /sbin/audispd 14 | name_format = NONE 15 | ##name = mydomain 16 | #max_log_file = 6 17 | #max_log_file_action = ROTATE 18 | #space_left = 75 19 | #space_left_action = SYSLOG 20 | #action_mail_acct = root 21 | #admin_space_left = 50 22 | #admin_space_left_action = SUSPEND 23 | #disk_full_action = SUSPEND 24 | #disk_error_action = SUSPEND 25 | ##tcp_listen_port = 26 | #tcp_listen_queue = 5 27 | #tcp_max_per_addr = 1 28 | ##tcp_client_ports = 1024-65535 29 | #tcp_client_max_idle = 0 30 | enable_krb5 = no 31 | krb5_principal = auditd 32 | ##krb5_key_file = /etc/audit/audit.key 33 | -------------------------------------------------------------------------------- /etc/auditd.rules: -------------------------------------------------------------------------------- 1 | # This file contains the auditctl rules that are loaded 2 | # whenever the audit daemon is started via the initscripts. 3 | # The rules are simply the parameters that would be passed 4 | # to auditctl. 5 | 6 | # First rule - delete all 7 | -D 8 | 9 | # Increase the buffers to survive stress events. 10 | # Make this bigger for busy systems 11 | -b 320 12 | 13 | # Feel free to add below this line. See auditctl man page 14 | -a exit,always -S 102 -S clone -S execve -S exit_group -S open -S write -S mkdir -S mkdirat -S mknod -S chmod -S fchmod -S fchmodat -S chown -S fchown32 -S fchownat -S lchown32 -S close -S fork -S unlink -S link -S getuid -S symlink -S unlinkat -S setuid32 -S setreuid32 -S setresuid32 15 | -------------------------------------------------------------------------------- /lib/actiontabs.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char action_strings[] = "always\0never\0possible"; 3 | static const unsigned action_s2i_s[] = { 4 | 0,7,13, 5 | }; 6 | static const int action_s2i_i[] = { 7 | 2,0,1, 8 | }; 9 | static int action_s2i(const char *s, int *value) { 10 | size_t len, i; 11 | len = strlen(s); 12 | { char copy[len + 1]; 13 | for (i = 0; i < len; i++) { 14 | char c = s[i]; 15 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 16 | } 17 | copy[i] = 0; 18 | return s2i__(action_strings, action_s2i_s, action_s2i_i, 3, copy, value); 19 | } 20 | } 21 | static const unsigned action_i2s_direct[] = { 22 | 7,13,0, 23 | }; 24 | static const char *action_i2s(int v) { 25 | return i2s_direct__(action_strings, action_i2s_direct, 0, 2, v); 26 | } 27 | -------------------------------------------------------------------------------- /lib/armeb_table.h: -------------------------------------------------------------------------------- 1 | /* armeb_table.h -- 2 | * Copyright 2009-10,2012 Red Hat Inc., Durham, North Carolina. 3 | * All Rights Reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Steve Grubb 21 | */ 22 | _S(0, "restart_syscall") 23 | _S(1, "exit") 24 | _S(2, "fork") 25 | _S(3, "read") 26 | _S(4, "write") 27 | _S(5, "open") 28 | _S(6, "close") 29 | _S(8, "creat") 30 | _S(9, "link") 31 | _S(10, "unlink") 32 | _S(11, "execve") 33 | _S(12, "chdir") 34 | _S(13, "time") 35 | _S(14, "mknod") 36 | _S(15, "chmod") 37 | _S(16, "lchown") 38 | _S(19, "lseek") 39 | _S(20, "getpid") 40 | _S(21, "mount") 41 | _S(22, "umount") 42 | _S(23, "setuid") 43 | _S(24, "getuid") 44 | _S(25, "stime") 45 | _S(26, "ptrace") 46 | _S(27, "alarm") 47 | _S(29, "pause") 48 | _S(30, "utime") 49 | _S(33, "access") 50 | _S(34, "nice") 51 | _S(36, "sync") 52 | _S(37, "kill") 53 | _S(38, "rename") 54 | _S(39, "mkdir") 55 | _S(40, "rmdir") 56 | _S(41, "dup") 57 | _S(42, "pipe") 58 | _S(43, "times") 59 | _S(45, "brk") 60 | _S(46, "setgid") 61 | _S(47, "getgid") 62 | _S(49, "geteuid") 63 | _S(50, "getegid") 64 | _S(51, "acct") 65 | _S(52, "umount2") 66 | _S(54, "ioctl") 67 | _S(55, "fcntl") 68 | _S(57, "setpgid") 69 | _S(60, "umask") 70 | _S(61, "chroot") 71 | _S(62, "ustat") 72 | _S(63, "dup2") 73 | _S(64, "getppid") 74 | _S(65, "getpgrp") 75 | _S(66, "setsid") 76 | _S(67, "sigaction") 77 | _S(70, "setreuid") 78 | _S(71, "setregid") 79 | _S(72, "sigsuspend") 80 | _S(73, "sigpending") 81 | _S(74, "sethostname") 82 | _S(75, "setrlimit") 83 | _S(76, "getrlimit") 84 | _S(77, "getrusage") 85 | _S(78, "gettimeofday") 86 | _S(79, "settimeofday") 87 | _S(80, "getgroups") 88 | _S(81, "setgroups") 89 | _S(82, "select") 90 | _S(83, "symlink") 91 | _S(85, "readlink") 92 | _S(86, "uselib") 93 | _S(87, "swapon") 94 | _S(88, "reboot") 95 | _S(89, "readdir") 96 | _S(90, "mmap") 97 | _S(91, "munmap") 98 | _S(92, "truncate") 99 | _S(93, "ftruncate") 100 | _S(94, "fchmod") 101 | _S(95, "fchown") 102 | _S(96, "getpriority") 103 | _S(97, "setpriority") 104 | _S(99, "statfs") 105 | _S(100, "fstatfs") 106 | _S(102, "socketcall") 107 | _S(103, "syslog") 108 | _S(104, "setitimer") 109 | _S(105, "getitimer") 110 | _S(106, "stat") 111 | _S(107, "lstat") 112 | _S(108, "fstat") 113 | _S(111, "vhangup") 114 | _S(113, "syscall") 115 | _S(114, "wait4") 116 | _S(115, "swapoff") 117 | _S(116, "sysinfo") 118 | _S(117, "ipc") 119 | _S(118, "fsync") 120 | _S(119, "sigreturn") 121 | _S(120, "clone") 122 | _S(121, "setdomainname") 123 | _S(122, "uname") 124 | _S(124, "adjtimex") 125 | _S(125, "mprotect") 126 | _S(126, "sigprocmask") 127 | _S(128, "init_module") 128 | _S(129, "delete_module") 129 | _S(131, "quotactl") 130 | _S(132, "getpgid") 131 | _S(133, "fchdir") 132 | _S(134, "bdflush") 133 | _S(135, "sysfs") 134 | _S(136, "personality") 135 | _S(138, "setfsuid") 136 | _S(139, "setfsgid") 137 | _S(140, "llseek") 138 | _S(141, "getdents") 139 | _S(142, "newselect") 140 | _S(143, "flock") 141 | _S(144, "msync") 142 | _S(145, "readv") 143 | _S(146, "writev") 144 | _S(147, "getsid") 145 | _S(148, "fdatasync") 146 | _S(149, "sysctl") 147 | _S(150, "mlock") 148 | _S(151, "munlock") 149 | _S(152, "mlockall") 150 | _S(153, "munlockall") 151 | _S(154, "sched_setparam") 152 | _S(155, "sched_getparam") 153 | _S(156, "sched_setscheduler") 154 | _S(157, "sched_getscheduler") 155 | _S(158, "sched_yield") 156 | _S(159, "sched_get_priority_max") 157 | _S(160, "sched_get_priority_min") 158 | _S(161, "sched_rr_get_interval") 159 | _S(162, "nanosleep") 160 | _S(163, "mremap") 161 | _S(164, "setresuid") 162 | _S(165, "getresuid") 163 | _S(168, "poll") 164 | _S(169, "nfsservctl") 165 | _S(170, "setresgid") 166 | _S(171, "getresgid") 167 | _S(172, "prctl") 168 | _S(173, "rt_sigreturn") 169 | _S(174, "rt_sigaction") 170 | _S(175, "rt_sigprocmask") 171 | _S(176, "rt_sigpending") 172 | _S(177, "rt_sigtimedwait") 173 | _S(178, "rt_sigqueueinfo") 174 | _S(179, "rt_sigsuspend") 175 | _S(180, "pread64") 176 | _S(181, "pwrite64") 177 | _S(182, "chown") 178 | _S(183, "getcwd") 179 | _S(184, "capget") 180 | _S(185, "capset") 181 | _S(186, "sigaltstack") 182 | _S(187, "sendfile") 183 | _S(190, "vfork") 184 | _S(191, "ugetrlimit") 185 | _S(192, "mmap2") 186 | _S(193, "truncate64") 187 | _S(194, "ftruncate64") 188 | _S(195, "stat64") 189 | _S(196, "lstat64") 190 | _S(197, "fstat64") 191 | _S(198, "lchown32") 192 | _S(199, "getuid32") 193 | _S(200, "getgid32") 194 | _S(201, "geteuid32") 195 | _S(202, "getegid32") 196 | _S(203, "setreuid32") 197 | _S(204, "setregid32") 198 | _S(205, "getgroups32") 199 | _S(206, "setgroups32") 200 | _S(207, "fchown32") 201 | _S(208, "setresuid32") 202 | _S(209, "getresuid32") 203 | _S(210, "setresgid32") 204 | _S(211, "getresgid32") 205 | _S(212, "chown32") 206 | _S(213, "setuid32") 207 | _S(214, "setgid32") 208 | _S(215, "setfsuid32") 209 | _S(216, "setfsgid32") 210 | _S(217, "getdents64") 211 | _S(218, "pivot_root") 212 | _S(219, "mincore") 213 | _S(220, "madvise") 214 | _S(221, "fcntl64") 215 | _S(224, "gettid") 216 | _S(225, "readahead") 217 | _S(226, "setxattr") 218 | _S(227, "lsetxattr") 219 | _S(228, "fsetxattr") 220 | _S(229, "getxattr") 221 | _S(230, "lgetxattr") 222 | _S(231, "fgetxattr") 223 | _S(232, "listxattr") 224 | _S(233, "llistxattr") 225 | _S(234, "flistxattr") 226 | _S(235, "removexattr") 227 | _S(236, "lremovexattr") 228 | _S(237, "fremovexattr") 229 | _S(238, "tkill") 230 | _S(239, "sendfile64") 231 | _S(240, "futex") 232 | _S(241, "sched_setaffinity") 233 | _S(242, "sched_getaffinity") 234 | _S(243, "io_setup") 235 | _S(244, "io_destroy") 236 | _S(245, "io_getevents") 237 | _S(246, "io_submit") 238 | _S(247, "io_cancel") 239 | _S(248, "exit_group") 240 | _S(249, "lookup_dcookie") 241 | _S(250, "epoll_create") 242 | _S(251, "epoll_ctl") 243 | _S(252, "epoll_wait") 244 | _S(253, "remap_file_pages") 245 | _S(256, "set_tid_address") 246 | _S(257, "timer_create") 247 | _S(258, "timer_settime") 248 | _S(259, "timer_gettime") 249 | _S(260, "timer_getoverrun") 250 | _S(261, "timer_delete") 251 | _S(262, "clock_settime") 252 | _S(263, "clock_gettime") 253 | _S(264, "clock_getres") 254 | _S(265, "clock_nanosleep") 255 | _S(266, "statfs64") 256 | _S(267, "fstatfs64") 257 | _S(268, "tgkill") 258 | _S(269, "utimes") 259 | _S(270, "fadvise64_64") 260 | _S(271, "pciconfig_iobase") 261 | _S(272, "pciconfig_read") 262 | _S(273, "pciconfig_write") 263 | _S(274, "mq_open") 264 | _S(275, "mq_unlink") 265 | _S(276, "mq_timedsend") 266 | _S(277, "mq_timedreceive") 267 | _S(278, "mq_notify") 268 | _S(279, "mq_getsetattr") 269 | _S(280, "waitid") 270 | _S(281, "socket") 271 | _S(282, "bind") 272 | _S(283, "connect") 273 | _S(284, "listen") 274 | _S(285, "accept") 275 | _S(286, "getsockname") 276 | _S(287, "getpeername") 277 | _S(288, "socketpair") 278 | _S(289, "send") 279 | _S(290, "sendto") 280 | _S(291, "recv") 281 | _S(292, "recvfrom") 282 | _S(293, "shutdown") 283 | _S(294, "setsockopt") 284 | _S(295, "getsockopt") 285 | _S(296, "sendmsg") 286 | _S(297, "recvmsg") 287 | _S(298, "semop") 288 | _S(299, "semget") 289 | _S(300, "semctl") 290 | _S(301, "msgsnd") 291 | _S(302, "msgrcv") 292 | _S(303, "msgget") 293 | _S(304, "msgctl") 294 | _S(305, "shmat") 295 | _S(306, "shmdt") 296 | _S(307, "shmget") 297 | _S(308, "shmctl") 298 | _S(309, "add_key") 299 | _S(310, "request_key") 300 | _S(311, "keyctl") 301 | _S(312, "semtimedop") 302 | _S(313, "vserver") 303 | _S(314, "ioprio_set") 304 | _S(315, "ioprio_get") 305 | _S(316, "inotify_init") 306 | _S(317, "inotify_add_watch") 307 | _S(318, "inotify_rm_watch") 308 | _S(319, "mbind") 309 | _S(320, "get_mempolicy") 310 | _S(321, "set_mempolicy") 311 | _S(322, "openat") 312 | _S(323, "mkdirat") 313 | _S(324, "mknodat") 314 | _S(325, "fchownat") 315 | _S(326, "futimesat") 316 | _S(327, "fstatat64") 317 | _S(328, "unlinkat") 318 | _S(329, "renameat") 319 | _S(330, "linkat") 320 | _S(331, "symlinkat") 321 | _S(332, "readlinkat") 322 | _S(333, "fchmodat") 323 | _S(334, "faccessat") 324 | _S(337, "unshare") 325 | _S(338, "set_robust_list") 326 | _S(339, "get_robust_list") 327 | _S(340, "splice") 328 | _S(341, "sync_file_range") 329 | _S(342, "tee") 330 | _S(343, "vmsplice") 331 | _S(344, "move_pages") 332 | _S(345, "getcpu") 333 | _S(347, "kexec_load") 334 | _S(348, "utimensat") 335 | _S(349, "signalfd") 336 | _S(350, "timerfd_create") 337 | _S(351, "eventfd") 338 | _S(352, "fallocate") 339 | _S(353, "timerfd_settime") 340 | _S(354, "timerfd_gettime") 341 | _S(355, "signalfd4") 342 | _S(356, "eventfd2") 343 | _S(357, "epoll_create1") 344 | _S(358, "dup3") 345 | _S(359, "pipe2") 346 | _S(360, "inotify_init1") 347 | _S(361, "preadv") 348 | _S(362, "pwritev") 349 | _S(363, "rt_tgsigqueueinfo") 350 | _S(364, "perf_event_open") 351 | _S(365, "recvmmsg") 352 | _S(366, "accept4") 353 | _S(367, "fanotify_init") 354 | _S(368, "fanotify_mark") 355 | _S(369, "prlimit64") 356 | _S(370, "name_to_handle_at") 357 | _S(371, "open_by_handle_at") 358 | _S(372, "clock_adjtime") 359 | _S(373, "syncfs") 360 | _S(374, "sendmmsg") 361 | _S(375, "setns") 362 | _S(376, "process_vm_readv") 363 | _S(377, "process_vm_writev") 364 | -------------------------------------------------------------------------------- /lib/deprecated.c: -------------------------------------------------------------------------------- 1 | /* deprecated.c -- This file is the trash heap of things about to leave 2 | * Copyright 2006-07,2009 Red Hat Inc., Durham, North Carolina. 3 | * All Rights Reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Steve Grubb 21 | */ 22 | 23 | #include "config.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "libaudit.h" 33 | #include "private.h" 34 | 35 | /* 36 | * This function will send a user space message to the kernel. 37 | * It returns the sequence number which is > 0 on success 38 | * or <= 0 on error. (pam uses this) This is the main audit sending 39 | * function now. 40 | */ 41 | int audit_send_user_message(int fd, int type, hide_t hide_error, 42 | const char *message) 43 | { 44 | int retry_cnt = 0; 45 | int rc; 46 | retry: 47 | rc = audit_send(fd, type, message, strlen(message)+1); 48 | if (rc == -ECONNREFUSED) { 49 | /* This is here to let people that build their own kernel 50 | and disable the audit system get in. ECONNREFUSED is 51 | issued by the kernel when there is "no on listening". */ 52 | return 0; 53 | } else if (rc == -EPERM && getuid() != 0 && hide_error == HIDE_IT) { 54 | /* If we get this, then the kernel supports auditing 55 | * but we don't have enough privilege to write to the 56 | * socket. Therefore, we have already been authenticated 57 | * and we are a common user. Just act as though auditing 58 | * is not enabled. Any other error we take seriously. 59 | * This is here basically to satisfy Xscreensaver. */ 60 | return 0; 61 | } else if (rc == -EINVAL) { 62 | /* If we get this, the kernel doesn't understand the 63 | * netlink message type. This is most likely due to 64 | * being an old kernel. Use the old message type. */ 65 | if (type >= AUDIT_FIRST_USER_MSG && 66 | type <= AUDIT_LAST_USER_MSG && !retry_cnt) { 67 | 68 | /* do retry */ 69 | type = AUDIT_USER; 70 | retry_cnt++; 71 | goto retry; 72 | } 73 | } 74 | return rc; 75 | } 76 | hidden_def(audit_send_user_message) 77 | 78 | -------------------------------------------------------------------------------- /lib/errormsg.h: -------------------------------------------------------------------------------- 1 | /* errormsg.h -- 2 | * Copyright 2008 FUJITSU Inc. 3 | * All Rights Reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Zhang Xiliang 21 | */ 22 | 23 | struct msg_tab { 24 | int key; /* error number */ 25 | /* 26 | * the field string position in the error message 27 | * 0: don't output field string 28 | * 1: output field string before error message 29 | * 2: output field string after error message 30 | */ 31 | int position; 32 | const char *cvalue; 33 | }; 34 | 35 | #ifndef NO_TABLES 36 | static const struct msg_tab err_msgtab[] = { 37 | { -1, 2, "-F missing operation for" }, 38 | { -2, 2, "-F unknown field:" }, 39 | { -3, 1, "must be before -S" }, 40 | { -4, 1, "machine type not found" }, 41 | { -5, 1, "elf mapping not found" }, 42 | { -6, 1, "requested bit level not supported by machine" }, 43 | { -7, 1, "can only be used with exit filter list" }, 44 | { -8, 2, "-F unknown message type -" }, 45 | { -9, 0, "msgtype field can only be used with exclude filter list" }, 46 | { -10, 0, "Failed upgrading rule" }, 47 | { -11, 0, "String value too long" }, 48 | { -12, 0, "Only msgtype field can be used with exclude filter" }, 49 | { -13, 1, "only takes = or != operators" }, 50 | { -14, 0, "Permission can only contain \'rwxa\'" }, 51 | { -15, 2, "-F unknown errno -"}, 52 | { -16, 2, "-F unknown file type - " }, 53 | { -17, 1, "can only be used with exit and entry filter list" }, 54 | { -18, 1, "" }, // Unused 55 | { -19, 0, "Key field needs a watch or syscall given prior to it" }, 56 | { -20, 2, "-F missing value after operation for" }, 57 | { -21, 2, "-F value should be number for" }, 58 | { -22, 2, "-F missing field name before operator for" }, 59 | { -23, 2, "-C missing operation for "}, 60 | { -24, 2, "-C missing field name before operator for" }, 61 | { -25, 2, "-C missing value after operation for "}, 62 | { -26, 2, "-C unknown field:" }, 63 | { -27, 2, "-C unknown right hand value for comparison with:" }, 64 | }; 65 | #endif 66 | -------------------------------------------------------------------------------- /lib/errtabs.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char err_strings[] = "E2BIG\0EACCES\0EADDRINUSE\0EADDRNOTAVAIL\0EADV\0EAFNOSUPPORT\0EAGAIN\0EALREADY\0EBADE\0EBADF\0" 3 | "EBADFD\0EBADMSG\0EBADR\0EBADRQC\0EBADSLT\0EBFONT\0EBUSY\0ECANCELED\0ECHILD\0ECHRNG\0" 4 | "ECOMM\0ECONNABORTED\0ECONNREFUSED\0ECONNRESET\0EDEADLK\0EDEADLOCK\0EDESTADDRREQ\0EDOM\0EDOTDOT\0EDQUOT\0" 5 | "EEXIST\0EFAULT\0EFBIG\0EHOSTDOWN\0EHOSTUNREACH\0EIDRM\0EILSEQ\0EINPROGRESS\0EINTR\0EINVAL\0" 6 | "EIO\0EISCONN\0EISDIR\0EISNAM\0EKEYEXPIRED\0EKEYREJECTED\0EKEYREVOKED\0EL2HLT\0EL2NSYNC\0EL3HLT\0" 7 | "EL3RST\0ELIBACC\0ELIBBAD\0ELIBEXEC\0ELIBMAX\0ELIBSCN\0ELNRNG\0ELOOP\0EMEDIUMTYPE\0EMFILE\0" 8 | "EMLINK\0EMSGSIZE\0EMULTIHOP\0ENAMETOOLONG\0ENAVAIL\0ENETDOWN\0ENETRESET\0ENETUNREACH\0ENFILE\0ENOANO\0" 9 | "ENOBUFS\0ENOCSI\0ENODATA\0ENODEV\0ENOENT\0ENOEXEC\0ENOKEY\0ENOLCK\0ENOLINK\0ENOMEDIUM\0" 10 | "ENOMEM\0ENOMSG\0ENONET\0ENOPKG\0ENOPROTOOPT\0ENOSPC\0ENOSR\0ENOSTR\0ENOSYS\0ENOTBLK\0" 11 | "ENOTCONN\0ENOTDIR\0ENOTEMPTY\0ENOTNAM\0ENOTRECOVERABLE\0ENOTSOCK\0ENOTTY\0ENOTUNIQ\0ENXIO\0EOPNOTSUPP\0" 12 | "EOVERFLOW\0EOWNERDEAD\0EPERM\0EPFNOSUPPORT\0EPIPE\0EPROTO\0EPROTONOSUPPORT\0EPROTOTYPE\0ERANGE\0EREMCHG\0" 13 | "EREMOTE\0EREMOTEIO\0ERESTART\0EROFS\0ESHUTDOWN\0ESOCKTNOSUPPORT\0ESPIPE\0ESRCH\0ESRMNT\0ESTALE\0" 14 | "ESTRPIPE\0ETIME\0ETIMEDOUT\0ETOOMANYREFS\0ETXTBSY\0EUCLEAN\0EUNATCH\0EUSERS\0EWOULDBLOCK\0EXDEV\0" 15 | "EXFULL"; 16 | static const unsigned err_s2i_s[] = { 17 | 0,6,13,24,38,43,56,63,72,78, 18 | 84,91,99,105,113,121,128,134,144,151, 19 | 158,164,177,190,201,209,219,232,237,245, 20 | 252,259,266,272,282,295,301,308,320,326, 21 | 333,337,345,352,359,371,384,396,403,412, 22 | 419,426,434,442,451,459,467,474,480,492, 23 | 499,506,515,525,538,546,555,565,577,584, 24 | 591,599,606,614,621,628,636,643,650,658, 25 | 668,675,682,689,696,708,715,721,728,735, 26 | 743,752,760,770,778,794,803,810,819,825, 27 | 836,846,857,863,876,882,889,905,916,923, 28 | 931,939,949,958,964,974,990,997,1003,1010, 29 | 1017,1026,1032,1042,1055,1063,1071,1079,1086,1098, 30 | 1104, 31 | }; 32 | static const int err_s2i_i[] = { 33 | 7,13,98,99,68,97,11,114,52,9, 34 | 77,74,53,56,57,59,16,125,10,44, 35 | 70,103,111,104,35,35,89,33,73,122, 36 | 17,14,27,112,113,43,84,115,4,22, 37 | 5,106,21,120,127,129,128,51,45,46, 38 | 47,79,80,83,82,81,48,40,124,24, 39 | 31,90,72,36,119,100,102,101,23,55, 40 | 105,50,61,19,2,8,126,37,67,123, 41 | 12,42,64,65,92,28,63,60,38,15, 42 | 107,20,39,118,131,88,25,76,6,95, 43 | 75,130,1,96,32,71,93,91,34,78, 44 | 66,121,85,30,108,94,29,3,69,116, 45 | 86,62,110,109,26,117,49,87,11,18, 46 | 54, 47 | }; 48 | static int err_s2i(const char *s, int *value) { 49 | size_t len, i; 50 | len = strlen(s); 51 | { char copy[len + 1]; 52 | for (i = 0; i < len; i++) { 53 | char c = s[i]; 54 | copy[i] = GT_ISLOWER(c) ? c - 'a' + 'A' : c; 55 | } 56 | copy[i] = 0; 57 | return s2i__(err_strings, err_s2i_s, err_s2i_i, 131, copy, value); 58 | } 59 | } 60 | static const unsigned err_i2s_direct[] = { 61 | 857,621,997,320,333,819,0,628,78,144, 62 | 56,668,6,259,735,128,252,1098,614,752, 63 | 345,326,577,492,803,1055,266,708,990,958, 64 | 499,876,232,916,201,525,643,728,760,474, 65 | -1u,675,295,151,403,412,419,467,1071,599, 66 | 396,72,99,1104,584,105,113,-1u,121,721, 67 | 606,1026,715,682,689,931,650,38,1003,158, 68 | 882,515,237,91,836,810,84,923,426,434, 69 | 459,451,442,301,949,1017,1079,794,219,506, 70 | 905,696,889,974,825,863,43,13,24,546, 71 | 565,555,164,190,591,337,743,964,1042,1032, 72 | 177,272,282,63,308,1010,1063,770,538,352, 73 | 939,245,658,480,134,636,359,384,371,846, 74 | 778, 75 | }; 76 | static const char *err_i2s(int v) { 77 | return i2s_direct__(err_strings, err_i2s_direct, 1, 131, v); 78 | } 79 | -------------------------------------------------------------------------------- /lib/ev_vars.h: -------------------------------------------------------------------------------- 1 | /* 2 | * loop member variable declarations 3 | * 4 | * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modifica- 8 | * tion, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 19 | * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 21 | * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- 25 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * Alternatively, the contents of this file may be used under the terms of 29 | * the GNU General Public License ("GPL") version 2 or any later version, 30 | * in which case the provisions of the GPL are applicable instead of 31 | * the above. If you wish to allow the use of your version of this file 32 | * only under the terms of the GPL and not to allow others to use your 33 | * version of this file under the BSD license, indicate your decision 34 | * by deleting the provisions above and replace them with the notice 35 | * and other provisions required by the GPL. If you do not delete the 36 | * provisions above, a recipient may use your version of this file under 37 | * either the BSD or the GPL. 38 | */ 39 | 40 | #define VARx(type,name) VAR(name, type name) 41 | 42 | VARx(ev_tstamp, now_floor) /* last time we refreshed rt_time */ 43 | VARx(ev_tstamp, mn_now) /* monotonic clock "now" */ 44 | VARx(ev_tstamp, rtmn_diff) /* difference realtime - monotonic time */ 45 | 46 | VARx(ev_tstamp, io_blocktime) 47 | VARx(ev_tstamp, timeout_blocktime) 48 | 49 | VARx(int, backend) 50 | VARx(int, activecnt) /* total number of active events ("refcount") */ 51 | VARx(EV_ATOMIC_T, loop_done) /* signal by ev_break */ 52 | 53 | VARx(int, backend_fd) 54 | VARx(ev_tstamp, backend_mintime) /* assumed typical timer resolution */ 55 | VAR (backend_modify, void (*backend_modify)(EV_P_ int fd, int oev, int nev)) 56 | VAR (backend_poll , void (*backend_poll)(EV_P_ ev_tstamp timeout)) 57 | 58 | VARx(ANFD *, anfds) 59 | VARx(int, anfdmax) 60 | 61 | VAR (pendings, ANPENDING *pendings [NUMPRI]) 62 | VAR (pendingmax, int pendingmax [NUMPRI]) 63 | VAR (pendingcnt, int pendingcnt [NUMPRI]) 64 | VARx(ev_prepare, pending_w) /* dummy pending watcher */ 65 | 66 | /* for reverse feeding of events */ 67 | VARx(W *, rfeeds) 68 | VARx(int, rfeedmax) 69 | VARx(int, rfeedcnt) 70 | 71 | #if EV_USE_EVENTFD || EV_GENWRAP 72 | VARx(int, evfd) 73 | #endif 74 | VAR (evpipe, int evpipe [2]) 75 | VARx(ev_io, pipe_w) 76 | VARx(EV_ATOMIC_T, pipe_write_wanted) 77 | VARx(EV_ATOMIC_T, pipe_write_skipped) 78 | 79 | #if !defined(_WIN32) || EV_GENWRAP 80 | VARx(pid_t, curpid) 81 | #endif 82 | 83 | VARx(char, postfork) /* true if we need to recreate kernel state after fork */ 84 | 85 | #if EV_USE_SELECT || EV_GENWRAP 86 | VARx(void *, vec_ri) 87 | VARx(void *, vec_ro) 88 | VARx(void *, vec_wi) 89 | VARx(void *, vec_wo) 90 | #if defined(_WIN32) || EV_GENWRAP 91 | VARx(void *, vec_eo) 92 | #endif 93 | VARx(int, vec_max) 94 | #endif 95 | 96 | #if EV_USE_POLL || EV_GENWRAP 97 | VARx(struct pollfd *, polls) 98 | VARx(int, pollmax) 99 | VARx(int, pollcnt) 100 | VARx(int *, pollidxs) /* maps fds into structure indices */ 101 | VARx(int, pollidxmax) 102 | #endif 103 | 104 | #if EV_USE_EPOLL || EV_GENWRAP 105 | VARx(struct epoll_event *, epoll_events) 106 | VARx(int, epoll_eventmax) 107 | VARx(int *, epoll_eperms) 108 | VARx(int, epoll_epermcnt) 109 | VARx(int, epoll_epermmax) 110 | #endif 111 | 112 | #if EV_USE_KQUEUE || EV_GENWRAP 113 | VARx(struct kevent *, kqueue_changes) 114 | VARx(int, kqueue_changemax) 115 | VARx(int, kqueue_changecnt) 116 | VARx(struct kevent *, kqueue_events) 117 | VARx(int, kqueue_eventmax) 118 | #endif 119 | 120 | #if EV_USE_PORT || EV_GENWRAP 121 | VARx(struct port_event *, port_events) 122 | VARx(int, port_eventmax) 123 | #endif 124 | 125 | #if EV_USE_IOCP || EV_GENWRAP 126 | VARx(HANDLE, iocp) 127 | #endif 128 | 129 | VARx(int *, fdchanges) 130 | VARx(int, fdchangemax) 131 | VARx(int, fdchangecnt) 132 | 133 | VARx(ANHE *, timers) 134 | VARx(int, timermax) 135 | VARx(int, timercnt) 136 | 137 | #if EV_PERIODIC_ENABLE || EV_GENWRAP 138 | VARx(ANHE *, periodics) 139 | VARx(int, periodicmax) 140 | VARx(int, periodiccnt) 141 | #endif 142 | 143 | #if EV_IDLE_ENABLE || EV_GENWRAP 144 | VAR (idles, ev_idle **idles [NUMPRI]) 145 | VAR (idlemax, int idlemax [NUMPRI]) 146 | VAR (idlecnt, int idlecnt [NUMPRI]) 147 | #endif 148 | VARx(int, idleall) /* total number */ 149 | 150 | VARx(struct ev_prepare **, prepares) 151 | VARx(int, preparemax) 152 | VARx(int, preparecnt) 153 | 154 | VARx(struct ev_check **, checks) 155 | VARx(int, checkmax) 156 | VARx(int, checkcnt) 157 | 158 | #if EV_FORK_ENABLE || EV_GENWRAP 159 | VARx(struct ev_fork **, forks) 160 | VARx(int, forkmax) 161 | VARx(int, forkcnt) 162 | #endif 163 | 164 | #if EV_CLEANUP_ENABLE || EV_GENWRAP 165 | VARx(struct ev_cleanup **, cleanups) 166 | VARx(int, cleanupmax) 167 | VARx(int, cleanupcnt) 168 | #endif 169 | 170 | #if EV_ASYNC_ENABLE || EV_GENWRAP 171 | VARx(EV_ATOMIC_T, async_pending) 172 | VARx(struct ev_async **, asyncs) 173 | VARx(int, asyncmax) 174 | VARx(int, asynccnt) 175 | #endif 176 | 177 | #if EV_USE_INOTIFY || EV_GENWRAP 178 | VARx(int, fs_fd) 179 | VARx(ev_io, fs_w) 180 | VARx(char, fs_2625) /* whether we are running in linux 2.6.25 or newer */ 181 | VAR (fs_hash, ANFS fs_hash [EV_INOTIFY_HASHSIZE]) 182 | #endif 183 | 184 | VARx(EV_ATOMIC_T, sig_pending) 185 | #if EV_USE_SIGNALFD || EV_GENWRAP 186 | VARx(int, sigfd) 187 | VARx(ev_io, sigfd_w) 188 | VARx(sigset_t, sigfd_set) 189 | #endif 190 | 191 | VARx(unsigned int, origflags) /* original loop flags */ 192 | 193 | #if EV_FEATURE_API || EV_GENWRAP 194 | VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */ 195 | VARx(unsigned int, loop_depth) /* #ev_run enters - #ev_run leaves */ 196 | 197 | VARx(void *, userdata) 198 | VAR (release_cb, void (*release_cb)(EV_P)) 199 | VAR (acquire_cb, void (*acquire_cb)(EV_P)) 200 | VAR (invoke_cb , void (*invoke_cb) (EV_P)) 201 | #endif 202 | 203 | #undef VARx 204 | 205 | -------------------------------------------------------------------------------- /lib/ev_wrap.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT, automatically generated by update_ev_wrap */ 2 | #ifndef EV_WRAP_H 3 | #define EV_WRAP_H 4 | #define now_floor ((loop)->now_floor) 5 | #define mn_now ((loop)->mn_now) 6 | #define rtmn_diff ((loop)->rtmn_diff) 7 | #define io_blocktime ((loop)->io_blocktime) 8 | #define timeout_blocktime ((loop)->timeout_blocktime) 9 | #define backend ((loop)->backend) 10 | #define activecnt ((loop)->activecnt) 11 | #define loop_done ((loop)->loop_done) 12 | #define backend_fd ((loop)->backend_fd) 13 | #define backend_mintime ((loop)->backend_mintime) 14 | #define backend_modify ((loop)->backend_modify) 15 | #define backend_poll ((loop)->backend_poll) 16 | #define anfds ((loop)->anfds) 17 | #define anfdmax ((loop)->anfdmax) 18 | #define pendings ((loop)->pendings) 19 | #define pendingmax ((loop)->pendingmax) 20 | #define pendingcnt ((loop)->pendingcnt) 21 | #define pending_w ((loop)->pending_w) 22 | #define rfeeds ((loop)->rfeeds) 23 | #define rfeedmax ((loop)->rfeedmax) 24 | #define rfeedcnt ((loop)->rfeedcnt) 25 | #define evfd ((loop)->evfd) 26 | #define evpipe ((loop)->evpipe) 27 | #define pipe_w ((loop)->pipe_w) 28 | #define pipe_write_wanted ((loop)->pipe_write_wanted) 29 | #define pipe_write_skipped ((loop)->pipe_write_skipped) 30 | #define curpid ((loop)->curpid) 31 | #define postfork ((loop)->postfork) 32 | #define vec_ri ((loop)->vec_ri) 33 | #define vec_ro ((loop)->vec_ro) 34 | #define vec_wi ((loop)->vec_wi) 35 | #define vec_wo ((loop)->vec_wo) 36 | #define vec_eo ((loop)->vec_eo) 37 | #define vec_max ((loop)->vec_max) 38 | #define polls ((loop)->polls) 39 | #define pollmax ((loop)->pollmax) 40 | #define pollcnt ((loop)->pollcnt) 41 | #define pollidxs ((loop)->pollidxs) 42 | #define pollidxmax ((loop)->pollidxmax) 43 | #define epoll_events ((loop)->epoll_events) 44 | #define epoll_eventmax ((loop)->epoll_eventmax) 45 | #define epoll_eperms ((loop)->epoll_eperms) 46 | #define epoll_epermcnt ((loop)->epoll_epermcnt) 47 | #define epoll_epermmax ((loop)->epoll_epermmax) 48 | #define kqueue_changes ((loop)->kqueue_changes) 49 | #define kqueue_changemax ((loop)->kqueue_changemax) 50 | #define kqueue_changecnt ((loop)->kqueue_changecnt) 51 | #define kqueue_events ((loop)->kqueue_events) 52 | #define kqueue_eventmax ((loop)->kqueue_eventmax) 53 | #define port_events ((loop)->port_events) 54 | #define port_eventmax ((loop)->port_eventmax) 55 | #define iocp ((loop)->iocp) 56 | #define fdchanges ((loop)->fdchanges) 57 | #define fdchangemax ((loop)->fdchangemax) 58 | #define fdchangecnt ((loop)->fdchangecnt) 59 | #define timers ((loop)->timers) 60 | #define timermax ((loop)->timermax) 61 | #define timercnt ((loop)->timercnt) 62 | #define periodics ((loop)->periodics) 63 | #define periodicmax ((loop)->periodicmax) 64 | #define periodiccnt ((loop)->periodiccnt) 65 | #define idles ((loop)->idles) 66 | #define idlemax ((loop)->idlemax) 67 | #define idlecnt ((loop)->idlecnt) 68 | #define idleall ((loop)->idleall) 69 | #define prepares ((loop)->prepares) 70 | #define preparemax ((loop)->preparemax) 71 | #define preparecnt ((loop)->preparecnt) 72 | #define checks ((loop)->checks) 73 | #define checkmax ((loop)->checkmax) 74 | #define checkcnt ((loop)->checkcnt) 75 | #define forks ((loop)->forks) 76 | #define forkmax ((loop)->forkmax) 77 | #define forkcnt ((loop)->forkcnt) 78 | #define cleanups ((loop)->cleanups) 79 | #define cleanupmax ((loop)->cleanupmax) 80 | #define cleanupcnt ((loop)->cleanupcnt) 81 | #define async_pending ((loop)->async_pending) 82 | #define asyncs ((loop)->asyncs) 83 | #define asyncmax ((loop)->asyncmax) 84 | #define asynccnt ((loop)->asynccnt) 85 | #define fs_fd ((loop)->fs_fd) 86 | #define fs_w ((loop)->fs_w) 87 | #define fs_2625 ((loop)->fs_2625) 88 | #define fs_hash ((loop)->fs_hash) 89 | #define sig_pending ((loop)->sig_pending) 90 | #define sigfd ((loop)->sigfd) 91 | #define sigfd_w ((loop)->sigfd_w) 92 | #define sigfd_set ((loop)->sigfd_set) 93 | #define origflags ((loop)->origflags) 94 | #define loop_count ((loop)->loop_count) 95 | #define loop_depth ((loop)->loop_depth) 96 | #define userdata ((loop)->userdata) 97 | #define release_cb ((loop)->release_cb) 98 | #define acquire_cb ((loop)->acquire_cb) 99 | #define invoke_cb ((loop)->invoke_cb) 100 | #else 101 | #undef EV_WRAP_H 102 | #undef now_floor 103 | #undef mn_now 104 | #undef rtmn_diff 105 | #undef io_blocktime 106 | #undef timeout_blocktime 107 | #undef backend 108 | #undef activecnt 109 | #undef loop_done 110 | #undef backend_fd 111 | #undef backend_mintime 112 | #undef backend_modify 113 | #undef backend_poll 114 | #undef anfds 115 | #undef anfdmax 116 | #undef pendings 117 | #undef pendingmax 118 | #undef pendingcnt 119 | #undef pending_w 120 | #undef rfeeds 121 | #undef rfeedmax 122 | #undef rfeedcnt 123 | #undef evfd 124 | #undef evpipe 125 | #undef pipe_w 126 | #undef pipe_write_wanted 127 | #undef pipe_write_skipped 128 | #undef curpid 129 | #undef postfork 130 | #undef vec_ri 131 | #undef vec_ro 132 | #undef vec_wi 133 | #undef vec_wo 134 | #undef vec_eo 135 | #undef vec_max 136 | #undef polls 137 | #undef pollmax 138 | #undef pollcnt 139 | #undef pollidxs 140 | #undef pollidxmax 141 | #undef epoll_events 142 | #undef epoll_eventmax 143 | #undef epoll_eperms 144 | #undef epoll_epermcnt 145 | #undef epoll_epermmax 146 | #undef kqueue_changes 147 | #undef kqueue_changemax 148 | #undef kqueue_changecnt 149 | #undef kqueue_events 150 | #undef kqueue_eventmax 151 | #undef port_events 152 | #undef port_eventmax 153 | #undef iocp 154 | #undef fdchanges 155 | #undef fdchangemax 156 | #undef fdchangecnt 157 | #undef timers 158 | #undef timermax 159 | #undef timercnt 160 | #undef periodics 161 | #undef periodicmax 162 | #undef periodiccnt 163 | #undef idles 164 | #undef idlemax 165 | #undef idlecnt 166 | #undef idleall 167 | #undef prepares 168 | #undef preparemax 169 | #undef preparecnt 170 | #undef checks 171 | #undef checkmax 172 | #undef checkcnt 173 | #undef forks 174 | #undef forkmax 175 | #undef forkcnt 176 | #undef cleanups 177 | #undef cleanupmax 178 | #undef cleanupcnt 179 | #undef async_pending 180 | #undef asyncs 181 | #undef asyncmax 182 | #undef asynccnt 183 | #undef fs_fd 184 | #undef fs_w 185 | #undef fs_2625 186 | #undef fs_hash 187 | #undef sig_pending 188 | #undef sigfd 189 | #undef sigfd_w 190 | #undef sigfd_set 191 | #undef origflags 192 | #undef loop_count 193 | #undef loop_depth 194 | #undef userdata 195 | #undef release_cb 196 | #undef acquire_cb 197 | #undef invoke_cb 198 | #endif 199 | -------------------------------------------------------------------------------- /lib/event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libevent compatibility header, only core events supported 3 | * 4 | * Copyright (c) 2007,2008,2010 Marc Alexander Lehmann 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modifica- 8 | * tion, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 19 | * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 21 | * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- 25 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | * OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | * Alternatively, the contents of this file may be used under the terms of 29 | * the GNU General Public License ("GPL") version 2 or any later version, 30 | * in which case the provisions of the GPL are applicable instead of 31 | * the above. If you wish to allow the use of your version of this file 32 | * only under the terms of the GPL and not to allow others to use your 33 | * version of this file under the BSD license, indicate your decision 34 | * by deleting the provisions above and replace them with the notice 35 | * and other provisions required by the GPL. If you do not delete the 36 | * provisions above, a recipient may use your version of this file under 37 | * either the BSD or the GPL. 38 | */ 39 | 40 | #ifndef EVENT_H_ 41 | #define EVENT_H_ 42 | 43 | #ifdef EV_H 44 | # include EV_H 45 | #else 46 | # include "ev.h" 47 | #endif 48 | 49 | #ifndef EVLOOP_NONBLOCK 50 | # define EVLOOP_NONBLOCK EVRUN_NOWAIT 51 | #endif 52 | #ifndef EVLOOP_ONESHOT 53 | # define EVLOOP_ONESHOT EVRUN_ONCE 54 | #endif 55 | #ifndef EV_TIMEOUT 56 | # define EV_TIMEOUT EV_TIMER 57 | #endif 58 | 59 | #ifdef __cplusplus 60 | extern "C" { 61 | #endif 62 | 63 | /* we need sys/time.h for struct timeval only */ 64 | #if !defined (WIN32) || defined (__MINGW32__) 65 | # include /* mingw seems to need this, for whatever reason */ 66 | # include 67 | #endif 68 | 69 | struct event_base; 70 | 71 | #define EVLIST_TIMEOUT 0x01 72 | #define EVLIST_INSERTED 0x02 73 | #define EVLIST_SIGNAL 0x04 74 | #define EVLIST_ACTIVE 0x08 75 | #define EVLIST_INTERNAL 0x10 76 | #define EVLIST_INIT 0x80 77 | 78 | struct event 79 | { 80 | /* libev watchers we map onto */ 81 | union { 82 | struct ev_io io; 83 | struct ev_signal sig; 84 | } iosig; 85 | struct ev_timer to; 86 | 87 | /* compatibility slots */ 88 | struct event_base *ev_base; 89 | void (*ev_callback)(int, short, void *arg); 90 | void *ev_arg; 91 | int ev_fd; 92 | int ev_pri; 93 | int ev_res; 94 | int ev_flags; 95 | short ev_events; 96 | }; 97 | 98 | #define EV_READ EV_READ 99 | #define EV_WRITE EV_WRITE 100 | #define EV_PERSIST 0x10 101 | 102 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) 103 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) 104 | 105 | #define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT) 106 | 107 | #define evtimer_add(ev,tv) event_add (ev, tv) 108 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) 109 | #define evtimer_del(ev) event_del (ev) 110 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) 111 | #define evtimer_initialized(ev) event_initialized (ev) 112 | 113 | #define timeout_add(ev,tv) evtimer_add (ev, tv) 114 | #define timeout_set(ev,cb,data) evtimer_set (ev, cb, data) 115 | #define timeout_del(ev) evtimer_del (ev) 116 | #define timeout_pending(ev,tv) evtimer_pending (ev, tv) 117 | #define timeout_initialized(ev) evtimer_initialized (ev) 118 | 119 | #define signal_add(ev,tv) event_add (ev, tv) 120 | #define signal_set(ev,sig,cb,data) event_set (ev, sig, EV_SIGNAL | EV_PERSIST, cb, data) 121 | #define signal_del(ev) event_del (ev) 122 | #define signal_pending(ev,tv) event_pending (ev, EV_SIGNAL, tv) 123 | #define signal_initialized(ev) event_initialized (ev) 124 | 125 | const char *event_get_version (void); 126 | const char *event_get_method (void); 127 | 128 | void *event_init (void); 129 | void event_base_free (struct event_base *base); 130 | 131 | #define EVLOOP_ONCE EVLOOP_ONESHOT 132 | int event_loop (int); 133 | int event_loopexit (struct timeval *tv); 134 | int event_dispatch (void); 135 | 136 | #define _EVENT_LOG_DEBUG 0 137 | #define _EVENT_LOG_MSG 1 138 | #define _EVENT_LOG_WARN 2 139 | #define _EVENT_LOG_ERR 3 140 | typedef void (*event_log_cb)(int severity, const char *msg); 141 | void event_set_log_callback(event_log_cb cb); 142 | 143 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); 144 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); 145 | 146 | int event_add (struct event *ev, struct timeval *tv); 147 | int event_del (struct event *ev); 148 | void event_active (struct event *ev, int res, short ncalls); /* ncalls is being ignored */ 149 | 150 | int event_pending (struct event *ev, short, struct timeval *tv); 151 | 152 | int event_priority_init (int npri); 153 | int event_priority_set (struct event *ev, int pri); 154 | 155 | int event_base_set (struct event_base *base, struct event *ev); 156 | int event_base_loop (struct event_base *base, int); 157 | int event_base_loopexit (struct event_base *base, struct timeval *tv); 158 | int event_base_dispatch (struct event_base *base); 159 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); 160 | int event_base_priority_init (struct event_base *base, int fd); 161 | 162 | /* next line is different in the libevent+libev version */ 163 | /*libevent-include*/ 164 | 165 | #ifdef __cplusplus 166 | } 167 | #endif 168 | 169 | #endif 170 | 171 | -------------------------------------------------------------------------------- /lib/fieldtab.h: -------------------------------------------------------------------------------- 1 | /* fieldtab.h -- 2 | * Copyright 2005-07 Red Hat Inc., Durham, North Carolina. 3 | * All Rights Reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Steve Grubb 21 | */ 22 | 23 | _S(AUDIT_PID, "pid" ) 24 | _S(AUDIT_UID, "uid" ) 25 | _S(AUDIT_EUID, "euid" ) 26 | _S(AUDIT_SUID, "suid" ) 27 | _S(AUDIT_FSUID, "fsuid" ) 28 | _S(AUDIT_GID, "gid" ) 29 | _S(AUDIT_EGID, "egid" ) 30 | _S(AUDIT_SGID, "sgid" ) 31 | _S(AUDIT_FSGID, "fsgid" ) 32 | _S(AUDIT_LOGINUID, "auid" ) 33 | _S(AUDIT_LOGINUID, "loginuid" ) 34 | _S(AUDIT_PERS, "pers" ) 35 | _S(AUDIT_ARCH, "arch" ) 36 | _S(AUDIT_MSGTYPE, "msgtype" ) 37 | _S(AUDIT_SUBJ_USER, "subj_user" ) 38 | _S(AUDIT_SUBJ_ROLE, "subj_role" ) 39 | _S(AUDIT_SUBJ_TYPE, "subj_type" ) 40 | _S(AUDIT_SUBJ_SEN, "subj_sen" ) 41 | _S(AUDIT_SUBJ_CLR, "subj_clr" ) 42 | _S(AUDIT_PPID, "ppid" ) 43 | _S(AUDIT_OBJ_USER, "obj_user" ) 44 | _S(AUDIT_OBJ_ROLE, "obj_role" ) 45 | _S(AUDIT_OBJ_TYPE, "obj_type" ) 46 | _S(AUDIT_OBJ_LEV_LOW, "obj_lev_low" ) 47 | _S(AUDIT_OBJ_LEV_HIGH, "obj_lev_high" ) 48 | 49 | _S(AUDIT_DEVMAJOR, "devmajor" ) 50 | _S(AUDIT_DEVMINOR, "devminor" ) 51 | _S(AUDIT_INODE, "inode" ) 52 | _S(AUDIT_EXIT, "exit" ) 53 | _S(AUDIT_SUCCESS, "success" ) 54 | _S(AUDIT_WATCH, "path" ) 55 | _S(AUDIT_PERM, "perm" ) 56 | _S(AUDIT_DIR, "dir" ) 57 | _S(AUDIT_FILETYPE, "filetype" ) 58 | _S(AUDIT_OBJ_UID, "obj_uid" ) 59 | _S(AUDIT_OBJ_GID, "obj_gid" ) 60 | 61 | _S(AUDIT_ARG0, "a0" ) 62 | _S(AUDIT_ARG1, "a1" ) 63 | _S(AUDIT_ARG2, "a2" ) 64 | _S(AUDIT_ARG3, "a3" ) 65 | 66 | _S(AUDIT_FILTERKEY, "key" ) 67 | 68 | _S(AUDIT_FIELD_COMPARE, "field_compare" ) 69 | -------------------------------------------------------------------------------- /lib/fieldtabs.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char field_strings[] = "a0\0a1\0a2\0a3\0arch\0auid\0devmajor\0devminor\0dir\0egid\0" 3 | "euid\0exit\0field_compare\0filetype\0fsgid\0fsuid\0gid\0inode\0key\0loginuid\0" 4 | "msgtype\0obj_gid\0obj_lev_high\0obj_lev_low\0obj_role\0obj_type\0obj_uid\0obj_user\0path\0perm\0" 5 | "pers\0pid\0ppid\0sgid\0subj_clr\0subj_role\0subj_sen\0subj_type\0subj_user\0success\0" 6 | "suid\0uid"; 7 | static const unsigned field_s2i_s[] = { 8 | 0,3,6,9,12,17,22,31,40,44, 9 | 49,54,59,73,82,88,94,98,104,108, 10 | 117,125,133,146,158,167,176,184,193,198, 11 | 203,208,212,217,222,231,241,250,260,270, 12 | 278,283, 13 | }; 14 | static const int field_s2i_i[] = { 15 | 200,201,202,203,11,9,100,101,107,6, 16 | 2,103,111,108,8,4,5,102,210,9, 17 | 12,110,23,22,20,21,109,19,105,106, 18 | 10,0,18,7,17,14,16,15,13,104, 19 | 3,1, 20 | }; 21 | static int field_s2i(const char *s, int *value) { 22 | size_t len, i; 23 | len = strlen(s); 24 | { char copy[len + 1]; 25 | for (i = 0; i < len; i++) { 26 | char c = s[i]; 27 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 28 | } 29 | copy[i] = 0; 30 | return s2i__(field_strings, field_s2i_s, field_s2i_i, 42, copy, value); 31 | } 32 | } 33 | static const int field_i2s_i[] = { 34 | 0,1,2,3,4,5,6,7,8,9, 35 | 10,11,12,13,14,15,16,17,18,19, 36 | 20,21,22,23,100,101,102,103,104,105, 37 | 106,107,108,109,110,111,200,201,202,203, 38 | 210, 39 | }; 40 | static const unsigned field_i2s_s[] = { 41 | 208,283,49,278,88,94,44,217,82,17, 42 | 203,12,117,260,231,250,241,222,212,184, 43 | 158,167,146,133,22,31,98,54,270,193, 44 | 198,40,73,176,125,59,0,3,6,9, 45 | 104, 46 | }; 47 | static const char *field_i2s(int v) { 48 | return i2s_bsearch__(field_strings, field_i2s_i, field_i2s_s, 41, v); 49 | } 50 | -------------------------------------------------------------------------------- /lib/flagtabs.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char flag_strings[] = "entry\0exclude\0exit\0task\0user"; 3 | static const unsigned flag_s2i_s[] = { 4 | 0,6,14,19,24, 5 | }; 6 | static const int flag_s2i_i[] = { 7 | 2,5,4,1,0, 8 | }; 9 | static int flag_s2i(const char *s, int *value) { 10 | size_t len, i; 11 | len = strlen(s); 12 | { char copy[len + 1]; 13 | for (i = 0; i < len; i++) { 14 | char c = s[i]; 15 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 16 | } 17 | copy[i] = 0; 18 | return s2i__(flag_strings, flag_s2i_s, flag_s2i_i, 5, copy, value); 19 | } 20 | } 21 | static const unsigned flag_i2s_direct[] = { 22 | 24,19,0,-1u,14,6, 23 | }; 24 | static const char *flag_i2s(int v) { 25 | return i2s_direct__(flag_strings, flag_i2s_direct, 0, 5, v); 26 | } 27 | -------------------------------------------------------------------------------- /lib/ftypetabs.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char ftype_strings[] = "block\0character\0dir\0fifo\0file\0link\0socket"; 3 | static const unsigned ftype_s2i_s[] = { 4 | 0,6,16,20,25,30,35, 5 | }; 6 | static const int ftype_s2i_i[] = { 7 | 24576,8192,16384,4096,32768,40960,49152, 8 | }; 9 | static int ftype_s2i(const char *s, int *value) { 10 | size_t len, i; 11 | len = strlen(s); 12 | { char copy[len + 1]; 13 | for (i = 0; i < len; i++) { 14 | char c = s[i]; 15 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 16 | } 17 | copy[i] = 0; 18 | return s2i__(ftype_strings, ftype_s2i_s, ftype_s2i_i, 7, copy, value); 19 | } 20 | } 21 | static const int ftype_i2s_i[] = { 22 | 4096,8192,16384,24576,32768,40960,49152, 23 | }; 24 | static const unsigned ftype_i2s_s[] = { 25 | 20,6,16,0,25,30,35, 26 | }; 27 | static const char *ftype_i2s(int v) { 28 | return i2s_bsearch__(ftype_strings, ftype_i2s_i, ftype_i2s_s, 7, v); 29 | } 30 | -------------------------------------------------------------------------------- /lib/gen_tables.h: -------------------------------------------------------------------------------- 1 | /* gen_tables.h -- Declarations used for lookup tables. 2 | * Copyright 2008 Red Hat Inc., Durham, North Carolina. 3 | * All Rights Reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Miloslav Trmač 21 | */ 22 | #ifndef GEN_TABLES_H__ 23 | #define GEN_TABLES_H__ 24 | 25 | #include 26 | #include 27 | 28 | /* Assumes ASCII; verified in gen_tables.c. */ 29 | #define GT_ISUPPER(X) ((X) >= 'A' && (X) <= 'Z') 30 | #define GT_ISLOWER(X) ((X) >= 'a' && (X) <= 'z') 31 | 32 | inline static int s2i__(const char *strings, const unsigned *s_table, 33 | const int *i_table, size_t n, const char *s, int *value) 34 | { 35 | ssize_t left, right; 36 | 37 | left = 0; 38 | right = n - 1; 39 | while (left <= right) { /* invariant: left <= x <= right */ 40 | size_t mid; 41 | int r; 42 | 43 | mid = (left + right) / 2; 44 | /* FIXME? avoid recomparing a common prefix */ 45 | r = strcmp(s, strings + s_table[mid]); 46 | if (r == 0) { 47 | *value = i_table[mid]; 48 | return 1; 49 | } 50 | if (r < 0) 51 | right = mid - 1; 52 | else 53 | left = mid + 1; 54 | } 55 | return 0; 56 | } 57 | 58 | inline static const char *i2s_direct__(const char *strings, 59 | const unsigned *table, int min, int max, 60 | int v) 61 | { 62 | unsigned off; 63 | 64 | if (v < min || v > max) 65 | return NULL; 66 | off = table[v - min]; 67 | if (off != -1u) 68 | return strings + off; 69 | return NULL; 70 | } 71 | 72 | inline static const char *i2s_bsearch__(const char *strings, 73 | const int *i_table, 74 | const unsigned *s_table, size_t n, 75 | int v) 76 | { 77 | ssize_t left, right; 78 | 79 | left = 0; 80 | right = n - 1; 81 | while (left <= right) { /* invariant: left <= x <= right */ 82 | size_t mid; 83 | int mid_val; 84 | 85 | mid = (left + right) / 2; 86 | mid_val = i_table[mid]; 87 | if (v == mid_val) 88 | return strings + s_table[mid]; 89 | if (v < mid_val) 90 | right = mid - 1; 91 | else 92 | left = mid + 1; 93 | } 94 | return NULL; 95 | } 96 | 97 | struct transtab { 98 | int value; 99 | unsigned offset; 100 | }; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /lib/ia64_tables.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char ia64_syscall_strings[] = "_sysctl\0accept\0accept4\0access\0acct\0add_key\0adjtimex\0afs_syscall\0bdflush\0bind\0" 3 | "brk\0capget\0capset\0chdir\0chmod\0chown\0chroot\0clock_adjtime\0clock_getres\0clock_gettime\0" 4 | "clock_nanosleep\0clock_settime\0clone\0clone2\0close\0connect\0creat\0delete_module\0dup\0dup2\0" 5 | "dup3\0epoll_create\0epoll_create1\0epoll_ctl\0epoll_pwait\0epoll_wait\0eventfd\0eventfd2\0execve\0exit\0" 6 | "exit_group\0faccessat\0fadvise64\0fallocate\0fanotify_init\0fanotify_mark\0fchdir\0fchmod\0fchmodat\0fchown\0" 7 | "fchownat\0fcntl\0fdatasync\0fgetxattr\0flistxattr\0flock\0fremovexattr\0fsetxattr\0fstat\0fstatfs\0" 8 | "fstatfs64\0fsync\0ftruncate\0futex\0futimesat\0get_mempolicy\0get_robust_list\0getcpu\0getcwd\0getdents\0" 9 | "getdents64\0getegid\0geteuid\0getgid\0getgroups\0getitimer\0getpeername\0getpgid\0getpid\0getpmsg\0" 10 | "getppid\0getpriority\0getresgid\0getresuid\0getrlimit\0getrusage\0getsid\0getsockname\0getsockopt\0gettid\0" 11 | "gettimeofday\0getuid\0getunwind\0getxattr\0init_module\0inotify_add_watch\0inotify_init\0inotify_init1\0inotify_rm_watch\0io_cancel\0" 12 | "io_destroy\0io_getevents\0io_setup\0io_submit\0ioctl\0ioprio_get\0ioprio_set\0kexec_load\0keyctl\0kill\0" 13 | "lchown\0lgetxattr\0link\0linkat\0listen\0listxattr\0llistxattr\0lookup_dcookie\0lremovexattr\0lseek\0" 14 | "lsetxattr\0lstat\0madvise\0mbind\0migrate_pages\0mincore\0mkdir\0mkdirat\0mknod\0mknodat\0" 15 | "mlock\0mlockall\0mmap\0mmap2\0mount\0mprotect\0mq_getsetattr\0mq_notify\0mq_open\0mq_timedreceive\0" 16 | "mq_timedsend\0mq_unlink\0mremap\0msgctl\0msgget\0msgrcv\0msgsnd\0msync\0munlock\0munlockall\0" 17 | "munmap\0name_to_handle_at\0nanosleep\0newfstatat\0nfsservctl\0ni_syscall\0open\0open_by_handle_at\0openat\0pciconfig_read\0" 18 | "pciconfig_write\0perfmonctl\0personality\0pipe\0pipe2\0pivot_root\0poll\0ppoll\0prctl\0pread64\0" 19 | "preadv\0prlimit64\0process_vm_readv\0process_vm_writev\0pselect\0ptrace\0putpmsg\0pwrite64\0pwritev\0quotactl\0" 20 | "read\0readahead\0readlink\0readlinkat\0readv\0reboot\0recv\0recvfrom\0recvmmsg\0recvmsg\0" 21 | "remap_file_pages\0removexattr\0rename\0renameat\0request_key\0restart_syscall\0rmdir\0rt_sigaction\0rt_sigpending\0rt_sigprocmask\0" 22 | "rt_sigqueueinfo\0rt_sigreturn\0rt_sigsuspend\0rt_sigtimedwait\0rt_tgsigqueueinfo\0sched_get_priority_max\0sched_get_priority_min\0sched_getaffinity\0sched_getparam\0sched_getscheduler\0" 23 | "sched_rr_get_interval\0sched_setaffinity\0sched_setparam\0sched_setscheduler\0sched_yield\0select\0semctl\0semget\0semop\0semtimedop\0" 24 | "send\0sendfile\0sendmmsg\0sendmsg\0sendto\0set_mempolicy\0set_robust_list\0set_tid_address\0set_zone_reclaim\0setdomainname\0" 25 | "setfsgid\0setfsuid\0setgid\0setgroups\0sethostname\0setitimer\0setns\0setpgid\0setpriority\0setregid\0" 26 | "setresgid\0setresuid\0setreuid\0setrlimit\0setsid\0setsockopt\0settimeofday\0setuid\0setxattr\0shmat\0" 27 | "shmctl\0shmdt\0shmget\0shutdown\0sigaltstack\0signalfd\0signalfd4\0socket\0socketpair\0splice\0" 28 | "stat\0statfs\0statfs64\0swapoff\0swapon\0symlink\0symlinkat\0sync\0sync_file_range\0syncfs\0" 29 | "sysfs\0sysinfo\0syslog\0tee\0tgkill\0timer_create\0timer_delete\0timer_getoverrun\0timer_gettime\0timer_settime\0" 30 | "timerfd\0timerfd_create\0timerfd_gettime\0timerfd_settime\0times\0tkill\0truncate\0tux\0umask\0umount\0" 31 | "uname\0unlink\0unlinkat\0unshare\0uselib\0ustat\0utimensat\0utimes\0vhangup\0vmsplice\0" 32 | "vserver\0wait4\0waitid\0write\0writev"; 33 | static const unsigned ia64_syscall_s2i_s[] = { 34 | 0,8,15,23,30,35,43,52,64,72, 35 | 77,81,88,95,101,107,113,120,134,147, 36 | 161,177,191,197,204,210,218,224,238,242, 37 | 247,252,265,279,289,301,312,320,329,336, 38 | 341,352,362,372,382,396,410,417,424,433, 39 | 440,449,455,465,475,486,492,505,515,521, 40 | 529,539,545,555,561,571,585,601,608,615, 41 | 624,635,643,651,658,668,678,690,698,705, 42 | 713,721,733,743,753,763,773,780,792,803, 43 | 810,823,830,840,849,861,879,892,906,923, 44 | 933,944,957,966,976,982,993,1004,1015,1022, 45 | 1027,1034,1044,1049,1056,1063,1073,1084,1099,1112, 46 | 1118,1128,1134,1142,1148,1162,1170,1176,1184,1190, 47 | 1198,1204,1213,1218,1224,1230,1239,1253,1263,1271, 48 | 1287,1300,1310,1317,1324,1331,1338,1345,1351,1359, 49 | 1370,1377,1395,1405,1416,1427,1438,1443,1461,1468, 50 | 1483,1499,1510,1522,1527,1533,1544,1549,1555,1561, 51 | 1569,1576,1586,1603,1621,1629,1636,1644,1653,1661, 52 | 1670,1675,1685,1694,1705,1711,1718,1723,1732,1741, 53 | 1749,1766,1778,1785,1794,1806,1822,1828,1841,1855, 54 | 1870,1886,1899,1913,1929,1947,1970,1993,2011,2026, 55 | 2045,2067,2085,2100,2119,2131,2138,2145,2152,2158, 56 | 2169,2174,2183,2192,2200,2207,2221,2237,2253,2270, 57 | 2284,2293,2302,2309,2319,2331,2341,2347,2355,2367, 58 | 2376,2386,2396,2405,2415,2422,2433,2446,2453,2462, 59 | 2468,2475,2481,2488,2497,2509,2518,2528,2535,2546, 60 | 2553,2558,2565,2574,2582,2589,2597,2607,2612,2628, 61 | 2635,2641,2649,2656,2660,2667,2680,2693,2710,2724, 62 | 2738,2746,2761,2777,2793,2799,2805,2814,2818,2824, 63 | 2831,2837,2844,2853,2861,2868,2874,2884,2891,2899, 64 | 2908,2916,2922,2929,2935, 65 | }; 66 | static const int ia64_syscall_s2i_i[] = { 67 | 1150,1194,1334,1049,1064,1271,1131,1141,1138,1191, 68 | 1060,1185,1186,1034,1038,1039,1068,1328,1255,1254, 69 | 1256,1253,1128,1213,1029,1192,1030,1134,1057,1070, 70 | 1316,1243,1315,1244,1305,1245,1309,1314,1033,1025, 71 | 1236,1293,1234,1303,1323,1324,1035,1099,1292,1100, 72 | 1284,1066,1052,1222,1225,1145,1228,1219,1212,1104, 73 | 1257,1051,1098,1230,1285,1260,1299,1304,1184,1144, 74 | 1214,1063,1047,1062,1077,1119,1196,1079,1041,1188, 75 | 1042,1101,1075,1073,1085,1086,1082,1195,1204,1105, 76 | 1087,1046,1215,1220,1133,1278,1277,1318,1279,1242, 77 | 1239,1240,1238,1241,1065,1275,1274,1268,1273,1053, 78 | 1124,1221,1031,1289,1193,1223,1224,1237,1227,1040, 79 | 1218,1211,1209,1259,1280,1208,1055,1282,1037,1283, 80 | 1153,1154,1151,1172,1043,1155,1267,1266,1262,1265, 81 | 1264,1263,1156,1112,1109,1111,1110,1157,1158,1159, 82 | 1152,1326,1168,1286,1169,1024,1028,1327,1281,1173, 83 | 1174,1175,1140,1058,1317,1207,1090,1295,1170,1148, 84 | 1319,1325,1332,1333,1294,1048,1189,1149,1320,1137, 85 | 1026,1216,1092,1291,1146,1096,1200,1201,1322,1206, 86 | 1125,1226,1054,1288,1272,1246,1056,1177,1178,1179, 87 | 1180,1181,1182,1183,1321,1165,1166,1232,1160,1162, 88 | 1167,1231,1161,1163,1164,1089,1108,1106,1107,1247, 89 | 1198,1187,1331,1205,1199,1261,1298,1233,1276,1129, 90 | 1143,1142,1061,1078,1083,1118,1330,1080,1102,1072, 91 | 1076,1074,1071,1084,1081,1203,1088,1045,1217,1114, 92 | 1116,1115,1113,1202,1176,1307,1313,1190,1197,1297, 93 | 1210,1103,1258,1095,1094,1091,1290,1050,1300,1329, 94 | 1139,1127,1117,1301,1235,1248,1252,1251,1250,1249, 95 | 1308,1310,1312,1311,1059,1229,1097,1120,1067,1044, 96 | 1130,1032,1287,1296,1093,1069,1306,1036,1123,1302, 97 | 1269,1126,1270,1027,1147, 98 | }; 99 | static int ia64_syscall_s2i(const char *s, int *value) { 100 | size_t len, i; 101 | len = strlen(s); 102 | { char copy[len + 1]; 103 | for (i = 0; i < len; i++) { 104 | char c = s[i]; 105 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 106 | } 107 | copy[i] = 0; 108 | return s2i__(ia64_syscall_strings, ia64_syscall_s2i_s, ia64_syscall_s2i_i, 305, copy, value); 109 | } 110 | } 111 | static const unsigned ia64_syscall_i2s_direct[] = { 112 | 1427,336,1670,2929,1438,204,218,1044,2837,329, 113 | 95,410,2884,1184,101,107,1112,698,713,1224, 114 | 2824,2446,823,643,1629,23,2607,539,455,1022, 115 | 1778,1170,1822,238,1522,2793,77,2302,651,635, 116 | 30,976,449,2818,113,2868,242,2396,2367,743, 117 | 2386,733,2376,658,2309,690,2347,2415,773,2319, 118 | 2405,753,763,810,2433,2131,1544,2589,1685,2861, 119 | 2582,2574,1711,2805,545,417,433,721,2355,2558, 120 | 521,803,2145,2152,2138,1324,1338,1331,1317,2481, 121 | 2462,2475,2468,2649,2331,668,2814,-1u,-1u,2891, 122 | 1027,1749,2916,2641,191,2270,2831,43,-1u,849, 123 | 224,-1u,-1u,1661,64,2635,1510,52,2293,2284, 124 | 615,486,1705,2935,1561,1644,0,1213,1370,1198, 125 | 1204,1230,1310,1345,1351,1359,2011,2085,2026,2100, 126 | 2119,1947,1970,2045,1395,1416,1555,-1u,1218,1468, 127 | 1483,1499,2497,1828,1841,1855,1870,1886,1899,1913, 128 | 608,81,88,2174,705,1636,2528,72,210,1056, 129 | 8,780,678,2535,2169,2200,1718,1723,2488,2422, 130 | 792,2192,1741,1533,1162,1134,2553,1128,515,197, 131 | 624,830,1675,2453,1118,505,840,1034,465,1063, 132 | 1073,475,1766,1099,492,2799,555,2067,1993,2237, 133 | 362,2660,341,1084,957,933,944,966,923,252, 134 | 279,301,1806,2158,2667,2724,2710,2693,2680,177, 135 | 147,134,161,529,2565,1142,571,2207,1263,1300, 136 | 1287,1271,1253,1239,1004,2908,2922,35,1794,1015, 137 | 993,982,2253,879,861,906,1148,1461,1176,1190, 138 | 440,561,1405,2844,1785,1049,2597,1694,424,352, 139 | 1621,1549,2853,2546,2221,585,2612,2656,2899,372, 140 | 601,289,2874,2509,2738,312,2746,2777,2761,2518, 141 | 320,265,247,1527,892,1569,1653,1929,1732,382, 142 | 396,1576,1377,1443,120,2628,2341,2183,1586,1603, 143 | 15, 144 | }; 145 | static const char *ia64_syscall_i2s(int v) { 146 | return i2s_direct__(ia64_syscall_strings, ia64_syscall_i2s_direct, 1024, 1334, v); 147 | } 148 | -------------------------------------------------------------------------------- /lib/lookup_table.c: -------------------------------------------------------------------------------- 1 | /* lookup_table.c -- 2 | * Copyright 2004-2008,2012 Red Hat Inc., Durham, North Carolina. 3 | * All Rights Reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Steve Grubb 21 | * Rickard E. (Rik) Faith 22 | */ 23 | 24 | #include "config.h" 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "libaudit.h" 34 | #include "gen_tables.h" 35 | #include "private.h" 36 | 37 | #include "armeb_tables.h" 38 | #include "i386_tables.h" 39 | #include "ia64_tables.h" 40 | #include "ppc_tables.h" 41 | #include "s390_tables.h" 42 | #include "s390x_tables.h" 43 | #include "x86_64_tables.h" 44 | #include "errtabs.h" 45 | #include "ftypetabs.h" 46 | #include "fieldtabs.h" 47 | #include "msg_typetabs.h" 48 | #include "actiontabs.h" 49 | #include "flagtabs.h" 50 | #include "machinetabs.h" 51 | #include "optabs.h" 52 | 53 | #ifndef EM_ARM 54 | #define EM_ARM 40 55 | #endif 56 | 57 | struct int_transtab { 58 | int key; 59 | unsigned int lvalue; 60 | }; 61 | 62 | static const struct int_transtab elftab[] = { 63 | { MACH_X86, AUDIT_ARCH_I386 }, 64 | { MACH_86_64, AUDIT_ARCH_X86_64 }, 65 | { MACH_IA64, AUDIT_ARCH_IA64 }, 66 | { MACH_PPC64, AUDIT_ARCH_PPC64 }, 67 | { MACH_PPC, AUDIT_ARCH_PPC }, 68 | { MACH_S390X, AUDIT_ARCH_S390X }, 69 | { MACH_S390, AUDIT_ARCH_S390 }, 70 | { MACH_ARMEB, AUDIT_ARCH_ARMEB } 71 | }; 72 | #define AUDIT_ELF_NAMES (sizeof(elftab)/sizeof(elftab[0])) 73 | 74 | int audit_name_to_field(const char *field) 75 | { 76 | #ifndef NO_TABLES 77 | int res; 78 | 79 | if (field_s2i(field, &res) != 0) 80 | return res; 81 | #endif 82 | return -1; 83 | } 84 | hidden_def(audit_name_to_field) 85 | 86 | const char *audit_field_to_name(int field) 87 | { 88 | #ifndef NO_TABLES 89 | return field_i2s(field); 90 | #else 91 | return NULL; 92 | #endif 93 | } 94 | 95 | int audit_name_to_syscall(const char *sc, int machine) 96 | { 97 | int res, found; 98 | 99 | switch (machine) 100 | { 101 | #ifndef NO_TABLES 102 | case MACH_X86: 103 | found = i386_syscall_s2i(sc, &res); 104 | break; 105 | case MACH_86_64: 106 | found = x86_64_syscall_s2i(sc, &res); 107 | break; 108 | case MACH_IA64: 109 | found = ia64_syscall_s2i(sc, &res); 110 | break; 111 | case MACH_PPC64: 112 | case MACH_PPC: 113 | found = ppc_syscall_s2i(sc, &res); 114 | break; 115 | case MACH_S390X: 116 | found = s390x_syscall_s2i(sc, &res); 117 | break; 118 | case MACH_S390: 119 | found = s390_syscall_s2i(sc, &res); 120 | break; 121 | case MACH_ARMEB: 122 | found = armeb_syscall_s2i(sc, &res); 123 | break; 124 | #endif 125 | default: 126 | return -1; 127 | } 128 | if (found) 129 | return res; 130 | return -1; 131 | } 132 | hidden_def(audit_name_to_syscall) 133 | 134 | const char *audit_syscall_to_name(int sc, int machine) 135 | { 136 | #ifndef NO_TABLES 137 | switch (machine) 138 | { 139 | case MACH_X86: 140 | return i386_syscall_i2s(sc); 141 | case MACH_86_64: 142 | return x86_64_syscall_i2s(sc); 143 | case MACH_IA64: 144 | return ia64_syscall_i2s(sc); 145 | case MACH_PPC64: 146 | case MACH_PPC: 147 | return ppc_syscall_i2s(sc); 148 | case MACH_S390X: 149 | return s390x_syscall_i2s(sc); 150 | case MACH_S390: 151 | return s390_syscall_i2s(sc); 152 | case MACH_ARMEB: 153 | return armeb_syscall_i2s(sc); 154 | } 155 | #endif 156 | return NULL; 157 | } 158 | 159 | int audit_name_to_flag(const char *flag) 160 | { 161 | int res; 162 | 163 | if (flag_s2i(flag, &res) != 0) 164 | return res; 165 | return -1; 166 | } 167 | 168 | const char *audit_flag_to_name(int flag) 169 | { 170 | return flag_i2s(flag); 171 | } 172 | 173 | int audit_name_to_action(const char *action) 174 | { 175 | int res; 176 | 177 | if (action_s2i(action, &res) != 0) 178 | return res; 179 | return -1; 180 | } 181 | 182 | const char *audit_action_to_name(int action) 183 | { 184 | return action_i2s(action); 185 | } 186 | 187 | // On the critical path for ausearch parser 188 | int audit_name_to_msg_type(const char *msg_type) 189 | { 190 | int rc; 191 | 192 | if (msg_type_s2i(msg_type, &rc) != 0) 193 | return rc; 194 | 195 | /* Take a stab at converting */ 196 | if (strncmp(msg_type, "UNKNOWN[", 8) == 0) { 197 | int len; 198 | char buf[8]; 199 | const char *end = strchr(msg_type + 8, ']'); 200 | if (end == NULL) 201 | return -1; 202 | 203 | len = end - (msg_type + 8); 204 | if (len > 7) 205 | len = 7; 206 | memset(buf, 0, sizeof(buf)); 207 | strncpy(buf, msg_type + 8, len); 208 | errno = 0; 209 | return strtol(buf, NULL, 10); 210 | } else if (isdigit(*msg_type)) { 211 | errno = 0; 212 | return strtol(msg_type, NULL, 10); 213 | } 214 | 215 | return -1; 216 | } 217 | hidden_def(audit_name_to_msg_type) 218 | 219 | const char *audit_msg_type_to_name(int msg_type) 220 | { 221 | return msg_type_i2s(msg_type); 222 | } 223 | hidden_def(audit_msg_type_to_name) 224 | 225 | int audit_name_to_machine(const char *machine) 226 | { 227 | int res; 228 | 229 | if (machine_s2i(machine, &res) != 0) 230 | return res; 231 | return -1; 232 | } 233 | hidden_def(audit_name_to_machine) 234 | 235 | const char *audit_machine_to_name(int machine) 236 | { 237 | return machine_i2s(machine); 238 | } 239 | 240 | unsigned int audit_machine_to_elf(int machine) 241 | { 242 | unsigned int i; 243 | 244 | for (i = 0; i < AUDIT_ELF_NAMES; i++) 245 | if (elftab[i].key == machine) 246 | return elftab[i].lvalue; 247 | return 0; 248 | } 249 | hidden_def(audit_machine_to_elf) 250 | 251 | int audit_elf_to_machine(unsigned int elf) 252 | { 253 | unsigned int i; 254 | 255 | for (i = 0; i < AUDIT_ELF_NAMES; i++) 256 | if (elftab[i].lvalue == elf) return elftab[i].key; 257 | return -1; 258 | } 259 | hidden_def(audit_elf_to_machine) 260 | 261 | const char *audit_operator_to_symbol(int op) 262 | { 263 | return op_i2s(op); 264 | } 265 | hidden_def(audit_operator_to_symbol) 266 | 267 | /* This function returns 0 on error, otherwise the converted value */ 268 | int audit_name_to_errno(const char *error) 269 | { 270 | #ifndef NO_TABLES 271 | int rc, minus = 1; 272 | 273 | if (*error == '-') { 274 | minus = -1; 275 | error++; 276 | } 277 | if (err_s2i(error, &rc) == 0) 278 | rc = 0; 279 | 280 | return rc*minus; 281 | #else 282 | return 0; 283 | #endif 284 | } 285 | hidden_def(audit_name_to_errno) 286 | 287 | /* This function does not handle negative numbers yet */ 288 | const char *audit_errno_to_name(int error) 289 | { 290 | #ifndef NO_TABLES 291 | if (error < 0) 292 | return NULL; 293 | 294 | return err_i2s(error); 295 | #else 296 | return NULL; 297 | #endif 298 | } 299 | 300 | int audit_name_to_ftype(const char *name) 301 | { 302 | int res; 303 | 304 | #ifndef NO_TABLES 305 | if (ftype_s2i(name, &res) != 0) 306 | return res; 307 | #endif 308 | return -1; 309 | } 310 | hidden_def(audit_name_to_ftype) 311 | 312 | const char *audit_ftype_to_name(int ftype) 313 | { 314 | #ifndef NO_TABLES 315 | return ftype_i2s(ftype); 316 | #else 317 | return NULL; 318 | #endif 319 | } 320 | 321 | -------------------------------------------------------------------------------- /lib/machinetab.h: -------------------------------------------------------------------------------- 1 | /* machine.h -- 2 | * Copyright 2005,2006,2009 Red Hat Inc., Durham, North Carolina. 3 | * Copyright 2012 Nathaniel Husted 4 | * All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Authors: 21 | * Steve Grubb 22 | * Nathaniel Husted 23 | */ 24 | 25 | _S(MACH_X86, "i386" ) 26 | _S(MACH_X86, "i486" ) 27 | _S(MACH_X86, "i586" ) 28 | _S(MACH_X86, "i686" ) 29 | _S(MACH_86_64, "x86_64" ) 30 | _S(MACH_IA64, "ia64" ) 31 | _S(MACH_PPC64, "ppc64" ) 32 | _S(MACH_PPC, "ppc" ) 33 | _S(MACH_S390X, "s390x" ) 34 | _S(MACH_S390, "s390" ) 35 | #ifdef WITH_ALPHA 36 | _S(MACH_ALPHA, "alpha" ) 37 | #endif 38 | #ifdef WITH_ARMEB 39 | _S(MACH_ARMEB, "armeb" ) 40 | _S(MACH_ARMEB, "armv5tejl" ) 41 | _S(MACH_ARMEB, "armv7l" ) 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/machinetabs.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char machine_strings[] = "armeb\0armv5tejl\0armv7l\0i386\0i486\0i586\0i686\0ia64\0ppc\0ppc64\0" 3 | "s390\0s390x\0x86_64"; 4 | static const unsigned machine_s2i_s[] = { 5 | 0,6,16,23,28,33,38,43,48,52, 6 | 58,63,69, 7 | }; 8 | static const int machine_s2i_i[] = { 9 | 8,8,8,0,0,0,0,2,4,3, 10 | 6,5,1, 11 | }; 12 | static int machine_s2i(const char *s, int *value) { 13 | size_t len, i; 14 | len = strlen(s); 15 | { char copy[len + 1]; 16 | for (i = 0; i < len; i++) { 17 | char c = s[i]; 18 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 19 | } 20 | copy[i] = 0; 21 | return s2i__(machine_strings, machine_s2i_s, machine_s2i_i, 13, copy, value); 22 | } 23 | } 24 | static const unsigned machine_i2s_direct[] = { 25 | 23,69,43,52,48,63,58,-1u,0, 26 | }; 27 | static const char *machine_i2s(int v) { 28 | return i2s_direct__(machine_strings, machine_i2s_direct, 0, 8, v); 29 | } 30 | -------------------------------------------------------------------------------- /lib/message.c: -------------------------------------------------------------------------------- 1 | /* message.c -- 2 | * Copyright 2004, 2005 Red Hat Inc., Durham, North Carolina. 3 | * Copyright 2012 Nathaniel Husted 4 | * All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Authors: 21 | * Steve Grubb 22 | * Nathaniel Husted 23 | */ 24 | 25 | #include "config.h" 26 | #include 27 | #include 28 | #include "libaudit.h" 29 | #include "private.h" 30 | #include // Android logging 31 | 32 | #define MSG_WARN ANDROID_LOG_WARN 33 | #define MSG_ERROR ANDROID_LOG_ERROR 34 | #define MSG_INFO ANDROID_LOG_INFO 35 | 36 | /* The message mode refers to where informational messages go 37 | 0 - stderr, 1 - syslog, 2 - quiet. The default is quiet. */ 38 | static message_t message_mode = MSG_QUIET; 39 | static debug_message_t debug_message = DBG_NO; 40 | 41 | //extern int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap); 42 | 43 | void set_aumessage_mode(message_t mode, debug_message_t debug) 44 | { 45 | message_mode = mode; 46 | debug_message = debug; 47 | } 48 | 49 | /** 50 | * Print a message to Android's logcat. Message type can be of 51 | * MSG_WARN, MSG_ERROR, or MSG_INFO. These are aliases for their 52 | * ANDROID_LOG equivalents. 53 | */ 54 | void audit_msg(int message_type, const char *fmt, ...) 55 | { 56 | va_list ap; 57 | 58 | if (message_type == ANDROID_LOG_SILENT) 59 | return; 60 | 61 | va_start(ap, fmt); 62 | 63 | __android_log_vprint(message_type, "auditd", fmt, ap); 64 | 65 | va_end( ap ); 66 | } 67 | hidden_def(audit_msg) 68 | -------------------------------------------------------------------------------- /lib/msg_typetabs.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char msg_type_strings[] = "ADD_GROUP\0ADD_USER\0ANOM_ABEND\0ANOM_ACCESS_FS\0ANOM_ADD_ACCT\0ANOM_AMTU_FAIL\0ANOM_CRYPTO_FAIL\0ANOM_DEL_ACCT\0ANOM_EXEC\0ANOM_LOGIN_ACCT\0" 3 | "ANOM_LOGIN_FAILURES\0ANOM_LOGIN_LOCATION\0ANOM_LOGIN_SESSIONS\0ANOM_LOGIN_TIME\0ANOM_MAX_DAC\0ANOM_MAX_MAC\0ANOM_MK_EXEC\0ANOM_MOD_ACCT\0ANOM_PROMISCUOUS\0ANOM_RBAC_FAIL\0" 4 | "ANOM_RBAC_INTEGRITY_FAIL\0ANOM_ROOT_TRANS\0AVC\0AVC_PATH\0BPRM_FCAPS\0CAPSET\0CHGRP_ID\0CHUSER_ID\0CONFIG_CHANGE\0CRED_ACQ\0" 5 | "CRED_DISP\0CRED_REFR\0CRYPTO_FAILURE_USER\0CRYPTO_KEY_USER\0CRYPTO_LOGIN\0CRYPTO_LOGOUT\0CRYPTO_PARAM_CHANGE_USER\0CRYPTO_REPLAY_USER\0CRYPTO_SESSION\0CRYPTO_TEST_USER\0" 6 | "CWD\0DAC_CHECK\0DAEMON_ABORT\0DAEMON_ACCEPT\0DAEMON_CLOSE\0DAEMON_CONFIG\0DAEMON_END\0DAEMON_RESUME\0DAEMON_ROTATE\0DAEMON_START\0" 7 | "DEL_GROUP\0DEL_USER\0DEV_ALLOC\0DEV_DEALLOC\0EOE\0EXECVE\0FD_PAIR\0FS_RELABEL\0GRP_AUTH\0INTEGRITY_DATA\0" 8 | "INTEGRITY_HASH\0INTEGRITY_METADATA\0INTEGRITY_PCR\0INTEGRITY_RULE\0INTEGRITY_STATUS\0IPC\0IPC_SET_PERM\0KERNEL\0KERNEL_OTHER\0LABEL_LEVEL_CHANGE\0" 9 | "LABEL_OVERRIDE\0LIST_RULES\0LOGIN\0MAC_CIPSOV4_ADD\0MAC_CIPSOV4_DEL\0MAC_CONFIG_CHANGE\0MAC_IPSEC_ADDSA\0MAC_IPSEC_ADDSPD\0MAC_IPSEC_DELSA\0MAC_IPSEC_DELSPD\0" 10 | "MAC_IPSEC_EVENT\0MAC_MAP_ADD\0MAC_MAP_DEL\0MAC_POLICY_LOAD\0MAC_STATUS\0MAC_UNLBL_ALLOW\0MAC_UNLBL_STCADD\0MAC_UNLBL_STCDEL\0MMAP\0MQ_GETSETATTR\0" 11 | "MQ_NOTIFY\0MQ_OPEN\0MQ_SENDRECV\0NETFILTER_CFG\0NETFILTER_PKT\0OBJ_PID\0PATH\0RESP_ACCT_LOCK\0RESP_ACCT_LOCK_TIMED\0RESP_ACCT_REMOTE\0" 12 | "RESP_ACCT_UNLOCK_TIMED\0RESP_ALERT\0RESP_ANOMALY\0RESP_EXEC\0RESP_HALT\0RESP_KILL_PROC\0RESP_SEBOOL\0RESP_SINGLE\0RESP_TERM_ACCESS\0RESP_TERM_LOCK\0" 13 | "ROLE_ASSIGN\0ROLE_MODIFY\0ROLE_REMOVE\0SELINUX_ERR\0SERVICE_START\0SERVICE_STOP\0SOCKADDR\0SOCKETCALL\0SYSCALL\0SYSTEM_BOOT\0" 14 | "SYSTEM_RUNLEVEL\0SYSTEM_SHUTDOWN\0TEST\0TRUSTED_APP\0TTY\0TTY_GET\0TTY_SET\0USER\0USER_ACCT\0USER_AUTH\0" 15 | "USER_AVC\0USER_CHAUTHTOK\0USER_CMD\0USER_END\0USER_ERR\0USER_LABELED_EXPORT\0USER_LOGIN\0USER_LOGOUT\0USER_MAC_POLICY_LOAD\0USER_MGMT\0" 16 | "USER_ROLE_CHANGE\0USER_SELINUX_ERR\0USER_START\0USER_TTY\0USER_UNLABELED_EXPORT\0USYS_CONFIG\0VIRT_CONTROL\0VIRT_MACHINE_ID\0VIRT_RESOURCE"; 17 | static const unsigned msg_type_s2i_s[] = { 18 | 0,10,19,30,45,59,74,91,105,115, 19 | 131,151,171,191,207,220,233,246,260,277, 20 | 292,317,333,337,346,357,364,373,383,397, 21 | 406,416,426,446,462,475,489,514,533,548, 22 | 565,569,579,592,606,619,633,644,658,672, 23 | 685,695,704,714,726,730,737,745,756,765, 24 | 780,795,814,828,843,860,864,877,884,897, 25 | 916,931,942,948,964,980,998,1014,1031,1047, 26 | 1064,1080,1092,1104,1120,1131,1147,1164,1181,1186, 27 | 1200,1210,1218,1230,1244,1258,1266,1271,1286,1307, 28 | 1324,1347,1358,1371,1381,1391,1406,1418,1430,1447, 29 | 1462,1474,1486,1498,1510,1524,1537,1546,1557,1565, 30 | 1577,1593,1609,1614,1626,1630,1638,1646,1651,1661, 31 | 1671,1680,1695,1704,1713,1722,1742,1753,1765,1786, 32 | 1796,1813,1830,1841,1850,1872,1884,1897,1913, 33 | }; 34 | static const int msg_type_s2i_i[] = { 35 | 1116,1114,1701,2111,2114,2107,2110,2115,2112,2103, 36 | 2100,2104,2102,2101,2105,2106,2113,2116,1700,2108, 37 | 2109,2117,1400,1402,1321,1322,1119,1125,1305,1103, 38 | 1104,1110,2405,2404,2402,2403,2401,2406,2407,2400, 39 | 1307,1118,1202,1207,1208,1203,1201,1206,1205,1200, 40 | 1117,1115,2307,2308,1320,1309,1317,2309,1126,1800, 41 | 1803,1801,1804,1805,1802,1303,1311,2000,1316,2304, 42 | 2303,1013,1006,1407,1408,1405,1411,1413,1412,1414, 43 | 1415,1409,1410,1403,1404,1406,1416,1417,1323,1315, 44 | 1314,1312,1313,1325,1324,1318,1302,2207,2205,2204, 45 | 2206,2201,2200,2210,2212,2202,2209,2211,2203,2208, 46 | 2301,2311,2302,1401,1130,1131,1306,1304,1300,1127, 47 | 1129,1128,1120,1121,1319,1016,1017,1005,1101,1100, 48 | 1107,1108,1123,1106,1109,2305,1112,1113,2310,1102, 49 | 2300,1122,1105,1124,2306,1111,2500,2502,2501, 50 | }; 51 | static int msg_type_s2i(const char *s, int *value) { 52 | size_t len, i; 53 | len = strlen(s); 54 | { char copy[len + 1]; 55 | for (i = 0; i < len; i++) { 56 | char c = s[i]; 57 | copy[i] = GT_ISLOWER(c) ? c - 'a' + 'A' : c; 58 | } 59 | copy[i] = 0; 60 | return s2i__(msg_type_strings, msg_type_s2i_s, msg_type_s2i_i, 149, copy, value); 61 | } 62 | } 63 | static const int msg_type_i2s_i[] = { 64 | 1005,1006,1013,1016,1017,1100,1101,1102,1103,1104, 65 | 1105,1106,1107,1108,1109,1110,1111,1112,1113,1114, 66 | 1115,1116,1117,1118,1119,1120,1121,1122,1123,1124, 67 | 1125,1126,1127,1128,1129,1130,1131,1200,1201,1202, 68 | 1203,1205,1206,1207,1208,1300,1302,1303,1304,1305, 69 | 1306,1307,1309,1311,1312,1313,1314,1315,1316,1317, 70 | 1318,1319,1320,1321,1322,1323,1324,1325,1400,1401, 71 | 1402,1403,1404,1405,1406,1407,1408,1409,1410,1411, 72 | 1412,1413,1414,1415,1416,1417,1700,1701,1800,1801, 73 | 1802,1803,1804,1805,2000,2100,2101,2102,2103,2104, 74 | 2105,2106,2107,2108,2109,2110,2111,2112,2113,2114, 75 | 2115,2116,2117,2200,2201,2202,2203,2204,2205,2206, 76 | 2207,2208,2209,2210,2211,2212,2300,2301,2302,2303, 77 | 2304,2305,2306,2307,2308,2309,2310,2311,2400,2401, 78 | 2402,2403,2404,2405,2406,2407,2500,2501,2502, 79 | }; 80 | static const unsigned msg_type_i2s_s[] = { 81 | 1646,942,931,1630,1638,1661,1651,1786,397,406, 82 | 1830,1704,1671,1680,1713,416,1872,1742,1753,10, 83 | 695,0,685,569,364,1609,1614,1813,1695,1841, 84 | 373,756,1565,1593,1577,1510,1524,672,633,579, 85 | 619,658,644,592,606,1557,1266,860,1546,383, 86 | 1537,565,730,864,1210,1218,1200,1186,884,737, 87 | 1258,1626,726,346,357,1181,1244,1230,333,1498, 88 | 337,1104,1120,980,1131,948,964,1080,1092,998, 89 | 1031,1014,1047,1064,1147,1164,260,19,765,795, 90 | 843,780,814,828,877,131,191,171,115,151, 91 | 207,220,59,277,292,74,30,105,233,45, 92 | 91,246,317,1358,1347,1391,1430,1307,1286,1324, 93 | 1271,1447,1406,1371,1418,1381,1796,1462,1486,916, 94 | 897,1722,1850,704,714,745,1765,1474,548,489, 95 | 462,475,446,426,514,533,1884,1913,1897, 96 | }; 97 | static const char *msg_type_i2s(int v) { 98 | return i2s_bsearch__(msg_type_strings, msg_type_i2s_i, msg_type_i2s_s, 149, v); 99 | } 100 | -------------------------------------------------------------------------------- /lib/netlink.c: -------------------------------------------------------------------------------- 1 | /* netlink.c -- 2 | * Copyright 2004, 2005, 2009 Red Hat Inc., Durham, North Carolina. 3 | * All Rights Reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Steve Grubb 21 | * Rickard E. (Rik) Faith 22 | */ 23 | 24 | #include "config.h" 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include "libaudit.h" 32 | #include "private.h" 33 | 34 | #ifndef NETLINK_AUDIT 35 | #define NETLINK_AUDIT 9 36 | #endif 37 | 38 | static int adjust_reply(struct audit_reply *rep, int len); 39 | static int check_ack(int fd, int seq); 40 | 41 | /* 42 | * This function opens a connection to the kernel's audit 43 | * subsystem. You must be root for the call to succeed. On error, 44 | * a negative value is returned. On success, the file descriptor is 45 | * returned - which can be 0 or higher. 46 | */ 47 | int audit_open(void) 48 | { 49 | int saved_errno; 50 | int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_AUDIT); 51 | 52 | if (fd < 0) { 53 | saved_errno = errno; 54 | if (errno == EINVAL || errno == EPROTONOSUPPORT || 55 | errno == EAFNOSUPPORT) 56 | audit_msg(LOG_ERR, 57 | "Error - audit support not in kernel"); 58 | else 59 | audit_msg(LOG_ERR, 60 | "Error opening audit netlink socket (%s)", 61 | strerror(errno)); 62 | errno = saved_errno; 63 | return fd; 64 | } 65 | if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { 66 | saved_errno = errno; 67 | close(fd); 68 | audit_msg(LOG_ERR, 69 | "Error setting audit netlink socket CLOEXEC flag (%s)", 70 | strerror(errno)); 71 | errno = saved_errno; 72 | return -1; 73 | } 74 | return fd; 75 | } 76 | 77 | 78 | void audit_close(int fd) 79 | { 80 | if (fd >= 0) 81 | close(fd); 82 | } 83 | 84 | 85 | /* 86 | * This function returns -1 on error, 0 if error response received, 87 | * and > 0 if packet OK. 88 | */ 89 | int audit_get_reply(int fd, struct audit_reply *rep, reply_t block, int peek) 90 | { 91 | int len; 92 | struct sockaddr_nl nladdr; 93 | socklen_t nladdrlen = sizeof(nladdr); 94 | 95 | if (fd < 0) 96 | return -EBADF; 97 | 98 | if (block == GET_REPLY_NONBLOCKING) 99 | block = MSG_DONTWAIT; 100 | 101 | retry: 102 | len = recvfrom(fd, &rep->msg, sizeof(rep->msg), block|peek, 103 | (struct sockaddr*)&nladdr, &nladdrlen); 104 | 105 | if (len < 0) { 106 | if (errno == EINTR) 107 | goto retry; 108 | if (errno != EAGAIN) { 109 | int saved_errno = errno; 110 | audit_msg(LOG_ERR, 111 | "Error receiving audit netlink packet (%s)", 112 | strerror(errno)); 113 | errno = saved_errno; 114 | } 115 | return -errno; 116 | } 117 | if (nladdrlen != sizeof(nladdr)) { 118 | audit_msg(LOG_ERR, 119 | "Bad address size reading audit netlink socket"); 120 | return -EPROTO; 121 | } 122 | if (nladdr.nl_pid) { 123 | audit_msg(LOG_ERR, 124 | "Spoofed packet received on audit netlink socket"); 125 | return -EINVAL; 126 | } 127 | 128 | len = adjust_reply(rep, len); 129 | if (len == 0) 130 | len = -errno; 131 | return len; 132 | } 133 | hidden_def(audit_get_reply) 134 | 135 | 136 | /* 137 | * This function returns 0 on error and len on success. 138 | */ 139 | static int adjust_reply(struct audit_reply *rep, int len) 140 | { 141 | rep->type = rep->msg.nlh.nlmsg_type; 142 | rep->len = rep->msg.nlh.nlmsg_len; 143 | rep->nlh = &rep->msg.nlh; 144 | rep->status = NULL; 145 | rep->ruledata = NULL; 146 | rep->login = NULL; 147 | rep->message = NULL; 148 | rep->error = NULL; 149 | rep->signal_info = NULL; 150 | rep->conf = NULL; 151 | if (!NLMSG_OK(rep->nlh, (unsigned int)len)) { 152 | if (len == sizeof(rep->msg)) { 153 | audit_msg(LOG_ERR, 154 | "Netlink event from kernel is too big"); 155 | errno = EFBIG; 156 | } else { 157 | audit_msg(LOG_ERR, 158 | "Netlink message from kernel was not OK"); 159 | errno = EBADE; 160 | } 161 | return 0; 162 | } 163 | 164 | /* Next we'll set the data structure to point to msg.data. This is 165 | * to avoid having to use casts later. */ 166 | switch (rep->type) { 167 | case NLMSG_ERROR: 168 | rep->error = NLMSG_DATA(rep->nlh); 169 | break; 170 | case AUDIT_GET: 171 | rep->status = NLMSG_DATA(rep->nlh); 172 | break; 173 | case AUDIT_LIST_RULES: 174 | rep->ruledata = NLMSG_DATA(rep->nlh); 175 | break; 176 | case AUDIT_USER: 177 | case AUDIT_LOGIN: 178 | case AUDIT_KERNEL: 179 | case AUDIT_FIRST_USER_MSG...AUDIT_LAST_USER_MSG: 180 | case AUDIT_FIRST_USER_MSG2...AUDIT_LAST_USER_MSG2: 181 | case AUDIT_FIRST_EVENT...AUDIT_INTEGRITY_LAST_MSG: 182 | rep->message = NLMSG_DATA(rep->nlh); 183 | break; 184 | case AUDIT_SIGNAL_INFO: 185 | rep->signal_info = NLMSG_DATA(rep->nlh); 186 | break; 187 | } 188 | return len; 189 | } 190 | 191 | 192 | /* 193 | * Return values: success: positive non-zero sequence number 194 | * error: -errno 195 | * short: 0 196 | */ 197 | int audit_send(int fd, int type, const void *data, unsigned int size) 198 | { 199 | static int sequence = 0; 200 | struct audit_message req; 201 | int retval; 202 | struct sockaddr_nl addr; 203 | 204 | /* Due to user space library callbacks, there's a chance that 205 | a -1 for the fd could be passed. Just check for and handle it. */ 206 | if (fd < 0) { 207 | errno = EBADF; 208 | return -errno; 209 | } 210 | 211 | if (NLMSG_SPACE(size) > MAX_AUDIT_MESSAGE_LENGTH) { 212 | errno = EINVAL; 213 | return -errno; 214 | } 215 | 216 | if (++sequence < 0) 217 | sequence = 1; 218 | 219 | memset(&req, 0, sizeof(req)); 220 | req.nlh.nlmsg_len = NLMSG_SPACE(size); 221 | req.nlh.nlmsg_type = type; 222 | req.nlh.nlmsg_flags = NLM_F_REQUEST|NLM_F_ACK; 223 | req.nlh.nlmsg_seq = sequence; 224 | if (size && data) 225 | memcpy(NLMSG_DATA(&req.nlh), data, size); 226 | memset(&addr, 0, sizeof(addr)); 227 | addr.nl_family = AF_NETLINK; 228 | addr.nl_pid = 0; 229 | addr.nl_groups = 0; 230 | 231 | do { 232 | retval = sendto(fd, &req, req.nlh.nlmsg_len, 0, 233 | (struct sockaddr*)&addr, sizeof(addr)); 234 | } while (retval < 0 && errno == EINTR); 235 | if (retval == (int)req.nlh.nlmsg_len) { 236 | if ((retval = check_ack(fd, sequence)) == 0) 237 | return sequence; 238 | else 239 | return retval; 240 | } 241 | if (retval < 0) 242 | return -errno; 243 | 244 | return 0; 245 | } 246 | hidden_def(audit_send) 247 | 248 | /* 249 | * This function will take a peek into the next packet and see if there's 250 | * an error. If so, the error is returned and its non-zero. Otherwise a 251 | * zero is returned indicating that we don't know of any problems. 252 | */ 253 | static int check_ack(int fd, int seq) 254 | { 255 | int rc, retries = 80; 256 | struct audit_reply rep; 257 | struct pollfd pfd[1]; 258 | 259 | retry: 260 | pfd[0].fd = fd; 261 | pfd[0].events = POLLIN; 262 | do { 263 | rc = poll(pfd, 1, 500); /* .5 second */ 264 | } while (rc < 0 && errno == EINTR); 265 | 266 | /* We don't look at rc from above as it doesn't matter. We are 267 | * going to try to read nonblocking just in case packet shows up. */ 268 | 269 | /* NOTE: whatever is returned is treated as the errno */ 270 | rc = audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, MSG_PEEK); 271 | if (rc == -EAGAIN && retries) { 272 | retries--; 273 | goto retry; 274 | } else if (rc < 0) 275 | return rc; 276 | else if (rc == 0) 277 | return -EINVAL; /* This can't happen anymore */ 278 | else if (rc > 0 && rep.type == NLMSG_ERROR) { 279 | /* Eat the message */ 280 | struct audit_reply rep2; /* throw away */ 281 | (void)audit_get_reply(fd, &rep2, GET_REPLY_NONBLOCKING, 0); 282 | 283 | /* NLMSG_ERROR can indicate success, only report nonzero */ 284 | if (rep.error->error) { 285 | errno = -rep.error->error; 286 | return rep.error->error; 287 | } 288 | } 289 | return 0; 290 | } 291 | 292 | -------------------------------------------------------------------------------- /lib/optabs.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char op_strings[] = "!=\0&\0&=\0<\0<=\0=\0>\0>="; 3 | static const int op_i2s_i[] = { 4 | 134217728,268435456,536870912,805306368,1073741824,1207959552,1342177280,1610612736, 5 | }; 6 | static const unsigned op_i2s_s[] = { 7 | 3,8,15,0,13,5,10,17, 8 | }; 9 | static const char *op_i2s(int v) { 10 | return i2s_bsearch__(op_strings, op_i2s_i, op_i2s_s, 8, v); 11 | } 12 | -------------------------------------------------------------------------------- /lib/ppc_tables.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char ppc_syscall_strings[] = "_llseek\0_newselect\0_sysctl\0accept\0accept4\0access\0acct\0add_key\0adjtimex\0afs_syscall\0" 3 | "alarm\0bdflush\0bind\0break\0brk\0capget\0capset\0chdir\0chmod\0chown\0" 4 | "chroot\0clock_adjtime\0clock_getres\0clock_gettime\0clock_nanosleep\0clock_settime\0clone\0close\0connect\0creat\0" 5 | "create_module\0delete_module\0dup\0dup2\0dup3\0epoll_create\0epoll_create1\0epoll_ctl\0epoll_pwait\0epoll_wait\0" 6 | "eventfd\0eventfd2\0execve\0exit\0exit_group\0faccessat\0fadvise64\0fadvise64_64\0fallocate\0fanotify_init\0" 7 | "fanotify_mark\0fchdir\0fchmod\0fchmodat\0fchown\0fchownat\0fcntl\0fcntl64\0fdatasync\0fgetxattr\0" 8 | "flistxattr\0flock\0fork\0fremovexattr\0fsetxattr\0fstat\0fstat64\0fstatat\0fstatfs\0fstatfs64\0" 9 | "fsync\0ftime\0ftruncate\0ftruncate64\0futex\0futimesat\0get_kernel_syms\0get_robust_list\0getcpu\0getcwd\0" 10 | "getdents\0getdents64\0getegid\0geteuid\0getgid\0getgroups\0getitimer\0getpeername\0getpgid\0getpgrp\0" 11 | "getpid\0getpmsg\0getppid\0getpriority\0getresgid\0getresuid\0getrlimit\0getrusage\0getsid\0getsockname\0" 12 | "getsockopt\0gettid\0gettimeofday\0getuid\0getxattr\0gtty\0idle\0init_module\0inotify_add_watch\0inotify_init\0" 13 | "inotify_init1\0inotify_rm_watch\0io_cancel\0io_destroy\0io_getevents\0io_setup\0io_submit\0ioctl\0ioperm\0iopl\0" 14 | "ioprio_get\0ioprio_set\0ipc\0kexec_load\0keyctl\0kill\0lchown\0lgetxattr\0link\0linkat\0" 15 | "listen\0listxattr\0llistxattr\0lock\0lookup_dcookie\0lremovexattr\0lseek\0lsetxattr\0lstat\0lstat64\0" 16 | "madvise\0mincore\0mkdir\0mkdirat\0mknod\0mknodat\0mlock\0mlockall\0mmap\0mmap2\0" 17 | "modify_ldt\0mount\0move_pages\0mprotect\0mpx\0mq_getsetattr\0mq_notify\0mq_open\0mq_timedreceive\0mq_timedsend\0" 18 | "mq_unlink\0mremap\0msync\0multiplexer\0munlock\0munlockall\0munmap\0name_to_handle_at\0nanosleep\0nfsservctl\0" 19 | "nice\0oldfstat\0oldlstat\0oldolduname\0oldstat\0olduname\0open\0open_by_handle_at\0openat\0pause\0" 20 | "pciconfig_iobase\0pciconfig_read\0pciconfig_write\0perf_counter_open\0personality\0pipe\0pipe2\0pivot_root\0poll\0ppoll\0" 21 | "prctl\0pread\0preadv\0prlimit64\0process_vm_readv\0process_vm_writev\0prof\0profil\0pselect6\0ptrace\0" 22 | "putpmsg\0pwrite\0pwritev\0query_module\0quotactl\0read\0readahead\0readdir\0readlink\0readlinkat\0" 23 | "readv\0reboot\0recv\0recvfrom\0recvmmsg\0recvmsg\0remap_file_pages\0removexattr\0rename\0renameat\0" 24 | "request_key\0rmdir\0rt_sigaction\0rt_sigpending\0rt_sigprocmask\0rt_sigqueueinfo\0rt_sigreturn\0rt_sigsuspend\0rt_sigtimedwait\0rt_tgsigqueueinfo\0" 25 | "rtas\0sched_get_priority_max\0sched_get_priority_min\0sched_getaffinity\0sched_getparam\0sched_getscheduler\0sched_rr_get_interval\0sched_setaffinity\0sched_setparam\0sched_setscheduler\0" 26 | "sched_yield\0select\0send\0sendfile\0sendfile64\0sendmmsg\0sendmsg\0sendto\0set_robust_list\0set_tid_address\0" 27 | "setdomainname\0setfsgid\0setfsuid\0setgid\0setgroups\0sethostname\0setitimer\0setns\0setpgid\0setpriority\0" 28 | "setregid\0setresgid\0setresuid\0setreuid\0setrlimit\0setsid\0setsockopt\0settimeofday\0setuid\0setxattr\0" 29 | "sgetmask\0shutdown\0sigaction\0sigaltstack\0signal\0signalfd\0signalfd4\0sigpending\0sigprocmask\0sigreturn\0" 30 | "sigsuspend\0socket\0socketcall\0socketpair\0splice\0spu_create\0spu_run\0ssetmask\0stat\0stat64\0" 31 | "statfs\0statfs64\0stime\0stty\0subpage_prot\0swapcontext\0swapoff\0swapon\0symlink\0symlinkat\0" 32 | "sync\0sync_file_range2\0syncfs\0sysfs\0sysinfo\0syslog\0tee\0tgkill\0time\0timer_create\0" 33 | "timer_delete\0timer_getoverrun\0timer_gettime\0timer_settime\0timerfd\0timerfd_gettime\0timerfd_settime\0times\0tkill\0truncate\0" 34 | "truncate64\0tuxcall\0ugetrlimit\0ulimit\0umask\0umount\0umount2\0uname\0unlink\0unlinkat\0" 35 | "unshare\0uselib\0ustat\0utime\0utimensat\0utimes\0vfork\0vhangup\0vm86\0vmsplice\0" 36 | "wait4\0waitid\0waitpid\0write\0writev"; 37 | static const unsigned ppc_syscall_s2i_s[] = { 38 | 0,8,19,27,34,42,49,54,62,71, 39 | 83,89,97,102,108,112,119,126,132,138, 40 | 144,151,165,178,192,208,222,228,234,242, 41 | 248,262,276,280,285,290,303,317,327,339, 42 | 350,358,367,374,379,390,400,410,423,433, 43 | 447,461,468,475,484,491,500,506,514,524, 44 | 534,545,551,556,569,579,585,593,601,609, 45 | 619,625,631,641,653,659,669,685,701,708, 46 | 715,724,735,743,751,758,768,778,790,798, 47 | 806,813,821,829,841,851,861,871,881,888, 48 | 900,911,918,931,938,947,952,957,969,987, 49 | 1000,1014,1031,1041,1052,1065,1074,1084,1090,1097, 50 | 1102,1113,1124,1128,1139,1146,1151,1158,1168,1173, 51 | 1180,1187,1197,1208,1213,1228,1241,1247,1257,1263, 52 | 1271,1279,1287,1293,1301,1307,1315,1321,1330,1335, 53 | 1341,1352,1358,1369,1378,1382,1396,1406,1414,1430, 54 | 1443,1453,1460,1466,1478,1486,1497,1504,1522,1532, 55 | 1543,1548,1557,1566,1578,1586,1595,1600,1618,1625, 56 | 1631,1648,1663,1679,1697,1709,1714,1720,1731,1736, 57 | 1742,1748,1754,1761,1771,1788,1806,1811,1818,1827, 58 | 1834,1842,1849,1857,1870,1879,1884,1894,1902,1911, 59 | 1922,1928,1935,1940,1949,1958,1966,1983,1995,2002, 60 | 2011,2023,2029,2042,2056,2071,2087,2100,2114,2130, 61 | 2148,2153,2176,2199,2217,2232,2251,2273,2291,2306, 62 | 2325,2337,2344,2349,2358,2369,2378,2386,2393,2409, 63 | 2425,2439,2448,2457,2464,2474,2486,2496,2502,2510, 64 | 2522,2531,2541,2551,2560,2570,2577,2588,2601,2608, 65 | 2617,2626,2635,2645,2657,2664,2673,2683,2694,2706, 66 | 2716,2727,2734,2745,2756,2763,2774,2782,2791,2796, 67 | 2803,2810,2819,2825,2830,2843,2855,2863,2870,2878, 68 | 2888,2893,2910,2917,2923,2931,2938,2942,2949,2954, 69 | 2967,2980,2997,3011,3025,3033,3049,3065,3071,3077, 70 | 3086,3097,3105,3116,3123,3129,3136,3144,3150,3157, 71 | 3166,3174,3181,3187,3193,3203,3210,3216,3224,3229, 72 | 3238,3244,3251,3259,3265, 73 | }; 74 | static const int ppc_syscall_s2i_i[] = { 75 | 140,142,149,330,344,33,51,269,124,137, 76 | 27,134,327,17,45,183,184,12,15,181, 77 | 61,347,247,246,248,245,120,6,328,8, 78 | 127,129,41,63,316,236,315,237,303,238, 79 | 307,314,11,1,234,298,233,254,309,323, 80 | 324,133,94,297,95,289,55,204,148,214, 81 | 217,143,2,220,211,108,197,291,100,253, 82 | 118,35,93,194,221,290,130,299,302,182, 83 | 141,202,50,49,47,80,105,332,132,65, 84 | 20,187,64,96,170,165,76,77,147,331, 85 | 340,207,78,24,212,32,112,128,276,275, 86 | 318,277,231,228,229,227,230,54,101,110, 87 | 274,273,117,268,271,37,16,213,9,294, 88 | 329,215,216,53,235,219,19,210,107,196, 89 | 205,206,39,287,14,288,150,152,90,192, 90 | 123,21,301,125,56,267,266,262,265,264, 91 | 263,163,144,201,151,153,91,345,162,168, 92 | 34,28,84,59,18,109,5,346,286,29, 93 | 200,198,199,319,136,42,317,203,167,281, 94 | 171,179,320,325,351,352,44,98,280,26, 95 | 188,180,321,166,131,3,191,89,85,296, 96 | 145,88,336,337,343,342,239,218,38,293, 97 | 270,40,173,175,174,177,172,178,176,322, 98 | 255,159,160,223,155,157,161,222,154,156, 99 | 158,82,334,186,226,349,341,335,300,232, 100 | 121,139,138,46,81,74,104,350,57,97, 101 | 71,169,164,70,75,66,339,79,23,209, 102 | 68,338,67,185,48,305,313,73,126,119, 103 | 72,326,102,333,283,279,278,69,106,195, 104 | 99,252,25,31,310,249,115,87,83,295, 105 | 36,308,348,135,116,103,284,250,13,240, 106 | 244,243,242,241,306,312,311,43,208,92, 107 | 193,225,190,58,60,22,52,122,10,292, 108 | 282,86,62,30,304,251,189,111,113,285, 109 | 114,272,7,4,146, 110 | }; 111 | static int ppc_syscall_s2i(const char *s, int *value) { 112 | size_t len, i; 113 | len = strlen(s); 114 | { char copy[len + 1]; 115 | for (i = 0; i < len; i++) { 116 | char c = s[i]; 117 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 118 | } 119 | copy[i] = 0; 120 | return s2i__(ppc_syscall_strings, ppc_syscall_s2i_s, ppc_syscall_s2i_i, 345, copy, value); 121 | } 122 | } 123 | static const unsigned ppc_syscall_i2s_direct[] = { 124 | 374,551,1879,3259,1595,228,3251,242,1168,3150, 125 | 367,126,2949,1301,132,1151,102,1578,1241,806, 126 | 1352,3129,2601,931,2819,1827,83,1548,1625,3187, 127 | 2825,947,42,1543,625,2888,1146,1995,1287,2023, 128 | 276,1709,3065,1806,108,2457,751,2657,743,735, 129 | 49,3136,1208,1084,500,1378,2502,3116,1566,3123, 130 | 144,3181,280,821,798,2570,2635,2617,2782,2551, 131 | 2522,2716,2683,2474,2560,861,871,918,2588,758, 132 | 2464,2337,2870,1557,1902,3174,2863,1928,1894,1330, 133 | 1497,3077,631,468,484,829,2510,1811,2803,601, 134 | 1090,2734,2931,2486,768,2791,1257,579,1586,1097, 135 | 3216,952,3224,3238,2855,2923,1124,619,2706,222, 136 | 2425,3144,1341,62,1369,2694,248,957,262,669, 137 | 1870,790,461,89,2917,1697,71,2448,2439,0, 138 | 715,8,545,1460,1922,3265,881,514,19,1315, 139 | 1478,1321,1486,2291,2217,2306,2232,2325,2153,2176, 140 | 2251,1522,1453,2541,851,1857,1731,1532,2531,841, 141 | 1742,2087,2029,2056,2042,2114,2071,2100,1748,1842, 142 | 138,708,112,119,2645,2349,813,1834,3210,3105, 143 | 1884,1335,3086,641,2796,1263,585,1648,1663,1631, 144 | 1466,724,1720,506,1271,1279,911,3071,2608,1247, 145 | 569,938,1158,524,1187,1197,534,1983,1228,556, 146 | 653,2273,2199,-1u,3097,2358,1065,1041,1052,1074, 147 | 1031,2409,400,379,1213,290,317,339,1966,2954, 148 | 3011,2997,2980,2967,208,178,165,192,2843,2942, 149 | 3203,2810,609,410,2148,-1u,-1u,-1u,-1u,-1u, 150 | -1u,1406,1443,1430,1414,1396,1382,1128,54,2011, 151 | 1139,3244,1113,1102,987,969,1014,2774,2763,1818, 152 | 1736,3166,2756,2938,3229,1618,1293,1307,491,659, 153 | 593,3157,2002,1173,2878,1911,475,390,685,2393, 154 | 1358,701,327,3193,2664,3025,350,2893,423,2830, 155 | 3049,3033,2673,358,303,285,1714,1000,1679,1754, 156 | 1849,2130,433,447,1761,2727,97,234,1180,27, 157 | 888,778,2745,2344,2386,1935,1940,2626,2577,900, 158 | 2378,1958,1949,34,1504,1600,151,2910,2369,2496, 159 | 1771,1788, 160 | }; 161 | static const char *ppc_syscall_i2s(int v) { 162 | return i2s_direct__(ppc_syscall_strings, ppc_syscall_i2s_direct, 1, 352, v); 163 | } 164 | -------------------------------------------------------------------------------- /lib/private.h: -------------------------------------------------------------------------------- 1 | /* private.h -- 2 | * Copyright 2005,2006,2009 Red Hat Inc., Durham, North Carolina. 3 | * All Rights Reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Steve Grubb 21 | */ 22 | #ifndef _PRIVATE_H_ 23 | #define _PRIVATE_H_ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #ifdef PIC 30 | # define hidden __attribute__ ((visibility ("hidden"))) 31 | # define hidden_proto(fct) __hidden_proto (fct, fct##_internal) 32 | # define __hidden_proto(fct, internal) \ 33 | extern __typeof (fct) internal; \ 34 | extern __typeof (fct) fct __asm (#internal) hidden; 35 | # if defined(__alpha__) || defined(__mips__) 36 | # define hidden_def(fct) \ 37 | asm (".globl " #fct "\n" #fct " = " #fct "_internal"); 38 | # else 39 | # define hidden_def(fct) \ 40 | asm (".globl " #fct "\n.set " #fct ", " #fct "_internal"); 41 | #endif 42 | #else 43 | # define hidden 44 | # define hidden_proto(fct) 45 | # define hidden_def(fct) 46 | #endif 47 | 48 | typedef enum { REAL_ERR, HIDE_IT } hide_t; 49 | 50 | /* Internal syslog messaging */ 51 | void audit_msg(int message_type, const char *fmt, ...) 52 | #ifdef __GNUC__ 53 | __attribute__ ((format (printf, 2, 3))); 54 | #else 55 | ; 56 | #endif 57 | 58 | /* This structure is for protocol reference only. All fields are 59 | packed and in network order (LSB first). */ 60 | struct auditd_remote_message_wrapper { 61 | /* The magic number shall never have LF (0x0a) as one of its bytes. */ 62 | uint32_t magic; 63 | /* Bumped when the layout of this structure changes. */ 64 | uint8_t header_version; 65 | /* The minimum support needed to understand this message type. 66 | * Normally zero. */ 67 | uint8_t message_version; 68 | /* Upper 8 bits are generic type, see below. */ 69 | uint32_t type; 70 | /* Number of bytes that follow this header Must be 0..MAX_AUDIT_MESSAGE_LENGTH. */ 71 | uint16_t length; 72 | /* Copied from message to its reply. */ 73 | uint32_t sequence_id; 74 | /* The message follows for LENGTH bytes. */ 75 | }; 76 | 77 | #define AUDIT_RMW_HEADER_SIZE 16 78 | /* The magic number shall never have LF (0x0a) as one of its bytes. */ 79 | #define AUDIT_RMW_MAGIC 0xff0000feUL 80 | 81 | #define AUDIT_RMW_HEADER_VERSION 0 82 | 83 | /* If set, this is a reply. */ 84 | #define AUDIT_RMW_TYPE_REPLYMASK 0x40000000 85 | /* If set, this reply indicates a fatal error of some sort. */ 86 | #define AUDIT_RMW_TYPE_FATALMASK 0x20000000 87 | /* If set, this reply indicates success but with some warnings. */ 88 | #define AUDIT_RMW_TYPE_WARNMASK 0x10000000 89 | /* This part of the message type is the details for the above. */ 90 | #define AUDIT_RMW_TYPE_DETAILMASK 0x0fffffff 91 | 92 | /* Version 0 messages. */ 93 | #define AUDIT_RMW_TYPE_MESSAGE 0x00000000 94 | #define AUDIT_RMW_TYPE_HEARTBEAT 0x00000001 95 | #define AUDIT_RMW_TYPE_ACK 0x40000000 96 | #define AUDIT_RMW_TYPE_ENDING 0x40000001 97 | #define AUDIT_RMW_TYPE_DISKLOW 0x50000001 98 | #define AUDIT_RMW_TYPE_DISKFULL 0x60000001 99 | #define AUDIT_RMW_TYPE_DISKERROR 0x60000002 100 | 101 | /* These next four should not be called directly. */ 102 | #define _AUDIT_RMW_PUTN32(header,i,v) \ 103 | header[i] = v & 0xff; \ 104 | header[i+1] = (v>>8) & 0xff; \ 105 | header[i+2] = (v>>16) & 0xff; \ 106 | header[i+3] = (v>>24) & 0xff; 107 | #define _AUDIT_RMW_PUTN16(header,i,v) \ 108 | header[i] = v & 0xff; \ 109 | header[i+1] = (v>>8) & 0xff; 110 | #define _AUDIT_RMW_GETN32(header,i) \ 111 | (((uint32_t)(header[i] & 0xFF)) | \ 112 | (((uint32_t)(header[i+1] & 0xFF))<<8) | \ 113 | (((uint32_t)(header[i+2] & 0xFF ))<<16) | \ 114 | (((uint32_t)(header[i+3] & 0xFF))<<24)) 115 | #define _AUDIT_RMW_GETN16(header,i) \ 116 | ((uint32_t)(header[i] & 0xFF) | ((uint32_t)(header[i+1] & 0xFF)<<8)) 117 | 118 | /* For these, HEADER must by of type "unsigned char *" or "unsigned 119 | char []" */ 120 | 121 | #define AUDIT_RMW_PACK_HEADER(header,mver,type,len,seq) \ 122 | _AUDIT_RMW_PUTN32 (header,0, AUDIT_RMW_MAGIC); \ 123 | header[4] = AUDIT_RMW_HEADER_VERSION; \ 124 | header[5] = mver; \ 125 | _AUDIT_RMW_PUTN32 (header,6, type); \ 126 | _AUDIT_RMW_PUTN16 (header,10, len); \ 127 | _AUDIT_RMW_PUTN32 (header,12, seq); 128 | 129 | #define AUDIT_RMW_IS_MAGIC(header,length) \ 130 | (length >= 4 && _AUDIT_RMW_GETN32 (header,0) == AUDIT_RMW_MAGIC) 131 | 132 | #define AUDIT_RMW_UNPACK_HEADER(header,hver,mver,type,len,seq) \ 133 | hver = header[4]; \ 134 | mver = header[5]; \ 135 | type = _AUDIT_RMW_GETN32 (header,6); \ 136 | len = _AUDIT_RMW_GETN16 (header,10); \ 137 | seq = _AUDIT_RMW_GETN32 (header,12); 138 | 139 | /* General */ 140 | extern int audit_send(int fd, int type, const void *data, unsigned int size); 141 | 142 | // This is the main messaging function used internally 143 | // Don't hide it, it used to be a part of the public API! 144 | extern int audit_send_user_message(int fd, int type, hide_t hide_err, 145 | const char *message); 146 | 147 | // libaudit.c 148 | extern int _audit_permadded; 149 | extern int _audit_archadded; 150 | extern int _audit_syscalladded; 151 | extern unsigned int _audit_elf; 152 | 153 | hidden_proto(audit_send_user_message); 154 | hidden_proto(audit_add_watch_dir); 155 | hidden_proto(audit_detect_machine); 156 | hidden_proto(audit_request_status); 157 | hidden_proto(audit_rule_syscall_data); 158 | hidden_proto(audit_rule_syscallbyname_data); 159 | 160 | // lookup_table.c 161 | hidden_proto(audit_elf_to_machine); 162 | hidden_proto(audit_machine_to_elf); 163 | hidden_proto(audit_msg_type_to_name); 164 | hidden_proto(audit_name_to_errno); 165 | hidden_proto(audit_name_to_field); 166 | hidden_proto(audit_name_to_machine); 167 | hidden_proto(audit_name_to_msg_type); 168 | hidden_proto(audit_name_to_syscall); 169 | hidden_proto(audit_operator_to_symbol); 170 | hidden_proto(audit_name_to_ftype); 171 | 172 | // netlink.c 173 | hidden_proto(audit_get_reply); 174 | hidden_proto(audit_send) 175 | 176 | // message.c 177 | hidden_proto(audit_msg) 178 | 179 | #ifdef __cplusplus 180 | } 181 | #endif 182 | 183 | #endif 184 | 185 | -------------------------------------------------------------------------------- /lib/s390_tables.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char s390_syscall_strings[] = "_llseek\0_newselect\0_sysctl\0access\0acct\0add_key\0adjtimex\0afs_syscall\0alarm\0bdflush\0" 3 | "brk\0capget\0capset\0chdir\0chmod\0chown\0chown32\0chroot\0clock_adjtime\0clock_getres\0" 4 | "clock_gettime\0clock_nanosleep\0clock_settime\0clone\0close\0creat\0create_module\0delete_module\0dup\0dup2\0" 5 | "dup3\0epoll_create\0epoll_create1\0epoll_ctl\0epoll_pwait\0epoll_wait\0eventfd\0eventfd2\0execve\0exit\0" 6 | "exit_group\0faccessat\0fadvise64\0fadvise64_64\0fallocate\0fanotify_init\0fanotify_mark\0fchdir\0fchmod\0fchmodat\0" 7 | "fchown\0fchown32\0fchownat\0fcntl\0fcntl64\0fdatasync\0fgetxattr\0flistxattr\0flock\0fork\0" 8 | "fremovexattr\0fsetxattr\0fstat\0fstat64\0fstatat\0fstatfs\0fstatfs64\0fsync\0ftruncate\0ftruncate64\0" 9 | "futex\0futimesat\0get_kernel_syms\0get_robust_list\0getcpu\0getcwd\0getdents\0getdents64\0getegid\0getegid32\0" 10 | "geteuid\0geteuid32\0getgid\0getgid32\0getgroups\0getgroups32\0getitimer\0getpgid\0getpgrp\0getpid\0" 11 | "getpmsg\0getppid\0getpriority\0getresgid\0getresgid32\0getresuid\0getresuid32\0getrlimit\0getrusage\0getsid\0" 12 | "gettid\0gettimeofday\0getuid\0getuid32\0getxattr\0idle\0init_module\0inotify_add_watch\0inotify_init\0inotify_init1\0" 13 | "inotify_rm_watch\0io_cancel\0io_destroy\0io_getevents\0io_setup\0io_submit\0ioctl\0ioperm\0ioprio_get\0ioprio_set\0" 14 | "ipc\0kexec_load\0keyctl\0kill\0lchown\0lchown32\0lgetxattr\0link\0linkat\0listxattr\0" 15 | "llistxattr\0lremovexattr\0lseek\0lsetxattr\0lstat\0lstat64\0madvise\0mincore\0mkdir\0mkdirat\0" 16 | "mknod\0mknodat\0mlock\0mlockall\0mmap\0mmap2\0mount\0mprotect\0mq_getsetattr\0mq_notify\0" 17 | "mq_open\0mq_timedreceive\0mq_timedsend\0mq_unlink\0mremap\0msync\0munlock\0munlockall\0munmap\0name_to_handle_at\0" 18 | "nanosleep\0nfsservctl\0nice\0open\0open_by_handle_at\0openat\0pause\0perf_event_open\0personality\0pipe\0" 19 | "pipe2\0pivot_root\0poll\0ppoll\0prctl\0pread\0preadv\0prlimit64\0process_vm_readv\0process_vm_writev\0" 20 | "pselect6\0ptrace\0putpmsg\0pwrite\0pwritev\0query_module\0quotactl\0read\0readahead\0readdir\0" 21 | "readlink\0readlinkat\0readv\0reboot\0remap_file_pages\0removexattr\0rename\0renameat\0request_key\0rmdir\0" 22 | "rt_sigaction\0rt_sigpending\0rt_sigprocmask\0rt_sigqueueinfo\0rt_sigreturn\0rt_sigsuspend\0rt_sigtimedwait\0rt_tgsigqueueinfo\0sched_get_priority_max\0sched_get_priority_min\0" 23 | "sched_getaffinity\0sched_getparam\0sched_getscheduler\0sched_rr_get_interval\0sched_setaffinity\0sched_setparam\0sched_setscheduler\0sched_yield\0sendfile\0sendfile64\0" 24 | "set_robust_list\0set_tid_address\0setdomainname\0setfsgid\0setfsgid32\0setfsuid\0setfsuid32\0setgid\0setgid32\0setgroups\0" 25 | "setgroups32\0sethostname\0setitimer\0setns\0setpgid\0setpriority\0setregid\0setregid32\0setresgid\0setresgid32\0" 26 | "setresuid\0setresuid32\0setreuid\0setreuid32\0setrlimit\0setsid\0settimeofday\0setuid\0setuid32\0setxattr\0" 27 | "sigaction\0sigaltstack\0signal\0signalfd\0signalfd4\0sigpending\0sigprocmask\0sigreturn\0sigsuspend\0socketcall\0" 28 | "splice\0stat\0stat64\0statfs\0statfs64\0stime\0swapoff\0swapon\0symlink\0symlinkat\0" 29 | "sync\0sync_file_range\0syncfs\0sysfs\0sysinfo\0syslog\0tee\0tgkill\0time\0timer_create\0" 30 | "timer_delete\0timer_getoverrun\0timer_gettime\0timer_settime\0timerfd\0timerfd_create\0timerfd_gettime\0timerfd_settime\0times\0tkill\0" 31 | "truncate\0truncate64\0ugetrlimit\0umask\0umount\0umount2\0uname\0unlink\0unlinkat\0unshare\0" 32 | "uselib\0ustat\0utime\0utimensat\0utimes\0vfork\0vhangup\0vmsplice\0wait4\0waitid\0" 33 | "write\0writev"; 34 | static const unsigned s390_syscall_s2i_s[] = { 35 | 0,8,19,27,34,39,47,56,68,74, 36 | 82,86,93,100,106,112,118,126,133,147, 37 | 160,174,190,204,210,216,222,236,250,254, 38 | 259,264,277,291,301,313,324,332,341,348, 39 | 353,364,374,384,397,407,421,435,442,449, 40 | 458,465,474,483,489,497,507,517,528,534, 41 | 539,552,562,568,576,584,592,602,608,618, 42 | 630,636,646,662,678,685,692,701,712,720, 43 | 730,738,748,755,764,774,786,796,804,812, 44 | 819,827,835,847,857,869,879,891,901,911, 45 | 918,925,938,945,954,963,968,980,998,1011, 46 | 1025,1042,1052,1063,1076,1085,1095,1101,1108,1119, 47 | 1130,1134,1145,1152,1157,1164,1173,1183,1188,1195, 48 | 1205,1216,1229,1235,1245,1251,1259,1267,1275,1281, 49 | 1289,1295,1303,1309,1318,1323,1329,1335,1344,1358, 50 | 1368,1376,1392,1405,1415,1422,1428,1436,1447,1454, 51 | 1472,1482,1493,1498,1503,1521,1528,1534,1550,1562, 52 | 1567,1573,1584,1589,1595,1601,1607,1614,1624,1641, 53 | 1659,1668,1675,1683,1690,1698,1711,1720,1725,1735, 54 | 1743,1752,1763,1769,1776,1793,1805,1812,1821,1833, 55 | 1839,1852,1866,1881,1897,1910,1924,1940,1958,1981, 56 | 2004,2022,2037,2056,2078,2096,2111,2130,2142,2151, 57 | 2162,2178,2194,2208,2217,2228,2237,2248,2255,2264, 58 | 2274,2286,2298,2308,2314,2322,2334,2343,2354,2364, 59 | 2376,2386,2398,2407,2418,2428,2435,2448,2455,2464, 60 | 2473,2483,2495,2502,2511,2521,2532,2544,2554,2565, 61 | 2576,2583,2588,2595,2602,2611,2617,2625,2632,2640, 62 | 2650,2655,2671,2678,2684,2692,2699,2703,2710,2715, 63 | 2728,2741,2758,2772,2786,2794,2809,2825,2841,2847, 64 | 2853,2862,2873,2884,2890,2897,2905,2911,2918,2927, 65 | 2935,2942,2948,2954,2964,2971,2977,2985,2994,3000, 66 | 3007,3013, 67 | }; 68 | static const int s390_syscall_s2i_i[] = { 69 | 140,142,149,33,51,278,124,137,27,134, 70 | 45,184,185,12,15,182,212,61,337,261, 71 | 260,262,259,120,6,8,127,129,41,63, 72 | 326,249,327,250,312,251,318,323,11,1, 73 | 248,300,253,264,314,332,333,133,94,299, 74 | 95,207,291,55,221,148,229,232,143,2, 75 | 235,226,108,197,293,100,266,118,93,194, 76 | 238,292,130,305,311,183,141,220,50,202, 77 | 49,201,47,200,80,205,105,132,65,20, 78 | 188,64,96,171,211,165,209,76,77,147, 79 | 236,78,24,199,227,112,128,285,284,324, 80 | 286,247,244,245,243,246,54,101,283,282, 81 | 117,277,280,37,16,198,228,9,296,230, 82 | 231,234,19,225,107,196,219,218,39,289, 83 | 14,290,150,152,90,192,21,125,276,275, 84 | 271,274,273,272,163,144,151,153,91,335, 85 | 162,169,34,5,336,288,29,331,136,42, 86 | 325,217,168,302,172,180,328,334,340,341, 87 | 301,26,189,181,329,167,131,3,222,89, 88 | 85,298,145,88,267,233,38,295,279,40, 89 | 174,176,175,178,173,179,177,330,159,160, 90 | 240,155,157,161,239,154,156,158,187,223, 91 | 304,252,121,139,216,138,215,46,214,81, 92 | 206,74,104,339,57,97,71,204,170,210, 93 | 164,208,70,203,75,66,79,23,213,224, 94 | 67,186,48,316,322,73,126,119,72,102, 95 | 306,106,195,99,265,25,115,87,83,297, 96 | 36,307,338,135,116,103,308,241,13,254, 97 | 258,257,256,255,317,319,321,320,43,237, 98 | 92,193,191,60,22,52,122,10,294,303, 99 | 86,62,30,315,313,190,111,309,114,281, 100 | 4,146, 101 | }; 102 | static int s390_syscall_s2i(const char *s, int *value) { 103 | size_t len, i; 104 | len = strlen(s); 105 | { char copy[len + 1]; 106 | for (i = 0; i < len; i++) { 107 | char c = s[i]; 108 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 109 | } 110 | copy[i] = 0; 111 | return s2i__(s390_syscall_strings, s390_syscall_s2i_s, s390_syscall_s2i_i, 312, copy, value); 112 | } 113 | } 114 | static const unsigned s390_syscall_i2s_direct[] = { 115 | 348,534,1720,3007,1498,210,-1u,216,1183,2911, 116 | 341,100,2710,1289,106,1157,-1u,-1u,1229,812, 117 | 1329,2890,2448,938,2611,1668,68,-1u,1528,2948, 118 | -1u,-1u,27,1493,-1u,2650,1152,1805,1275,1833, 119 | 250,1562,2841,-1u,82,2248,748,2495,730,712, 120 | 34,2897,-1u,1095,483,-1u,2314,-1u,-1u,2884, 121 | 126,2942,254,827,804,2428,2473,-1u,-1u,2398, 122 | 2334,2554,2521,2286,2418,891,901,925,2435,764, 123 | 2264,-1u,2632,-1u,1743,2935,2625,1769,1735,1318, 124 | 1447,2853,608,442,458,835,2322,-1u,2595,584, 125 | 1101,2565,2692,2298,786,2583,1245,562,-1u,-1u, 126 | 2977,963,-1u,2994,2617,2684,1130,602,2544,204, 127 | 2194,2905,-1u,47,1335,2532,222,968,236,646, 128 | 1711,796,435,74,2678,1550,56,2228,2208,0, 129 | 692,8,528,1422,1763,3013,911,497,19,1303, 130 | 1428,1309,1436,2096,2022,2111,2037,2130,1958,1981, 131 | 2056,1472,1415,2376,869,-1u,1698,1584,1482,2354, 132 | 847,1595,1897,1839,1866,1852,1924,1881,1910,1601, 133 | 1683,112,685,86,93,2483,2142,819,1675,2971, 134 | 2873,1323,2862,618,2588,1251,568,1164,945,755, 135 | 738,720,2407,2343,774,2274,465,2386,879,2364, 136 | 857,118,2455,2255,2237,2217,1573,1267,1259,701, 137 | 489,1725,2151,2464,1235,552,954,1173,507,1195, 138 | 1205,517,1793,1216,539,918,2847,630,2078,2004, 139 | 2703,-1u,1076,1052,1063,1085,1042,353,264,291, 140 | 313,2178,374,2715,2772,2758,2741,2728,190,160, 141 | 147,174,-1u,384,2602,592,1776,-1u,-1u,-1u, 142 | 1368,1405,1392,1376,1358,1344,1134,39,1821,1145, 143 | 3000,1119,1108,998,980,1025,-1u,1521,1281,1295, 144 | 474,636,576,2918,1812,1188,2640,1752,449,364, 145 | 1659,1589,2927,2162,662,2576,2655,2699,2985,-1u, 146 | 678,301,2964,397,2954,2502,2786,324,2794,2825, 147 | 2809,2511,332,1011,1567,259,277,1607,1690,1940, 148 | 1534,407,421,1614,1454,1503,133,2671,2308,1624, 149 | 1641, 150 | }; 151 | static const char *s390_syscall_i2s(int v) { 152 | return i2s_direct__(s390_syscall_strings, s390_syscall_i2s_direct, 1, 341, v); 153 | } 154 | -------------------------------------------------------------------------------- /lib/s390x_tables.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char s390x_syscall_strings[] = "_sysctl\0access\0acct\0add_key\0adjtimex\0afs_syscall\0alarm\0bdflush\0brk\0capget\0" 3 | "capset\0chdir\0chmod\0chown\0chroot\0clock_adjtime\0clock_getres\0clock_gettime\0clock_nanosleep\0clock_settime\0" 4 | "clone\0close\0creat\0create_module\0delete_module\0dup\0dup2\0dup3\0epoll_create\0epoll_create1\0" 5 | "epoll_ctl\0epoll_pwait\0epoll_wait\0eventfd\0eventfd2\0execve\0exit\0exit_group\0faccessat\0fadvise64\0" 6 | "fallocate\0fanotify_init\0fanotify_mark\0fchdir\0fchmod\0fchmodat\0fchown\0fchownat\0fcntl\0fdatasync\0" 7 | "fgetxattr\0flistxattr\0flock\0fork\0fremovexattr\0fsetxattr\0fstat\0fstatfs\0fstatfs64\0fsync\0" 8 | "ftruncate\0futex\0futimesat\0get_kernel_syms\0get_robust_list\0getcpu\0getcwd\0getdents\0getegid\0geteuid\0" 9 | "getgid\0getgroups\0getitimer\0getpgid\0getpgrp\0getpid\0getpmsg\0getppid\0getpriority\0getresgid\0" 10 | "getresuid\0getrlimit\0getrusage\0getsid\0gettid\0gettimeofday\0getuid\0getxattr\0idle\0init_module\0" 11 | "inotify_add_watch\0inotify_init\0inotify_init1\0inotify_rm_watch\0io_cancel\0io_destroy\0io_getevents\0io_setup\0io_submit\0ioctl\0" 12 | "ioprio_get\0ioprio_set\0ipc\0kexec_load\0keyctl\0kill\0lchown\0lgetxattr\0link\0linkat\0" 13 | "listxattr\0llistxattr\0lremovexattr\0lseek\0lsetxattr\0lstat\0madvise\0mincore\0mkdir\0mkdirat\0" 14 | "mknod\0mknodat\0mlock\0mlockall\0mmap\0mount\0mprotect\0mq_getsetattr\0mq_notify\0mq_open\0" 15 | "mq_timedreceive\0mq_timedsend\0mq_unlink\0mremap\0msync\0munlock\0munlockall\0munmap\0name_to_handle_at\0nanosleep\0" 16 | "newfstatat\0nfsservctl\0nice\0open\0open_by_handle_at\0openat\0pause\0perf_event_open\0personality\0pipe\0" 17 | "pipe2\0pivot_root\0poll\0ppoll\0prctl\0pread\0preadv\0prlimit64\0process_vm_readv\0process_vm_writev\0" 18 | "pselect6\0ptrace\0putpmsg\0pwrite\0pwritev\0query_module\0quotactl\0read\0readahead\0readdir\0" 19 | "readlink\0readlinkat\0readv\0reboot\0remap_file_pages\0removexattr\0rename\0renameat\0request_key\0rmdir\0" 20 | "rt_sigaction\0rt_sigpending\0rt_sigprocmask\0rt_sigqueueinfo\0rt_sigreturn\0rt_sigsuspend\0rt_sigtimedwait\0rt_tgsigqueueinfo\0sched_get_priority_max\0sched_get_priority_min\0" 21 | "sched_getaffinity\0sched_getparam\0sched_getscheduler\0sched_rr_get_interval\0sched_setaffinity\0sched_setparam\0sched_setscheduler\0sched_yield\0select\0sendfile\0" 22 | "set_robust_list\0set_tid_address\0setdomainname\0setfsgid\0setfsuid\0setgid\0setgroups\0sethostname\0setitimer\0setns\0" 23 | "setpgid\0setpriority\0setregid\0setresgid\0setresuid\0setreuid\0setrlimit\0setsid\0settimeofday\0setuid\0" 24 | "setxattr\0sigaction\0sigaltstack\0signal\0signalfd\0signalfd4\0sigpending\0sigprocmask\0sigreturn\0sigsuspend\0" 25 | "socketcall\0splice\0stat\0statfs\0statfs64\0swapoff\0swapon\0symlink\0symlinkat\0sync\0" 26 | "sync_file_range\0syncfs\0sysfs\0sysinfo\0syslog\0tee\0tgkill\0timer_create\0timer_delete\0timer_getoverrun\0" 27 | "timer_gettime\0timer_settime\0timerfd\0timerfd_create\0timerfd_gettime\0timerfd_settime\0times\0tkill\0truncate\0umask\0" 28 | "umount\0umount2\0uname\0unlink\0unlinkat\0unshare\0uselib\0ustat\0utime\0utimensat\0" 29 | "utimes\0vfork\0vhangup\0vmsplice\0wait4\0waitid\0write\0writev"; 30 | static const unsigned s390x_syscall_s2i_s[] = { 31 | 0,8,15,20,28,37,49,55,63,67, 32 | 74,81,87,93,99,106,120,133,147,163, 33 | 177,183,189,195,209,223,227,232,237,250, 34 | 264,274,286,297,305,314,321,326,337,347, 35 | 357,367,381,395,402,409,418,425,434,440, 36 | 450,460,471,477,482,495,505,511,519,529, 37 | 535,545,551,561,577,593,600,607,616,624, 38 | 632,639,649,659,667,675,682,690,698,710, 39 | 720,730,740,750,757,764,777,784,793,798, 40 | 810,828,841,855,872,882,893,906,915,925, 41 | 931,942,953,957,968,975,980,987,997,1002, 42 | 1009,1019,1030,1043,1049,1059,1065,1073,1081,1087, 43 | 1095,1101,1109,1115,1124,1129,1135,1144,1158,1168, 44 | 1176,1192,1205,1215,1222,1228,1236,1247,1254,1272, 45 | 1282,1293,1304,1309,1314,1332,1339,1345,1361,1373, 46 | 1378,1384,1395,1400,1406,1412,1418,1425,1435,1452, 47 | 1470,1479,1486,1494,1501,1509,1522,1531,1536,1546, 48 | 1554,1563,1574,1580,1587,1604,1616,1623,1632,1644, 49 | 1650,1663,1677,1692,1708,1721,1735,1751,1769,1792, 50 | 1815,1833,1848,1867,1889,1907,1922,1941,1953,1960, 51 | 1969,1985,2001,2015,2024,2033,2040,2050,2062,2072, 52 | 2078,2086,2098,2107,2117,2127,2136,2146,2153,2166, 53 | 2173,2182,2192,2204,2211,2220,2230,2241,2253,2263, 54 | 2274,2285,2292,2297,2304,2313,2321,2328,2336,2346, 55 | 2351,2367,2374,2380,2388,2395,2399,2406,2419,2432, 56 | 2449,2463,2477,2485,2500,2516,2532,2538,2544,2553, 57 | 2559,2566,2574,2580,2587,2596,2604,2611,2617,2623, 58 | 2633,2640,2646,2654,2663,2669,2676,2682, 59 | }; 60 | static const int s390x_syscall_s2i_i[] = { 61 | 149,33,51,278,124,137,27,134,45,184, 62 | 185,12,15,212,61,337,261,260,262,259, 63 | 120,6,8,127,129,41,63,326,249,327, 64 | 250,312,251,318,323,11,1,248,300,253, 65 | 314,332,333,133,94,299,207,291,55,148, 66 | 229,232,143,2,235,226,108,100,266,118, 67 | 93,238,292,130,305,311,183,141,202,201, 68 | 200,205,105,132,65,20,188,64,96,211, 69 | 209,191,77,147,236,78,199,227,112,128, 70 | 285,284,324,286,247,244,245,243,246,54, 71 | 283,282,117,277,280,37,198,228,9,296, 72 | 230,231,234,19,225,107,219,218,39,289, 73 | 14,290,150,152,90,21,125,276,275,271, 74 | 274,273,272,163,144,151,153,91,335,162, 75 | 293,169,34,5,336,288,29,331,136,42, 76 | 325,217,168,302,172,180,328,334,340,341, 77 | 301,26,189,181,329,167,131,3,222,89, 78 | 85,298,145,88,267,233,38,295,279,40, 79 | 174,176,175,178,173,179,177,330,159,160, 80 | 240,155,157,161,239,154,156,158,142,187, 81 | 304,252,121,216,215,214,206,74,104,339, 82 | 57,97,204,210,208,203,75,66,79,213, 83 | 224,67,186,48,316,322,73,126,119,72, 84 | 102,306,106,99,265,115,87,83,297,36, 85 | 307,338,135,116,103,308,241,254,258,257, 86 | 256,255,317,319,321,320,43,237,92,60, 87 | 22,52,122,10,294,303,86,62,30,315, 88 | 313,190,111,309,114,281,4,146, 89 | }; 90 | static int s390x_syscall_s2i(const char *s, int *value) { 91 | size_t len, i; 92 | len = strlen(s); 93 | { char copy[len + 1]; 94 | for (i = 0; i < len; i++) { 95 | char c = s[i]; 96 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 97 | } 98 | copy[i] = 0; 99 | return s2i__(s390x_syscall_strings, s390x_syscall_s2i_s, s390x_syscall_s2i_i, 278, copy, value); 100 | } 101 | } 102 | static const unsigned s390x_syscall_i2s_direct[] = { 103 | 321,477,1531,2676,1309,183,-1u,189,997,2580, 104 | 314,81,-1u,1095,87,-1u,-1u,-1u,1043,675, 105 | 1129,2559,-1u,-1u,-1u,1479,49,-1u,1339,2617, 106 | -1u,-1u,8,1304,-1u,2346,975,1616,1081,1644, 107 | 223,1373,2532,-1u,63,-1u,-1u,2204,-1u,-1u, 108 | 15,2566,-1u,925,434,-1u,2078,-1u,-1u,2553, 109 | 99,2611,227,690,667,2146,2182,-1u,-1u,-1u, 110 | -1u,2263,2230,2050,2136,-1u,740,764,2153,-1u, 111 | -1u,-1u,2328,-1u,1554,2604,2321,1580,1546,1124, 112 | 1247,2544,535,402,-1u,698,2086,-1u,2297,511, 113 | -1u,2274,2388,2062,649,2292,1059,505,-1u,-1u, 114 | 2646,793,-1u,2663,2313,2380,953,529,2253,177, 115 | 2001,2574,-1u,28,1135,2241,195,798,209,561, 116 | 1522,659,395,55,2374,1361,37,-1u,-1u,-1u, 117 | 607,1953,471,1222,1574,2682,750,440,0,1109, 118 | 1228,1115,1236,1907,1833,1922,1848,1941,1769,1792, 119 | 1867,1272,1215,-1u,-1u,-1u,1509,1395,1293,-1u, 120 | -1u,1406,1708,1650,1677,1663,1735,1692,1721,1412, 121 | 1494,-1u,600,67,74,2192,1960,682,1486,2640, 122 | 730,-1u,-1u,-1u,-1u,-1u,-1u,980,777,632, 123 | 624,616,2127,2098,639,2040,418,2117,720,2107, 124 | 710,93,2166,2033,2024,2015,1384,1073,1065,-1u, 125 | -1u,1536,-1u,2173,1049,495,784,987,450,1009, 126 | 1019,460,1604,1030,482,757,2538,545,1889,1815, 127 | 2399,-1u,906,882,893,915,872,326,237,264, 128 | 286,1985,347,2406,2463,2449,2432,2419,163,133, 129 | 120,147,-1u,-1u,2304,519,1587,-1u,-1u,-1u, 130 | 1168,1205,1192,1176,1158,1144,957,20,1632,968, 131 | 2669,942,931,828,810,855,-1u,1332,1087,1101, 132 | 425,551,1282,2587,1623,1002,2336,1563,409,337, 133 | 1470,1400,2596,1969,577,2285,2351,2395,2654,-1u, 134 | 593,274,2633,357,2623,2211,2477,297,2485,2516, 135 | 2500,2220,305,841,1378,232,250,1418,1501,1751, 136 | 1345,367,381,1425,1254,1314,106,2367,2072,1435, 137 | 1452, 138 | }; 139 | static const char *s390x_syscall_i2s(int v) { 140 | return i2s_direct__(s390x_syscall_strings, s390x_syscall_i2s_direct, 1, 341, v); 141 | } 142 | -------------------------------------------------------------------------------- /lib/x86_64_tables.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, see Makefile.am for its inputs. */ 2 | static const char x86_64_syscall_strings[] = "_sysctl\0accept\0accept4\0access\0acct\0add_key\0adjtimex\0afs_syscall\0alarm\0arch_prctl\0" 3 | "bind\0brk\0capget\0capset\0chdir\0chmod\0chown\0chroot\0clock_adjtime\0clock_getres\0" 4 | "clock_gettime\0clock_nanosleep\0clock_settime\0clone\0close\0connect\0creat\0create_module\0delete_module\0dup\0" 5 | "dup2\0dup3\0epoll_create\0epoll_create1\0epoll_ctl\0epoll_ctl_old\0epoll_pwait\0epoll_wait\0epoll_wait_old\0eventfd\0" 6 | "eventfd2\0execve\0exit\0exit_group\0faccessat\0fadvise64\0fallocate\0fanotify_init\0fanotify_mark\0fchdir\0" 7 | "fchmod\0fchmodat\0fchown\0fchownat\0fcntl\0fdatasync\0fgetxattr\0flistxattr\0flock\0fork\0" 8 | "fremovexattr\0fsetxattr\0fstat\0fstatfs\0fsync\0ftruncate\0futex\0futimesat\0get_kernel_syms\0get_mempolicy\0" 9 | "get_robust_list\0get_thread_area\0getcpu\0getcwd\0getdents\0getdents64\0getegid\0geteuid\0getgid\0getgroups\0" 10 | "getitimer\0getpeername\0getpgid\0getpgrp\0getpid\0getpmsg\0getppid\0getpriority\0getresgid\0getresuid\0" 11 | "getrlimit\0getrusage\0getsid\0getsockname\0getsockopt\0gettid\0gettimeofday\0getuid\0getxattr\0init_module\0" 12 | "inotify_add_watch\0inotify_init\0inotify_init1\0inotify_rm_watch\0io_cancel\0io_destroy\0io_getevents\0io_setup\0io_submit\0ioctl\0" 13 | "ioperm\0iopl\0ioprio_get\0ioprio_set\0kexec_load\0keyctl\0kill\0lchown\0lgetxattr\0link\0" 14 | "linkat\0listen\0listxattr\0llistxattr\0lookup_dcookie\0lremovexattr\0lseek\0lsetxattr\0lstat\0madvise\0" 15 | "mbind\0migrate_pages\0mincore\0mkdir\0mkdirat\0mknod\0mknodat\0mlock\0mlockall\0mmap\0" 16 | "modify_ldt\0mount\0move_pages\0mprotect\0mq_getsetattr\0mq_notify\0mq_open\0mq_timedreceive\0mq_timedsend\0mq_unlink\0" 17 | "mremap\0msgctl\0msgget\0msgrcv\0msgsnd\0msync\0munlock\0munlockall\0munmap\0name_to_handle_at\0" 18 | "nanosleep\0newfstatat\0nfsservctl\0open\0open_by_handle_at\0openat\0pause\0perf_event_open\0personality\0pipe\0" 19 | "pipe2\0pivot_root\0poll\0ppoll\0prctl\0pread\0preadv\0prlimit64\0process_vm_readv\0process_vm_writev\0" 20 | "pselect6\0ptrace\0putpmsg\0pwrite\0pwritev\0query_module\0quotactl\0read\0readahead\0readlink\0" 21 | "readlinkat\0readv\0reboot\0recvfrom\0recvmmsg\0recvmsg\0remap_file_pages\0removexattr\0rename\0renameat\0" 22 | "request_key\0restart_syscall\0rmdir\0rt_sigaction\0rt_sigpending\0rt_sigprocmask\0rt_sigqueueinfo\0rt_sigreturn\0rt_sigsuspend\0rt_sigtimedwait\0" 23 | "rt_tgsigqueueinfo\0sched_get_priority_max\0sched_get_priority_min\0sched_getaffinity\0sched_getparam\0sched_getscheduler\0sched_rr_get_interval\0sched_setaffinity\0sched_setparam\0sched_setscheduler\0" 24 | "sched_yield\0security\0select\0semctl\0semget\0semop\0semtimedop\0sendfile\0sendmmsg\0sendmsg\0" 25 | "sendto\0set_mempolicy\0set_robust_list\0set_thread_area\0set_tid_address\0setdomainname\0setfsgid\0setfsuid\0setgid\0setgroups\0" 26 | "sethostname\0setitimer\0setns\0setpgid\0setpriority\0setregid\0setresgid\0setresuid\0setreuid\0setrlimit\0" 27 | "setsid\0setsockopt\0settimeofday\0setuid\0setxattr\0shmat\0shmctl\0shmdt\0shmget\0shutdown\0" 28 | "sigaltstack\0signalfd\0signalfd4\0socket\0socketpair\0splice\0stat\0statfs\0swapoff\0swapon\0" 29 | "symlink\0symlinkat\0sync\0sync_file_range\0syncfs\0sysfs\0sysinfo\0syslog\0tee\0tgkill\0" 30 | "time\0timer_create\0timer_delete\0timer_getoverrun\0timer_gettime\0timer_settime\0timerfd\0timerfd_gettime\0timerfd_settime\0times\0" 31 | "tkill\0truncate\0tuxcall\0umask\0umount2\0uname\0unlink\0unlinkat\0unshare\0uselib\0" 32 | "ustat\0utime\0utimensat\0utimes\0vfork\0vhangup\0vmsplice\0vserver\0wait4\0waitid\0" 33 | "write\0writev"; 34 | static const unsigned x86_64_syscall_s2i_s[] = { 35 | 0,8,15,23,30,35,43,52,64,70, 36 | 81,86,90,97,104,110,116,122,129,143, 37 | 156,170,186,200,206,212,220,226,240,254, 38 | 258,263,268,281,295,305,319,331,342,357, 39 | 365,374,381,386,397,407,417,427,441,455, 40 | 462,469,478,485,494,500,510,520,531,537, 41 | 542,555,565,571,579,585,595,601,611,627, 42 | 641,657,673,680,687,696,707,715,723,730, 43 | 740,750,762,770,778,785,793,801,813,823, 44 | 833,843,853,860,872,883,890,903,910,919, 45 | 931,949,962,976,993,1003,1014,1027,1036,1046, 46 | 1052,1059,1064,1075,1086,1097,1104,1109,1116,1126, 47 | 1131,1138,1145,1155,1166,1181,1194,1200,1210,1216, 48 | 1224,1230,1244,1252,1258,1266,1272,1280,1286,1295, 49 | 1300,1311,1317,1328,1337,1351,1361,1369,1385,1398, 50 | 1408,1415,1422,1429,1436,1443,1449,1457,1468,1475, 51 | 1493,1503,1514,1525,1530,1548,1555,1561,1577,1589, 52 | 1594,1600,1611,1616,1622,1628,1634,1641,1651,1668, 53 | 1686,1695,1702,1710,1717,1725,1738,1747,1752,1762, 54 | 1771,1782,1788,1795,1804,1813,1821,1838,1850,1857, 55 | 1866,1878,1894,1900,1913,1927,1942,1958,1971,1985, 56 | 2001,2019,2042,2065,2083,2098,2117,2139,2157,2172, 57 | 2191,2203,2212,2219,2226,2233,2239,2250,2259,2268, 58 | 2276,2283,2297,2313,2329,2345,2359,2368,2377,2384, 59 | 2394,2406,2416,2422,2430,2442,2451,2461,2471,2480, 60 | 2490,2497,2508,2521,2528,2537,2543,2550,2556,2563, 61 | 2572,2584,2593,2603,2610,2621,2628,2633,2640,2648, 62 | 2655,2663,2673,2678,2694,2701,2707,2715,2722,2726, 63 | 2733,2738,2751,2764,2781,2795,2809,2817,2833,2849, 64 | 2855,2861,2870,2878,2884,2892,2898,2905,2914,2922, 65 | 2929,2935,2941,2951,2958,2964,2972,2981,2989,2995, 66 | 3002,3008, 67 | }; 68 | static const int x86_64_syscall_s2i_i[] = { 69 | 156,43,288,21,163,248,159,183,37,158, 70 | 49,12,125,126,80,90,92,161,305,229, 71 | 228,230,227,56,3,42,85,174,176,32, 72 | 33,292,213,291,233,214,281,232,215,284, 73 | 290,59,60,231,269,221,285,300,301,81, 74 | 91,268,93,260,72,75,193,196,73,57, 75 | 199,190,5,138,74,77,202,261,177,239, 76 | 274,211,309,79,78,217,108,107,104,115, 77 | 36,52,121,111,39,181,110,140,120,118, 78 | 97,98,124,51,55,186,96,102,191,175, 79 | 254,253,294,255,210,207,208,206,209,16, 80 | 173,172,252,251,246,250,62,94,192,86, 81 | 265,50,194,195,212,198,8,189,6,28, 82 | 237,256,27,83,258,133,259,149,151,9, 83 | 154,165,279,10,245,244,240,243,242,241, 84 | 25,71,68,70,69,26,150,152,11,303, 85 | 35,262,180,2,304,257,34,298,135,22, 86 | 293,155,7,271,157,17,295,302,310,311, 87 | 270,101,182,18,296,178,179,0,187,89, 88 | 267,19,169,45,299,47,216,197,82,264, 89 | 249,219,84,13,127,14,129,15,130,128, 90 | 297,146,147,204,143,145,148,203,142,144, 91 | 24,185,23,66,64,65,220,40,307,46, 92 | 44,238,273,205,218,171,123,122,106,116, 93 | 170,38,308,109,141,114,119,117,113,160, 94 | 112,54,164,105,188,30,31,67,29,48, 95 | 131,282,289,41,53,275,4,137,168,167, 96 | 88,266,162,277,306,139,99,103,276,234, 97 | 201,222,226,225,224,223,283,287,286,100, 98 | 200,76,184,95,166,63,87,263,272,134, 99 | 136,132,280,235,58,153,278,236,61,247, 100 | 1,20, 101 | }; 102 | static int x86_64_syscall_s2i(const char *s, int *value) { 103 | size_t len, i; 104 | len = strlen(s); 105 | { char copy[len + 1]; 106 | for (i = 0; i < len; i++) { 107 | char c = s[i]; 108 | copy[i] = GT_ISUPPER(c) ? c - 'A' + 'a' : c; 109 | } 110 | copy[i] = 0; 111 | return s2i__(x86_64_syscall_strings, x86_64_syscall_s2i_s, x86_64_syscall_s2i_i, 312, copy, value); 112 | } 113 | } 114 | static const unsigned x86_64_syscall_i2s_direct[] = { 115 | 1747,3002,1525,206,2628,565,1210,1611,1194,1295, 116 | 1328,1468,86,1900,1927,1958,1046,1628,1710,1782, 117 | 3008,23,1589,2212,2191,1408,1443,1244,1216,2556, 118 | 2537,2543,254,258,1555,1493,740,64,2406,778, 119 | 2250,2603,212,8,2276,1795,2268,1813,2563,81, 120 | 1138,860,750,2610,2497,872,200,537,2958,374, 121 | 381,2989,1104,2892,2226,2233,2219,2550,1422,1436, 122 | 1429,1415,494,531,579,500,2861,585,687,680, 123 | 104,455,1850,1252,1894,220,1126,2898,2655,1762, 124 | 110,462,116,478,1109,2878,890,833,843,2707, 125 | 2849,1695,903,2715,723,2521,2377,715,707,2422, 126 | 793,770,2490,2471,2442,730,2384,2461,823,2451, 127 | 813,762,2368,2359,853,90,97,1913,1985,1942, 128 | 1971,2572,2935,1266,2922,1577,2929,2633,571,2701, 129 | 801,2430,2157,2083,2172,2098,2019,2042,2117,1280, 130 | 1449,1286,1457,2964,1300,1600,0,1622,70,43, 131 | 2480,122,2673,30,2508,1311,2884,2648,2640,1788, 132 | 2394,2345,1059,1052,226,919,240,611,1725,1738, 133 | 1514,785,1702,52,2870,2203,883,1752,2528,1200, 134 | 555,910,1116,510,1145,1155,520,1838,1181,542, 135 | 2855,2733,595,2139,2065,2313,1027,1003,1014,1036, 136 | 993,657,1166,268,305,342,1821,696,2329,1878, 137 | 2239,407,2738,2795,2781,2764,2751,186,156,143, 138 | 170,386,331,295,2726,2951,2981,1224,2283,627, 139 | 1361,1398,1385,1369,1351,1337,1086,2995,35,1866, 140 | 1097,1075,1064,949,931,976,1230,1548,1258,1272, 141 | 485,601,1503,2905,1857,1131,2663,1771,469,397, 142 | 1686,1616,2914,2297,641,2621,2722,2678,2972,1317, 143 | 2941,319,2584,2809,357,417,2833,2817,15,2593, 144 | 365,281,263,1594,962,1634,1717,2001,1561,1804, 145 | 427,441,1641,1475,1530,129,2694,2259,2416,673, 146 | 1651,1668, 147 | }; 148 | static const char *x86_64_syscall_i2s(int v) { 149 | return i2s_direct__(x86_64_syscall_strings, x86_64_syscall_i2s_direct, 0, 311, v); 150 | } 151 | -------------------------------------------------------------------------------- /libc/stpcpy.c: -------------------------------------------------------------------------------- 1 | /* stpcpy.c -- 2 | * Copyright 2004-2012 SRI International 3 | * All Rights Reserved. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Nathaniel Husted 21 | */ 22 | 23 | #include 24 | 25 | char *stpcpy(register char * __restrict s1, const char * __restrict s2) 26 | { 27 | do { 28 | *s1++ = *s2++; 29 | } while (*s2 != '\0'); 30 | 31 | return s1; 32 | } 33 | -------------------------------------------------------------------------------- /libc/stpcpy.h: -------------------------------------------------------------------------------- 1 | /* stpcpy.h -- 2 | * Copyright 2004-2012 SRI International 3 | * All Rights Reserved. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Nathaniel Husted 21 | */ 22 | 23 | char *stpcpy(register char * __restrict s1, const char * __restrict s2); 24 | -------------------------------------------------------------------------------- /libc/stpcpytest.c: -------------------------------------------------------------------------------- 1 | /* stpcpytest.c -- 2 | * Copyright 2004-2012 SRI International 3 | * All Rights Reserved. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * Authors: 20 | * Nathaniel Husted 21 | */ 22 | 23 | #include "stpcpy.h" 24 | #include 25 | #include 26 | int main (void) 27 | { 28 | char buffer[256]; 29 | bzero(buffer,256); 30 | char *to = buffer; 31 | to = stpcpy (to, "foo"); 32 | to = stpcpy (to, "bar"); 33 | printf ("%s\n", buffer); 34 | } 35 | -------------------------------------------------------------------------------- /patches/android-kernel-goldfish-2.6.29-audit.patch: -------------------------------------------------------------------------------- 1 | diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h 2 | index b9dc8a8..6c68341 100644 3 | --- a/arch/arm/include/asm/thread_info.h 4 | +++ b/arch/arm/include/asm/thread_info.h 5 | @@ -134,6 +134,7 @@ extern void vfp_sync_state(struct thread_info *thread); 6 | #define TIF_SIGPENDING 0 7 | #define TIF_NEED_RESCHED 1 8 | #define TIF_SYSCALL_TRACE 8 9 | +#define TIF_SYSCALL_AUDIT 9 10 | #define TIF_POLLING_NRFLAG 16 11 | #define TIF_USING_IWMMXT 17 12 | #define TIF_MEMDIE 18 13 | @@ -142,10 +143,15 @@ extern void vfp_sync_state(struct thread_info *thread); 14 | #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 15 | #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 16 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 17 | +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 18 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 19 | #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) 20 | #define _TIF_FREEZE (1 << TIF_FREEZE) 21 | 22 | + 23 | +/* Checks for any syscall work in entry-common.S */ 24 | +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT) 25 | + 26 | /* 27 | * Change these and you break ASM code in entry-common.S 28 | */ 29 | diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S 30 | index 159d041..ef9050f 100644 31 | --- a/arch/arm/kernel/entry-common.S 32 | +++ b/arch/arm/kernel/entry-common.S 33 | @@ -87,7 +87,7 @@ ENTRY(ret_from_fork) 34 | get_thread_info tsk 35 | ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing 36 | mov why, #1 37 | - tst r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? 38 | + tst r1, #_TIF_SYSCALL_WORK @ are we tracing syscalls? 39 | beq ret_slow_syscall 40 | mov r1, sp 41 | mov r0, #1 @ trace exit [IP = 1] 42 | @@ -261,7 +261,7 @@ ENTRY(vector_swi) 43 | #endif 44 | 45 | stmdb sp!, {r4, r5} @ push fifth and sixth args 46 | - tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? 47 | + tst ip, #_TIF_SYSCALL_WORK @ are we tracing syscalls? 48 | bne __sys_trace 49 | 50 | cmp scno, #NR_syscalls @ check upper syscall limit 51 | diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c 52 | index 89882a1..79906d5 100644 53 | --- a/arch/arm/kernel/ptrace.c 54 | +++ b/arch/arm/kernel/ptrace.c 55 | @@ -19,10 +19,12 @@ 56 | #include 57 | #include 58 | #include 59 | +#include 60 | 61 | #include 62 | #include 63 | #include 64 | +#include 65 | 66 | #include "ptrace.h" 67 | 68 | @@ -845,6 +847,13 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno) 69 | { 70 | unsigned long ip; 71 | 72 | + if (why) 73 | + audit_syscall_exit(AUDITSC_RESULT(regs->ARM_r0), regs->ARM_r0 ); 74 | + else 75 | + audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, 76 | + regs->ARM_r1, regs->ARM_r2, regs->ARM_r3); 77 | + 78 | + 79 | if (!test_thread_flag(TIF_SYSCALL_TRACE)) 80 | return scno; 81 | if (!(current->ptrace & PT_PTRACED)) 82 | diff --git a/init/Kconfig b/init/Kconfig 83 | index bc99154..40a9e0b 100644 84 | --- a/init/Kconfig 85 | +++ b/init/Kconfig 86 | @@ -226,7 +226,7 @@ config AUDIT 87 | 88 | config AUDITSYSCALL 89 | bool "Enable system-call auditing support" 90 | - depends on AUDIT && (X86 || PPC || PPC64 || S390 || IA64 || UML || SPARC64|| SUPERH) 91 | + depends on AUDIT && (X86 || PPC || PPC64 || S390 || IA64 || UML || SPARC64|| SUPERH || ARM) 92 | default y if SECURITY_SELINUX 93 | help 94 | Enable low-overhead system-call auditing infrastructure that 95 | -------------------------------------------------------------------------------- /patches/android-kernel-omap-tuna-3.0-jb-pre1-audit.patch: -------------------------------------------------------------------------------- 1 | diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h 2 | index 7b5cc8d..de1039c 100644 3 | --- a/arch/arm/include/asm/thread_info.h 4 | +++ b/arch/arm/include/asm/thread_info.h 5 | @@ -139,6 +139,7 @@ extern void vfp_flush_hwstate(struct thread_info *); 6 | #define TIF_NEED_RESCHED 1 7 | #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ 8 | #define TIF_SYSCALL_TRACE 8 9 | +#define TIF_SYSCALL_AUDIT 9 10 | #define TIF_POLLING_NRFLAG 16 11 | #define TIF_USING_IWMMXT 17 12 | #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ 13 | @@ -150,12 +151,16 @@ extern void vfp_flush_hwstate(struct thread_info *); 14 | #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 15 | #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 16 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 17 | +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 18 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 19 | #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) 20 | #define _TIF_FREEZE (1 << TIF_FREEZE) 21 | #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 22 | #define _TIF_SECCOMP (1 << TIF_SECCOMP) 23 | 24 | +/* Checks for any syscall work in entry-common.S */ 25 | +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT) 26 | + 27 | /* 28 | * Change these and you break ASM code in entry-common.S 29 | */ 30 | diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S 31 | index b2a27b6..520889c 100644 32 | --- a/arch/arm/kernel/entry-common.S 33 | +++ b/arch/arm/kernel/entry-common.S 34 | @@ -87,7 +87,7 @@ ENTRY(ret_from_fork) 35 | get_thread_info tsk 36 | ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing 37 | mov why, #1 38 | - tst r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? 39 | + tst r1, #_TIF_SYSCALL_WORK @ are we tracing syscalls? 40 | beq ret_slow_syscall 41 | mov r1, sp 42 | mov r0, #1 @ trace exit [IP = 1] 43 | @@ -443,7 +443,7 @@ ENTRY(vector_swi) 44 | 1: 45 | #endif 46 | 47 | - tst r10, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? 48 | + tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls? 49 | bne __sys_trace 50 | 51 | cmp scno, #NR_syscalls @ check upper syscall limit 52 | diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c 53 | index 172ae01..a24a50c 100644 54 | --- a/arch/arm/kernel/ptrace.c 55 | +++ b/arch/arm/kernel/ptrace.c 56 | @@ -928,6 +928,12 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno) 57 | { 58 | unsigned long ip; 59 | 60 | + if (why) 61 | + audit_syscall_exit(AUDITSC_RESULT(regs->ARM_r0), regs->ARM_r0); 62 | + else 63 | + audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, 64 | + regs->ARM_r1, regs->ARM_r2, regs->ARM_r3); 65 | + 66 | if (!test_thread_flag(TIF_SYSCALL_TRACE)) 67 | return scno; 68 | if (!(current->ptrace & PT_PTRACED)) 69 | diff --git a/init/Kconfig b/init/Kconfig 70 | index 4fe9168..cad41fd 100644 71 | --- a/init/Kconfig 72 | +++ b/init/Kconfig 73 | @@ -355,7 +355,7 @@ config AUDIT 74 | 75 | config AUDITSYSCALL 76 | bool "Enable system-call auditing support" 77 | - depends on AUDIT && (X86 || PPC || S390 || IA64 || UML || SPARC64 || SUPERH) 78 | + depends on AUDIT && (X86 || PPC || S390 || IA64 || UML || SPARC64 || SUPERH ||ARM) 79 | default y if SECURITY_SELINUX 80 | help 81 | Enable low-overhead system-call auditing infrastructure that 82 | -------------------------------------------------------------------------------- /patches/jellybean/audit_permission.patch: -------------------------------------------------------------------------------- 1 | diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml 2 | index 6546fed..37a3b0d 100644 3 | --- a/core/res/AndroidManifest.xml 4 | +++ b/core/res/AndroidManifest.xml 5 | @@ -777,6 +777,13 @@ 6 | android:label="@string/permlab_removeTasks" 7 | android:description="@string/permdesc_removeTasks" /> 8 | 9 | + 10 | + 15 | + 16 | 18 | 26 | 27 | + 28 | + access audit stream 29 | + 30 | + Allows the app to access the system audit stream. This stream could leak sensitive data from other applications running on the system. 31 | + 32 | 33 | start any activity 34 | 35 | diff --git a/data/etc/platform.xml b/data/etc/platform.xml 36 | index 4b93e74..d2490b1 100644 37 | --- a/data/etc/platform.xml 38 | +++ b/data/etc/platform.xml 39 | @@ -77,7 +77,12 @@ 40 | 42 | 43 | - 44 | + 45 | + 46 | + 47 | + 48 | + 49 | + 50 | 51 | 52 |