Пример #1
0
bool serviceInstall(std::string serviceName, std::string displayName)
{
	bool result = true;

	// Open Service Control Manager
	SC_HANDLE hSCM;
	hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);

	if (hSCM == NULL)
	{
		result = false;
	}
	else
	{
		// Get full path of executable
		TCHAR szPath[MAX_PATH];
		int num_bytes = GetModuleFileName(NULL, szPath, MAX_PATH);
		if (num_bytes == 0)
		{
			result = false;
		}
		else
		{
			s_strcat(szPath, MAX_PATH, " ");

			// Call create service
			SC_HANDLE hService;
			hService = CreateService(
					hSCM,
					serviceName.c_str(),
					displayName.c_str(),
					SERVICE_ALL_ACCESS,
					SERVICE_WIN32_OWN_PROCESS,
					SERVICE_AUTO_START,
					SERVICE_ERROR_NORMAL,
					szPath,
					NULL,
					NULL,
					NULL,
					NULL,
					NULL);

			if (hService == NULL)
			{
				result = false;
			}
			else
			{
				// register the service as an event source
				install_event_source(g_serviceName);
				CloseServiceHandle(hService);
			}
		}
		CloseServiceHandle(hSCM);
	}
	return result;
}
Пример #2
0
bool_t dat_to_rt(restable_t *rt, dat_t *dat)
{
	uint32_t i;

	if (rt_set_number(rt, dat->numfiles) == FALSE)
		return FALSE;
	for(i = 0; i < dat->numfiles; i++)
	{
		s_strcpy(&(rt->entries[i].name),
			dat->paths[dat->files[i].path].name);
		s_strcat(&(rt->entries[i].name), DAT_PATH_SDELIM);
		s_strcat(&(rt->entries[i].name), dat->files[i].name);
		rt->entries[i].compression = dat->files[i].compression;
		rt->entries[i].offset = dat->files[i].offset;
		rt->entries[i].size = dat->files[i].size;
		rt->entries[i].compressed = dat->files[i].compressed;
		if (rt->entries[i].compression == 0x20)
			rt->entries[i].compressed = rt->entries[i].size;
	}
	return TRUE;
}
Пример #3
0
/*
 * Delete registry entries to remove event source
 */
int uninstall_event_source(const char *service_name)
{
	int ret = COMMON_SUCCESS;
	char path[MAX_PATH] = EVENT_PATH;

	s_strcat(path, MAX_PATH, service_name);
	ret = RegDeleteKey(HKEY_LOCAL_MACHINE, path);
	if (ret != ERROR_SUCCESS)
	{
		ret = COMMON_ERR_FAILED;
	}

	return ret;
}
Пример #4
0
bool_t dat_extract_resource(restable_t *rt, uint32_t i)
{
	char *filename;

	filename = NULL;
	s_strcpy(&filename, rt->basepath);
	s_strcat(&filename, rt->entries[i].filename);
	fseek(rt->file, rt->entries[i].offset, SEEK_SET);
	if (c_fextract(filename, rt->file, rt->entries[i].size,
                rt->entries[i].compression == 0x40 ? rt->entries[i].compressed : 0,
                &comdec_dat) == FALSE)
	{
		fprintf(stderr, "dat_unpack_files: Can't extract entry #%u.\n", i);
		s_free(&filename);
	   	return FALSE;
	}
	s_free(&filename);
	return TRUE;
}
Пример #5
0
bool_t dat_add_resource(restable_t *rt, uint32_t i)
{
	char *filename;

	filename = NULL;
	rt->entries[i].offset = ftell(rt->file);
	s_strcpy(&filename, rt->basepath);
	s_strcat(&filename, rt->entries[i].filename);
	if (c_fadd(rt->file, filename, &(rt->entries[i].size),
                &(rt->entries[i].compressed),
                &comdec_dat, 9) == FALSE)
	{
		fprintf(stderr, "dat_add_resource: Can't add entry #%u.\n", i);
		s_free(&filename);
		return FALSE;
	}
	if (rt->entries[i].compressed != 0)
                rt->entries[i].compression = 0x40;
        else
                rt->entries[i].compression = 0x20;
	s_free(&filename);
	return TRUE;
}
Пример #6
0
/*
 * Create registry entries for installing service as an event source
 */
int install_event_source(const char *service_name)
{
	HKEY regkey;
	char path[MAX_PATH] = EVENT_PATH;

	s_strcat(path, MAX_PATH, service_name);

	int ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
			path,
			0,
			0,
			REG_OPTION_NON_VOLATILE,
			KEY_SET_VALUE,
			0,
			&regkey,
			0);
	if (ret == ERROR_SUCCESS)
	{
		DWORD types_supported = EVENTLOG_ERROR_TYPE |
				EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;

		TCHAR message_lib[MAX_PATH];
		char *last_slash;
		GetModuleFileName(NULL, message_lib, MAX_PATH);
		last_slash = s_strrchr(message_lib, '\\', MAX_PATH);
		if (NULL != last_slash)
			*last_slash = '\0';
		s_strcat(message_lib, MAX_PATH, "\\");
		s_strcat(message_lib, MAX_PATH, MESSAGE_LIB);

		ret = RegSetValueEx(regkey,
				"EventMessageFile",
				0,
				REG_SZ,
				(BYTE *) message_lib,
				strlen(message_lib));

		if (ret == ERROR_SUCCESS)
		{
			ret = RegSetValueEx(regkey,
					"TypesSupported",
					0,
					REG_DWORD,
					(LPBYTE) &types_supported,
					sizeof (types_supported));
		}

		if (ret != ERROR_SUCCESS) // Failed to create either of the values
		{
			ret = COMMON_ERR_FAILED;
		}
		else
		{
			ret = COMMON_SUCCESS;
		}

		RegCloseKey(regkey);
	}

	return ret;
}
Пример #7
0
static void print_list(const SList *list, char *buf, s_erc *error)
{
	SIterator *itr;
	size_t list_size;


	S_CLR_ERR(error);

	list_size = SListSize(list, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "print_list",
				  "Call to \"list_size\" failed"))
		return;

	s_strcat(buf, "[", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "print_list",
				  "Call to \"s_strcat\" failed"))
		return;

	itr = S_ITERATOR_GET(list, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "print_list",
				  "Call to \"S_ITERATOR_GET\" failed"))
		return;

	for (/* NOP */; itr != NULL; itr = SIteratorNext(itr), --list_size)
	{
		s_bool type_ok;
		const SObject *tmp;


		tmp = SIteratorObject(itr, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "print_list",
					  "Call to \"SIteratorObject\" failed"))
		{
			S_DELETE(itr, "print_list", error);
			return;
		}

		type_ok = SObjectIsType(tmp, "SList", error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "print_word",
					  "Call to \"SObjectIsType\" failed"))
		{
			S_DELETE(itr, "print_list", error);
			return;
		}

		if (type_ok)
		{
			print_list(S_LIST(tmp), buf, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "print_list",
						  "Call to \"print_list\" failed"))
			{
				S_DELETE(itr, "print_list", error);
				return;
			}
		}
		else
		{
			type_ok = SObjectIsType(tmp, "SString", error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "print_list",
						  "Call to \"SObjectIsType\" failed"))
			{
				S_DELETE(itr, "print_list", error);
				return;
			}

			if (type_ok)
			{
				const char *string = SObjectGetString(S_OBJECT(tmp), error);

				if (S_CHK_ERR(error, S_CONTERR,
							  "print_list",
							  "Call to \"SObjectGetString\" failed"))
				{
					S_DELETE(itr, "print_list", error);
					return;
				}
				s_strcat(buf, string, error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "print_list",
							  "Call to \"s_strcat\" failed"))
				{
					S_DELETE(itr, "print_list", error);
					return;
				}

				if ((list_size-1) != 0)
				{
					s_strcat(buf, " ", error);
					if (S_CHK_ERR(error, S_CONTERR,
								  "print_list",
								  "Call to \"s_strcat\" failed"))
					{
						S_DELETE(itr, "print_list", error);
						return;
					}
				}
			}
			else
			{
				S_CTX_ERR(error, S_FAILURE,
						  "print_list",
						  "Unknown type in list");
				{
					S_DELETE(itr, "print_list", error);
					return;
				}
			}
		}
	}

	s_strcat(buf, "]", error);
	S_CHK_ERR(error, S_CONTERR,
			  "print_list",
			  "Call to \"s_strcat\" failed");
}
Пример #8
0
int main(const carg, const char *varg[])
{
	char *s;
	int i;

	s = NULL;
	i = 0;

	fprintf(stdout, "s_strcpy(NULL, \"\") == FALSE: ");
	if (s_strcpy(NULL, "") == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strncpy(NULL, \"\", 10) == FALSE: ");
	if (s_strncpy(NULL, "", 10) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strcat(NULL, \"\") == FALSE: ");
	if (s_strcat(NULL, "") == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strncat(NULL, \"\", 10) == FALSE: ");
	if (s_strncat(NULL, "", 10) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strcpy(&s, NULL) == FALSE: ");
	if (s_strcpy(&s, NULL) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strncpy(&s, NULL, 10) == FALSE: ");
	if (s_strncpy(&s, NULL, 10) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strcat(&s, NULL) == FALSE: ");
	if (s_strcat(&s, NULL) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strncat(&s, NULL, 10) == FALSE: ");
	if (s_strncat(&s, NULL, 10) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}


	fprintf(stdout, "s_strcpy(&s, \"ab\"), strcmp(s, \"ab\") == 0: ");
	s_strcpy(&s, "ab");
	if (strcmp(s, "ab") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strncpy(&s, \"ab\", 1), strcmp(s, \"a\") == 0: ");
	s_strncpy(&s, "ab", 1);
	if (strcmp(s, "a") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	
	fprintf(stdout, "s_strcat(&s, \"ab\"), strcmp(s, \"aab\") == 0: ");
	s_strcat(&s, "ab");
	if (strcmp(s, "aab") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strncat(&s, \"ab\", 1), strcmp(s, \"aaba\") == 0: ");
	s_strncat(&s, "ab", 1);
	if (strcmp(s, "aaba") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_strcpy(&s, \"abcdefghij klmnop\"), s_strcpy(&s, s), strcmp(s, \"abcdefghij klmnop\") == 0: ");
	s_strcpy(&s, "abcdefghij klmnop");
	s_strcpy(&s, s);
	if (strcmp(s, "abcdefghij klmnop") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}
	
	fprintf(stdout, "s_strncpy(&s, s, 10), strcmp(s, \"abcdefghij\") == 0: ");
	s_strncpy(&s, s, 10);
	if (strcmp(s, "abcdefghij") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}
	
	fprintf(stdout, "s_strcat(&s, s), strcmp(s, \"abcdefghijabcdefghij\") == 0: ");
	s_strcat(&s, s);
	if (strcmp(s, "abcdefghijabcdefghij") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}
	
	fprintf(stdout, "s_strncat(&s, s, 10), strcmp(s, \"abcdefghijabcdefghijabcdefghij\") == 0: ");
	s_strncat(&s, s, 10);
	if (strcmp(s, "abcdefghijabcdefghijabcdefghij") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_path(NULL, \"\", SYS_PATH_DELIM) == FALSE: ");
	if (s_path(NULL, "", SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_pathname(NULL, \"\", SYS_PATH_DELIM) == FALSE: ");
	if (s_pathname(NULL, "", SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_name(NULL, \"\", SYS_PATH_DELIM) == FALSE: ");
	if (s_name(NULL, "", SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_nameext(NULL, \"\", SYS_PATH_DELIM) == FALSE: ");
	if (s_nameext(NULL, "", SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_ext(NULL, \"\", SYS_PATH_DELIM) == FALSE: ");
	if (s_ext(NULL, "", SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_path(&s, NULL, SYS_PATH_DELIM) == FALSE: ");
	if (s_path(&s, NULL, SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_pathname(&s, NULL, SYS_PATH_DELIM) == FALSE: ");
	if (s_pathname(&s, NULL, SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_name(&s, NULL, SYS_PATH_DELIM) == FALSE: ");
	if (s_name(&s, NULL, SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_nameext(&s, NULL, SYS_PATH_DELIM) == FALSE: ");
	if (s_nameext(&s, NULL, SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	fprintf(stdout, "s_ext(&s, NULL, SYS_PATH_DELIM) == FALSE: ");
	if (s_ext(&s, NULL, SYS_PATH_DELIM) == FALSE)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	s_strcpy(&s, "/path/name.ext");
	s_path(&s, s, SYS_PATH_DELIM);
	fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_path(&s, s, SYS_PATH_DELIM), strcmp(s, \"/path/\") == 0: ");
	if (strcmp(s, "/path/") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}	
	
	s_strcpy(&s, "/path/name.ext");
	s_pathname(&s, s, SYS_PATH_DELIM);
	fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_pathname(&s, s, SYS_PATH_DELIM), strcmp(s, \"/path/name\") == 0: ");
	if (strcmp(s, "/path/name") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	s_strcpy(&s, "/path/name.ext");
	s_name(&s, s, SYS_PATH_DELIM);
	fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_name(&s, s, SYS_PATH_DELIM), strcmp(s, \"name\") == 0: ");
	if (strcmp(s, "name") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}

	s_strcpy(&s, "/path/name.ext");
	s_nameext(&s, s, SYS_PATH_DELIM);
	fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_nameext(&s, s, SYS_PATH_DELIM), strcmp(s, \"name.ext\") == 0: ");
	if (strcmp(s, "name.ext") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}
	
	s_strcpy(&s, "/path/name.ext");
	s_ext(&s, s, SYS_PATH_DELIM);
	fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_ext(&s, s, SYS_PATH_DELIM), strcmp(s, \".ext\") == 0: ");
	if (strcmp(s, ".ext") == 0)
		fprintf(stdout, "OK\n");
	else
	{
		fprintf(stdout, "failed.\n");
		i++;
	}
	
	i += check_pathnameext("", "", "", "", "", "");
	i += check_pathnameext("/", "/", "/", "", "", "");
	i += check_pathnameext("path/", "path/", "path/", "", "", "");
	i += check_pathnameext("name", "", "name", "name", "name", "");
	i += check_pathnameext(".ext", "", "", "", ".ext", ".ext");
	i += check_pathnameext("path/name", "path/", "path/name", "name", "name", "");
	i += check_pathnameext("path/.ext", "path/", "path/", "", ".ext", ".ext");
	i += check_pathnameext("name.ext", "", "name", "name", "name.ext", ".ext");
	i += check_pathnameext("path/name.ext", "path/", "path/name", "name", "name.ext", ".ext");
	i += check_pathnameext("path.e/", "path.e/", "path.e/", "", "", "");
	i += check_pathnameext("path.e/name", "path.e/", "path.e/name", "name", "name", "");
	i += check_pathnameext("path.e/.ext", "path.e/", "path.e/", "", ".ext", ".ext");
	i += check_pathnameext("path.e/name.ext", "path.e/", "path.e/name", "name", "name.ext", ".ext");

	fprintf(stdout, "s_sprintf(NULL, \"%%d abc %%s\", -2147483648, \"def\") == FALSE: ");
	if (s_sprintf(NULL, "%d abc %s", -2147483648, "def") == FALSE)
                fprintf(stdout, "OK\n");
        else
        {
                fprintf(stdout, "failed.\n");
                i++;
        }

	fprintf(stdout, "s_sprintf(&s, NULL, -2147483648, \"def\") == FALSE: ");
	if (s_sprintf(&s, NULL, -2147483648, "def") == FALSE)
                fprintf(stdout, "OK\n");
        else
        {
                fprintf(stdout, "failed.\n");
                i++;
        }

	s_sprintf(&s, "%d abc %s", -2147483648, "def");
	fprintf(stdout, "s_sprintf(&s, \"%%d abc %%s\", -2147483648, \"def\"), strcmp(s, \"-2147483648 abc def\") == 0: ");
	if (strcmp(s, "-2147483648 abc def") == 0)
                fprintf(stdout, "OK\n");
        else
        {
                fprintf(stdout, "failed.\n");
                i++;
        }

	fprintf(stdout, "is_equal_files(\"%s\", \"%s\") == TRUE: ", varg[0], varg[0]);
	if (is_equal_files(varg[0], varg[0]) == TRUE)
                fprintf(stdout, "OK\n");
        else
        {
                fprintf(stdout, "failed.\n");
                i++;
        }

	s_free(&s);
	fprintf(stderr, "Found %d errors.\n", i);
	return i;
}
Пример #9
0
/*
 * Run the security check diagnostic algorithm
 */
int diag_security_check(const struct diagnostic *p_diagnostic, NVM_UINT32 *p_results)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_SUCCESS;
	int dev_count = 0;
	*p_results = 0;

	// clear previous results
	diag_clear_results(EVENT_TYPE_DIAG_SECURITY, 0, NULL);

	if ((rc = IS_NVM_FEATURE_SUPPORTED(security_diagnostic)) != NVM_SUCCESS)
	{
		COMMON_LOG_ERROR("The security diagnostic is not supported.");
	}
	else
	{
		dev_count = nvm_get_device_count();
		if (dev_count == 0)
		{
			store_event_by_parts(EVENT_TYPE_DIAG_SECURITY, EVENT_SEVERITY_WARN,
					EVENT_CODE_DIAG_SECURITY_NO_DIMMS, NULL, 0, NULL, NULL, NULL,
					DIAGNOSTIC_RESULT_ABORTED);
			(*p_results)++;
		}
		else if (dev_count > 0)
		{
			// get device_discovery information of all dimms
			struct device_discovery dimms[dev_count];
			int manageable_dev_count = 0;
			dev_count = nvm_get_devices(dimms, dev_count);
			if (dev_count > 0)
			{
				rc = NVM_SUCCESS;
				// count the number of dimms in each security state.
				int security_state_count = (int)LOCK_STATE_NOT_SUPPORTED;

				int count[security_state_count+1];
				memset(count, 0, sizeof (int) * (security_state_count + 1));
				for (int i = 0; i < dev_count; i++)
				{
					// only take dimms that are manageable into account
					if (dimms[i].manageability == MANAGEMENT_VALIDCONFIG)
						{
							count[dimms[i].lock_state]++;
							manageable_dev_count++;
						}
				}

				// check if all manageable dimms are security not supported
				if ((count[LOCK_STATE_NOT_SUPPORTED] == manageable_dev_count) &&
						(!(p_diagnostic->excludes &
								DIAG_THRESHOLD_SECURITY_ALL_NOTSUPPORTED)))
				{
					store_event_by_parts(EVENT_TYPE_DIAG_SECURITY,
							EVENT_SEVERITY_WARN,
							EVENT_CODE_DIAG_SECURITY_ALL_NOTSUPPORTED, NULL, 0, NULL,
							NULL, NULL, DIAGNOSTIC_RESULT_FAILED);
					(*p_results)++;
				}
				// check if all manageable dimms are disabled
				else if ((count[LOCK_STATE_DISABLED] == manageable_dev_count) &&
					(!(p_diagnostic->excludes & DIAG_THRESHOLD_SECURITY_ALL_DISABLED)))
				{
					store_event_by_parts(EVENT_TYPE_DIAG_SECURITY,
							EVENT_SEVERITY_WARN,
							EVENT_CODE_DIAG_SECURITY_ALL_DISABLED, NULL, 0, NULL,
							NULL, NULL, DIAGNOSTIC_RESULT_FAILED);
					(*p_results)++;
				}

				if (*p_results == 0)
				{
					// check if all manageable dimms have the same security state
					if (!(p_diagnostic->excludes & DIAG_THRESHOLD_SECURITY_CONSISTENT))
					{
						char inconsistent_security_state_event_arg_str[NVM_EVENT_ARG_LEN];
						NVM_BOOL inconsistent_flag = 0;
						for (int j = 0; j < security_state_count; j++)
						{
							// check if security settings are inconsistent
							if (count[j] > 0 && count[j] != manageable_dev_count)
							{
								// appending to the argument
								if (inconsistent_flag)
								{
									s_strcat(inconsistent_security_state_event_arg_str,
											NVM_EVENT_ARG_LEN, ", ");
								}
								char arg_str_security_state[NVM_EVENT_ARG_LEN];
								s_snprintf(arg_str_security_state, NVM_EVENT_ARG_LEN,
										"%d %s", count[j], lock_state_strings[j]);
								s_strcat(inconsistent_security_state_event_arg_str,
										NVM_EVENT_ARG_LEN, arg_str_security_state);
								inconsistent_flag = 1;
							}
						}

						if (inconsistent_flag)
						{
							store_event_by_parts(EVENT_TYPE_DIAG_SECURITY,
									EVENT_SEVERITY_WARN,
									EVENT_CODE_DIAG_SECURITY_INCONSISTENT, NULL, 0,
									inconsistent_security_state_event_arg_str, NULL,
									NULL, DIAGNOSTIC_RESULT_FAILED);
							(*p_results)++;
						}
					}
				}

			} // nvm_get_devices failed
			else
			{
				rc = dev_count;
			}
		} // nvm_get_device_count failed
		else
		{
			rc = dev_count;
		}

		// add success message
		if ((rc == NVM_SUCCESS) && (*p_results == 0)) // No errors/warnings
		{
			// store success event
			store_event_by_parts(
				EVENT_TYPE_DIAG_SECURITY,
				EVENT_SEVERITY_INFO,
				EVENT_CODE_DIAG_SECURITY_SUCCESS,
				NULL,
				0,
				NULL,
				NULL,
				NULL,
				DIAGNOSTIC_RESULT_OK);
			(*p_results)++;
		}

	}

	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}