I have been experiencing some issues with authentication. I have my ejabberd setup to use PAM for authentication with a custom module ( I will put code below for the AUTH). In FreeBSD, if I use 'pamtester -v service user password' to test the pam service it works fine, however, it will always fail when I try with a chat client.
Here is the code that matters with some of my debug code:
111 FILE *fp;
112 char path[1035];
113 /*Open the command for reading */
114 char command[256];
115 int result = 1;
116 syslog(LOG_AUTH, command);
117 sprintf(command, "sudo -u www /usr/local/bin/php /usr/local/www/portal/index.php tools authenticate %s %s", user, password);
118 syslog(LOG_AUTH, "Executed command");
119 fp = popen (command, "r");
120 if (fp == NULL){
121 syslog(LOG_AUTH, "FP ERROR");
122 return (PAM_USER_UNKNOWN);
123 }
124
125 if (fgets(path, 1035, fp) != NULL){
126 result = strncmp("1", path, 1);
127 syslog(LOG_AUTH, "%s", path);
128 //syslog(LOG_AUTH, "strcmp:%d", result);
129 }else{
130 syslog(LOG_AUTH, "Error with fgets");
131
132 }
We have our own php functions that take care of user auth and a bunch of other housekeeping items. This code has to be used. The code returns back a 0 or 1 to indicate a fail or success on auth. When I use pamtester, I get the correct output back. When I use a client, such as Swift or PIdgin, I get garbage back and its usually the same. Something like: Ðm.#001#010
The system is setup so that anyone local can make that php call and everything is being run locally. Any ideas?