proxy_services.c revision 681742138b2afbbefa7f14de937beb438409208e
/*
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 "util/strtonum.h"
#include "db/sysdb_services.h"
#define BUFLEN 1024
struct sss_domain_info *domain,
bool lowercase,
{
char *cased_name;
const char **protocols;
const char **cased_aliases;
if (!cased_name) {
goto done;
}
if (!protocols) {
goto done;
}
!lowercase);
if (!protocols[0]) {
goto done;
}
/* Count the aliases */
!lowercase, &cased_aliases);
goto done;
}
now);
done:
return ret;
}
struct sss_domain_info *dom,
const char *name,
const char *protocol)
{
enum nss_status status;
if (!result) {
goto done;
}
("getservbyname_r failed for service [%s].\n", name));
return ret;
}
if (status == NSS_STATUS_NOTFOUND) {
/* Make sure we remove it from the cache */
} else {
/* Results found. Save them into the cache */
}
done:
return ret;
}
struct sss_domain_info *dom,
const char *be_filter,
const char *protocol)
{
enum nss_status status;
if (!result) {
goto done;
}
errno = 0;
if (errno) {
goto done;
}
("getservbyport_r failed for service [%s].\n", be_filter));
return ret;
}
if (status == NSS_STATUS_NOTFOUND) {
/* Make sure we remove it from the cache */
} else {
/* Results found. Save them into the cache */
}
done:
return ret;
}
struct sss_domain_info *dom)
{
bool in_transaction = false;
enum nss_status status;
char *buffer;
char *newbuf;
const char **cased_aliases;
bool again;
if (!tmpctx) {
return ENOMEM;
}
if (!svc) {
goto done;
}
if (!buffer) {
goto done;
}
if (ret) {
goto done;
}
in_transaction = true;
if (status != NSS_STATUS_SUCCESS) {
goto done;
}
do {
again = false;
/* always zero out the svc structure */
/* get entry */
switch (status) {
case NSS_STATUS_TRYAGAIN:
/* buffer too small ? */
if (buflen < MAX_BUF_SIZE) {
buflen *= 2;
}
if (buflen > MAX_BUF_SIZE) {
}
if (!newbuf) {
goto done;
}
again = true;
break;
case NSS_STATUS_NOTFOUND:
/* we are done here */
goto done;
}
in_transaction = false;
break;
case NSS_STATUS_SUCCESS:
("Service found (%s, %d/%s)\n",
if (!protocols[0]) {
goto done;
}
/* Do not fail completely on errors.
* Just report the failure to save and go on */
("Failed to store service [%s]. Ignoring.\n",
again = true;
break;
}
now);
if (ret) {
/* Do not fail completely on errors.
* Just report the failure to save and go on */
("Failed to store service [%s]. Ignoring.\n",
}
again = true;
break;
case NSS_STATUS_UNAVAIL:
/* "remote" backend unavailable. Enter offline mode */
break;
default:
("proxy -> getservent_r failed (%d)[%s]\n",
break;
}
} while (again);
done:
if (in_transaction) {
("Could not cancel transaction! [%s]\n",
}
}
return ret;
}