extern "C" { #include "pam_conf.h" } #include #include #include #include #include using std::string; /* * Get the configuration for this service as provided by SMF. * This configuration will be used in place of the default configuration * if provided. * * XXX - assumes column numbers in pamcfg table won't change! * 0 service * 1 type * 2 sequence * 3 control * 4 module * 5 arguments */ void _pam_get_conf(const char *service_name, char *buf, int buflen) { pamcfg_iterator itr(0); int bufused = 0; buf[0] = (char)0; while(itr.next()) { if (itr.toString_service() == service_name) { string newRow; newRow = itr.toString_type() + " " + itr.toString_control() + " " + itr.toString_module() + " " + itr.toString_arguments() + "\n"; if (newRow.size() > (unsigned)(buflen - bufused - 1)) { pam_system_log(0, 0, LOG_ERR, "cannot load PAM configuration for %s. " "Using default configuration", service_name); buf[0] = (char)0; return; } strcpy(&buf[bufused], newRow.c_str()); bufused += (int) newRow.size(); } } return; }