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-pwd.c,v 1.11 2004/11/13 16:25:26 cinergi Exp $ ";
26 MYSQL_RES *mresult_pwent = NULL;
33 _nss_mysql_getpwnam_r (const char *name, struct passwd *result, char *buffer,
34 size_t buflen, int *errnop)
35 #elif defined(HAVE_NSS_COMMON_H)
36 _nss_mysql_getpwnam_r (nss_backend_t *be, void *args)
39 DN ("_nss_mysql_getpwnam_r")
41 MYSQL_RES *mresult = NULL;
46 retVal = _nss_mysql_lookup (BYNAME, name, 0, conf.sql.query.getpwnam,
47 nfalse, result, buffer, buflen, errnop,
48 _nss_mysql_load_passwd, &mresult, FUNCNAME);
50 retVal = _nss_mysql_lookup (BYNAME, NSS_ARGS(args)->key.name, 0,
51 conf.sql.query.getpwnam, nfalse,
52 NSS_ARGS(args)->buf.result,
53 NSS_ARGS(args)->buf.buffer,
54 NSS_ARGS(args)->buf.buflen,
55 &NSS_ARGS(args)->erange,
56 _nss_mysql_load_passwd, &mresult, FUNCNAME);
57 if (retVal == NSS_SUCCESS)
58 NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result;
69 _nss_mysql_getpwuid_r (uid_t uid, struct passwd *result, char *buffer,
70 size_t buflen, int *errnop)
71 #elif defined(HAVE_NSS_COMMON_H)
72 _nss_mysql_getpwuid_r (nss_backend_t *be, void *args)
75 DN ("_nss_mysql_getpwuid_r")
77 MYSQL_RES *mresult = NULL;
82 retVal = _nss_mysql_lookup (BYNUM, NULL, uid, conf.sql.query.getpwuid,
83 nfalse, result, buffer, buflen, errnop,
84 _nss_mysql_load_passwd, &mresult, FUNCNAME);
86 retVal = _nss_mysql_lookup (BYNUM, NULL, NSS_ARGS(args)->key.uid,
87 conf.sql.query.getpwuid, nfalse,
88 NSS_ARGS(args)->buf.result,
89 NSS_ARGS(args)->buf.buffer,
90 NSS_ARGS(args)->buf.buflen,
91 &NSS_ARGS(args)->erange,
92 _nss_mysql_load_passwd, &mresult, FUNCNAME);
93 if (retVal == NSS_SUCCESS)
94 NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result;
115 _nss_mysql_getpwent_r (struct passwd *result, char *buffer, size_t buflen,
117 #elif defined(HAVE_NSS_COMMON_H)
118 _nss_mysql_getpwent_r (nss_backend_t *be, void *args)
121 DN ("_nss_mysql_getpwent_r")
127 retVal = _nss_mysql_lookup (BYNONE, NULL, 0, conf.sql.query.getpwent,
128 nfalse, result, buffer, buflen, errnop,
129 _nss_mysql_load_passwd, &mresult_pwent, FUNCNAME);
131 retVal = _nss_mysql_lookup (BYNONE, NULL, 0, conf.sql.query.getpwent,
132 nfalse, NSS_ARGS(args)->buf.result,
133 NSS_ARGS(args)->buf.buffer,
134 NSS_ARGS(args)->buf.buflen,
135 &NSS_ARGS(args)->erange,
136 _nss_mysql_load_passwd, &mresult_pwent, FUNCNAME);
137 if (retVal == NSS_SUCCESS)
138 NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result;
144 #ifdef HAVE_NSS_COMMON_H
146 static nss_backend_op_t passwd_ops[] = {
147 _nss_mysql_default_destr, /* NSS_DBOP_DESTRUCTOR */
148 _nss_mysql_endpwent, /* NSS_DBOP_ENDENT */
149 _nss_mysql_setpwent, /* NSS_DBOP_SETENT */
150 _nss_mysql_getpwent_r, /* NSS_DBOP_GETENT */
151 _nss_mysql_getpwnam_r, /* NSS_DBOP_PASSWD_BYNAME */
152 _nss_mysql_getpwuid_r /* NSS_DBOP_PASSWD_BYUID */