userdb-passwd.c revision 66d2db642fe24d555d113ba463e446b038d476ef
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/* Copyright (C) 2002-2003 Timo Sirainen */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen#include "config.h"
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen#undef HAVE_CONFIG_H
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
76a99afe0914951d20d96e0bf5e6d8d3ea3fd503Timo Sirainen#ifdef USERDB_PASSWD
55639052253ff28c6a0f569ae76dfda33e02c5f2Timo Sirainen
bdd36cfdba3ff66d25570a9ff568d69e1eb543cfTimo Sirainen#include "common.h"
76a99afe0914951d20d96e0bf5e6d8d3ea3fd503Timo Sirainen#include "userdb.h"
596ec384269cad3b0f0661df89b9cf33cbd171b7Timo Sirainen
666286d8ecc6c450b2232dcc628f79454215acfcTimo Sirainen#include <pwd.h>
2521fd0986302cdabc8b0711eef63ac188f32cd6Timo Sirainen
b039dabf4c53f72454e795930e7643b6e0e625f9Timo Sirainenstatic void passwd_lookup(struct auth_request *auth_request,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen userdb_callback_t *callback)
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen{
fa3fc0b4c821874ccc56a1512604f661b411d3a4Aki Tuomi struct passwd *pw;
fa3fc0b4c821874ccc56a1512604f661b411d3a4Aki Tuomi const char *result;
7f4fa37676bac8efcf4e2ac706172b1bad779a8aMartti Rannanjärvi
94e1adead9faddec88a623485b9999a87b1684faTimo Sirainen pw = getpwnam(auth_request->user);
503e5ef896c7b4a51cf73efb0d132860a8c747e6Timo Sirainen if (pw == NULL) {
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen auth_request_log_info(auth_request, "passwd", "unknown user");
cb2b5a7d6e7e651191bf9ee1eda94a6e207288b0Timo Sirainen callback(NULL, auth_request);
cb2b5a7d6e7e651191bf9ee1eda94a6e207288b0Timo Sirainen return;
2521fd0986302cdabc8b0711eef63ac188f32cd6Timo Sirainen }
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
55639052253ff28c6a0f569ae76dfda33e02c5f2Timo Sirainen result = t_strdup_printf("%s\tsystem_user=%s\tuid=%s\tgid=%s\t"
55639052253ff28c6a0f569ae76dfda33e02c5f2Timo Sirainen "home=%s", pw->pw_name, pw->pw_name,
55639052253ff28c6a0f569ae76dfda33e02c5f2Timo Sirainen dec2str(pw->pw_uid), dec2str(pw->pw_gid),
55639052253ff28c6a0f569ae76dfda33e02c5f2Timo Sirainen pw->pw_dir);
55639052253ff28c6a0f569ae76dfda33e02c5f2Timo Sirainen callback(result, auth_request);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen}
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenstruct userdb_module userdb_passwd = {
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen "passwd",
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen FALSE,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen NULL, NULL, NULL,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen passwd_lookup
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen};
c4db1218645ed8ec8b5ae67c05bc5d7a80c1b8aeTimo Sirainen
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen#endif
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen