+/* cmoraes: begin add */
+
+/** char *os_read_agent_profile()
+ * Reads the agent profile name for the current agent.
+ * Returns NULL on error.
+ *
+ * Description:
+ * Comma separated list of strings that used to identify what type
+ * of configuration is used for this agent.
+ * The profile name is set in the agent's etc/ossec.conf file
+ * It is matched with the ossec manager's agent.conf file to read
+ * configuration only applicable to this profile name.
+ *
+ */
+char* os_read_agent_profile()
+{
+ char buf[1024 + 1];
+ FILE *fp;
+
+ debug2("%s: calling os_read_agent_profile().", __local_name);
+
+ if(isChroot())
+ fp = fopen(AGENT_INFO_FILE, "r");
+ else
+ fp = fopen(AGENT_INFO_FILEP, "r");
+
+ if(!fp)
+ {
+ debug2("%s: Failed to open file. Errno=%d.", ARGV0, errno);
+ merror(FOPEN_ERROR, __local_name, AGENT_INFO_FILE);
+ return(NULL);
+ }
+
+ buf[1024] = '\0';
+
+
+ /* Getting profile */
+ if(fgets(buf, 1024, fp) && fgets(buf, 1024, fp) &&
+ fgets(buf, 1024, fp) && fgets(buf, 1024, fp))
+ {
+ char *ret = NULL;
+
+ /* Trim the /n and/or /r at the end of the string */
+ os_trimcrlf(buf);
+
+ os_strdup(buf, ret);
+ debug2("%s: os_read_agent_profile() = [%s]", __local_name, ret);
+
+ fclose(fp);
+
+ return(ret);
+ }
+
+ fclose(fp);
+ return(NULL);
+}
+/* cmoraes: end add */
+