]> andersk Git - moira.git/blame - clients/moira/delete.c
sms -> moira
[moira.git] / clients / moira / delete.c
CommitLineData
402461ad 1#if (!defined(lint) && !defined(SABER))
08345b74 2 static char rcsid_module_c[] = "$Header$";
3#endif lint
4
8defc06b 5/* This is the file delete.c for the MOIRA Client, which allows a nieve
6 * user to quickly and easily maintain most parts of the MOIRA database.
08345b74 7 * It Contains: functions for deleting users and lists.
8 *
9 * Created: 5/18/88
10 * By: Chris D. Peterson
11 *
12 * $Source$
13 * $Author$
14 * $Header$
15 *
0a2c64cb 16 * Copyright 1988 by the Massachusetts Institute of Technology.
08345b74 17 *
18 * For further information on copyright and distribution
19 * see the file mit-copyright.h
20 */
21
08345b74 22#include <stdio.h>
23#include <strings.h>
8defc06b 24#include <moira.h>
25#include <moira_site.h>
08345b74 26#include <menu.h>
27
461c03b6 28#include "mit-copyright.h"
0a2c64cb 29#include "defs.h"
30#include "f_defs.h"
461c03b6 31#include "globals.h"
461c03b6 32
08345b74 33/* Function Name: CheckListForDeletion
34 * Description: Check one of the lists in which we just removed a member.
35 * if the list is empty then it will delete it.
36 * Arguments: name - name of the list to check.
37 * verbose - verbose mode?
38 * Returns: none.
39 */
40
41void
42CheckListForDeletion(name, verbose)
43char * name;
44Bool verbose;
45{
461c03b6 46 struct qelem *elem = NULL;
075fe5bb 47 int status;
461c03b6 48 char *args[2], buf[BUFSIZ], **info;
08345b74 49
8defc06b 50 if ( (status = do_mr_query("count_members_of_list", 1, &name, StoreInfo,
14f99d7d 51 (char *) &elem)) != 0) {
461c03b6 52 com_err(program_name, status,
53 " in DeleteList (count_members_of_list).");
54 return;
08345b74 55 }
461c03b6 56 info = (char **) elem->q_data;
0a2c64cb 57 if ( strcmp(info[NAME],"0") == 0) {
461c03b6 58 if (verbose) {
59 sprintf(buf, "Delete the empty list %s? ", name);
075fe5bb 60 if (YesNoQuestion(buf, FALSE) != TRUE) {
461c03b6 61 Put_message("Aborting Deletion!");
62 FreeQueue(elem);
63 return;
64 }
08345b74 65 }
461c03b6 66 args[0] = "foo"; /* not used. */
67 args[1] = name;
68 DeleteList(2, args);
08345b74 69 }
461c03b6 70 FreeQueue(elem);
08345b74 71}
72
075fe5bb 73/* Function Name: CheckAce
74 * Description: Checks an ace to see of we should delete it.
75 * Arguments: type - the type of this ace.
76 * name - the name of the ace.
08345b74 77 * verbose - query user?
78 * Returns: none.
79 */
80
81void
075fe5bb 82CheckAce(type, name, verbose)
08345b74 83char * type, *name;
84Bool verbose;
85{
86 char *args[2], buf[BUFSIZ];
075fe5bb 87 int status;
08345b74 88
461c03b6 89 if ( strcmp(type, "LIST") != 0 )
075fe5bb 90 return; /* If the ace is not a list the ignore it. */
08345b74 91
92 args[0] = type;
93 args[1] = name;
8defc06b 94 status = do_mr_query("get_ace_use", 2, args, NullFunc, (char *) NULL);
95 if (status != MR_NO_MATCH)
075fe5bb 96 return; /* If this query fails the ace will
461c03b6 97 not be deleted even if it is empty. */
08345b74 98 if (verbose) {
0a2c64cb 99 sprintf(buf, "Delete the unused Access Control Entity (ACE) %s? ",
100 name);
075fe5bb 101 if ( YesNoQuestion(buf, FALSE) != TRUE) {
461c03b6 102 Put_message("Aborting Deletion!");
103 return;
104 }
08345b74 105 }
106/*
075fe5bb 107 * Delete the ACE.
08345b74 108 *
109 * NOTE: Delete list expects only the name of the list to delete in argv[1].
110 * since, 'args' already satisfies this, there is no need to create
111 * a special argument list.
112 */
113 DeleteList(2, args);
114}
115
116
075fe5bb 117/* Function Name: CheckIfAce
118 * Description: Checks to see if this is an ace of another data object.
08345b74 119 * Arguments: name - name of the object.
253517e2 120 * Returns: SUB_ERROR if this list is an ace, or if the query did not
08345b74 121 * succeed.
122 */
123
124int
075fe5bb 125CheckIfAce(name, type, verbose)
461c03b6 126char * name, * type;
08345b74 127Bool verbose;
128{
253517e2 129 char * args[2], buf[BUFSIZ], **info;
075fe5bb 130 struct qelem *local, *elem;
461c03b6 131 int status;
08345b74 132 elem = NULL;
133
134 args[0] = type;
135 args[1] = name;
8defc06b 136 switch (status = do_mr_query("get_ace_use", 2, args,
14f99d7d 137 StoreInfo, (char *) &elem)) {
8defc06b 138 case MR_NO_MATCH:
075fe5bb 139 return(DM_NORMAL);
8defc06b 140 case MR_SUCCESS:
075fe5bb 141 local = elem = QueueTop(elem);
253517e2 142 info = (char **) local->q_data;
143 if (QueueCount(elem) == 1 &&
144 !strcmp(info[0], "LIST") &&
145 !strcmp(info[1], name)) {
146 FreeQueue(elem);
147 return(DM_NORMAL);
148 }
075fe5bb 149 if (verbose) {
219bbe64 150 sprintf(buf, "%s %s %s", type, name,
151 "is the ACE for the following data objects:");
075fe5bb 152 Put_message(buf);
219bbe64 153 Put_message("");
075fe5bb 154 while (local != NULL) {
253517e2 155 info = (char **) local->q_data;
156 if (!strcmp(info[0], "LIST") &&
157 !strcmp(info[1], name))
158 continue;
8429393f 159 Print(CountArgs(info), info, NULL);
075fe5bb 160 local = local->q_forw;
161 }
8429393f 162 Put_message("");
163 Put_message(
164 "The ACE for each of these items must be changed before");
075fe5bb 165 sprintf(buf,"the %s %s can be deleted.\n", type, name);
8429393f 166 Put_message(buf);
08345b74 167 }
075fe5bb 168 break;
169 default:
8429393f 170 com_err(program_name, status, " in CheckIfAce (get_ace_use).");
171 return(SUB_ERROR);
08345b74 172 }
8429393f 173 FreeQueue(elem);
174 return(SUB_ERROR);
08345b74 175}
176
8429393f 177/* Function Name: RemoveItemFromLists
178 * Description: this function removes a list from all other lists of
08345b74 179 * which it is a member.
8429393f 180 * Arguments: name - name of the item
181 * elem - a pointer to a queue element. RETURNED
08345b74 182 * verbose - verbose mode.
8429393f 183 * Returns: SUB_ERROR if there is an error.
08345b74 184 */
185
186int
8429393f 187RemoveItemFromLists(name, type, elem, verbose)
461c03b6 188char * name, *type;
189struct qelem ** elem;
08345b74 190int verbose;
191{
461c03b6 192 struct qelem *local;
8429393f 193 char *args[10], temp_buf[BUFSIZ];
0a2c64cb 194 int lists;
075fe5bb 195 register int status;
08345b74 196
197 args[0] = type;
198 args[1] = name;
8429393f 199 *elem = NULL;
08345b74 200
201/*
8429393f 202 * Get all list of which this item is a member, and store them in a queue.
08345b74 203 */
204
8defc06b 205 status = do_mr_query("get_lists_of_member", 2, args, StoreInfo,
14f99d7d 206 (char *) elem);
08345b74 207
8defc06b 208 if (status == MR_NO_MATCH)
8429393f 209 return(SUB_NORMAL);
08345b74 210
8defc06b 211 if (status != MR_SUCCESS) {
8429393f 212 com_err(program_name, status, " in DeleteList (get_lists_of_member).");
213 return(SUB_ERROR);
08345b74 214 }
215
216/*
8429393f 217 * If verbose mode, ask user of we should remove our list from
08345b74 218 * all these lists.
219 */
220
8429393f 221 local = *elem = QueueTop(*elem);
222 lists = QueueCount(*elem);
0a2c64cb 223 if (lists == 0)
8429393f 224 return(SUB_NORMAL);
08345b74 225 if (verbose) {
0a2c64cb 226 sprintf(temp_buf, "%s %s is a member of %d other list%s.\n", type,
227 name, lists, ((lists == 1) ? "" : "s") );
8429393f 228 Put_message(temp_buf);
229 while (local != NULL) {
461c03b6 230 char ** info = (char **) local->q_data;
8429393f 231 Print( 1, &info[GLOM_NAME], (char *) NULL);
08345b74 232 local = local->q_forw;
233 }
8429393f 234 Put_message(" "); /* Blank Line. */
235 sprintf(temp_buf,"Remove %s %s from these lists? ", type, name);
236 if (YesNoQuestion(temp_buf, FALSE) != TRUE) {
237 Put_message("Aborting...");
238 FreeQueue(*elem);
239 *elem = NULL;
240 return(SUB_ERROR);
08345b74 241 }
242 }
243
244/*
8429393f 245 * Remove this list from all lists that it is a member of.
08345b74 246 */
247
248 local = *elem;
8429393f 249 args[DM_MEMBER] = name;
250 args[DM_TYPE] = type;
251 while (local != NULL) {
461c03b6 252 char ** info = (char **) local->q_data;
8429393f 253 args[DM_LIST] = info[GLOM_NAME];
8defc06b 254 if ( (status = do_mr_query("delete_member_from_list",
14f99d7d 255 3, args, Scream, NULL)) != 0) {
8429393f 256 com_err(program_name, status, " in delete_member\nAborting\n");
257 FreeQueue(*elem);
258 return(SUB_ERROR);
08345b74 259 }
260 local = local->q_forw;
261 }
8429393f 262 return(SUB_NORMAL);
08345b74 263}
264
8429393f 265/* Function Name: RemoveMembersOfList
266 * Description: Deletes the members of the list.
267 * Arguments: name - name of the list.
08345b74 268 * verbose - query user, about deletion?
8429393f 269 * Returns: SUB_ERROR - if we could not delete, or the user abouted.
08345b74 270 */
271
272int
8429393f 273RemoveMembersOfList(name, verbose)
08345b74 274char * name;
8429393f 275Bool verbose;
08345b74 276{
8429393f 277 char buf[BUFSIZ], *args[10];
278 struct qelem *local, *elem = NULL;
0a2c64cb 279 int status, members;
08345b74 280/*
8429393f 281 * Get the members of this list.
08345b74 282 */
8defc06b 283 status = do_mr_query("get_members_of_list", 1, &name, StoreInfo,
14f99d7d 284 (char *) &elem);
8defc06b 285 if (status == MR_NO_MATCH)
8429393f 286 return(SUB_NORMAL);
08345b74 287
288 if (status != 0) {
8429393f 289 com_err(program_name, status, " in DeleteList (get_members_of_list).");
290 return(SUB_ERROR);
08345b74 291 }
08345b74 292/*
8429393f 293 * If verbose mode, then ask the user if we should delete.
08345b74 294 */
8429393f 295 local = elem = QueueTop(elem);
296 if ( (members = QueueCount(elem)) == 0)
297 return(SUB_NORMAL);
08345b74 298 if (verbose) {
8429393f 299 sprintf(buf, "List %s has %d member%s:", name, QueueCount(elem),
0a2c64cb 300 ((members == 1) ? "" : "s") );
8429393f 301 Put_message(buf);
302 Put_message(" "); /* Blank Line. */
303 while (local != NULL) {
461c03b6 304 char ** info = (char **) local->q_data;
8429393f 305 Print( CountArgs(info), info, NULL);
08345b74 306 local = local->q_forw;
307 }
8429393f 308 Put_message(" "); /* Blank Line. */
309 sprintf(buf, "Remove th%s member%s from list %s? ",
0a2c64cb 310 ((members == 1) ? "is" : "ese"),
219bbe64 311 ((members == 1) ? "" : "s"), name );
8429393f 312 if ( YesNoQuestion(buf, FALSE) != TRUE) {
313 Put_message("Aborting...");
314 FreeQueue(elem);
315 return(SUB_ERROR);
08345b74 316 }
317 }
08345b74 318/*
8429393f 319 * Perform The Removal.
08345b74 320 */
08345b74 321 local = elem;
322 args[0] = name;
8429393f 323 while (local != NULL) {
461c03b6 324 char ** info = (char **) local->q_data;
08345b74 325 args[1] = info[0];
326 args[2] = info[1];
8defc06b 327 if ( (status = do_mr_query("delete_member_from_list",
14f99d7d 328 3, args, Scream, NULL)) != 0) {
8429393f 329 com_err(program_name, status, " in delete_member\nAborting\n");
330 FreeQueue(elem);
331 return(SUB_ERROR);
08345b74 332 }
333 local = local->q_forw;
334 }
8429393f 335 return(SUB_NORMAL);
08345b74 336}
337
8429393f 338/* Function Name: DeleteUserGroup
339 * Description: Deletes the list given by name if it exists.
08345b74 340 * intended to be used to delete user groups
341 * Arguments: name - the name of the list to delete.
342 * verbose - flag that if TRUE queries the user to
343 * ask if list should be deleted.
8defc06b 344 * Returns: MR_ERROR if there is an error.
08345b74 345 */
346
347int
348DeleteUserGroup(name, verbose)
349char * name;
350Bool verbose;
351{
352 int status, ans;
461c03b6 353 char buf[BUFSIZ], *args[10];
08345b74 354
8defc06b 355 status = do_mr_query("get_list_info", 1, &name, NullFunc, (char *) NULL);
08345b74 356 if (status == 0) {
357 if (verbose) {
358 sprintf(buf, "There is also a list named %s, delete it?", name);
075fe5bb 359 ans = YesNoQuestion(buf, FALSE);
08345b74 360 if (ans == FALSE) {
361 Put_message("Leaving group alone.");
461c03b6 362 return(SUB_NORMAL);
08345b74 363 }
364 if (ans < 0) {
365 Put_message("Aborting...\n");
366 return(SUB_ERROR);
367 }
368 }
369 /* ans == TRUE || ~verbose */
370 args[0] = "foo"; /* not used. */
371 args[1] = name;
372 DeleteList(2, args);
373 }
8defc06b 374 else if (status != MR_NO_MATCH) {
461c03b6 375 com_err(program_name, status, " Aborting Delete User.");
08345b74 376 return(SUB_ERROR);
377 }
461c03b6 378 return(SUB_NORMAL);
08345b74 379}
380
381/* Function Name: DeleteHomeFilesys
382 * Description: Delete the home filesystem for the named user.
383 * Arguments: name - name of the user (and filsystem) to delete.
384 * verbose - if TRUE query user.
385 * Returns: SUB_NORMAL if home filesystem deleted, or nonexistant.
386 */
387
388int
389DeleteHomeFilesys(name, verbose)
390char * name;
391Bool verbose;
392{
075fe5bb 393 int status;
08345b74 394 char buf[BUFSIZ];
395
8defc06b 396 switch (status = do_mr_query("get_filesys_by_label", 1, &name, NullFunc,
14f99d7d 397 (char *) NULL)) {
8defc06b 398 case MR_NO_MATCH:
075fe5bb 399 break;
8defc06b 400 case MR_SUCCESS:
08345b74 401 if (verbose) {
402 sprintf(buf, "Delete the filesystem named %s (y/n)?", name);
075fe5bb 403 switch (YesNoQuestion(buf, FALSE)) {
404 case FALSE:
405 Put_message("Filesystem Not Deleted, continuing...\n");
406 return(SUB_NORMAL);
407 case TRUE:
408 break;
409 default:
08345b74 410 Put_message("Filesystem Not Deleted, aborting...\n\n");
461c03b6 411 return(SUB_ERROR);
08345b74 412 }
413 }
8defc06b 414 if ( (status = do_mr_query("delete_filesys", 1, &name, Scream,
415 (char *) NULL) ) != MR_SUCCESS) {
075fe5bb 416 com_err(program_name, status, " in delete_filesys.");
08345b74 417 return(SUB_ERROR);
418 }
075fe5bb 419 else
420 Put_message("Filesystem Successfully Deleted.");
421 break;
422 default:
423 com_err(program_name, status, " in get_filesystem_by_label).");
424 return(SUB_ERROR);
08345b74 425 }
075fe5bb 426 return(SUB_NORMAL);
08345b74 427}
428
075fe5bb 429/* Function Name: RealDeleteUser
430 * Description: Just Deletes the user.
431 * Arguments: name - name of User to delete
432 * Returns: SUB_ERROR if the deletion failed.
08345b74 433 */
434
075fe5bb 435static int
436RealDeleteUser(name)
08345b74 437char * name;
08345b74 438{
075fe5bb 439 char buf[BUFSIZ];
440 int status;
441
8defc06b 442 if ( (status = do_mr_query("delete_user", 1, &name, Scream,
443 (char *) NULL)) != MR_SUCCESS) {
075fe5bb 444 com_err(program_name, status, ": user not deleted");
08345b74 445 return(SUB_ERROR);
446 }
075fe5bb 447 (void) sprintf(buf, "User %s deleted.", name);
448 Put_message(buf);
08345b74 449 return(SUB_NORMAL);
450}
451
85ca828a 452/* Function Name: RealDeleteList
453 * Description: Just Deletes the list.
454 * Arguments: name - name of list to delete
455 * Returns: SUB_ERROR if the deletion failed.
08345b74 456 */
457
85ca828a 458static int
459RealDeleteList(name)
460char * name;
08345b74 461{
85ca828a 462 char buf[BUFSIZ];
461c03b6 463 int status;
08345b74 464
8defc06b 465 if ( (status = do_mr_query("delete_list", 1, &name, Scream,
466 (char *) NULL)) != MR_SUCCESS) {
85ca828a 467 com_err(program_name, status, ": list not deleted");
468 return(SUB_ERROR);
08345b74 469 }
402461ad 470 (void) sprintf(buf, "List %s deleted.", name);
85ca828a 471 Put_message(buf);
402461ad 472 Put_message("");
85ca828a 473 return(SUB_NORMAL);
474}
08345b74 475
85ca828a 476/* Function Name: AttemptToDeleteList
477 * Description: Atempts to delete list, in the following manner:
478 * 1) try to delet it, if this fails in a known error then
479 * a) try to clean up each of those known methods, or
480 * at least explain why we failed.
402461ad 481 * Arguments: list_info - info about this list.
85ca828a 482 * ask_first - (T/F) query user before preparing for deletion,
483 * and cleaning up?
484 * Returns: none - all is taken care of and error messages printed
485 * one way or the other.
08345b74 486 */
487
85ca828a 488void
402461ad 489AttemptToDeleteList(list_info, ask_first)
490char ** list_info;
85ca828a 491Bool ask_first;
492{
493 int status;
402461ad 494 struct qelem *local, *member_of;
495 char *name = list_info[L_NAME];
496 member_of = NULL;
85ca828a 497
498 /*
499 * Attempt delete. - will only work if:
500 * 1) This list has no members.
501 * 2) This list in a member of no other lists.
075fe5bb 502 * 3) This list is not an ace of another object.
85ca828a 503 */
504
8defc06b 505 switch (status = do_mr_query("delete_list", 1, &name,
14f99d7d 506 Scream, (char *) NULL)) {
8defc06b 507 case MR_SUCCESS:
08345b74 508 Put_message("List Sucessfully Deleted.");
0a2c64cb 509 CheckAce(list_info[L_ACE_TYPE], list_info[L_ACE_NAME], ask_first);
85ca828a 510 break;
8defc06b 511 case MR_IN_USE:
85ca828a 512 /*
513 * This list is in use. Try to find out why,
514 * and for the cases where we have a good idea of
515 * what to do we will query and then do it.
516 */
517
60b3185f 518 if ((CheckIfAce(name, "list", ask_first) != SUB_NORMAL) ||
85ca828a 519 (RemoveItemFromLists(name, "list",
60b3185f 520 &member_of, ask_first) != SUB_NORMAL))
521 break;
522 /*
523 * If the list is it's own ACL, then make the person performing
524 * the delete the owner before removing this person from the list
525 */
526 if (!strcmp(list_info[L_ACE_TYPE], "LIST") &&
527 !strcmp(list_info[L_ACE_NAME], list_info[L_NAME])) {
528 free(list_info[L_ACE_TYPE]);
529 free(list_info[L_ACE_NAME]);
530 list_info[L_ACE_TYPE] = Strsave("USER");
531 list_info[L_ACE_NAME] = Strsave(user);
532 SlipInNewName(list_info, Strsave(list_info[L_NAME]));
8defc06b 533 if ((status = do_mr_query("update_list", CountArgs(list_info)-3,
60b3185f 534 list_info, Scream, (char *) NULL))
8defc06b 535 != MR_SUCCESS) {
60b3185f 536 com_err(program_name, status, " while updating list owner");
537 Put_message("List may be only partly deleted.");
538 }
539 }
540 if ((RemoveMembersOfList(name, ask_first) == SUB_NORMAL) &&
85ca828a 541 (RealDeleteList(name) == SUB_NORMAL) )
542 { /* if... */
075fe5bb 543 CheckAce(list_info[L_ACE_TYPE], list_info[L_ACE_NAME], ask_first);
08345b74 544
0a2c64cb 545 local = QueueTop(member_of);
85ca828a 546 while (local != NULL) {
402461ad 547 char ** info = (char **) local->q_data;
85ca828a 548 CheckListForDeletion(info[LM_LIST], ask_first);
549 local = local->q_forw;
550 }
402461ad 551 FreeQueue(member_of);
08345b74 552 }
85ca828a 553 break;
554 default:
555 com_err(program_name, status, " in DeleteList (delete_list).");
556 break;
08345b74 557 }
08345b74 558}
559
85ca828a 560/* Function Name: DeleteList
561 * Description: deletes a list
8defc06b 562 * Arguments: argc, argv - standard MR argc and argv.
85ca828a 563 * Returns: DM Status Code.
08345b74 564 */
565
85ca828a 566/* ARGSUSED */
567int
568DeleteList(argc, argv)
569int argc;
570char *argv[];
08345b74 571{
572 char buf[BUFSIZ];
85ca828a 573 struct qelem *top, *list;
574 register int status;
575 Bool one_list;
08345b74 576
85ca828a 577 list = NULL;
578
8defc06b 579 switch(status = do_mr_query("get_list_info", 1, argv + 1,
14f99d7d 580 StoreInfo, (char *) &list)){
8defc06b 581 case MR_SUCCESS:
85ca828a 582 break;
8defc06b 583/* case MR_NO_WILDCARD:
85ca828a 584 Put_message("Wildcards are not accepted here.");
585 return(DM_NORMAL);
8defc06b 586*/ case MR_NO_MATCH:
587 case MR_LIST:
402461ad 588 Put_message("There is no list that matches that name.");
85ca828a 589 return(DM_NORMAL);
590 default:
591 com_err(program_name, status, " in DeleteList (get_list_info).");
592 return(DM_NORMAL);
08345b74 593 }
85ca828a 594
595 top = list = QueueTop(list);
596 one_list = (QueueCount(list) == 1);
597 while (list != NULL) {
598 char ** info = (char**) list->q_data;
599 if (one_list) {
402461ad 600 sprintf( buf, "Are you sure that you want to delete the list %s",
601 info[L_NAME]);
602 if ( Confirm(buf) ) AttemptToDeleteList(info, TRUE);
85ca828a 603 }
604 else {
605 sprintf(buf, "Delete the list %s", info[L_NAME]);
606 switch( YesNoQuestion( buf, FALSE ) ) {
607 case TRUE:
402461ad 608 AttemptToDeleteList(info, TRUE);
85ca828a 609 break;
610 case FALSE:
611 break;
612 default:
613 Put_message ("Aborting...");
614 FreeQueue(top);
615 return(DM_NORMAL);
616 }
617 }
618 list = list->q_forw;
619 }
620 FreeQueue(top);
621 return(DM_NORMAL);
08345b74 622}
623
624/* Function Name: DeleteUser
625 * Description: Deletes a user from the database.
626 * Arguments: argc, argv - name of the user in argv[1].
627 * Returns: DM_NORMAL.
628 */
629
85ca828a 630/* ARGSUSED */
08345b74 631int
632DeleteUser(argc, argv)
633int argc;
634char ** argv;
635{
636 int status;
637 char buf[BUFSIZ];
638 char * name = argv[1]; /* name of the user we are deleting. */
461c03b6 639 struct qelem *local, *member_of = NULL;
08345b74 640
075fe5bb 641 if (!ValidName(name))
642 return(DM_NORMAL);
643
08345b74 644 if (!Confirm("Are you sure that you want to delete this user?"))
645 return(DM_NORMAL);
646
8defc06b 647 status = do_mr_query("delete_user", 1, &name, Scream, (char *) NULL);
648 if (status != MR_IN_USE && status != 0) {
8429393f 649 com_err(program_name, status, ": user not deleted");
08345b74 650 return(DM_NORMAL);
651 }
652 if (status == 0) {
653 sprintf(buf,"User %s deleted.", name);
654 Put_message(buf);
75e021c5 655 /* delete this return if the policy decision below is reversed */
656 return(DM_NORMAL);
08345b74 657 }
8429393f 658/* Design decision not to allow registered users to be deleted.
253517e2 659 */
a52461dc 660 Put_message("Sorry, registered users cannot be deleted from the database.");
661 Put_message("Deactivate the user now, and the system manager will expunge later.");
253517e2 662#ifdef notdef
8defc06b 663 else if (status == MR_IN_USE) {
08345b74 664
665/*
666 * Check:
075fe5bb 667 * 1) Query - Delete home filesytem.
668 * 2) Query - Delete user Group.
669 * 2) Is the user an ACE of any object in the database?
670 * 3) Query - Remove user from all list of which he is a member.
08345b74 671 *
672 * If all these have been accomplished, then attempt to delete the user again.
673 */
075fe5bb 674 if ( (DeleteHomeFilesys(name, TRUE) == SUB_ERROR) ||
675 (DeleteUserGroup(name, TRUE) == SUB_ERROR) ||
676 (CheckIfAce(name, "user", TRUE) == SUB_ERROR) ||
08345b74 677 (RemoveItemFromLists(name, "user",
678 &member_of, TRUE) == SUB_ERROR) ||
679 (RealDeleteUser(name) == SUB_ERROR) ) {
08345b74 680 return(DM_NORMAL);
681 }
682 }
683
684/*
08345b74 685 * Query - Delete all empty lists created by removing this user from them.
686 */
687
08345b74 688 local = member_of;
689 while (local != NULL) {
461c03b6 690 char ** info = (char **) local->q_data;
08345b74 691 CheckListForDeletion(info[0], TRUE);
461c03b6 692 local = local->q_forw;
08345b74 693 }
694
695 FreeQueue(member_of); /* Free memory and return. */
253517e2 696#endif
08345b74 697 return(DM_NORMAL);
698}
This page took 0.197424 seconds and 5 git commands to generate.