sss_sync_ops.c revision 87f8bee53ee1b4ca87b602ff8536bc5fd5b5b595
/*
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"
#define ATTR_NAME_SEP '='
#define ATTR_VAL_SEP ','
return val; \
} \
} while(0)
{
char *name;
char **values;
const char *vals;
int nvals;
goto done;
}
goto done;
}
vals++;
goto done;
}
done:
return ret;
}
{
struct sysdb_attrs *attrs;
char *name;
char **vals;
int nvals;
int i;
switch(op) {
case SYSDB_MOD_ADD:
case SYSDB_MOD_DEL:
case SYSDB_MOD_REP:
break;
default:
return EINVAL;
}
goto done;
}
goto done;
}
for (i=0; i < nvals; i++) {
continue;
}
}
done:
return ret;
}
/*
* Generic modify groups member
*/
char **grouplist,
int optype)
{
int ret;
int i;
if (!tmpctx) {
return ENOMEM;
}
/* FIXME: add transaction around loop */
for (i = 0; grouplist[i]; i++) {
if (!parent_dn) {
goto done;
}
if (ret) {
goto done;
}
}
done:
return ret;
}
/*
* Modify a user
*/
struct user_mod_state {
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;
}
/*
* Public interface for modifying users
*/
{
int ret;
if (!member_dn) {
return ENOMEM;
}
}
&attrs);
return ret;
}
if (ret) {
return ret;
}
}
if (ret) {
return ret;
}
}
if (ret) {
return ret;
}
}
if (ret) {
return ret;
}
}
if (ret) {
return ret;
}
}
if (ret) {
return ret;
}
}
return EOK;
}
/*
* Public interface for modifying groups
*/
{
int ret;
if (!member_dn) {
return ENOMEM;
}
}
if (!attrs) {
return ENOMEM;
}
if (ret) {
return ret;
}
if (ret) {
return ret;
}
}
if (ret) {
return ret;
}
}
if (ret) {
return ret;
}
}
return EOK;
}
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
*/
{
int ret;
if (ret) {
goto done;
}
if (!member_dn) {
goto done;
}
if (ret) {
goto done;
}
}
done:
return ret;
}
/*
* Public interface for deleting users
*/
{
int ret;
if (!user_dn) {
return ENOMEM;
}
if (ret) {
}
return ret;
}
/*
* Public interface for adding groups
*/
{
int ret;
}
return ret;
}
/*
* Public interface for deleting groups
*/
{
int ret;
return ENOMEM;
}
if (ret) {
}
return ret;
}
/*
* getpwnam, getgrnam and friends
*/
const char *name,
{
struct ldb_result *res;
const char *str;
int ret;
if (ret) {
return ret;
}
case 0:
return ENOENT;
case 1:
/* fill ops_ctx */
return ENOMEM;
}
return ENOMEM;
}
return ENOMEM;
}
return ENOMEM;
}
} else {
} else { /* Invalid value */
return EIO;
}
}
break;
default:
"More than one result for sysdb_getpwnam call\n");
return EIO;
}
return EOK;
}
const char *name,
{
struct ldb_result *res;
const char *str;
int ret;
if (ret) {
return ret;
}
case 0:
return ENOENT;
case 1:
/* fill ops_ctx */
return ENOMEM;
}
break;
default:
"More than one result for sysdb_getgrnam call\n");
return EIO;
}
return EOK;
}