-/* Checking client is pre-defined middleware daemons *
- * Check privilege API is only allowed to middleware daemons *
- * list of middleware daemons' executables are listed in
- * /usr/share/security-server/mw-list */
-int search_middleware_exe_path(char *exe)
-{
- FILE *fp = NULL;
- int ret= SECURITY_SERVER_ERROR_AUTHENTICATION_FAILED;
- size_t len = 0;
- ssize_t cnt = 0;
- char *middleware = NULL;
- int cmp = 0;
-
- /* Open the list file */
- fp = fopen(SECURITY_SERVER_MIDDLEWARE_LIST_PATH, "r");
- if(fp == NULL)
- {
- /* error on file */
- SEC_SVR_DBG("%s", "Error oening mw-list file");
- return SECURITY_SERVER_ERROR_FILE_OPERATION;
- }
-
- /* read file line by line */
- while ((cnt = getline(&middleware, &len, fp)) != -1) {
-
- /* trim trailing whitespaces */
- while (cnt > 0 && isspace(middleware[cnt-1])!=0 )
- cnt--;
- middleware[cnt]='\0';
-
- /* compare middleware list entry with executable */
- cmp = strcmp(middleware, exe);
- free(middleware);
- middleware = NULL;
- if (cmp == 0)
- {
- /* found */
- SEC_SVR_DBG("%s", "found matching executable");
- ret = SECURITY_SERVER_SUCCESS;
- break;
- }
- }
- if(fp != NULL)
- fclose(fp);
- return ret;
-}
-