/*
SSSD
sss_usermod
Copyright (C) Jakub Hrozek <jhrozek@redhat.com> 2009
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 <stdio.h>
#include <stdlib.h>
#include <talloc.h>
#include <popt.h>
#include <errno.h>
#include <pwd.h>
#include <unistd.h>
#include "tools/tools_util.h"
#include "tools/sss_sync_ops.h"
{
int pc_lock = 0;
{ "debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug, 0, _("The debug level to run with"), NULL },
{ "addattr", '\0', POPT_ARG_STRING, NULL, 't' , _("Add an attribute/value pair. The format is attrname=value."), NULL },
{ "delattr", '\0', POPT_ARG_STRING, NULL, 'd' , _("Delete an attribute/value pair. The format is attrname=value."), NULL },
{ "setattr", '\0', POPT_ARG_STRING, NULL, 's' , _("Set an attribute to a name/value pair. The format is attrname=value. For multi-valued attributes, the command replaces the values already present"), NULL },
{ "selinux-user", 'Z', POPT_ARG_STRING, &pc_selinux_user, 0, _("The SELinux user for user's login"), NULL },
};
int ret;
bool in_transaction = false;
debug_prg_name = argv[0];
ret = set_locale();
ERROR("Error setting the locale\n");
ret = EXIT_FAILURE;
goto fini;
}
/* parse parameters */
switch (ret) {
case 'a':
}
break;
case 'r':
}
break;
case 'L':
break;
case 'U':
break;
case 't':
}
break;
case 'd':
}
break;
case 's':
}
break;
}
}
if (ret != -1) {
}
/* username is an argument without --option */
if (pc_username == NULL) {
}
ERROR("Error initializing the tools - no local domain\n");
} else {
ERROR("Error initializing the tools\n");
}
ret = EXIT_FAILURE;
goto fini;
}
/* if the domain was not given as part of FQDN, default to local domain */
ERROR("Invalid domain specified in FQDN\n");
ret = EXIT_FAILURE;
goto fini;
}
/* check the username to be able to give sensible error message */
ERROR("Cannot find user in local domain, "
"modifying users is allowed only in local domain\n");
ret = EXIT_FAILURE;
goto fini;
}
ERROR("The selected UID is outside the allowed range\n");
ret = EXIT_FAILURE;
goto fini;
}
if (addgroups) {
"Cannot parse groups to add the user to\n");
ERROR("Internal error while parsing parameters\n");
ret = EXIT_FAILURE;
goto fini;
}
"Cannot parse FQDN groups to add the user to\n");
ERROR("Groups must be in the same domain as user\n");
ret = EXIT_FAILURE;
goto fini;
}
/* Check group names in the LOCAL domain */
ERROR("Cannot find group %1$s in local domain, "
"only groups in local domain are allowed\n", badgroup);
ret = EXIT_FAILURE;
goto fini;
}
}
if (rmgroups) {
"Cannot parse groups to remove the user from\n");
ERROR("Internal error while parsing parameters\n");
ret = EXIT_FAILURE;
goto fini;
}
"Cannot parse FQDN groups to remove the user from\n");
ERROR("Groups must be in the same domain as user\n");
ret = EXIT_FAILURE;
goto fini;
}
/* Check group names in the LOCAL domain */
ERROR("Cannot find group %1$s in local domain, "
"only groups in local domain are allowed\n", badgroup);
ret = EXIT_FAILURE;
goto fini;
}
}
goto done;
}
in_transaction = true;
/* usermod */
goto done;
}
goto done;
}
in_transaction = false;
ERROR("NSS request failed (%1$d). Entry might remain in memory "
"cache.\n", ret);
/* Nothing we can do about it */
}
ERROR("NSS request failed (%1$d). Entry might remain in memory "
"cache.\n", ret);
/* Nothing we can do about it */
}
ERROR("NSS request failed (%1$d). Entry might remain in memory "
"cache.\n", ret);
/* Nothing we can do about it */
}
/* Set SELinux login context - must be done after transaction is done
* b/c libselinux calls getpwnam */
ERROR("Cannot set SELinux login context\n");
ret = EXIT_FAILURE;
goto fini;
}
done:
if (in_transaction) {
}
}
switch (ret) {
case ENOENT:
ERROR("Could not modify user - check if group names are correct\n");
break;
case EFAULT:
ERROR("Could not modify user - user already member of groups?\n");
break;
default:
ERROR("Transaction error. Could not modify user.\n");
break;
}
ret = EXIT_FAILURE;
goto fini;
}
ret = EXIT_SUCCESS;
fini:
}