sss_sync_ops.c revision ace612f5998f619ba41828d2ba4b80d02a965162
/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2009 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 <tevent.h>
#include <talloc.h>
#include "tools/sss_sync_ops.h"
/* Default settings for user attributes */
#define DFL_SHELL_VAL "/bin/bash"
#define DFL_BASEDIR_VAL "/home"
#define DFL_CREATE_HOMEDIR "TRUE"
#define DFL_REMOVE_HOMEDIR "TRUE"
#define DFL_UMASK 077
#define DFL_SKEL_DIR "/etc/skel"
#define DFL_MAIL_DIR "/var/spool/mail"
return val; \
} \
} while(0)
tevent_loop_once(ev); \
} \
} while(0)
struct sync_op_res {
int error;
bool done;
};
/*
* Generic recv function
*/
{
return EOK;
}
/*
* Generic add member to group
*/
struct add_to_groups_state {
struct tevent_context *ev;
struct sysdb_handle *handle;
int cur;
};
struct tevent_context *ev,
struct sysdb_handle *handle,
{
struct add_to_groups_state *state;
struct tevent_req *req;
struct tevent_req *subreq;
return NULL;
}
if (!parent_dn) {
return NULL;
}
if (!subreq) {
return NULL;
}
return req;
}
{
struct tevent_req);
struct add_to_groups_state);
int ret;
struct tevent_req *next_group_req;
if (ret) {
return;
}
/* go on to next group */
/* check if we added all of them */
return;
}
/* if not, schedule a new addition */
if (!parent_dn) {
return;
}
if (!next_group_req) {
return;
}
}
{
return sync_ops_recv(req);
}
/*
* Generic remove member from group
*/
struct remove_from_groups_state {
struct tevent_context *ev;
struct sysdb_handle *handle;
int cur;
};
struct tevent_context *ev,
struct sysdb_handle *handle,
{
struct tevent_req *req;
struct tevent_req *subreq;
struct remove_from_groups_state *state;
return NULL;
}
if (!parent_dn) {
return NULL;
}
if (!subreq) {
return NULL;
}
return req;
}
{
struct tevent_req);
struct remove_from_groups_state);
int ret;
struct tevent_req *next_group_req;
if (ret) {
return;
}
/* go on to next group */
/* check if we removed all of them */
return;
}
/* if not, schedule a new removal */
if (!parent_dn) {
return;
}
if (!next_group_req) {
return;
}
}
{
return sync_ops_recv(req);
}
/*
* Modify a user
*/
struct user_mod_state {
struct tevent_context *ev;
struct sysdb_handle *handle;
struct sysdb_attrs *attrs;
};
const char *gecos,
const char *home,
const char *shell,
int lock,
struct sysdb_attrs **_attrs)
{
int ret;
struct sysdb_attrs *attrs;
return ENOMEM;
}
if (shell) {
shell);
"Could not add attribute to changeset\n");
}
if (home) {
home);
"Could not add attribute to changeset\n");
}
if (gecos) {
gecos);
"Could not add attribute to changeset\n");
}
if (uid) {
uid);
"Could not add attribute to changeset\n");
}
if (gid) {
gid);
"Could not add attribute to changeset\n");
}
"true");
"Could not add attribute to changeset\n");
}
/* PAM code checks for 'false' value in SYSDB_DISABLED attribute */
"false");
"Could not add attribute to changeset\n");
}
return EOK;
}
struct tevent_context *ev,
struct sysdb_handle *handle,
{
struct tevent_req *req;
struct tevent_req *subreq;
int ret;
return NULL;
}
return NULL;
}
}
return NULL;
}
if (!subreq) {
return NULL;
}
return req;
}
{
struct tevent_req);
struct user_mod_state);
struct tevent_req *groupreq;
int ret;
if (ret) {
return;
}
}
if (!groupreq) {
return;
}
return;
}
if (!groupreq) {
return;
}
return;
}
/* No changes to be made, mark request as done */
}
{
struct tevent_req);
struct user_mod_state);
int ret;
struct tevent_req *addreq;
if (ret) {
return;
}
if (!addreq) {
}
return;
}
return;
}
{
struct tevent_req);
int ret;
if (ret) {
return;
}
return;
}
{
return sync_ops_recv(req);
}
/*
* Modify a group
*/
struct group_mod_state {
struct tevent_context *ev;
struct sysdb_handle *handle;
struct sysdb_attrs *attrs;
};
static void group_mod_attr_wakeup(struct tevent_req *);
struct tevent_context *ev,
struct sysdb_handle *handle,
{
struct group_mod_state *state;
struct tevent_req *req;
struct tevent_req *subreq;
return NULL;
}
return NULL;
}
}
if (!subreq) {
return NULL;
}
return req;
}
{
struct tevent_req);
struct group_mod_state);
struct sysdb_attrs *attrs;
struct tevent_req *groupreq;
int ret;
if (!attrs) {
return;
}
if (ret) {
return;
}
if (ret) {
return;
}
}
if (!groupreq) {
return;
}
return;
}
if (!groupreq) {
return;
}
return;
}
/* No changes to be made, mark request as done */
}
{
struct tevent_req);
struct group_mod_state);
int ret;
struct tevent_req *addreq;
if (ret) {
return;
}
if (!addreq) {
}
return;
}
return;
}
{
struct tevent_req);
int ret;
if (ret) {
return;
}
return;
}
{
return sync_ops_recv(req);
}
struct confdb_ctx *confdb,
int remove_home)
{
int ret;
char *conf_path;
bool dfl_remove_home;
if (!conf_path) {
return ENOMEM;
}
/* remove homedir on user creation? */
if (!remove_home) {
goto done;
}
} else {
}
/* a directory to remove mail spools from */
goto done;
}
done:
return ret;
}
/*
* Default values for add operations
*/
struct confdb_ctx *confdb,
const char *gecos,
const char *homedir,
const char *shell,
int create_home,
const char *skeldir)
{
int ret;
if (!conf_path) {
return ENOMEM;
}
/* gecos */
goto done;
}
/* homedir */
if (homedir) {
} else {
goto done;
}
}
goto done;
}
/* default shell */
if (!shell) {
goto done;
}
} else {
goto done;
}
}
/* create homedir on user creation? */
if (!create_home) {
goto done;
}
} else {
}
/* umask to create homedirs */
goto done;
}
/* a directory to create mail spools in */
goto done;
}
/* skeleton dir */
if (!skeldir) {
goto done;
}
} else {
goto done;
}
}
done:
return ret;
}
/*
* Public interface for adding users
*/
static void useradd_done(struct tevent_req *);
struct tevent_context *ev,
struct sysdb_handle *handle,
{
int ret;
struct tevent_req *req;
if (!res) {
return ENOMEM;
}
if (ret) {
goto done;
}
if (!member_dn) {
goto done;
}
if (!req) {
goto done;
}
}
done:
return ret;
}
{
int ret;
struct sync_op_res);
if (ret) {
}
}
/*
* Public interface for deleting users
*/
{
int ret;
if (!user_dn) {
return ENOMEM;
}
if (ret) {
}
return ret;
}
/*
* Public interface for modifying users
*/
struct tevent_context *ev,
struct sysdb_handle *handle,
{
int ret;
struct tevent_req *req;
if (!res) {
return ENOMEM;
}
if (!req) {
return ENOMEM;
}
return ret;
}
{
int ret;
struct sync_op_res);
if (ret) {
}
}
/*
* Public interface for adding groups
*/
struct tevent_context *ev,
struct sysdb_handle *handle,
{
int ret;
}
return ret;
}
/*
* Public interface for deleting groups
*/
{
int ret;
return ENOMEM;
}
if (ret) {
}
return ret;
}
/*
* Public interface for modifying groups
*/
struct tevent_context *ev,
struct sysdb_handle *handle,
{
int ret;
struct tevent_req *req;
if (!res) {
return ENOMEM;
}
if (!req) {
return ENOMEM;
}
return ret;
}
{
int ret;
struct sync_op_res);
if (ret) {
}
}
/*
* Synchronous transaction functions
*/
{
struct tevent_req *req;
/* make sure handle is NULL, as it is the spy to check if the transaction
* has been started */
if (!req) {
return;
}
/* loop to obtain a transaction */
}
}
{
struct tools_ctx);
int ret;
if (ret) {
}
}
}
{
struct tevent_req *req;
if (!req) {
/* free transaction and signal error */
return;
}
/* loop to obtain a transaction */
}
}
{
struct tools_ctx);
int ret;
tctx->transaction_done = true;
}
/*
* getpwnam, getgrnam and friends
*/
struct ldb_result *lrs);
struct tevent_context *ev,
const char *name,
struct sss_domain_info *domain,
{
int ret;
if (!res) {
return ENOMEM;
}
return EINVAL;
}
name,
res);
return ret;
}
struct ldb_result *lrs)
{
const char *str;
if (status != LDB_SUCCESS) {
return;
}
case 0:
break;
case 1:
/* fill ops_ctx */
SYSDB_UIDNUM, 0);
SYSDB_GIDNUM, 0);
SYSDB_NAME, NULL);
return;
}
SYSDB_GECOS, NULL);
return;
}
return;
}
SYSDB_SHELL, NULL);
return;
}
} else {
} else { /* Invalid value */
return;
}
}
break;
default:
break;
}
}
struct ldb_result *lrs);
struct tevent_context *ev,
const char *name,
struct sss_domain_info *domain,
{
int ret;
if (!res) {
return ENOMEM;
}
return EINVAL;
}
name,
res);
return ret;
}
struct ldb_result *lrs)
{
const char *str;
if (status != LDB_SUCCESS) {
return;
}
case 0:
break;
/* sysdb_getgrnam also returns members */
default:
/* fill ops_ctx */
SYSDB_GIDNUM, 0);
SYSDB_NAME, NULL);
return;
}
break;
}
}