April 11, 2008

SASL2

I grew annoyed at not knowing whether or not my SASL2 plugins were as "installed" as I thought they were and had permissions correct enough to work, so I created this lousy program to print them out. As it turns out you can build the NTLM mechanism from the cyrus sources, plop it into /usr/lib/sasl2 on a Mac and it will in fact work.


#include <stdio.h>
#include <stdlib.h>
#include <sasl/sasl.h>

int main() {
if (SASL_OK == sasl_client_init(NULL)) {
const char ** list = sasl_global_listmech();
if (list != NULL) {
fprintf(stdout, "Available SASL mechs:\n");
int pos;
for (pos = 0; list[pos] != NULL; pos += 1) {
fprintf(stdout, "\t%s\n", list[pos]);
}
return EXIT_SUCCESS;
} else {
fprintf(stderr, "No mechanisms available!\n");
return EXIT_FAILURE;
}
} else {
fprintf(stderr, "SASL init failed\n");
return EXIT_FAILURE;
}
}