- perm_int = atoi(perm);
- snprintf(perm_str, 35,
- "%c%c%c%c%c%c%c%c%c",
- (perm_int & S_IRUSR)? 'r' : '-',
- (perm_int & S_IWUSR)? 'w' : '-',
-
- (perm_int & S_ISUID)? 's' :
- (perm_int & S_IXUSR)? 'x' : '-',
-
-
- (perm_int & S_IRGRP)? 'r' : '-',
- (perm_int & S_IWGRP)? 'w' : '-',
-
- (perm_int & S_ISGID)? 's' :
- (perm_int & S_IXGRP)? 'x' : '-',
-
-
- (perm_int & S_IROTH)? 'r' : '-',
- (perm_int & S_IWOTH)? 'w' : '-',
- (perm_int & S_ISVTX)? 't' :
- (perm_int & S_IXOTH)? 'x' : '-');
-
-
- printf("Integrity checking values:\n");
- printf(" Size:%s%s\n", (strcmp(size,p_size) == 0)? " ": " >", size);
- if(!is_win)
- {
- printf(" Perm:%s%s\n", (strcmp(perm,p_perm) == 0)? " ": " >", perm_str);
- printf(" Uid: %s%s\n", (strcmp(uid,p_uid) == 0)? " ": " >", uid);
- printf(" Gid: %s%s\n", (strcmp(gid,p_gid) == 0)? " ": " >", gid);
+ snprintf(perm_str, 35, "%9.9s", agent_file_perm(perm));
+
+ if (json_output) {
+ cJSON_AddStringToObject(json_output, "size", size);
+ // Legacy
+ //cJSON_AddNumberToObject(json_output, "mode", is_win ? 0 : perm_int);
+ cJSON_AddStringToObject(json_output, "perm", is_win ? "" : perm_str);
+ cJSON_AddStringToObject(json_output, "uid", is_win ? "" : uid);
+ cJSON_AddStringToObject(json_output, "gid", is_win ? "" : gid);
+ cJSON_AddStringToObject(json_output, "md5", md5);
+ cJSON_AddStringToObject(json_output, "sha1", sha1);
+
+ } else{
+ printf("Integrity checking values:\n");
+ printf(" Size:%s%s\n", (strcmp(size, p_size) == 0) ? " " : " >", size);
+ if (!is_win) {
+ printf(" Perm:%s%s\n", (strcmp(perm, p_perm) == 0) ? " " : " >", perm_str);
+ printf(" Uid: %s%s\n", (strcmp(uid, p_uid) == 0) ? " " : " >", uid);
+ printf(" Gid: %s%s\n", (strcmp(gid, p_gid) == 0) ? " " : " >", gid);
+ }
+ printf(" Md5: %s%s\n", (strcmp(md5, p_md5) == 0) ? " " : " >", md5);
+ printf(" Sha1:%s%s\n", (strcmp(sha1, p_sha1) == 0) ? " " : " >", sha1);