/* simple checkpassword wrapper to send userdb data back to dovecot-auth */
#include "lib.h"
#include "str.h"
#include "strescape.h"
#include "write-full.h"
#include <unistd.h>
int main(void)
{
lib_init();
/* ORIG_UID should have the auth process's UID that forked us.
if the checkpassword changed the UID, this could be a security hole
because the UID's other processes can ptrace this process and write
any kind of a reply to fd 4. so we can run only if:
a) INSECURE_SETUID environment is set.
c) checkpassword didn't actually change the UID (but used
userdb_uid instead)
*/
if (orig_uid_env == NULL) {
i_error("checkpassword: ORIG_UID environment was dropped by checkpassword. "
"Can't verify if we're safe to run. See "
"http://wiki2.dovecot.org/AuthDatabase/CheckPassword#Security");
} else {
i_error("checkpassword: The checkpassword couldn't be run securely. See "
"http://wiki2.dovecot.org/AuthDatabase/CheckPassword#Security");
}
return 111;
}
i_error("checkpassword: USER contains TAB");
return 1;
}
}
i_error("checkpassword: HOME contains TAB");
return 1;
}
}
}
}
}
if (!uid_found)
if (!gid_found)
i_error("checkpassword: write_full() failed: %m");
exit(111);
}
if (authorized == NULL) {
/* authentication */
return 0;
return 2;
} else {
return 111;
}
}