/*
SSSD
Authors:
Stephen Gallagher <sgallagh@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 <nss.h>
#include <netdb.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "sss_cli.h"
static struct sss_nss_getservent_data {
static void sss_nss_getservent_data_clean(void) {
}
}
/* GETSERVBYNAME Request
*
* 0-X: Sequence of two, zero-terminated strings (name, protocol).
* Protocol may be zero-length to imply "any"
*
* GETSERVBYPORT Request:
* 0-3: 16-bit port number in network byte order
* 16-X: Zero-terminated string (protocol)
* Protocol may be zero-length to imply "any"
*
* Replies:
* 0-3: 32-bit unsigned number of results
* 7-X: Result data (blocks equal to number of results)
*
* Result data:
* 0-3: 32-bit unsigned port number in network byte order
* 4-7: 32-bit unsigned number of aliases
* 8-X: sequence of zero-terminated strings
* (name, protocol, zero or more aliases)
*/
struct sss_nss_svc_rep {
char *buffer;
};
static errno_t
{
uint32_t c;
char *sbuf;
/* Buffer must contain two 32-bit integers,
* at least one character and null-terminator
* for the name, and at least a null-
* terminator for the protocol.
*/
if (*len < 11) {
/* not enough space for data, bad packet */
return EBADMSG;
}
/* Get the port */
/* Get the number of aliases */
/* Copy in the name */
i = 0;
NULL);
/* Copy in the protocol */
NULL);
/* Make sure sr->buffer[i+pad] is aligned to sizeof(char *) */
pad = PADDING_SIZE(i, char *);
/* Copy in the aliases */
return ERANGE; /* not ENOMEM, ERANGE is what glibc looks for */
}
ptaliases += i;
for (l = 0; l < num_aliases; l++) {
&alen);
}
return EOK;
}
enum nss_status
const char *protocol,
int *errnop)
{
int ret;
/* Caught once glibc passing in buffer == 0x0 */
return NSS_STATUS_TRYAGAIN;
}
if (ret != 0) {
return NSS_STATUS_NOTFOUND;
}
if (protocol) {
if (ret != 0) {
return NSS_STATUS_NOTFOUND;
}
}
goto out;
}
if (protocol) {
} else {
/* No protocol specified, pass empty string */
}
sss_nss_lock();
if (nret != NSS_STATUS_SUCCESS) {
goto out;
}
/* Get number of results from repbuf. */
/* no results if not found */
if (num_results == 0) {
goto out;
}
/* only 1 result is accepted for this function */
if (num_results != 1) {
goto out;
}
&len);
if (ret) {
goto out;
}
out:
return nret;
}
enum nss_status
int *errnop)
{
size_t p = 0;
int ret;
/* Caught once glibc passing in buffer == 0x0 */
return NSS_STATUS_TRYAGAIN;
}
if (protocol) {
if (ret != 0) {
return NSS_STATUS_NOTFOUND;
}
}
goto out;
}
/* Padding */
SAFEALIGN_SET_UINT16(data + p, 0, &p);
SAFEALIGN_SET_UINT32(data + p, 0, &p);
if (protocol) {
} else {
/* No protocol specified, pass empty string */
data[p] = '\0';
}
sss_nss_lock();
if (nret != NSS_STATUS_SUCCESS) {
goto out;
}
/* Get number of results from repbuf. */
/* no results if not found */
if (num_results == 0) {
goto out;
}
/* only 1 result is accepted for this function */
if (num_results != 1) {
goto out;
}
&len);
if (ret) {
goto out;
}
out:
return nret;
}
enum nss_status
_nss_sss_setservent(void)
{
int errnop;
sss_nss_lock();
/* make sure we do not have leftovers, and release memory */
if (nret != NSS_STATUS_SUCCESS) {
}
return nret;
}
int *errnop);
enum nss_status
int *errnop)
{
sss_nss_lock();
return nret;
}
int *errnop)
{
int ret;
/* Caught once glibc passing in buffer == 0x0 */
return NSS_STATUS_TRYAGAIN;
}
/* if there are leftovers return the next one */
if (ret) {
return NSS_STATUS_TRYAGAIN;
}
/* advance buffer pointer */
return NSS_STATUS_SUCCESS;
}
/* release memory if any */
/* retrieve no more than SSS_NSS_MAX_ENTRIES at a time */
if (nret != NSS_STATUS_SUCCESS) {
return nret;
}
/* Get number of results from repbuf */
/* no results if not found */
return NSS_STATUS_NOTFOUND;
}
/* skip metadata fields */
/* call again ourselves, this will return the first result */
}
enum nss_status
_nss_sss_endservent(void)
{
int errnop;
sss_nss_lock();
/* make sure we do not have leftovers, and release memory */
if (nret != NSS_STATUS_SUCCESS) {
}
return nret;
}