+ /* If user accepts to add */
+ if (user_input[0] == 'y' || user_input[0] == 'Y') {
+ time3 = time(0);
+ rand2 = random();
+
+ fp = fopen(authfile, "a");
+ if (!fp) {
+ if (json_output) {
+ char buffer[1024];
+ cJSON *json_root = cJSON_CreateObject();
+ snprintf(buffer, 1023, "Could not open file '%s' due to [(%d)-(%s)]", KEYS_FILE, errno, strerror(errno));
+ cJSON_AddNumberToObject(json_root, "error", 71);
+ cJSON_AddStringToObject(json_root, "description", buffer);
+ printf("%s", cJSON_PrintUnformatted(json_root));
+ exit(1);
+ } else
+ ErrorExit(FOPEN_ERROR, ARGV0, KEYS_FILE, errno, strerror(errno));
+ }
+#ifndef WIN32
+ if ((chmod(authfile, 0440)) != 0) {
+ if(json_output) {
+ char buffer[1024];
+ snprintf(buffer, 1023, "%s: Could not chmod file %s due to [(%d)-(%s)]", ARGV0, authfile, errno, strerror(errno));
+ cJSON *json_root = cJSON_CreateObject();
+ cJSON_AddNumberToObject(json_root, "error", 76);
+ cJSON_AddStringToObject(json_root, "description", buffer);
+ printf("%s", cJSON_PrintUnformatted(json_root));
+ exit(errno);
+ } else {
+ ErrorExit("%s: Cannot chmod %s: %s", ARGV0, authfile, strerror(errno));
+ }
+ }
+#endif