[156] | 1 | /* |
---|
[1927] | 2 | * |
---|
| 3 | * Copyright (C) 1989 by the Massachusetts Institute of Technology |
---|
| 4 | * Developed by the MIT Student Information Processing Board (SIPB). |
---|
| 5 | * For copying information, see the file mit-copyright.h in this release. |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | /* |
---|
[22404] | 9 | * $Id: list_acl.c,v 1.14 2006-03-10 07:11:31 ghudson Exp $ |
---|
[156] | 10 | * |
---|
| 11 | */ |
---|
| 12 | |
---|
| 13 | #ifndef lint |
---|
[1428] | 14 | static char rcsid_list_acl_c[] = |
---|
[22404] | 15 | "$Id: list_acl.c,v 1.14 2006-03-10 07:11:31 ghudson Exp $"; |
---|
[12459] | 16 | #endif /* lint */ |
---|
[156] | 17 | |
---|
[1637] | 18 | #include <string.h> |
---|
[156] | 19 | #include <stdio.h> |
---|
[22404] | 20 | #include <stdlib.h> |
---|
[1637] | 21 | #include <discuss/discuss.h> |
---|
[156] | 22 | #include "globals.h" |
---|
| 23 | |
---|
[22404] | 24 | extern char *local_realm(); |
---|
[156] | 25 | |
---|
[189] | 26 | list_acl(argc, argv) |
---|
| 27 | int argc; |
---|
[160] | 28 | char **argv; |
---|
[156] | 29 | { |
---|
[1428] | 30 | dsc_acl *list; |
---|
[156] | 31 | int code; |
---|
| 32 | char *modes; |
---|
| 33 | |
---|
[236] | 34 | if (!dsc_public.attending) { |
---|
[156] | 35 | (void) fprintf(stderr, "No current meeting.\n"); |
---|
| 36 | return; |
---|
| 37 | } |
---|
| 38 | /* |
---|
| 39 | * List access to current meeting. |
---|
| 40 | */ |
---|
| 41 | |
---|
| 42 | if (argc == 1) { |
---|
| 43 | /* long form; dump the access control list */ |
---|
[292] | 44 | dsc_get_acl(&dsc_public.nb, &code, &list); |
---|
[156] | 45 | if (code) { |
---|
| 46 | fprintf(stderr, "Can't read ACL: %s\n", |
---|
| 47 | error_message(code)); |
---|
| 48 | return; |
---|
| 49 | } |
---|
| 50 | print_acl(list); |
---|
| 51 | acl_destroy(list); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | while(++argv,--argc) { |
---|
[292] | 55 | dsc_get_access(&dsc_public.nb, *argv, &modes, &code); |
---|
[156] | 56 | if (code) { |
---|
| 57 | fprintf(stderr, "Can't read ACL for %s: %s\n", |
---|
| 58 | *argv, error_message(code)); |
---|
| 59 | continue; |
---|
| 60 | } |
---|
| 61 | printf("%-10s %s\n", modes, *argv); |
---|
| 62 | free(modes); |
---|
| 63 | } |
---|
| 64 | return; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | print_acl(list) |
---|
[1428] | 68 | dsc_acl *list; |
---|
[156] | 69 | { |
---|
[1428] | 70 | register dsc_acl_entry *ae; |
---|
[156] | 71 | register int n; |
---|
| 72 | for (ae = list->acl_entries, n = list->acl_length; n; --n, ++ae) |
---|
| 73 | printf("%-10s %s\n", ae->modes, ae->principal); |
---|
| 74 | } |
---|
| 75 | |
---|
[236] | 76 | static char buf[120]; |
---|
| 77 | |
---|
[189] | 78 | set_acl(argc, argv) |
---|
| 79 | int argc; |
---|
[236] | 80 | register char **argv; |
---|
[156] | 81 | { |
---|
[236] | 82 | register char *modes, *principal; |
---|
[156] | 83 | int code; |
---|
[236] | 84 | |
---|
| 85 | |
---|
[156] | 86 | if (!dsc_public.attending) { |
---|
| 87 | (void) fprintf(stderr, "No current meeting.\n"); |
---|
| 88 | return; |
---|
| 89 | } |
---|
| 90 | if (argc != 3) { |
---|
| 91 | printf("usage: %s [ modes | null ] principal \n", argv[0]); |
---|
| 92 | return; |
---|
| 93 | } |
---|
| 94 | if(!strcmp("null", argv[1])) modes = ""; |
---|
| 95 | else modes = argv[1]; |
---|
| 96 | |
---|
[7167] | 97 | if (strcmp(argv[2],"*") != 0 && strchr(argv[2], '@') == 0) { |
---|
[236] | 98 | strcpy(buf, argv[2]); |
---|
| 99 | strcat(buf, "@"); |
---|
| 100 | strcat(buf, local_realm()); |
---|
| 101 | principal = buf; |
---|
| 102 | } else principal=argv[2]; |
---|
| 103 | |
---|
[292] | 104 | dsc_set_access(&dsc_public.nb, principal, modes, &code); |
---|
[156] | 105 | if(code) fprintf(stderr, "Can't set access for %s: %s\n", |
---|
[236] | 106 | principal, error_message(code)); |
---|
[156] | 107 | } |
---|
| 108 | |
---|
[189] | 109 | del_acl(argc, argv) |
---|
| 110 | int argc; |
---|
[236] | 111 | register char **argv; |
---|
[156] | 112 | { |
---|
| 113 | int code; |
---|
[236] | 114 | register char *principal; |
---|
| 115 | |
---|
[156] | 116 | if (!dsc_public.attending) { |
---|
| 117 | (void) fprintf(stderr, "No current meeting.\n"); |
---|
| 118 | return; |
---|
| 119 | } |
---|
[236] | 120 | if (argc < 2) { |
---|
| 121 | printf("usage: %s principal [ , principal ... ]\n", *argv); |
---|
[156] | 122 | return; |
---|
| 123 | } |
---|
[236] | 124 | |
---|
| 125 | while(++argv,--argc) { |
---|
[7167] | 126 | if (strcmp(*argv,"*") != 0 && strchr(*argv, '@') == 0) { |
---|
[236] | 127 | strcpy(buf, *argv); |
---|
| 128 | strcat(buf, "@"); |
---|
| 129 | strcat(buf, local_realm()); |
---|
| 130 | principal = buf; |
---|
| 131 | } else principal = *argv; |
---|
[292] | 132 | dsc_delete_access(&dsc_public.nb, principal, &code); |
---|
[236] | 133 | if(code) fprintf(stderr, "Can't delete access of %s: %s\n", |
---|
| 134 | principal, error_message(code)); |
---|
| 135 | } |
---|
[156] | 136 | } |
---|