]>
Commit | Line | Data |
---|---|---|
402461ad | 1 | #if (!defined(lint) && !defined(SABER)) |
08345b74 | 2 | static char rcsid_module_c[] = "$Header$"; |
7798ebc3 | 3 | #endif |
08345b74 | 4 | |
8defc06b | 5 | /* This is the file user.c for the MOIRA Client, which allows a nieve |
6 | * user to quickly and easily maintain most parts of the MOIRA database. | |
0a2c64cb | 7 | * It Contains: Functions for manipulating user information. |
5eaef520 | 8 | * |
08345b74 | 9 | * Created: 5/9/88 |
10 | * By: Chris D. Peterson | |
11 | * | |
12 | * $Source$ | |
13 | * $Author$ | |
14 | * $Header$ | |
5eaef520 | 15 | * |
0a2c64cb | 16 | * Copyright 1988 by the Massachusetts Institute of Technology. |
08345b74 | 17 | * |
5eaef520 | 18 | * For further information on copyright and distribution |
08345b74 | 19 | * see the file mit-copyright.h |
20 | */ | |
21 | ||
08345b74 | 22 | #include <stdio.h> |
5eaef520 | 23 | #include <stdlib.h> |
dcfa270a | 24 | #include <string.h> |
8defc06b | 25 | #include <moira.h> |
26 | #include <moira_site.h> | |
08345b74 | 27 | #include <menu.h> |
1e80e2f4 | 28 | #include <ctype.h> |
559fe7ab | 29 | #include <sys/time.h> |
30 | #ifdef GDSS | |
31 | #include <des.h> | |
32 | #include <krb.h> | |
33 | #include <gdss.h> | |
34 | #endif | |
461c03b6 | 35 | #include "mit-copyright.h" |
0a2c64cb | 36 | #include "defs.h" |
37 | #include "f_defs.h" | |
461c03b6 | 38 | #include "globals.h" |
461c03b6 | 39 | |
08345b74 | 40 | #define LOGIN 0 |
41 | #define UID 1 | |
402461ad | 42 | #define BY_NAME 2 |
075fe5bb | 43 | #define CLASS 3 |
81701699 | 44 | #define ID 4 |
08345b74 | 45 | |
d6db948b | 46 | #ifdef ATHENA |
47 | #define DEFAULT_SHELL "/bin/athena/tcsh" | |
48 | #else | |
07b2e652 | 49 | #define DEFAULT_SHELL "/bin/csh" |
d6db948b | 50 | #endif |
07b2e652 | 51 | #define DEFAULT_CLASS "?" |
52 | ||
53 | ||
32de30b0 | 54 | /* Function Name: UserState |
55 | * Description: Convert a numeric state into a descriptive string. | |
56 | * Arguments: state value | |
57 | * Returns: pointer to statically allocated string. | |
58 | */ | |
59 | ||
5eaef520 | 60 | static char *states[] = { |
61 | "Registerable (0)", | |
62 | "Active (1)", | |
63 | "Half Registered (2)", | |
64 | "Deleted (3)", | |
65 | "Not registerable (4)", | |
66 | "Enrolled/Registerable (5)", | |
67 | "Enrolled/Not Registerable (6)", | |
68 | "Half Enrolled (7)" | |
69 | }; | |
70 | ||
71 | static char *UserState(int state) | |
32de30b0 | 72 | { |
5eaef520 | 73 | static char buf[BUFSIZ]; |
78fce9fa | 74 | |
5eaef520 | 75 | if (state < 0 || state >= US_END) |
76 | { | |
77 | sprintf(buf, "Unknown (%d)", state); | |
78 | return buf; | |
78fce9fa | 79 | } |
5eaef520 | 80 | return states[state]; |
32de30b0 | 81 | } |
82 | ||
83 | ||
075fe5bb | 84 | /* Function Name: PrintUserName |
85 | * Description: Print name of a user. | |
86 | * Arguments: info - the information about a user. | |
87 | * Returns: none. | |
88 | */ | |
89 | ||
5eaef520 | 90 | static void PrintUserName(char **info) |
075fe5bb | 91 | { |
5eaef520 | 92 | char buf[BUFSIZ], print_buf[BUFSIZ]; |
93 | sprintf(buf, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]); | |
94 | sprintf(print_buf, "%-40s User Name: %s", buf, info[U_NAME]); | |
95 | Put_message(print_buf); | |
075fe5bb | 96 | } |
97 | ||
98 | /* Function Name: PrintUserInfo | |
99 | * Description: Prints Information about a user. | |
100 | * Arguments: info - an argument list with the user information | |
101 | * in it. | |
102 | * Returns: none | |
103 | */ | |
104 | ||
5eaef520 | 105 | static void PrintUserInfo(char **info) |
075fe5bb | 106 | { |
5eaef520 | 107 | char name[BUFSIZ], buf[BUFSIZ]; |
108 | int status; | |
edd2ce4e | 109 | #ifdef GDSS |
5eaef520 | 110 | SigInfo si; |
559fe7ab | 111 | #endif |
075fe5bb | 112 | |
5eaef520 | 113 | sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]); |
114 | sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name); | |
115 | Put_message(buf); | |
116 | sprintf(buf, "User id: %-23s Login shell %-10s Class: %s", | |
117 | info[U_UID], info[U_SHELL], info[U_CLASS]); | |
118 | Put_message(buf); | |
559fe7ab | 119 | |
120 | #ifdef GDSS | |
5eaef520 | 121 | sprintf(buf, "%s:%s", info[U_NAME], info[U_MITID]); |
122 | si.rawsig = NULL; | |
123 | status = GDSS_Verify(buf, strlen(buf), info[U_SIGNATURE], &si); | |
559fe7ab | 124 | #else /* GDSS */ |
5eaef520 | 125 | status = 0; |
559fe7ab | 126 | #endif /* GDSS */ |
127 | ||
5eaef520 | 128 | sprintf(buf, "Account is: %-20s MIT ID number: %s Signed: %s", |
129 | UserState(atoi(info[U_STATE])), info[U_MITID], | |
130 | *info[U_SIGNATURE] ? (status ? "Bad" : "Yes") : "No"); | |
131 | Put_message(buf); | |
132 | if (atoi(info[U_SECURE])) | |
133 | sprintf(buf, "Secure password set on %s.", atot(info[U_SECURE])); | |
134 | else | |
135 | sprintf(buf, "No secure password set."); | |
136 | Put_message(buf); | |
137 | sprintf(buf, "Comments: %s", info[U_COMMENT]); | |
138 | Put_message(buf); | |
139 | sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME], info[U_MODWITH]); | |
140 | Put_message(buf); | |
075fe5bb | 141 | } |
142 | ||
143 | /* Function Name: SetUserDefaults | |
144 | * Description: Sets the default values for add user. | |
145 | * Arguments: info - a blank user info array of char *'s. | |
146 | * Returns: args - the filled info structure. | |
147 | */ | |
148 | ||
5eaef520 | 149 | static char **SetUserDefaults(char **info) |
075fe5bb | 150 | { |
5eaef520 | 151 | info[U_NAME] = Strsave(UNIQUE_LOGIN); |
152 | info[U_UID] = Strsave(UNIQUE_UID); | |
153 | info[U_SHELL] = Strsave(DEFAULT_SHELL); | |
154 | info[U_LAST] = Strsave(DEFAULT_NONE); | |
155 | info[U_FIRST] = Strsave(DEFAULT_NONE); | |
156 | info[U_MIDDLE] = Strsave(DEFAULT_NONE); | |
157 | info[U_STATE] = Strsave(DEFAULT_NO); | |
158 | info[U_MITID] = Strsave(DEFAULT_NONE); | |
159 | info[U_CLASS] = Strsave(DEFAULT_CLASS); | |
160 | info[U_COMMENT] = Strsave(""); | |
161 | info[U_SIGNATURE] = Strsave(""); | |
162 | info[U_SECURE] = Strsave("0"); | |
163 | info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL; | |
164 | return info; | |
075fe5bb | 165 | } |
461c03b6 | 166 | |
f0a54771 | 167 | |
5eaef520 | 168 | /* Check that the supplied name follows the capitalization rules, and |
f0a54771 | 169 | * offer to correct it if not. |
170 | */ | |
171 | ||
5eaef520 | 172 | int CorrectCapitalization(char **name) |
f0a54771 | 173 | { |
5eaef520 | 174 | char temp_buf[BUFSIZ], fixname[BUFSIZ]; |
175 | ||
176 | strcpy(fixname, *name); | |
177 | FixCase(fixname); | |
178 | if (strcmp(fixname, *name)) | |
179 | { | |
180 | Put_message("You entered a name which does not follow the capitalization conventions."); | |
181 | sprintf(temp_buf, "Correct it to \"%s\"", fixname); | |
182 | if (YesNoQuestion(temp_buf, 1) == TRUE) | |
183 | { | |
184 | free(*name); | |
185 | *name = strsave(fixname); | |
f0a54771 | 186 | } |
187 | } | |
188 | } | |
189 | ||
190 | ||
08345b74 | 191 | /* Function Name: AskUserInfo. |
5eaef520 | 192 | * Description: This function askes the user for information about a |
08345b74 | 193 | * machine and saves it into a structure. |
194 | * Arguments: info - a pointer the the structure to put the info into. | |
195 | * flags - Flags asking us which info we want. | |
196 | * Returns: the args to pass to the query. | |
197 | * NOTES: the return args are not necessarily in the correct order to | |
198 | * use the #defined names (e.g args[UID] is not the uid anymore). | |
199 | */ | |
200 | ||
5eaef520 | 201 | char **AskUserInfo(char **info, Bool name) |
08345b74 | 202 | { |
5eaef520 | 203 | int i; |
edd2ce4e | 204 | #ifdef GDSS |
5eaef520 | 205 | SigInfo si; |
edd2ce4e | 206 | #endif |
5eaef520 | 207 | char temp_buf[BUFSIZ], *newname; |
208 | ||
209 | if (name) | |
210 | { | |
211 | sprintf(temp_buf, "\nChanging Attributes of user %s.\n", info[U_NAME]); | |
212 | Put_message(temp_buf); | |
213 | } | |
214 | else | |
215 | { | |
216 | struct qelem *elem = NULL; | |
217 | char *argv[3]; | |
218 | ||
219 | if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR) | |
220 | return NULL; | |
221 | CorrectCapitalization(&info[U_LAST]); | |
222 | if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR) | |
223 | return NULL; | |
224 | CorrectCapitalization(&info[U_FIRST]); | |
225 | if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR) | |
226 | return NULL; | |
227 | CorrectCapitalization(&info[U_MIDDLE]); | |
228 | argv[0] = info[U_FIRST]; | |
229 | argv[1] = info[U_LAST]; | |
230 | if (do_mr_query("get_user_account_by_name", 2, argv, | |
231 | StoreInfo, (char *) &elem) == MR_SUCCESS) | |
232 | { | |
233 | Put_message("A user by that name already exists in the database."); | |
234 | Loop(QueueTop(elem), PrintUserInfo); | |
235 | Loop(QueueTop(elem), FreeInfo); | |
236 | FreeQueue(elem); | |
237 | if (YesNoQuestion("Add new user anyway", TRUE) != TRUE) | |
238 | return NULL; | |
ebd96e37 | 239 | } |
075fe5bb | 240 | } |
5eaef520 | 241 | if (name) |
242 | { | |
243 | newname = Strsave(info[U_NAME]); | |
244 | if (GetValueFromUser("The new login name for this user", &newname) == | |
245 | SUB_ERROR) | |
246 | return NULL; | |
ebd96e37 | 247 | } |
5eaef520 | 248 | else if (GetValueFromUser("Login name for this user", &info[U_NAME]) == |
249 | SUB_ERROR) | |
250 | return NULL; | |
251 | ||
252 | if (GetValueFromUser("User's UID", &info[U_UID]) == SUB_ERROR) | |
253 | return NULL; | |
254 | if (GetValueFromUser("User's shell", &info[U_SHELL]) == SUB_ERROR) | |
255 | return NULL; | |
256 | if (name) | |
257 | { | |
258 | if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR) | |
259 | return NULL; | |
260 | CorrectCapitalization(&info[U_LAST]); | |
261 | if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR) | |
262 | return NULL; | |
263 | CorrectCapitalization(&info[U_FIRST]); | |
264 | if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR) | |
265 | return NULL; | |
266 | CorrectCapitalization(&info[U_MIDDLE]); | |
267 | } | |
268 | while (1) | |
269 | { | |
270 | int i; | |
271 | if (GetValueFromUser("User's status (? for help)", &info[U_STATE]) == | |
272 | SUB_ERROR) | |
273 | return NULL; | |
274 | if (isdigit(info[U_STATE][0])) | |
275 | break; | |
276 | Put_message("Valid status numbers:"); | |
277 | for (i = 0; i < US_END; i++) | |
278 | { | |
279 | sprintf(temp_buf, " %d: %s", i, states[i]); | |
280 | Put_message(temp_buf); | |
1e80e2f4 | 281 | } |
282 | } | |
5eaef520 | 283 | if (GetValueFromUser("User's MIT ID number", &info[U_MITID]) == SUB_ERROR) |
284 | return NULL; | |
285 | RemoveHyphens(info[U_MITID]); | |
286 | if (GetTypeFromUser("User's MIT Year (class)", "class", &info[U_CLASS]) == | |
287 | SUB_ERROR) | |
288 | return NULL; | |
289 | if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR) | |
290 | return NULL; | |
291 | ||
292 | if (YesNoQuestion("Secure password set", | |
293 | atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE) | |
294 | { | |
295 | free(info[U_SECURE]); | |
296 | info[U_SECURE] = strsave("0"); | |
297 | } | |
298 | else if (!strcmp(info[U_SECURE], "0")) | |
299 | { | |
300 | char buf[16]; | |
301 | struct timeval tv; | |
302 | ||
303 | gettimeofday(&tv, NULL); | |
304 | sprintf(buf, "%ld", (long) tv.tv_sec); | |
305 | free(info[U_SECURE]); | |
306 | info[U_SECURE] = strsave(buf); | |
559fe7ab | 307 | } |
308 | ||
5eaef520 | 309 | /* Sign record */ |
b8322cb3 | 310 | #ifdef GDSS |
5eaef520 | 311 | if (strcmp(info[U_NAME], UNIQUE_LOGIN)) |
312 | { | |
313 | if (name) | |
314 | sprintf(temp_buf, "%s:%s", newname, info[U_MITID]); | |
315 | else | |
316 | sprintf(temp_buf, "%s:%s", info[U_NAME], info[U_MITID]); | |
317 | si.rawsig = NULL; | |
318 | i = GDSS_Verify(temp_buf, strlen(temp_buf), info[U_SIGNATURE], &si); | |
319 | /* If it's already signed OK, don't resign it. */ | |
320 | if (i != GDSS_SUCCESS) | |
321 | { | |
322 | free(info[U_SIGNATURE]); | |
323 | info[U_SIGNATURE] = malloc(GDSS_Sig_Size() * 2); | |
cd42d372 | 324 | sign_again: |
5eaef520 | 325 | i = GDSS_Sign(temp_buf, strlen(temp_buf), info[U_SIGNATURE]); |
326 | if (i != GDSS_SUCCESS) | |
327 | com_err(program_name, gdss2et(i), "Failed to create signature"); | |
328 | else | |
329 | { | |
330 | unsigned char buf[256]; | |
331 | si.rawsig = buf; | |
332 | i = GDSS_Verify(temp_buf, strlen(temp_buf), | |
333 | info[U_SIGNATURE], &si); | |
334 | if (strlen(buf) > 68) | |
335 | goto sign_again; | |
cd42d372 | 336 | } |
559fe7ab | 337 | } |
338 | } | |
b8322cb3 | 339 | #else /* GDSS */ |
5eaef520 | 340 | info[U_SIGNATURE] = strsave(""); |
b8322cb3 | 341 | #endif /* GDSS */ |
342 | ||
5eaef520 | 343 | FreeAndClear(&info[U_MODTIME], TRUE); |
344 | FreeAndClear(&info[U_MODBY], TRUE); | |
345 | FreeAndClear(&info[U_MODWITH], TRUE); | |
08345b74 | 346 | |
5eaef520 | 347 | /* |
348 | * Slide the newname into the #2 slot, this screws up all future references | |
349 | * to this list, since we slip the pointer into a info list it gets freed | |
350 | * when the rest of the list gets freed. | |
351 | */ | |
352 | if (name) | |
353 | SlipInNewName(info, newname); | |
08345b74 | 354 | |
5eaef520 | 355 | return info; |
08345b74 | 356 | } |
357 | ||
358 | /* Function Name: GetUserInfo | |
359 | * Description: Stores the user information in a queue. | |
360 | * Arguments: type - type of field given to get info, one of: | |
402461ad | 361 | * LOGIN, UID, BY_NAME, CLASS. |
08345b74 | 362 | * name1 - name of thing specified by type (wildcards okay) |
363 | * name2 - other name, only used in get user by first and last. | |
364 | * (wildcards okay). | |
365 | * Returns: the first element of the queue containing the user info. | |
dcfa270a | 366 | * |
08345b74 | 367 | */ |
368 | ||
5eaef520 | 369 | struct qelem *GetUserInfo(int type, char *name1, char *name2) |
08345b74 | 370 | { |
5eaef520 | 371 | char *args[2]; |
44d12d58 | 372 | int status; |
5eaef520 | 373 | struct qelem *elem = NULL; |
08345b74 | 374 | |
5eaef520 | 375 | switch (type) |
376 | { | |
08345b74 | 377 | case LOGIN: |
5eaef520 | 378 | args[0] = name1; |
379 | if ((status = do_mr_query("get_user_account_by_login", 1, args, | |
380 | StoreInfo, (char *) &elem))) | |
381 | { | |
382 | com_err(program_name, status, | |
383 | " when attempting to get_user_account_by_login."); | |
384 | return NULL; | |
08345b74 | 385 | } |
5eaef520 | 386 | break; |
08345b74 | 387 | case UID: |
5eaef520 | 388 | args[0] = name1; |
389 | if ((status = do_mr_query("get_user_account_by_uid", 1, args, | |
390 | StoreInfo, (char *) &elem))) | |
391 | { | |
392 | com_err(program_name, status, | |
393 | " when attempting to get_user_account_by_uid."); | |
394 | return NULL; | |
08345b74 | 395 | } |
5eaef520 | 396 | break; |
402461ad | 397 | case BY_NAME: |
5eaef520 | 398 | args[0] = name1; |
399 | args[1] = name2; | |
400 | if ((status = do_mr_query("get_user_account_by_name", 2, args, | |
401 | StoreInfo, (char *) &elem))) | |
402 | { | |
403 | com_err(program_name, status, | |
404 | " when attempting to get_user_account_by_name."); | |
405 | return NULL; | |
08345b74 | 406 | } |
5eaef520 | 407 | break; |
08345b74 | 408 | case CLASS: |
5eaef520 | 409 | args[0] = name1; |
410 | if ((status = do_mr_query("get_user_account_by_class", 1, args, | |
411 | StoreInfo, (char *) &elem))) | |
412 | { | |
413 | com_err(program_name, status, | |
414 | " when attempting to get_user_account_by_class."); | |
415 | return NULL; | |
08345b74 | 416 | } |
5eaef520 | 417 | break; |
81701699 | 418 | case ID: |
5eaef520 | 419 | args[0] = name1; |
420 | if ((status = do_mr_query("get_user_account_by_id", 1, args, | |
421 | StoreInfo, (char *) &elem))) | |
422 | { | |
423 | com_err(program_name, status, | |
424 | " when attempting to get_user_account_by_id."); | |
425 | return NULL; | |
81701699 | 426 | } |
5eaef520 | 427 | break; |
08345b74 | 428 | } |
5eaef520 | 429 | return QueueTop(elem) ; |
08345b74 | 430 | } |
431 | ||
075fe5bb | 432 | /* Function Name: AddNewUser |
433 | * Description: Adds a new user to the database. | |
434 | * Arguments: none. | |
08345b74 | 435 | * Returns: DM_NORMAL. |
436 | */ | |
437 | ||
5eaef520 | 438 | int AddNewUser(void) |
08345b74 | 439 | { |
44d12d58 | 440 | int status; |
5eaef520 | 441 | char **args, *info[MAX_ARGS_SIZE]; |
075fe5bb | 442 | |
5eaef520 | 443 | if (!(args = AskUserInfo(SetUserDefaults(info), FALSE))) |
444 | { | |
445 | Put_message("Aborted."); | |
446 | return DM_NORMAL; | |
e4f91beb | 447 | } |
5eaef520 | 448 | if ((status = do_mr_query("add_user_account", CountArgs(args), |
449 | args, Scream, NULL))) | |
450 | com_err(program_name, status, " in add_user_account"); | |
451 | else | |
452 | Put_message("New user added to database."); | |
453 | FreeInfo(args); | |
454 | return DM_NORMAL; | |
08345b74 | 455 | } |
456 | ||
457 | ||
075fe5bb | 458 | /* Function Name: GetLoginName |
459 | * Description: Asks the user for a login name and reserves | |
460 | * it with kerberous. | |
461 | * Arguments: none. | |
462 | * Returns: a malloced login name for the user. | |
08345b74 | 463 | */ |
464 | ||
5eaef520 | 465 | static char *GetLoginName(void) |
08345b74 | 466 | { |
5eaef520 | 467 | char *name; |
075fe5bb | 468 | |
5eaef520 | 469 | name = strsave(""); |
470 | if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR) | |
471 | return NULL; | |
472 | Put_message("KERBEROS code not added, did not reserve name with kerberos."); | |
473 | return name; | |
075fe5bb | 474 | } |
475 | ||
476 | ||
477 | /* Function Name: ChooseUser | |
478 | * Description: Choose a user from a list and return the uid. | |
479 | * Arguments: top - a queue of user information. | |
480 | * Returns: uid - the malloced uid of the user that was chosen. | |
481 | */ | |
08345b74 | 482 | |
5eaef520 | 483 | static char *ChooseUser(struct qelem *elem) |
075fe5bb | 484 | { |
5eaef520 | 485 | while (elem) |
486 | { | |
487 | char **info = (char **) elem->q_data; | |
488 | PrintUserInfo(info); | |
489 | switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE)) | |
490 | { | |
075fe5bb | 491 | case TRUE: |
5eaef520 | 492 | return Strsave(info[U_UID]); |
075fe5bb | 493 | case FALSE: |
5eaef520 | 494 | break; |
075fe5bb | 495 | default: /* quit or ^C. */ |
5eaef520 | 496 | return NULL; |
08345b74 | 497 | } |
5eaef520 | 498 | elem = elem->q_forw; |
08345b74 | 499 | } |
5eaef520 | 500 | return NULL; |
08345b74 | 501 | } |
502 | ||
075fe5bb | 503 | /* Function Name: GetUidNumberFromName |
504 | * Description: Gets the users uid number, from the name. | |
505 | * Arguments: none. | |
506 | * Returns: uid - a malloced string containing the uid. | |
08345b74 | 507 | */ |
508 | ||
5eaef520 | 509 | static char *GetUidNumberFromName(void) |
08345b74 | 510 | { |
5eaef520 | 511 | char *args[5], *uid, first[BUFSIZ], last[BUFSIZ]; |
44d12d58 | 512 | int status; |
5eaef520 | 513 | struct qelem *top = NULL; |
514 | ||
515 | if (!Prompt_input("First Name: ", first, BUFSIZ)) | |
516 | return NULL; | |
517 | if (!Prompt_input("Last Name: ", last, BUFSIZ)) | |
518 | return NULL; | |
519 | FixCase(first); | |
520 | FixCase(last); | |
521 | ||
522 | args[0] = first; | |
523 | args[1] = last; | |
524 | ||
525 | switch ((status = do_mr_query("get_user_account_by_name", 2, args, | |
526 | StoreInfo, (char *) &top))) | |
527 | { | |
8defc06b | 528 | case MR_SUCCESS: |
5eaef520 | 529 | break; |
8defc06b | 530 | case MR_NO_MATCH: |
5eaef520 | 531 | Put_message("There is no user in the database with that name."); |
532 | return NULL; | |
075fe5bb | 533 | default: |
5eaef520 | 534 | com_err(program_name, status, " in get_account_user_by_name."); |
535 | return NULL; | |
08345b74 | 536 | } |
5eaef520 | 537 | |
538 | top = QueueTop(top); | |
539 | if (QueueCount(top) == 1) /* This is a unique name. */ | |
540 | { | |
541 | char **info = (char **) top->q_data; | |
542 | Put_message("User ID Number retrieved for the user: "); | |
543 | Put_message(""); | |
544 | PrintUserName(info); | |
545 | uid = Strsave(info[U_UID]); | |
546 | FreeQueue(top); | |
547 | return Strsave(uid); | |
075fe5bb | 548 | } |
08345b74 | 549 | |
5eaef520 | 550 | Put_message("That name is not unique, choose the user that you want."); |
551 | uid = ChooseUser(top); | |
552 | FreeQueue(top); | |
553 | return uid; | |
08345b74 | 554 | } |
555 | ||
075fe5bb | 556 | /* Function Name: SetUserPassword |
557 | * Description: Set the new kerberos password for this user. | |
558 | * Arguments: name - kerberos principle name for this user, (login name). | |
559 | * Returns: none. | |
08345b74 | 560 | */ |
561 | ||
5eaef520 | 562 | static void SetUserPassword(char *name) |
08345b74 | 563 | { |
5eaef520 | 564 | name = name; /* make saber happy. */ |
565 | Put_message("Kerberos password not changed, code non-existant."); | |
566 | /* clever message to call account_admin, if this fails. */ | |
075fe5bb | 567 | } |
08345b74 | 568 | |
075fe5bb | 569 | /* Function Name: GiveBackLogin |
570 | * Description: Gives back previously reserved kerberous principle. | |
571 | * Arguments: name - principle to give back. | |
572 | * Returns: void. | |
08345b74 | 573 | */ |
574 | ||
5eaef520 | 575 | static void GiveBackLogin(char *name) |
08345b74 | 576 | { |
5eaef520 | 577 | name = name; /* make saber happy. */ |
578 | Put_message("kerberos code not implimented, name not given back."); | |
579 | /* send mail to db maintainer if this fails. */ | |
08345b74 | 580 | } |
581 | ||
075fe5bb | 582 | /* Function Name: RegisterUser |
583 | * Description: This function registers a user. | |
584 | * Arguments: none. | |
585 | * Returns: DM_NORMAL. | |
08345b74 | 586 | */ |
587 | ||
5eaef520 | 588 | int RegisterUser(void) |
08345b74 | 589 | { |
5eaef520 | 590 | char *args[MAX_ARGS_SIZE]; |
591 | char *login, *fstype = NULL; | |
592 | char temp_buf[BUFSIZ]; | |
44d12d58 | 593 | int status; |
5eaef520 | 594 | |
595 | Put_message("This function has NO kerberos support, so strange things"); | |
596 | Put_message("may happen if you use it to register a user."); | |
597 | ||
598 | switch (YesNoQuestion("Do you know the users UID Number (y/n)", FALSE)) | |
599 | { | |
075fe5bb | 600 | case TRUE: |
5eaef520 | 601 | Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ); |
602 | args[0] = Strsave(temp_buf); | |
603 | break; | |
075fe5bb | 604 | case FALSE: |
5eaef520 | 605 | if (!(args[0] = GetUidNumberFromName())) |
606 | return DM_NORMAL; | |
607 | break; | |
075fe5bb | 608 | default: |
5eaef520 | 609 | return DM_NORMAL; |
461c03b6 | 610 | } |
075fe5bb | 611 | |
5eaef520 | 612 | sprintf(temp_buf, "u%s", args[0]); |
613 | login = strsave(temp_buf); | |
614 | if ((GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) || | |
615 | (GetFSTypes(&fstype, FALSE) == SUB_ERROR)) | |
616 | { | |
617 | args[1] = login; | |
618 | FreeInfo(args); /* This work because the NULL temination is ok. */ | |
619 | return DM_NORMAL; | |
075fe5bb | 620 | } |
5eaef520 | 621 | Put_message("KERBEROS code not added, did not reserve name with kerberos."); |
622 | args[1] = login; | |
623 | args[2] = fstype; | |
624 | args[3] = NULL; | |
625 | ||
626 | switch ((status = do_mr_query("register_user", CountArgs(args), | |
627 | args, Scream, NULL))) | |
628 | { | |
8defc06b | 629 | case MR_SUCCESS: |
5eaef520 | 630 | sprintf(temp_buf, "User %s successfully registered.", login); |
631 | Put_message(temp_buf); | |
632 | SetUserPassword(login); | |
633 | break; | |
8defc06b | 634 | case MR_IN_USE: |
5eaef520 | 635 | GiveBackLogin(login); |
636 | sprintf(temp_buf, "The username %s is already in use.", login); | |
637 | Put_message(temp_buf); | |
638 | break; | |
075fe5bb | 639 | default: |
5eaef520 | 640 | com_err(program_name, status, " in register_user"); |
641 | break; | |
075fe5bb | 642 | } |
5eaef520 | 643 | FreeInfo(args); |
644 | return DM_NORMAL; | |
08345b74 | 645 | } |
646 | ||
075fe5bb | 647 | /* Function Name: RealUpdateUser |
648 | * Description: actuall updates the user information. | |
649 | * Arguments: info - all current information for the user fields. | |
650 | * junk - an UNUSED boolean. | |
651 | * Returns: none. | |
08345b74 | 652 | */ |
653 | ||
5eaef520 | 654 | static void RealUpdateUser(char **info, Bool junk) |
08345b74 | 655 | { |
44d12d58 | 656 | int status; |
5eaef520 | 657 | char error_buf[BUFSIZ]; |
658 | char **args = AskUserInfo(info, TRUE); | |
659 | ||
660 | if (!args) | |
661 | { | |
662 | Put_message("Aborted."); | |
663 | return; | |
e4f91beb | 664 | } |
5eaef520 | 665 | if ((status = do_mr_query("update_user_account", CountArgs(args), |
666 | args, Scream, NULL))) | |
667 | { | |
668 | com_err(program_name, status, " in ModifyFields"); | |
669 | sprintf(error_buf, "User %s not updated due to errors.", info[NAME]); | |
670 | Put_message(error_buf); | |
08345b74 | 671 | } |
08345b74 | 672 | } |
673 | ||
075fe5bb | 674 | /* Function Name: UpdateUser |
675 | * Description: Modify some of the information about a user. | |
676 | * Arguments: argc, argv - login name of the user in argv[1]. | |
08345b74 | 677 | * Returns: DM_NORMAL. |
678 | */ | |
679 | ||
5eaef520 | 680 | int UpdateUser(int argc, char **argv) |
08345b74 | 681 | { |
5eaef520 | 682 | struct qelem *elem; |
683 | ||
684 | elem = GetUserInfo(LOGIN, argv[1], NULL); | |
685 | QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user"); | |
08345b74 | 686 | |
5eaef520 | 687 | FreeQueue(elem); |
688 | return DM_NORMAL; | |
08345b74 | 689 | } |
690 | ||
b3e25186 | 691 | /* Function Name: RealDeactivateUser |
692 | * Description: sets the user's status to 3. | |
693 | * Arguments: info - all current information for the user fields | |
694 | * one_item - indicates the user hasn't been queried yet | |
695 | * Returns: none. | |
696 | */ | |
697 | ||
5eaef520 | 698 | static void RealDeactivateUser(char **info, Bool one_item) |
b3e25186 | 699 | { |
44d12d58 | 700 | int status; |
5eaef520 | 701 | char txt_buf[BUFSIZ]; |
702 | char *qargs[2], **args; | |
703 | struct qelem *elem = NULL; | |
704 | ||
705 | if (one_item) | |
706 | { | |
707 | sprintf(txt_buf, "Deactivate user %s (y/n)", info[NAME]); | |
708 | if (YesNoQuestion(txt_buf, FALSE) != TRUE) | |
709 | return; | |
b3e25186 | 710 | } |
711 | ||
5eaef520 | 712 | qargs[0] = info[NAME]; |
713 | qargs[1] = "3"; | |
714 | if ((status = do_mr_query("update_user_status", 2, qargs, Scream, NULL))) | |
715 | { | |
716 | com_err(program_name, status, " in update_user_status"); | |
717 | sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]); | |
718 | Put_message(txt_buf); | |
719 | } | |
720 | else if (YesNoQuestion("Also deactivate matching list and filesystem (y/n)", | |
721 | FALSE) == TRUE) | |
722 | { | |
723 | status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo, | |
724 | (char *) &elem); | |
725 | if (status == MR_SUCCESS) | |
726 | { | |
727 | args = (char **) (QueueTop(elem)->q_data); | |
728 | free(args[L_ACTIVE]); | |
729 | args[L_ACTIVE] = strsave("0"); | |
730 | FreeAndClear(&args[L_MODTIME], TRUE); | |
731 | FreeAndClear(&args[L_MODBY], TRUE); | |
732 | FreeAndClear(&args[L_MODWITH], TRUE); | |
733 | SlipInNewName(args, args[L_NAME]); | |
734 | if ((status = do_mr_query("update_list", CountArgs(args), args, | |
735 | Scream, NULL))) | |
736 | { | |
737 | com_err(program_name, status, " updating list, " | |
738 | "not deactivating list or filesystem"); | |
739 | FreeInfo(args); | |
740 | FreeQueue(elem); | |
741 | return; | |
28da9b65 | 742 | } |
5eaef520 | 743 | FreeInfo(args); |
744 | FreeQueue(elem); | |
745 | elem = NULL; | |
746 | } | |
747 | else if (status != MR_NO_MATCH) | |
748 | { | |
749 | com_err(program_name, status, " getting list info, " | |
750 | "not deactivating list or filesystem"); | |
751 | return; | |
00d4c0ba | 752 | } |
28da9b65 | 753 | |
5eaef520 | 754 | if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]), |
755 | StoreInfo, (char *) &elem))) | |
756 | { | |
757 | com_err(program_name, status, " getting filsys info, " | |
758 | "not deactivating filesystem"); | |
759 | FreeInfo(args); | |
760 | FreeQueue(elem); | |
761 | return; | |
00d4c0ba | 762 | } |
5eaef520 | 763 | args = (char **) (QueueTop(elem)->q_data); |
764 | free(args[FS_TYPE]); | |
765 | args[FS_TYPE] = strsave("ERR"); | |
766 | free(args[FS_COMMENTS]); | |
767 | args[FS_COMMENTS] = strsave("Locker disabled; call 3-1325 for help"); | |
768 | FreeAndClear(&args[FS_MODTIME], TRUE); | |
769 | FreeAndClear(&args[FS_MODBY], TRUE); | |
770 | FreeAndClear(&args[FS_MODWITH], TRUE); | |
771 | SlipInNewName(args, args[FS_NAME]); | |
772 | if ((status = do_mr_query("update_filesys", CountArgs(args), args, | |
773 | Scream, NULL))) | |
774 | { | |
775 | com_err(program_name, status, " updating filesystem, " | |
776 | "not deactivating filesystem"); | |
777 | FreeInfo(args); | |
778 | FreeQueue(elem); | |
779 | return; | |
00d4c0ba | 780 | } |
5eaef520 | 781 | FreeInfo(args); |
782 | FreeQueue(elem); | |
b3e25186 | 783 | } |
784 | } | |
785 | ||
786 | ||
787 | /* Function Name: DeactivateUser | |
788 | * Description: sets the user's status to 3. | |
789 | * Arguments: argc, argv - login name of the user in argv[1]. | |
790 | * Returns: DM_NORMAL. | |
791 | */ | |
792 | ||
5eaef520 | 793 | int DeactivateUser(int argc, char **argv) |
b3e25186 | 794 | { |
5eaef520 | 795 | struct qelem *elem; |
b3e25186 | 796 | |
5eaef520 | 797 | elem = GetUserInfo(LOGIN, argv[1], NULL); |
798 | QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user"); | |
799 | ||
800 | FreeQueue(elem); | |
801 | return DM_NORMAL; | |
b3e25186 | 802 | } |
803 | ||
804 | ||
075fe5bb | 805 | /* ------------------------- Top Menu ------------------------- */ |
806 | ||
807 | /* DeleteUser() in delete.c */ | |
461c03b6 | 808 | |
075fe5bb | 809 | /* Function Name: DeleteUserByUid |
810 | * Description: Deletes the user given a uid number. | |
811 | * Arguments: argc, argv - uid if user in argv[1]. | |
08345b74 | 812 | * Returns: DM_NORMAL. |
5eaef520 | 813 | * NOTES: This just gets the username from the mr server |
075fe5bb | 814 | * and performs a DeleteUser(). |
08345b74 | 815 | */ |
816 | ||
5eaef520 | 817 | int DeleteUserByUid(int argc, char **argv) |
08345b74 | 818 | { |
5eaef520 | 819 | int status; |
820 | struct qelem *elem = NULL; | |
821 | char **info; | |
822 | ||
823 | if (!ValidName(argv[1])) | |
824 | return DM_NORMAL; | |
825 | ||
826 | if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo, | |
827 | (char *) &elem))) | |
828 | com_err(program_name, status, " in get_user_account_by_uid"); | |
829 | ||
830 | info = (char **) elem->q_data; | |
831 | argv[1] = info[U_NAME]; | |
832 | ||
833 | DeleteUser(argc, argv); | |
834 | return DM_NORMAL; | |
835 | } | |
08345b74 | 836 | |
075fe5bb | 837 | /* ------------------------- Show User Information ------------------------- */ |
08345b74 | 838 | |
839 | /* Function Name: ShowUserByLogin | |
840 | * Description: Shows user information given a login name. | |
841 | * Arguments: argc, argv - login name in argv[1]. | |
842 | * Returns: DM_NORMAL | |
843 | */ | |
844 | ||
5eaef520 | 845 | int ShowUserByLogin(int argc, char *argv[]) |
08345b74 | 846 | { |
5eaef520 | 847 | struct qelem *top, *elem; |
08345b74 | 848 | |
5eaef520 | 849 | elem = top = GetUserInfo(LOGIN, argv[1], NULL); |
850 | Loop(elem, PrintUserInfo); | |
08345b74 | 851 | |
5eaef520 | 852 | FreeQueue(top); |
853 | return DM_NORMAL; | |
08345b74 | 854 | } |
855 | ||
856 | /* Function Name: RetrieveUserByName | |
857 | * Description: Show information on a user give fist and/or last name. | |
858 | * Arguments: argc, argv - argv[1] - first name. | |
859 | * argv[2] - last name. | |
860 | * Returns: DM_NORMAL. | |
861 | */ | |
862 | ||
5eaef520 | 863 | int ShowUserByName(int argc, char *argv[]) |
08345b74 | 864 | { |
5eaef520 | 865 | struct qelem *top; |
866 | char buf[BUFSIZ]; | |
08345b74 | 867 | |
5eaef520 | 868 | top = GetUserInfo(BY_NAME, argv[1], argv[2]); |
08345b74 | 869 | |
5eaef520 | 870 | if (!top) /* if there was an error then return. */ |
871 | return DM_NORMAL; | |
08345b74 | 872 | |
5eaef520 | 873 | if (!PromptWithDefault("Print full information, or just the names (f/n)?", |
874 | buf, 2, "f")) | |
875 | return DM_NORMAL; | |
08345b74 | 876 | |
5eaef520 | 877 | switch (buf[0]) |
878 | { | |
075fe5bb | 879 | case 'F': |
880 | case 'f': | |
5eaef520 | 881 | Loop(top, PrintUserInfo); |
882 | break; | |
075fe5bb | 883 | case 'N': |
884 | case 'n': | |
5eaef520 | 885 | Loop(top, PrintUserName); |
886 | break; | |
075fe5bb | 887 | } |
5eaef520 | 888 | |
889 | FreeQueue(top); | |
890 | return DM_NORMAL; | |
08345b74 | 891 | } |
892 | ||
893 | /* Function Name: ShowUserByClass | |
894 | * Description: Shows real and login names of all users in class. | |
895 | * Arguments: argc, argv - argv[1] contains the class. | |
896 | * Returns: none. | |
897 | */ | |
898 | ||
5eaef520 | 899 | int ShowUserByClass(int argc, char **argv) |
08345b74 | 900 | { |
5eaef520 | 901 | struct qelem *top; |
08345b74 | 902 | |
5eaef520 | 903 | if (YesNoQuestion("This will take a long time. Are you sure", 0) == FALSE) |
904 | return DM_NORMAL; | |
905 | top = GetUserInfo(CLASS, argv[1], NULL); | |
906 | Loop(top, PrintUserName); | |
08345b74 | 907 | |
5eaef520 | 908 | FreeQueue(top); |
909 | return DM_NORMAL; | |
08345b74 | 910 | } |
1e80e2f4 | 911 | |
912 | ||
81701699 | 913 | /* Function Name: ShowUserById |
914 | * Description: Shows user information given an ID number. | |
915 | * Arguments: argc, argv - ID number in argv[1]. | |
916 | * Returns: DM_NORMAL | |
917 | */ | |
918 | ||
5eaef520 | 919 | int ShowUserById(int argc, char *argv[]) |
81701699 | 920 | { |
5eaef520 | 921 | struct qelem *top, *elem; |
81701699 | 922 | |
5eaef520 | 923 | elem = top = GetUserInfo(ID, argv[1], NULL); |
924 | Loop(elem, PrintUserInfo); | |
81701699 | 925 | |
5eaef520 | 926 | FreeQueue(top); |
927 | return DM_NORMAL; | |
81701699 | 928 | } |
929 | ||
930 | ||
1e80e2f4 | 931 | /* Function Name: GetKrbmap |
932 | * Description: Shows user <-> Kerberos mappings | |
933 | * Arguments: argc, argv - argv[1] contains the user login name, | |
934 | * argv[2] contains the principal | |
935 | * Returns: none. | |
936 | */ | |
937 | ||
5eaef520 | 938 | int GetKrbmap(int argc, char **argv) |
1e80e2f4 | 939 | { |
5eaef520 | 940 | int stat; |
941 | struct qelem *elem = NULL, *top; | |
942 | char buf[BUFSIZ]; | |
943 | ||
944 | if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1], | |
945 | StoreInfo, (char *)&elem))) | |
946 | { | |
947 | com_err(program_name, stat, " in GetKrbMap."); | |
948 | return DM_NORMAL; | |
1e80e2f4 | 949 | } |
950 | ||
5eaef520 | 951 | top = elem = QueueTop(elem); |
952 | Put_message(""); | |
953 | while (elem) | |
954 | { | |
955 | char **info = (char **) elem->q_data; | |
956 | sprintf(buf, "User: %-9s Principal: %s", | |
957 | info[KMAP_USER], info[KMAP_PRINCIPAL]); | |
958 | Put_message(buf); | |
959 | elem = elem->q_forw; | |
1e80e2f4 | 960 | } |
961 | ||
5eaef520 | 962 | FreeQueue(QueueTop(top)); |
963 | return DM_NORMAL; | |
1e80e2f4 | 964 | } |
965 | ||
966 | ||
967 | /* Function Name: AddKrbmap | |
968 | * Description: Add a new user <-> Kerberos mapping | |
969 | * Arguments: argc, argv - argv[1] contains the user login name, | |
970 | * argv[2] contains the principal | |
971 | * Returns: none. | |
972 | */ | |
973 | ||
5eaef520 | 974 | int AddKrbmap(int argc, char **argv) |
1e80e2f4 | 975 | { |
5eaef520 | 976 | int stat; |
1e80e2f4 | 977 | |
5eaef520 | 978 | if (!strchr(argv[KMAP_PRINCIPAL + 1], '@')) |
979 | { | |
980 | Put_message("Please specify a realm for the kerberos principal."); | |
981 | return DM_NORMAL; | |
1e80e2f4 | 982 | } |
5eaef520 | 983 | if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1], |
984 | Scream, NULL))) | |
985 | { | |
986 | com_err(program_name, stat, " in AddKrbMap."); | |
987 | if (stat == MR_EXISTS) | |
988 | Put_message("No user or principal may have more than one mapping."); | |
1e80e2f4 | 989 | } |
5eaef520 | 990 | return DM_NORMAL; |
1e80e2f4 | 991 | } |
992 | ||
993 | ||
994 | /* Function Name: DeleteKrbmap | |
995 | * Description: Remove a user <-> Kerberos mapping | |
996 | * Arguments: argc, argv - argv[1] contains the user login name, | |
997 | * argv[2] contains the principal | |
998 | * Returns: none. | |
999 | */ | |
1000 | ||
5eaef520 | 1001 | int DeleteKrbmap(int argc, char **argv) |
1e80e2f4 | 1002 | { |
5eaef520 | 1003 | int stat; |
1e80e2f4 | 1004 | |
5eaef520 | 1005 | if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1], |
1006 | Scream, NULL))) | |
1007 | com_err(program_name, stat, " in DeleteKrbMap."); | |
1008 | return DM_NORMAL; | |
1e80e2f4 | 1009 | } |
559fe7ab | 1010 | |
1011 | ||
10207d4d | 1012 | /* Function Name: GetDirFlags |
1013 | * Description: Shows MITdir listing preferences | |
1014 | * Arguments: argc, argv - argv[1] contains the user login name | |
1015 | * Returns: none. | |
1016 | */ | |
1017 | ||
5eaef520 | 1018 | int GetDirFlags(int argc, char **argv) |
10207d4d | 1019 | { |
5eaef520 | 1020 | int stat, flags; |
1021 | struct qelem *elem = NULL; | |
1022 | char buf[BUFSIZ], **info; | |
1023 | ||
1024 | if (!ValidName(argv[1])) | |
1025 | return DM_NORMAL; | |
1026 | ||
1027 | if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1], | |
1028 | StoreInfo, (char *)&elem))) | |
1029 | { | |
1030 | com_err(program_name, stat, " in GetDirFlags."); | |
1031 | return DM_NORMAL; | |
10207d4d | 1032 | } |
1033 | ||
5eaef520 | 1034 | info = (char **) QueueTop(elem)->q_data; |
1035 | flags = atoi(info[0]); | |
1036 | FreeQueue(QueueTop(elem)); | |
1037 | ||
1038 | Put_message(""); | |
1039 | sprintf(buf, "User: %s", argv[1]); | |
1040 | Put_message(buf); | |
1041 | if (flags & DIRFLAGS_SUPPRESS) | |
1042 | Put_message("Does NOT appear in the on-line directory."); | |
1043 | else | |
1044 | { | |
1045 | Put_message("Does appear in the on-line directory."); | |
1046 | if (flags & DIRFLAGS_NONLOCAL) | |
1047 | Put_message("Is listed with non-MIT.EDU email address (if known)"); | |
1048 | else | |
1049 | Put_message("Is listed with MIT.EDU email address."); | |
10207d4d | 1050 | } |
1051 | ||
5eaef520 | 1052 | return DM_NORMAL; |
10207d4d | 1053 | } |
1054 | ||
1055 | /* Function Name: SetDirFlags | |
1056 | * Description: Update online directory preferences | |
1057 | * Arguments: argc, argv - the login name of the user in argv[1]. | |
1058 | * Returns: DM_NORMAL. | |
1059 | */ | |
1060 | ||
5eaef520 | 1061 | int SetDirFlags(int argc, char **argv) |
559fe7ab | 1062 | { |
5eaef520 | 1063 | int stat, flags; |
1064 | char **info, buf[BUFSIZ], *args[2]; | |
1065 | struct qelem *elem = NULL; | |
1066 | ||
1067 | if (!ValidName(argv[1])) | |
1068 | return DM_NORMAL; | |
1069 | ||
1070 | /* Fetch current prefs */ | |
1071 | if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1], | |
1072 | StoreInfo, (char *) &elem))) | |
1073 | { | |
1074 | com_err(program_name, stat, " in GetDirFlags."); | |
1075 | return DM_NORMAL; | |
559fe7ab | 1076 | } |
5eaef520 | 1077 | info = (char **) QueueTop(elem)->q_data; |
1078 | flags = atoi(info[0]); | |
1079 | FreeQueue(QueueTop(elem)); | |
1080 | ||
1081 | sprintf(buf, "List %s in the on-line directory (y/n)", argv[1]); | |
1082 | if (YesNoQuestion(buf, !(flags & DIRFLAGS_SUPPRESS))) | |
1083 | flags &= ~DIRFLAGS_SUPPRESS; | |
1084 | else | |
1085 | flags |= DIRFLAGS_SUPPRESS; | |
1086 | ||
1087 | sprintf(buf, "List MIT.EDU email address even when mail is " | |
1088 | "forwarded elsewhere? (y/n)"); | |
1089 | if (YesNoQuestion(buf, !(flags & DIRFLAGS_NONLOCAL))) | |
1090 | flags &= ~DIRFLAGS_NONLOCAL; | |
1091 | else | |
1092 | flags |= DIRFLAGS_NONLOCAL; | |
1093 | ||
1094 | args[0] = argv[1]; | |
1095 | sprintf(buf, "%d", flags); | |
1096 | args[1] = buf; | |
1097 | if ((stat = do_mr_query("update_user_directory_flags", 2, | |
1098 | args, Scream, NULL))) | |
1099 | com_err(program_name, stat, " in SetDirFlags"); | |
1100 | else | |
1101 | Put_message("Directory preferences set."); | |
1102 | ||
1103 | return DM_NORMAL; | |
559fe7ab | 1104 | } |