sss_seed.c revision 6ea6ec5cb7d9985e2730fb9d4657624d10aed4d8
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <talloc.h>
#include <popt.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <grp.h>
#include <pwd.h>
#include <fcntl.h>
#include <ctype.h>
#include "tools/tools_util.h"
#include "tools/sss_sync_ops.h"
#ifndef BUFSIZE
#define BUFSIZE 1024
#endif
#ifndef PASS_MAX
#define PASS_MAX 64
#endif
enum seed_pass_method {
};
struct user_ctx {
char *domain_name;
char *name;
char *gecos;
char *home;
char *shell;
char *password;
};
struct seed_ctx {
struct confdb_ctx *confdb;
char *password_file;
bool interact;
bool user_cached;
};
static int seed_prompt(const char *req)
{
size_t i = 0;
goto done;
}
while (prompt[i] != '\0') {
errno = 0;
if (len == -1) {
goto done;
}
}
done:
return ret;
}
const char *req,
char **_input)
{
size_t bytes_read = 0;
return ret;
}
errno = 0;
if (bytes_read == -1) {
return ret;
}
break;
}
len += bytes_read;
}
}
return ret;
}
static int seed_id_input(const char *req,
{
size_t bytes_read = 0;
return ret;
}
errno = 0;
if (bytes_read == -1) {
return ret;
}
break;
}
len += bytes_read;
}
errno = 0;
if (errno != 0) {
return ret;
}
if (*endptr != '\0') {
}
} else {
}
return ret;
}
{
goto done;
}
goto done;
}
goto done;
}
goto done;
}
ERROR("Passwords do not match\n");
goto done;
}
done:
return ret;
}
char *filename,
char **_password)
{
int len = 0;
int fd = -1;
goto done;
}
if (fd == -1) {
"[%s] [%d][%s]\n",
goto done;
}
errno = 0;
if (len == -1) {
"[%s] [%d][%s]\n",
goto done;
}
goto done;
}
done:
return ret;
}
{
if (input_uctx == NULL) {
goto done;
}
("Username interactive input failed.\n"));
goto done;
}
} else {
goto done;
}
}
goto done;
}
} else {
}
goto done;
}
} else {
}
&input_uctx->gecos);
goto done;
}
} else {
goto done;
}
}
&input_uctx->home);
("Home directory interactive input fialed.\n"));
goto done;
}
} else {
goto done;
}
}
&input_uctx->shell);
goto done;
}
} else {
goto done;
}
}
done:
} else {
}
return ret;
}
const int argc,
const char **argv,
{
int pc_debug = SSSDBG_DEFAULT;
const char *pc_password_file = NULL;
struct poptOption options[] = {
_("The debug level to run with"), NULL },
_("Comment string"), NULL},
_("Home directory"), NULL },
_("Use interactive mode to enter user data"), NULL },
_("File from which user's password is read "
"(default is to prompt for password)"),NULL },
};
/* init contexts */
goto fini;
}
goto fini;
}
goto fini;
}
debug_prg_name = argv[0];
ret = set_locale();
ERROR("Error setting the locale\n");
goto fini;
}
/* parse arguments */
if (argc < 2) {
goto fini;
}
switch (ret) {
case 'i':
break;
}
}
if (ret != -1) {
}
/* check username provided */
}
goto fini;
}
/* check domain is provided */
}
goto fini;
}
/* copy all information provided from popt */
goto fini;
}
}
goto fini;
}
}
goto fini;
}
}
/* check if password file provided */
if (pc_password_file != NULL) {
goto fini;
}
} else {
}
fini:
return ret;
}
const char *domain_name,
struct confdb_ctx **_confdb,
{
char *confdb_path = NULL;
goto done;
}
/* setup confdb */
if (confdb_path == NULL) {
goto done;
}
("Could not initialize connection to the confdb\n"));
ERROR("Could not initialize connection to the confdb\n");
goto done;
}
("Could not initialize connection to the sysdb\n"));
ERROR("Could not initialize the connection to the sysdb\n");
goto done;
}
done:
return ret;
}
static int seed_domain_user_info(const char *name,
const char *domain_name,
bool *is_cached)
{
goto done;
}
goto done;
}
errno = 0;
goto done;
}
/* look for user in cache */
("Couldn't lookup user (%s) in the cache\n", name));
goto done;
}
("User (%s) wasn't found in the cache\n", name));
*is_cached = false;
goto done;
("Multiple user (%s) entries were found in the cache\n", name));
goto done;
} else {
*is_cached = true;
errno = 0;
goto done;
}
}
done:
}
return ret;
}
{
bool in_transaction = false;
goto done;
}
in_transaction = true;
if (sctx->user_cached == false) {
("Failed to add user to the cache. (%d)[%s]\n",
ERROR("Failed to create user cache entry\n");
goto done;
}
}
ERROR("Failed to cache password\n");
goto done;
}
goto done;
}
in_transaction = false;
done:
if (in_transaction == true) {
}
}
return ret;
}
{
/* initialize seed context and parse options */
goto done;
}
/* set up confdb,sysdb and domain */
goto done;
}
/* get user info from domain */
}
/* interactive mode to fill in user information */
if (sctx->user_cached == true) {
ERROR(_("User entry already exists in the cache.\n"));
goto done;
} else {
goto done;
}
}
}
if (sctx->user_cached == false) {
/* require username, UID, and GID to continue */
ERROR("UID and primary GID not provided.\n");
goto done;
}
}
/* password input */
goto done;
}
} else {
goto done;
}
}
/* Add user info and password to sysdb cache */
goto done;
} else {
if (sctx->user_cached == false) {
}
printf(_("Temporary password added to cache entry for %1$s\n"),
}
done:
ret = EXIT_FAILURE;
} else {
ret = EXIT_SUCCESS;
}
}