lib.c (95a0c7c2d6cfde3fb5fdb713428ed0df4d6bdd58) lib.c (651e28c5537abb39076d3949fb7618536f1d242e)
1/*
2 * AppArmor security module
3 *
4 * This file contains basic common functions used in AppArmor
5 *
6 * Copyright (C) 1998-2008 Novell/SUSE
7 * Copyright 2009-2010 Canonical Ltd.
8 *

--- 197 unchanged lines hidden (view full) ---

206
207 for (i = 0; i < 32; perm <<= 1, i++) {
208 if (mask & perm)
209 *str++ = chrs[i];
210 }
211 *str = '\0';
212}
213
1/*
2 * AppArmor security module
3 *
4 * This file contains basic common functions used in AppArmor
5 *
6 * Copyright (C) 1998-2008 Novell/SUSE
7 * Copyright 2009-2010 Canonical Ltd.
8 *

--- 197 unchanged lines hidden (view full) ---

206
207 for (i = 0; i < 32; perm <<= 1, i++) {
208 if (mask & perm)
209 *str++ = chrs[i];
210 }
211 *str = '\0';
212}
213
214void aa_audit_perm_names(struct audit_buffer *ab, const char **names, u32 mask)
214void aa_audit_perm_names(struct audit_buffer *ab, const char * const *names,
215 u32 mask)
215{
216 const char *fmt = "%s";
217 unsigned int i, perm = 1;
218 bool prev = false;
219
220 for (i = 0; i < 32; perm <<= 1, i++) {
221 if (mask & perm) {
222 audit_log_format(ab, fmt, names[i]);
223 if (!prev) {
224 prev = true;
225 fmt = " %s";
226 }
227 }
228 }
229}
230
231void aa_audit_perm_mask(struct audit_buffer *ab, u32 mask, const char *chrs,
216{
217 const char *fmt = "%s";
218 unsigned int i, perm = 1;
219 bool prev = false;
220
221 for (i = 0; i < 32; perm <<= 1, i++) {
222 if (mask & perm) {
223 audit_log_format(ab, fmt, names[i]);
224 if (!prev) {
225 prev = true;
226 fmt = " %s";
227 }
228 }
229 }
230}
231
232void aa_audit_perm_mask(struct audit_buffer *ab, u32 mask, const char *chrs,
232 u32 chrsmask, const char **names, u32 namesmask)
233 u32 chrsmask, const char * const *names, u32 namesmask)
233{
234 char str[33];
235
236 audit_log_format(ab, "\"");
237 if ((mask & chrsmask) && chrs) {
238 aa_perm_mask_to_str(str, chrs, mask & chrsmask);
239 mask &= ~chrsmask;
240 audit_log_format(ab, "%s", str);

--- 283 unchanged lines hidden ---
234{
235 char str[33];
236
237 audit_log_format(ab, "\"");
238 if ((mask & chrsmask) && chrs) {
239 aa_perm_mask_to_str(str, chrs, mask & chrsmask);
240 mask &= ~chrsmask;
241 audit_log_format(ab, "%s", str);

--- 283 unchanged lines hidden ---