sss_autofs.c revision 0a78bac242d0172a858d6b65402276aa734a4671
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen Jakub Hrozek <jhrozek@redhat.com>
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen Copyright (C) 2012 Red Hat
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen This program is free software; you can redistribute it and/or modify
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen it under the terms of the GNU General Public License as published by
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen the Free Software Foundation; either version 3 of the License, or
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen (at your option) any later version.
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen This program is distributed in the hope that it will be useful,
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen GNU General Public License for more details.
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen You should have received a copy of the GNU General Public License
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen#include "sss_client/autofs/sss_autofs_private.h"
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen/* Historically, autofs map and key names were just file names */
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen/* How many entries shall _sss_getautomntent_r retreive at once */
3809b9691c46926aa54968ac8e418d04361e1efaTimo Sirainen memset(&sss_getautomntent_data, 0, sizeof(struct sss_getautomntent_data));
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen_sss_setautomntent(const char *mapname, void **context)
87b426af6a2365c6840b14281a98c23e903bf28eTimo Sirainen /* Make sure there are no leftovers from previous runs */
19e8adccba16ff419f5675b1575358c2956dce83Timo Sirainen ret = sss_strnlen(mapname, MAX_AUTOMNTMAPNAME_LEN, &name_len);
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen sss_autofs_make_request(SSS_AUTOFS_SETAUTOMNTENT, &rd,
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainen /* no results if not found */
7fb70daba4e571eab5b64f496d20b9e37e31141bTimo Sirainensss_getautomntent_data_return(const char *mapname, char **_key, char **_value)
27a7dee37444438522e04273ce17e6c48775b35cTimo Sirainen sss_getautomntent_data.ptr >= sss_getautomntent_data.len) {
27a7dee37444438522e04273ce17e6c48775b35cTimo Sirainen /* We're done with this buffer */
27a7dee37444438522e04273ce17e6c48775b35cTimo Sirainen ret = strcmp(mapname, sss_getautomntent_data.mapname);
27a7dee37444438522e04273ce17e6c48775b35cTimo Sirainen /* The map we're looking for is not cached. Let responder
27a7dee37444438522e04273ce17e6c48775b35cTimo Sirainen * do an implicit setautomntent */
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen SAFEALIGN_COPY_UINT32(&len, sss_getautomntent_data.data+dp, &dp);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (len + sss_getautomntent_data.ptr > sss_getautomntent_data.len) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen /* len is bigger than the buffer */
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen /* There are no more records. */
goto done;
goto done;
if (!key) {
goto done;
goto done;
if (!value) {
goto done;
return EOK;
done:
return ret;
static errno_t
rp = 0;
if (num == 0) {
return ENOENT;
return ENOENT;
return EOK;
int errnop;
uint32_t v;
sss_nss_lock();
if (!ctx) {
goto out;
if (ret != 0) {
goto out;
ret = 0;
goto out;
ret = 0;
if (!data) {
goto out;
if (errnop != 0) {
goto out;
goto out;
goto out;
goto out;
ret = 0;
out:
return ret;
int errnop;
uint32_t v;
char *buf;
sss_nss_lock();
goto out;
if (ret != 0) {
goto out;
if (ret != 0) {
goto out;
if (!data) {
goto out;
v = name_len;
v = key_len;
if (errnop != 0) {
goto out;
rp = 0;
if (len == 0) {
goto out;
goto out;
if (!buf) {
goto out;
ret = 0;
out:
return ret;
int errnop;
if (!context) return 0;
sss_nss_lock();
if (errnop != 0) {
goto out;
ret = 0;
out:
return ret;