sss_autofs.c revision a171d77f40aa92e240e91aa4bafe5a392a98b5a2
/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2012 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <stdlib.h>
#include "sss_client/autofs/sss_autofs_private.h"
#include "sss_client/sss_cli.h"
/* Historically, autofs map names were just file names. Direct key names
* may be full directory paths
*/
#define MAX_AUTOMNTMAPNAME_LEN NAME_MAX
#define MAX_AUTOMNTKEYNAME_LEN PATH_MAX
/* How many entries shall _sss_getautomntent_r retreive at once */
#define GETAUTOMNTENT_MAX_ENTRIES 512
struct automtent {
char *mapname;
};
static struct sss_getautomntent_data {
char *mapname;
static void
{
}
{
int errnop;
char *name;
struct sss_cli_req_data rd;
uint32_t num_results = 0;
sss_nss_lock();
/* Make sure there are no leftovers from previous runs */
if (ret != 0) {
goto out;
}
goto out;
}
if (errnop != 0) {
goto out;
}
/* Get number of results from repbuf. */
/* no results if not found */
if (num_results == 0) {
goto out;
}
if (!ctx) {
goto out;
}
goto out;
}
ret = 0;
out:
return ret;
}
static errno_t
{
/* We're done with this buffer */
goto done;
}
/* The map we're looking for is not cached. Let responder
* do an implicit setautomntent */
goto done;
}
/* len is bigger than the buffer */
goto done;
}
if (len == 0) {
/* There are no more records. */
goto done;
}
goto done;
}
if (!key) {
goto done;
}
goto done;
}
if (!value) {
goto done;
}
return EOK;
done:
return ret;
}
/* The repbuf is owned by the sss_getautomntent_data once this
* function is called */
static errno_t
{
rp = 0;
if (num == 0) {
return ENOENT;
}
return ENOENT;
}
return EOK;
}
{
int errnop;
struct sss_cli_req_data rd;
sss_nss_lock();
if (!ctx) {
goto out;
}
/* Be paranoid in case someone tries to smuggle in a huge map name */
if (ret != 0) {
goto out;
}
/* The results are available from cache. Just advance the
* cursor and return. */
ret = 0;
goto out;
}
/* Don't try to handle any error codes, just go to the responder again */
sizeof(uint32_t) + /* index into the map */
sizeof(uint32_t); /* num entries to retreive */
if (!data) {
goto out;
}
if (errnop != 0) {
goto out;
}
/* Got reply, let's save it and return from "cache" */
/* No results */
goto out;
/* Unexpected error */
goto out;
}
goto out;
}
/* Advance the cursor so that we'll fetch the next map
* next time getautomntent is called */
ret = 0;
out:
return ret;
}
{
int errnop;
struct sss_cli_req_data rd;
char *buf;
sss_nss_lock();
goto out;
}
/* Be paranoid in case someone tries to smuggle in a huge map name */
if (ret != 0) {
goto out;
}
if (ret != 0) {
goto out;
}
sizeof(uint32_t) + /* keyname len */
if (!data) {
goto out;
}
if (errnop != 0) {
goto out;
}
/* Got reply, let's parse it */
rp = 0;
if (len == 0) {
/* No data */
goto out;
}
goto out;
}
if (!buf) {
goto out;
}
ret = 0;
out:
return ret;
}
_sss_endautomntent(void **context)
{
int errnop;
if (!context) return 0;
sss_nss_lock();
if (errnop != 0) {
goto out;
}
ret = 0;
out:
return ret;
}