1 /* Copyright (C) 2002 Ben Goodwin
2 This file is part of the nss-mysql library.
4 The nss-mysql library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as published
6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 The nss-mysql library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with the nss-mysql library; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 static const char rcsid[] =
19 "$Id: mysql-spwd.c,v 1.12 2004/11/13 16:25:26 cinergi Exp $ ";
27 MYSQL_RES *mresult_spent = NULL;
34 _nss_mysql_getspnam_r (const char *name, struct spwd *result, char *buffer,
35 size_t buflen, int *errnop)
36 #elif defined(HAVE_NSS_COMMON_H)
37 _nss_mysql_getspnam_r (nss_backend_t *be, void *args)
40 DN ("_nss_mysql_getspnam_r")
42 MYSQL_RES *mresult = NULL;
47 retVal = _nss_mysql_lookup (BYNAME, name, 0, conf.sql.query.getspnam,
48 ntrue, result, buffer, buflen, errnop,
49 _nss_mysql_load_shadow, &mresult, FUNCNAME);
51 retVal = _nss_mysql_lookup (BYNAME, NSS_ARGS(args)->key.name, 0,
52 conf.sql.query.getspnam, ntrue,
53 NSS_ARGS(args)->buf.result,
54 NSS_ARGS(args)->buf.buffer,
55 NSS_ARGS(args)->buf.buflen,
56 &NSS_ARGS(args)->erange,
57 _nss_mysql_load_shadow, &mresult, FUNCNAME);
58 if (retVal == NSS_SUCCESS)
59 NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result;
80 _nss_mysql_getspent_r (struct spwd *result, char *buffer, size_t buflen,
82 #elif defined(HAVE_NSS_COMMON_H)
83 _nss_mysql_getspent_r (nss_backend_t *be, void *args)
86 DN ("_nss_mysql_getspent_r")
92 retVal = _nss_mysql_lookup (BYNONE, NULL, 0, conf.sql.query.getspent,
93 ntrue, result, buffer, buflen, errnop,
94 _nss_mysql_load_shadow, &mresult_spent, FUNCNAME);
96 retVal = _nss_mysql_lookup (BYNONE, NULL, 0, conf.sql.query.getspent,
97 ntrue, NSS_ARGS(args)->buf.result,
98 NSS_ARGS(args)->buf.buffer,
99 NSS_ARGS(args)->buf.buflen,
100 &NSS_ARGS(args)->erange,
101 _nss_mysql_load_shadow, &mresult_spent, FUNCNAME);
102 if (retVal == NSS_SUCCESS)
103 NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result;
109 #ifdef HAVE_NSS_COMMON_H
111 static nss_backend_op_t shadow_ops[] = {
112 _nss_mysql_default_destr, /* NSS_DBOP_DESTRUCTOR */
113 _nss_mysql_endspent, /* NSS_DBOP_ENDENT */
114 _nss_mysql_setspent, /* NSS_DBOP_SETENT */
115 _nss_mysql_getspent_r, /* NSS_DBOP_GETENT */
116 _nss_mysql_getspnam_r /* NSS_DBOP_SHADOW_BYNAME */
122 #endif /* HAVE_SHADOW_H */