sss_userdel.c revision e391eb27c711a5d51f7a5ad92928212fdcb3133a
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek Copyright (C) Jakub Hrozek <jhrozek@redhat.com> 2009
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek This program is free software; you can redistribute it and/or modify
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek it under the terms of the GNU General Public License as published by
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek (at your option) any later version.
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek This program is distributed in the hope that it will be useful,
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek GNU General Public License for more details.
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek You should have received a copy of the GNU General Public License
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozekstatic int is_logged_in(TALLOC_CTX *mem_ctx, uid_t uid)
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov ret = hash_lookup(uid_table, &key, &value);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce /* parent */
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce while((child_pid = waitpid(pid, &status, 0)) > 0) {
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_CRIT_FAILURE, ("waitpid failed\n"));
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce { "debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce _("Remove home directory and mail spool"), NULL },
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce _("Do not remove home directory and mail spool"), NULL },
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce _("Force removal of files not owned by the user"), NULL },
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce _("Kill users' processes before removing him"), NULL },
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(1, ("set_locale failed (%d): %s\n", ret, strerror(ret)));
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce /* parse parameters */
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce pc = poptGetContext(NULL, argc, argv, long_options, 0);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce BAD_POPT_PARAMS(pc, _("Specify user to delete\n"), ret, fini);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(1, ("init_sss_tools failed (%d): %s\n", ret, strerror(ret)));
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ERROR("Error initializing the tools - no local domain\n");
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce /* if the domain was not given as part of FQDN, default to local domain */
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce * Fills in defaults for ops_ctx user did not specify.
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = userdel_defaults(tctx, tctx->confdb, tctx->octx, pc_remove);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce /* Error message will be printed in the switch */
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce (tctx->local->id_max && tctx->octx->uid > tctx->local->id_max)) {
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ERROR("User %1$s is outside the defined ID range for domain\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce /* userdel */
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce /* Set SELinux login context - must be done after transaction is done
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce * b/c libselinux calls getpwnam */
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ERROR("WARNING: The user (uid %1$lu) was still logged in when "
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ERROR("Cannot determine if the user was logged in on this "
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce "platform");
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ERROR("Error while checking if the user was logged in\n");
goto fini;
pc_force);
goto fini;
done:
if (ret) {
switch (ret) {
case ENOENT:
goto fini;
fini: