bsm_token.c (159985) | bsm_token.c (161630) |
---|---|
1/* 2 * Copyright (c) 2004 Apple Computer, Inc. 3 * Copyright (c) 2005 SPARTA, Inc. 4 * All rights reserved. 5 * 6 * This code was developed in part by Robert N. M. Watson, Senior Principal 7 * Scientist, SPARTA, Inc. 8 * --- 16 unchanged lines hidden (view full) --- 25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * | 1/* 2 * Copyright (c) 2004 Apple Computer, Inc. 3 * Copyright (c) 2005 SPARTA, Inc. 4 * All rights reserved. 5 * 6 * This code was developed in part by Robert N. M. Watson, Senior Principal 7 * Scientist, SPARTA, Inc. 8 * --- 16 unchanged lines hidden (view full) --- 25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * |
33 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#48 $ | 33 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#51 $ |
34 */ 35 36#include <sys/types.h> 37 38#include <config/config.h> 39#ifdef HAVE_SYS_ENDIAN_H 40#include <sys/endian.h> 41#else /* !HAVE_SYS_ENDIAN_H */ --- 262 unchanged lines hidden (view full) --- 304} 305 306/* 307 */ 308token_t * 309au_to_groups(int *groups) 310{ 311 | 34 */ 35 36#include <sys/types.h> 37 38#include <config/config.h> 39#ifdef HAVE_SYS_ENDIAN_H 40#include <sys/endian.h> 41#else /* !HAVE_SYS_ENDIAN_H */ --- 262 unchanged lines hidden (view full) --- 304} 305 306/* 307 */ 308token_t * 309au_to_groups(int *groups) 310{ 311 |
312 return (au_to_newgroups(BSM_MAX_GROUPS, groups)); | 312 return (au_to_newgroups(AUDIT_MAX_GROUPS, groups)); |
313} 314 315/* 316 * token ID 1 byte 317 * number groups 2 bytes 318 * group list count * 4 bytes 319 */ 320token_t * --- 729 unchanged lines hidden (view full) --- 1050#endif 1051 1052/* 1053 * token ID 1 byte 1054 * count 4 bytes 1055 * text count null-terminated strings 1056 */ 1057token_t * | 313} 314 315/* 316 * token ID 1 byte 317 * number groups 2 bytes 318 * group list count * 4 bytes 319 */ 320token_t * --- 729 unchanged lines hidden (view full) --- 1050#endif 1051 1052/* 1053 * token ID 1 byte 1054 * count 4 bytes 1055 * text count null-terminated strings 1056 */ 1057token_t * |
1058au_to_exec_args(const char **args) | 1058au_to_exec_args(char **argv) |
1059{ 1060 token_t *t; 1061 u_char *dptr = NULL; 1062 const char *nextarg; 1063 int i, count = 0; 1064 size_t totlen = 0; 1065 | 1059{ 1060 token_t *t; 1061 u_char *dptr = NULL; 1062 const char *nextarg; 1063 int i, count = 0; 1064 size_t totlen = 0; 1065 |
1066 nextarg = *args; | 1066 nextarg = *argv; |
1067 1068 while (nextarg != NULL) { 1069 int nextlen; 1070 1071 nextlen = strlen(nextarg); 1072 totlen += nextlen + 1; 1073 count++; | 1067 1068 while (nextarg != NULL) { 1069 int nextlen; 1070 1071 nextlen = strlen(nextarg); 1072 totlen += nextlen + 1; 1073 count++; |
1074 nextarg = *(args + count); | 1074 nextarg = *(argv + count); |
1075 } 1076 1077 totlen += count * sizeof(char); /* nul terminations. */ 1078 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + totlen); 1079 if (t == NULL) 1080 return (NULL); 1081 1082 ADD_U_CHAR(dptr, AUT_EXEC_ARGS); 1083 ADD_U_INT32(dptr, count); 1084 1085 for (i = 0; i < count; i++) { | 1075 } 1076 1077 totlen += count * sizeof(char); /* nul terminations. */ 1078 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + totlen); 1079 if (t == NULL) 1080 return (NULL); 1081 1082 ADD_U_CHAR(dptr, AUT_EXEC_ARGS); 1083 ADD_U_INT32(dptr, count); 1084 1085 for (i = 0; i < count; i++) { |
1086 nextarg = *(args + i); | 1086 nextarg = *(argv + i); |
1087 ADD_MEM(dptr, nextarg, strlen(nextarg) + 1); 1088 } 1089 1090 return (t); 1091} 1092 1093/* 1094 * token ID 1 byte 1095 * count 4 bytes 1096 * text count null-terminated strings 1097 */ 1098token_t * | 1087 ADD_MEM(dptr, nextarg, strlen(nextarg) + 1); 1088 } 1089 1090 return (t); 1091} 1092 1093/* 1094 * token ID 1 byte 1095 * count 4 bytes 1096 * text count null-terminated strings 1097 */ 1098token_t * |
1099au_to_exec_env(const char **env) | 1099au_to_exec_env(char **envp) |
1100{ 1101 token_t *t; 1102 u_char *dptr = NULL; 1103 int i, count = 0; 1104 size_t totlen = 0; 1105 const char *nextenv; 1106 | 1100{ 1101 token_t *t; 1102 u_char *dptr = NULL; 1103 int i, count = 0; 1104 size_t totlen = 0; 1105 const char *nextenv; 1106 |
1107 nextenv = *env; | 1107 nextenv = *envp; |
1108 1109 while (nextenv != NULL) { 1110 int nextlen; 1111 1112 nextlen = strlen(nextenv); 1113 totlen += nextlen + 1; 1114 count++; | 1108 1109 while (nextenv != NULL) { 1110 int nextlen; 1111 1112 nextlen = strlen(nextenv); 1113 totlen += nextlen + 1; 1114 count++; |
1115 nextenv = *(env + count); | 1115 nextenv = *(envp + count); |
1116 } 1117 1118 totlen += sizeof(char) * count; 1119 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + totlen); 1120 if (t == NULL) 1121 return (NULL); 1122 1123 ADD_U_CHAR(dptr, AUT_EXEC_ENV); 1124 ADD_U_INT32(dptr, count); 1125 1126 for (i = 0; i < count; i++) { | 1116 } 1117 1118 totlen += sizeof(char) * count; 1119 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + totlen); 1120 if (t == NULL) 1121 return (NULL); 1122 1123 ADD_U_CHAR(dptr, AUT_EXEC_ENV); 1124 ADD_U_INT32(dptr, count); 1125 1126 for (i = 0; i < count; i++) { |
1127 nextenv = *(env + i); | 1127 nextenv = *(envp + i); |
1128 ADD_MEM(dptr, nextenv, strlen(nextenv) + 1); 1129 } 1130 1131 return (t); 1132} 1133 1134/* 1135 * token ID 1 byte --- 14 unchanged lines hidden (view full) --- 1150 1151 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + 1152 sizeof(u_char) + 2 * sizeof(u_int16_t) + 2 * sizeof(u_int32_t)); 1153 if (t == NULL) 1154 return (NULL); 1155 1156 ADD_U_CHAR(dptr, AUT_HEADER32); 1157 ADD_U_INT32(dptr, rec_size); | 1128 ADD_MEM(dptr, nextenv, strlen(nextenv) + 1); 1129 } 1130 1131 return (t); 1132} 1133 1134/* 1135 * token ID 1 byte --- 14 unchanged lines hidden (view full) --- 1150 1151 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int32_t) + 1152 sizeof(u_char) + 2 * sizeof(u_int16_t) + 2 * sizeof(u_int32_t)); 1153 if (t == NULL) 1154 return (NULL); 1155 1156 ADD_U_CHAR(dptr, AUT_HEADER32); 1157 ADD_U_INT32(dptr, rec_size); |
1158 ADD_U_CHAR(dptr, HEADER_VERSION); | 1158 ADD_U_CHAR(dptr, AUDIT_HEADER_VERSION_OPENBSM); |
1159 ADD_U_INT16(dptr, e_type); 1160 ADD_U_INT16(dptr, e_mod); 1161 1162 timems = tm.tv_usec/1000; 1163 /* Add the timestamp */ 1164 ADD_U_INT32(dptr, tm.tv_sec); 1165 ADD_U_INT32(dptr, timems); /* We need time in ms. */ 1166 --- 54 unchanged lines hidden --- | 1159 ADD_U_INT16(dptr, e_type); 1160 ADD_U_INT16(dptr, e_mod); 1161 1162 timems = tm.tv_usec/1000; 1163 /* Add the timestamp */ 1164 ADD_U_INT32(dptr, tm.tv_sec); 1165 ADD_U_INT32(dptr, timems); /* We need time in ms. */ 1166 --- 54 unchanged lines hidden --- |