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