sss_tools.c revision 81cde110402e088508053aea79670b38d450cb83
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2015 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 <talloc.h>
#include <stdlib.h>
#include <string.h>
#include <popt.h>
#include "config.h"
#include "tools/common/sss_tools.h"
struct sss_cmdline {
const char *exec; /* argv[0] */
const char *command; /* command name */
int argc; /* rest of arguments */
const char **argv;
};
static void sss_tool_print_common_opts(int min_len)
{
_("The debug level to run with"));
_("Show this for a command"));
_("Show brief usage message for a command"));
}
static struct poptOption *sss_tool_common_opts_table(void)
{
static struct poptOption common_opts[] = {
};
return common_opts;
}
{
int debug = SSSDBG_DEFAULT;
int opt;
struct poptOption options[] = {
0, _("The debug level to run with"), NULL },
};
/* do nothing */
}
/* Strip common options from arguments. We will discard_const here,
* since it is not worth the trouble to convert it back and forth. */
}
struct confdb_ctx **_confdb)
{
struct confdb_ctx *confdb;
char *path;
return ENOMEM;
}
"Could not initialize connection to the confdb\n");
return ret;
}
}
return EOK;
}
struct confdb_ctx *confdb,
struct sss_domain_info **_domains)
{
struct sss_domain_info *domains;
struct sss_domain_info *dom;
return ret;
}
"Could not initialize connection to the sysdb\n");
return ret;
}
if (!IS_SUBDOMAIN(dom)) {
/* Get flat name and domain ID (SID) from the cache
* if available */
}
/* Update list of subdomains for this domain */
"Failed to update subdomains for domain %s.\n",
}
}
}
return ret;
}
}
return ret;
}
{
struct sss_tool_ctx *tool_ctx;
return NULL;
}
/* Connect to confdb. */
goto done;
}
/* Setup domains. */
goto done;
}
goto done;
}
done:
}
return tool_ctx;
}
{
return true;
}
return false;
}
{
int i;
if (sss_tool_is_delimiter(&commands[i])) {
continue;
}
}
}
return max;
}
int sss_tool_usage(const char *tool_name,
struct sss_route_cmd *commands)
{
int min_len;
int i;
if (sss_tool_is_delimiter(&commands[i])) {
continue;
}
} else {
}
}
return EXIT_FAILURE;
}
struct sss_tool_ctx *tool_ctx,
struct sss_route_cmd *commands,
void *pvt)
{
struct sss_cmdline cmdline;
const char *cmd;
int i;
return EXIT_FAILURE;
}
if (argc < 2) {
}
if (sss_tool_is_delimiter(&commands[i])) {
continue;
}
}
}
}
{
static struct poptOption empty[] = {
};
return empty;
}
return options;
}
struct poptOption *options,
enum sss_tool_opt require_option,
void *popt_fn_pvt,
const char *fopt_name,
const char *fopt_help,
const char **_fopt,
bool *_opt_set)
{
struct poptOption opts_table[] = {
0, _("Command options:"), NULL },
0, _("Common options:"), NULL },
};
const char *fopt;
char *help;
bool opt_set;
int ret;
/* Create help option string. We always need to append command name since
* we use POPT_CONTEXT_KEEP_FIRST. */
} else {
}
return EXIT_FAILURE;
}
/* Create popt context. This function is supposed to be called on
* command argv which does not contain executable (argv[0]), therefore
* we need to use KEEP_FIRST that ensures argv[0] is also processed. */
/* Parse options. Invoke custom function if provided. If no parsing
* function is provided, print error on unknown option. */
ret = EXIT_FAILURE;
goto done;
}
} else {
ret = EXIT_FAILURE;
goto done;
}
}
/* Parse free option which is always required if requested. */
ret = EXIT_FAILURE;
goto done;
}
/* No more arguments expected. If something follows it is an error. */
if (poptGetArg(pc)) {
ret = EXIT_FAILURE;
goto done;
}
/* Unexpected free argument. */
ret = EXIT_FAILURE;
goto done;
}
opt_set = true;
opt_set = false;
/* If at least one option is required and not provided, print error. */
if (require_option == SSS_TOOL_OPT_REQUIRED) {
ret = EXIT_FAILURE;
goto done;
}
}
}
ret = EXIT_SUCCESS;
done:
return ret;
}
struct poptOption *options,
enum sss_tool_opt require_option,
void *popt_fn_pvt)
{
}
struct sss_route_cmd *commands,
void *pvt)
{
struct sss_tool_ctx *tool_ctx;
int ret;
if (uid != 0) {
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
return ret;
}
struct sss_tool_ctx *tool_ctx,
const char *input,
const char **_username,
struct sss_domain_info **_domain)
{
struct sss_domain_info *domain;
int ret;
"be a subdomain that was not yet found.\n");
goto done;
goto done;
}
done:
}
return ret;
}