| 1 | /* |
| 2 | * AIDE (Advanced Intrusion Detection Environment) |
| 3 | * |
| 4 | * Copyright (C) 2015,2016,2019-2025 Hannes von Haugwitz |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; either version 2 of the |
| 9 | * License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #include <string.h> |
| 22 | #include <stdio.h> |
| 23 | #include <stdbool.h> |
| 24 | #include "util.h"cxx . . $ `<file>/include/util.h`/ |
| 25 | |
| 26 | #include "attributes.h"cxx . . $ `<file>/include/attributes.h`/ |
| 27 | |
| 28 | attributes_tcxx . . $ attributes_t# attributescxx . . $ attributes.[] = { |
| 29 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_filename), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "name", "name", '\0' }, |
| 30 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_linkname), "l", "Lname", "lname", "link_name", 'l' }, |
| 31 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_perm), "p", "Perm", "perm", "perm", 'p' }, |
| 32 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_uid), "u", "Uid", "uid", "uid", 'u' }, |
| 33 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_gid), "g", "Gid", "gid", "gid", 'g' }, |
| 34 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_size), "s", "Size", "size", "size", '>' }, |
| 35 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_atime), "a", "Atime", "atime", "access_time", 'a' }, |
| 36 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_ctime), "c", "Ctime", "ctime", "change_time", 'c' }, |
| 37 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_mtime), "m", "Mtime" , "mtime", "modify_time", 'm' }, |
| 38 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_inode), "i", "Inode", "inode", "inode", 'i' }, |
| 39 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_bcount), "b", "Bcount", "bcount", "block_count", 'b' }, |
| 40 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_linkcount), "n", "Linkcount", "lcount", "link_count", 'n' }, |
| 41 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_md5), "md5", "MD5", "md5", "md5", '\0' }, |
| 42 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_sha1), "sha1", "SHA1", "sha1", "sha1", '\0' }, |
| 43 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_rmd160), "rmd160", "RMD160", "rmd160", "rmd160", '\0' }, |
| 44 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_tiger), "tiger", "TIGER", "tiger", "tiger", '\0' }, |
| 45 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_crc32), "crc32", "CRC32", "crc32", "crc32", '\0' }, |
| 46 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_haval), "haval", "HAVAL", "haval", "haval", '\0' }, |
| 47 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_gostr3411_94), "gost", "GOST", "gost", "gost", '\0' }, |
| 48 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_crc32b), "crc32b", "CRC32B", "crc32b", "crc32b", '\0' }, |
| 49 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_attr), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "Attributes", "attr", "attributes", '\0' }, |
| 50 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_acl), "acl", "ACL", "acl", "acl", 'A' }, |
| 51 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_bsize), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, '\0' }, |
| 52 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_rdev), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! , NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, '\0' }, |
| 53 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_dev), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! , NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, '\0' }, |
| 54 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_allhashsums), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 'H' }, /* "H" is also default compound group for all compiled in hashsums */ |
| 55 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_sizeg), "S", "Size (>)", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "growing_size", '\0' }, |
| 56 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_checkinode), "I", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, '\0' }, |
| 57 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_allownewfile), "ANF", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, '\0' }, |
| 58 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_allowrmfile), "ARF", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, '\0' }, |
| 59 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_sha256), "sha256", "SHA256", "sha256", "sha256", '\0' }, |
| 60 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_sha512), "sha512", "SHA512", "sha512", "sha512", '\0' }, |
| 61 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_selinux), "selinux", "SELinux", "selinux", "selinux", 'S' }, |
| 62 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_xattrs), "xattrs", "XAttrs", "xattrs", "xattrs", 'X' }, |
| 63 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_whirlpool), "whirlpool", "WHIRLPOOL", "whirlpool", "whirlpool", '\0' }, |
| 64 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_ftype), "ftype", "File type", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "file_type", '!' }, |
| 65 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_e2fsattrs), "e2fsattrs", "E2FSAttrs", "e2fsattrs", "e2fsattrs", 'E' }, |
| 66 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_capabilities), "caps", "Caps", "capabilities", "capabilities", 'C' }, |
| 67 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_stribog256), "stribog256", "STRIBOG256", "stribog256", "stribog256", '\0' }, |
| 68 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_stribog512), "stribog512", "STRIBOG512", "stribog512", "stribog512", '\0' }, |
| 69 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_growing), "growing", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, '\0' }, |
| 70 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_compressed), "compressed", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, '\0' }, |
| 71 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_sha512_256), "sha512_256", "SHA512/256", "sha512_256", "sha512-256", '\0' }, |
| 72 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_sha3_256), "sha3_256", "SHA3-256", "sha3_256", "sha3-256", '\0' }, |
| 73 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_sha3_512), "sha3_512", "SHA3-512", "sha3_512", "sha3-512", '\0' }, |
| 74 | { ATTRcxx . . $ `include/attributes.h:28:9`!(attr_fs_type), "fstype", "FS type", "fstype", "fs_type", 'F' }, |
| 75 | }; |
| 76 | |
| 77 | DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! num_attrscxx . . $ num_attrs. = sizeof(attributescxx . . $ attributes.)/sizeof(attributes_tcxx . . $ attributes_t#); |
| 78 | |
| 79 | static int get_diff_attrs_stringcxx . . $ get_diff_attrs_string(4cbc807484bd7863).(DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! a, DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! b, char *str, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! db) { |
| 80 | int n = 0; |
| 81 | for (ATTRIBUTEcxx . . $ ATTRIBUTE# i = 0; i < num_attrscxx . . $ num_attrs.; ++i) { |
| 82 | if (db?attributescxx . . $ attributes.[i].db_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#db_name.:attributescxx . . $ attributes.[i].config_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#config_name.) { |
| 83 | if (((1LLU<<i)&a) ^ ((1LLU<<i)&b)) { |
| 84 | if (n || a != 0) { |
| 85 | if (str) { str[n] = ((1LLU<<i)&b)?'+':'-'; } |
| 86 | n++; |
| 87 | } |
| 88 | if (str) { |
| 89 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(&str[n], "%s", db?attributescxx . . $ attributes.[i].db_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#db_name.:attributescxx . . $ attributes.[i].config_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#config_name.); |
| 90 | } |
| 91 | n += strlencxx . . $ strlen(751346f8406fd082).(db?attributescxx . . $ attributes.[i].db_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#db_name.:attributescxx . . $ attributes.[i].config_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#config_name.); |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | if (str) { str[n] = '\0'; } |
| 96 | n++; |
| 97 | return n; |
| 98 | } |
| 99 | |
| 100 | char *diff_attributescxx . . $ diff_attributes(39cd1df6f24d7ad6).(DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! a, DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! b) { |
| 101 | char *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 102 | int n = get_diff_attrs_stringcxx . . $ get_diff_attrs_string(4cbc807484bd7863).(a, b, str, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!); |
| 103 | str = checked_malloccxx . . $ checked_malloc(bfcfa4d6b7f7ef64).(n); |
| 104 | get_diff_attrs_stringcxx . . $ get_diff_attrs_string(4cbc807484bd7863).(a, b, str, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!); |
| 105 | return str; |
| 106 | } |
| 107 | |
| 108 | char *diff_database_attributescxx . . $ diff_database_attributes(39cd1df6f24d7ad6).(DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! a, DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! b) { |
| 109 | char *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 110 | int n = get_diff_attrs_stringcxx . . $ get_diff_attrs_string(4cbc807484bd7863).(a, b, str, truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!); |
| 111 | str = checked_malloccxx . . $ checked_malloc(bfcfa4d6b7f7ef64).(n); |
| 112 | get_diff_attrs_stringcxx . . $ get_diff_attrs_string(4cbc807484bd7863).(a, b, str, truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!); |
| 113 | return str; |
| 114 | } |