1 #if (!defined(lint) && !defined(SABER))
2 static char rcsid_module_c[] = "$Header$";
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.
7 * It Contains: Functions for manipulating user information.
10 * By: Chris D. Peterson
16 * Copyright 1988 by the Massachusetts Institute of Technology.
18 * For further information on copyright and distribution
19 * see the file mit-copyright.h
25 #include <moira_site.h>
34 #include "mit-copyright.h"
46 #define DEFAULT_SHELL "/bin/athena/tcsh"
48 #define DEFAULT_SHELL "/bin/csh"
50 #define DEFAULT_CLASS "?"
53 /* Function Name: UserState
54 * Description: Convert a numeric state into a descriptive string.
55 * Arguments: state value
56 * Returns: pointer to statically allocated string.
59 static char *states[] = { "Registerable (0)",
61 "Half Registered (2)",
63 "Not registerable (4)",
64 "Enrolled/Registerable (5)",
65 "Enrolled/Not Registerable (6)",
66 "Half Enrolled (7)" };
68 static char *UserState(state)
71 static char buf[BUFSIZ];
73 if (state < 0 || state >= US_END) {
74 sprintf(buf, "Unknown (%d)", state);
77 return(states[state]);
81 /* Function Name: PrintUserName
82 * Description: Print name of a user.
83 * Arguments: info - the information about a user.
91 char buf[BUFSIZ], print_buf[BUFSIZ];
92 sprintf(buf, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
93 sprintf(print_buf, "%-40s User Name: %s", buf, info[U_NAME]);
94 Put_message(print_buf);
97 /* Function Name: PrintUserInfo
98 * Description: Prints Information about a user.
99 * Arguments: info - an argument list with the user information
108 char name[BUFSIZ], buf[BUFSIZ];
114 sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
115 sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name);
117 sprintf(buf, "User id: %-23s Login shell %-10s Class: %s",
118 info[U_UID], info[U_SHELL], info[U_CLASS]);
122 sprintf(buf, "%s:%s", info[U_NAME], info[U_MITID]);
124 status = GDSS_Verify(buf, strlen(buf), info[U_SIGNATURE], &si);
126 hex_dump(info[U_SIGNATURE]);
127 sprintf(buf, "GDSS_Verify => %d", status);
134 sprintf(buf, "Account is: %-20s MIT ID number: %s Signed: %s",
135 UserState(atoi(info[U_STATE])), info[U_MITID],
136 *info[U_SIGNATURE] ? (status ? "Bad" : "Yes") : "No");
138 if (atoi(info[U_SECURE]))
139 sprintf(buf, "Secure password set on %s.", atot(info[U_SECURE]));
141 sprintf(buf, "No secure password set.");
143 sprintf(buf, "Comments: %s", info[U_COMMENT]);
145 sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME],info[U_MODWITH]);
149 /* Function Name: SetUserDefaults
150 * Description: Sets the default values for add user.
151 * Arguments: info - a blank user info array of char *'s.
152 * Returns: args - the filled info structure.
156 SetUserDefaults(info)
159 info[U_NAME] = Strsave(UNIQUE_LOGIN);
160 info[U_UID] = Strsave(UNIQUE_UID);
161 info[U_SHELL] = Strsave(DEFAULT_SHELL);
162 info[U_LAST] = Strsave(DEFAULT_NONE);
163 info[U_FIRST] = Strsave(DEFAULT_NONE);
164 info[U_MIDDLE] = Strsave(DEFAULT_NONE);
165 info[U_STATE] = Strsave(DEFAULT_NO);
166 info[U_MITID] = Strsave(DEFAULT_NONE);
167 info[U_CLASS] = Strsave(DEFAULT_CLASS);
168 info[U_COMMENT] = Strsave("");
169 info[U_SIGNATURE] = Strsave("");
170 info[U_SECURE] = Strsave("0");
171 info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
176 /* Check that the supplied name follows the capitalization rules, and
177 * offer to correct it if not.
180 CorrectCapitalization(name)
183 char temp_buf[BUFSIZ], fixname[BUFSIZ];
185 strcpy(fixname, *name);
187 if (strcmp(fixname, *name)) {
188 Put_message("You entered a name which does not follow the capitalization conventions.");
189 sprintf(temp_buf, "Correct it to \"%s\"", fixname);
190 if (YesNoQuestion(temp_buf, 1) == TRUE) {
192 *name = strsave(fixname);
198 /* Function Name: AskUserInfo.
199 * Description: This function askes the user for information about a
200 * machine and saves it into a structure.
201 * Arguments: info - a pointer the the structure to put the info into.
202 * flags - Flags asking us which info we want.
203 * Returns: the args to pass to the query.
204 * NOTES: the return args are not necessarily in the correct order to
205 * use the #defined names (e.g args[UID] is not the uid anymore).
209 AskUserInfo(info, name)
217 char temp_buf[BUFSIZ], *newname, *temp_ptr, *sig, sig_buf[BUFSIZ];
220 sprintf(temp_buf,"\nChanging Attributes of user %s.\n",info[U_NAME]);
221 Put_message(temp_buf);
223 struct qelem *elem = NULL;
226 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
228 CorrectCapitalization(&info[U_LAST]);
229 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
231 CorrectCapitalization(&info[U_FIRST]);
232 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) ==
235 CorrectCapitalization(&info[U_MIDDLE]);
236 argv[0] = info[U_FIRST];
237 argv[1] = info[U_LAST];
238 if (do_mr_query("get_user_account_by_name", 2, argv,
239 StoreInfo, (char *) &elem) == 0) {
240 Put_message("A user by that name already exists in the database.");
241 Loop(QueueTop(elem), PrintUserInfo);
242 Loop(QueueTop(elem), FreeInfo);
244 if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
249 newname = Strsave(info[U_NAME]);
250 if (GetValueFromUser("The new login name for this user", &newname) ==
253 } else if (GetValueFromUser("Login name for this user", &info[U_NAME]) ==
257 if (GetValueFromUser("User's UID", &info[U_UID]) == SUB_ERROR)
259 if (GetValueFromUser("User's shell", &info[U_SHELL]) == SUB_ERROR)
262 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
264 CorrectCapitalization(&info[U_LAST]);
265 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
267 CorrectCapitalization(&info[U_FIRST]);
268 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) ==
271 CorrectCapitalization(&info[U_MIDDLE]);
275 if (GetValueFromUser("User's status (? for help)", &info[U_STATE]) ==
278 if (isdigit(info[U_STATE][0]))
280 Put_message("Valid status numbers:");
281 for (i = 0; i < US_END; i++) {
282 sprintf(temp_buf, " %d: %s", i, states[i]);
283 Put_message(temp_buf);
286 if (GetValueFromUser("User's MIT ID number", &info[U_MITID]) == SUB_ERROR)
288 RemoveHyphens(info[U_MITID]);
289 if (GetTypeFromUser("User's MIT Year (class)", "class", &info[U_CLASS]) ==
292 if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR)
295 if (YesNoQuestion("Secure password set",
296 atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE) {
297 free(info[U_SECURE]);
298 info[U_SECURE] = strsave("0");
299 } else if (!strcmp(info[U_SECURE], "0")) {
303 gettimeofday(&tv, (struct timezone *)NULL);
304 sprintf(buf, "%d", tv.tv_sec);
305 free(info[U_SECURE]);
306 info[U_SECURE] = strsave(buf);
311 if (strcmp(info[U_NAME], UNIQUE_LOGIN)) {
313 sprintf(temp_buf, "%s:%s", newname, info[U_MITID]);
315 sprintf(temp_buf, "%s:%s", info[U_NAME], info[U_MITID]);
317 i = GDSS_Verify(temp_buf, strlen(temp_buf), info[U_SIGNATURE], &si);
318 /* If it's already signed OK, don't resign it. */
319 if (i != GDSS_SUCCESS) {
320 free(info[U_SIGNATURE]);
321 info[U_SIGNATURE] = malloc(GDSS_Sig_Size() * 2);
323 i = GDSS_Sign(temp_buf, strlen(temp_buf), info[U_SIGNATURE]);
324 if (i != GDSS_SUCCESS)
325 com_err(program_name, gdss2et(i), "Failed to create signature");
327 unsigned char buf[256];
329 i = GDSS_Verify(temp_buf, strlen(temp_buf),
330 info[U_SIGNATURE], &si);
331 if (strlen(buf) > 68) {
333 Put_message("Signature too long, trying again");
339 Put_message("Made signature:");
341 Put_message("Don't need to remake signature");
345 hex_dump(info[U_SIGNATURE]);
349 info[U_SIGNATURE] = strsave("");
352 FreeAndClear(&info[U_MODTIME], TRUE);
353 FreeAndClear(&info[U_MODBY], TRUE);
354 FreeAndClear(&info[U_MODWITH], TRUE);
357 * Slide the newname into the #2 slot, this screws up all future references
358 * to this list, since we slip the pointer into a info list it gets freed
359 * when the rest of the list gets freed.
362 SlipInNewName(info, newname);
367 /* Function Name: GetUserInfo
368 * Description: Stores the user information in a queue.
369 * Arguments: type - type of field given to get info, one of:
370 * LOGIN, UID, BY_NAME, CLASS.
371 * name1 - name of thing specified by type (wildcards okay)
372 * name2 - other name, only used in get user by first and last.
374 * Returns: the first element of the queue containing the user info.
379 GetUserInfo(type, name1, name2)
385 struct qelem * elem = NULL;
390 if ( (status = do_mr_query("get_user_account_by_login", 1, args,
391 StoreInfo, (char *) &elem)) != 0) {
392 com_err(program_name, status,
393 " when attempting to get_user_account_by_login.");
399 if ( (status = do_mr_query("get_user_account_by_uid", 1, args,
400 StoreInfo, (char *) &elem)) != 0) {
401 com_err(program_name, status,
402 " when attempting to get_user_account_by_uid.");
409 if ( (status = do_mr_query("get_user_account_by_name", 2, args,
410 StoreInfo, (char *) &elem)) != 0) {
411 com_err(program_name, status,
412 " when attempting to get_user_account_by_name.");
418 if ( (status = do_mr_query("get_user_account_by_class", 1, args,
419 StoreInfo, (char *) &elem)) != 0) {
420 com_err(program_name, status,
421 " when attempting to get_user_account_by_class.");
427 if ( (status = do_mr_query("get_user_account_by_id", 1, args,
428 StoreInfo, (char *) &elem)) != 0) {
429 com_err(program_name, status,
430 " when attempting to get_user_account_by_id.");
435 return( QueueTop(elem) );
438 /* Function Name: AddNewUser
439 * Description: Adds a new user to the database.
441 * Returns: DM_NORMAL.
449 char ** args, *info[MAX_ARGS_SIZE];
451 if ((args = AskUserInfo(SetUserDefaults(info), FALSE)) == NULL) {
452 Put_message("Aborted.");
457 if ( (status = do_mr_query("add_user_account", CountArgs(args),
458 args, Scream, (char *) NULL)) != MR_SUCCESS)
459 com_err(program_name, status, " in add_user_account");
461 Put_message("New user added to database.");
467 /* Function Name: GetLoginName
468 * Description: Asks the user for a login name and reserves
471 * Returns: a malloced login name for the user.
480 if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
482 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
487 /* Function Name: ChooseUser
488 * Description: Choose a user from a list and return the uid.
489 * Arguments: top - a queue of user information.
490 * Returns: uid - the malloced uid of the user that was chosen.
497 while (elem != NULL) {
498 char ** info = (char **) elem->q_data;
500 switch(YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE)) {
502 return(Strsave(info[U_UID]));
505 default: /* quit or ^C. */
513 /* Function Name: GetUidNumberFromName
514 * Description: Gets the users uid number, from the name.
516 * Returns: uid - a malloced string containing the uid.
520 GetUidNumberFromName()
522 char *args[5], *uid, first[BUFSIZ], last[BUFSIZ];
524 struct qelem * top = NULL;
526 if (!Prompt_input("First Name: ", first, BUFSIZ))
528 if (!Prompt_input("Last Name: ", last, BUFSIZ))
536 switch (status = do_mr_query("get_user_account_by_name", 2, args,
537 StoreInfo, (char *) &top)) {
541 Put_message("There is no user in the database with that name.");
544 com_err(program_name, status, " in get_account_user_by_name.");
549 if (QueueCount(top) == 1) /* This is a unique name. */ {
550 char ** info = (char **) top->q_data;
551 Put_message("User ID Number retrieved for the user: ");
554 uid = Strsave(info[U_UID]);
556 return(Strsave(uid));
559 Put_message("That name is not unique, choose the user that you want.");
560 uid = ChooseUser(top);
565 /* Function Name: SetUserPassword
566 * Description: Set the new kerberos password for this user.
567 * Arguments: name - kerberos principle name for this user, (login name).
572 SetUserPassword(name)
575 name = name; /* make saber happy. */
576 Put_message("Kerberos password not changed, code non-existant.");
577 /* clever message to call account_admin, if this fails. */
580 /* Function Name: GiveBackLogin
581 * Description: Gives back previously reserved kerberous principle.
582 * Arguments: name - principle to give back.
590 name = name; /* make saber happy. */
591 Put_message("kerberos code not implimented, name not given back.");
592 /* send mail to db maintainer if this fails. */
595 /* Function Name: RegisterUser
596 * Description: This function registers a user.
598 * Returns: DM_NORMAL.
604 char * args[MAX_ARGS_SIZE];
605 char *login, *fstype = NULL;
606 char temp_buf[BUFSIZ];
609 Put_message("This function has NO kerberos support, so strange things");
610 Put_message("may happen if you use it to register a user.");
612 switch (YesNoQuestion("Do you know the users UID Number (y/n)", FALSE)) {
614 Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
615 args[0] = Strsave(temp_buf);
618 if ( (args[0] = GetUidNumberFromName()) == NULL)
625 sprintf(temp_buf, "u%s", args[0]);
626 login = strsave(temp_buf);
627 if ( (GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) ||
628 ( GetFSTypes(&fstype, FALSE) == SUB_ERROR ) ) {
630 FreeInfo(args); /* This work because the NULL temination is ok. */
633 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
638 switch (status = do_mr_query("register_user", CountArgs(args),
639 args, Scream, (char *) NULL)) {
641 sprintf(temp_buf, "User %s successfully registered.", login);
642 Put_message(temp_buf);
643 SetUserPassword(login);
646 GiveBackLogin(login);
647 sprintf(temp_buf, "The username %s is already in use.", login);
648 Put_message(temp_buf);
651 com_err(program_name, status, " in register_user");
658 /* Function Name: RealUpdateUser
659 * Description: actuall updates the user information.
660 * Arguments: info - all current information for the user fields.
661 * junk - an UNUSED boolean.
667 RealUpdateUser(info, junk)
672 char error_buf[BUFSIZ];
673 char ** args = AskUserInfo(info, TRUE);
676 Put_message("Aborted.");
679 if ( (status = do_mr_query("update_user_account", CountArgs(args),
680 args, Scream, (char *) NULL)) != MR_SUCCESS) {
681 com_err(program_name, status, " in ModifyFields");
682 sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
683 Put_message(error_buf);
687 /* Function Name: UpdateUser
688 * Description: Modify some of the information about a user.
689 * Arguments: argc, argv - login name of the user in argv[1].
690 * Returns: DM_NORMAL.
695 UpdateUser(argc, argv)
701 elem = GetUserInfo(LOGIN, argv[1], (char *) NULL);
702 QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user");
708 /* Function Name: RealDeactivateUser
709 * Description: sets the user's status to 3.
710 * Arguments: info - all current information for the user fields
711 * one_item - indicates the user hasn't been queried yet
716 RealDeactivateUser(info, one_item)
721 char txt_buf[BUFSIZ];
722 char * qargs[2], **args;
723 struct qelem *elem = NULL;
726 sprintf(txt_buf, "Deactivate user %s (y/n)", info[NAME]);
727 if (YesNoQuestion(txt_buf, FALSE) != TRUE)
731 qargs[0] = info[NAME];
733 if ((status = do_mr_query("update_user_status", 2, qargs, Scream,
734 (char *) NULL)) != MR_SUCCESS) {
735 com_err(program_name, status, " in update_user_status");
736 sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
737 Put_message(txt_buf);
738 } else if (YesNoQuestion("Also deactivate matching list and filesystem (y/n)",
740 if (status = do_mr_query("get_list_info", 1, &(info[NAME]),
741 StoreInfo, (char *) &elem)) {
742 com_err(program_name, status, " getting list info, not deactivating list or filesystem");
745 args =(char **) (QueueTop(elem)->q_data);
746 free(args[L_ACTIVE]);
747 args[L_ACTIVE] = strsave("0");
748 FreeAndClear(&args[L_MODTIME], TRUE);
749 FreeAndClear(&args[L_MODBY], TRUE);
750 FreeAndClear(&args[L_MODWITH], TRUE);
751 SlipInNewName(args, args[L_NAME]);
752 if (status = do_mr_query("update_list", CountArgs(args), args,
753 Scream, (char *) NULL)) {
754 com_err(program_name, status, " updating list, not deactivating list or filesystem");
761 elem = (struct qelem *) NULL;
762 if (status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
763 StoreInfo, (char *) &elem)) {
764 com_err(program_name, status, " getting filsys info, not deactivating filesystem");
769 args = (char **) (QueueTop(elem)->q_data);
771 args[FS_TYPE] = strsave("ERR");
772 free(args[FS_COMMENTS]);
773 args[FS_COMMENTS] = strsave("Locker disabled; call 3-1325 for help");
774 FreeAndClear(&args[FS_MODTIME], TRUE);
775 FreeAndClear(&args[FS_MODBY], TRUE);
776 FreeAndClear(&args[FS_MODWITH], TRUE);
777 SlipInNewName(args, args[FS_NAME]);
778 if (status = do_mr_query("update_filesys", CountArgs(args), args,
779 Scream, (char *) NULL)) {
780 com_err(program_name, status, " updating filesystem, not deactivating filesystem");
791 /* Function Name: DeactivateUser
792 * Description: sets the user's status to 3.
793 * Arguments: argc, argv - login name of the user in argv[1].
794 * Returns: DM_NORMAL.
799 DeactivateUser(argc, argv)
805 elem = GetUserInfo(LOGIN, argv[1], (char *) NULL);
806 QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user");
813 /* ------------------------- Top Menu ------------------------- */
815 /* DeleteUser() in delete.c */
817 /* Function Name: DeleteUserByUid
818 * Description: Deletes the user given a uid number.
819 * Arguments: argc, argv - uid if user in argv[1].
820 * Returns: DM_NORMAL.
821 * NOTES: This just gets the username from the mr server
822 * and performs a DeleteUser().
826 DeleteUserByUid(argc, argv)
831 struct qelem *elem = NULL;
834 if(!ValidName(argv[1]))
837 if ( (status = do_mr_query("get_user_account_by_uid", 1, argv+1, StoreInfo,
838 (char * ) &elem)) != MR_SUCCESS)
839 com_err(program_name, status, " in get_user_account_by_uid");
841 info = (char **) elem->q_data;
842 argv[1] = info[U_NAME];
844 (void) DeleteUser(argc, argv);
848 /* ------------------------- Show User Information ------------------------- */
850 /* Function Name: ShowUserByLogin
851 * Description: Shows user information given a login name.
852 * Arguments: argc, argv - login name in argv[1].
858 ShowUserByLogin(argc, argv)
862 struct qelem *top, *elem;
864 elem = top = GetUserInfo(LOGIN, argv[1], (char *) NULL);
865 Loop(elem, PrintUserInfo);
871 /* Function Name: RetrieveUserByName
872 * Description: Show information on a user give fist and/or last name.
873 * Arguments: argc, argv - argv[1] - first name.
874 * argv[2] - last name.
875 * Returns: DM_NORMAL.
880 ShowUserByName(argc, argv)
887 top = GetUserInfo(BY_NAME, argv[1], argv[2]);
889 if (top == NULL) /* if there was an error then return. */
892 if (!PromptWithDefault("Print full information, or just the names (f/n)?",
899 Loop(top, PrintUserInfo);
903 Loop(top, PrintUserName);
911 /* Function Name: ShowUserByClass
912 * Description: Shows real and login names of all users in class.
913 * Arguments: argc, argv - argv[1] contains the class.
919 ShowUserByClass(argc, argv)
925 if (YesNoQuestion("This will take a long time. Are you sure", 0) == FALSE)
927 top = GetUserInfo(CLASS, argv[1], (char *) NULL);
928 Loop(top, PrintUserName);
935 /* Function Name: ShowUserById
936 * Description: Shows user information given an ID number.
937 * Arguments: argc, argv - ID number in argv[1].
943 ShowUserById(argc, argv)
947 struct qelem *top, *elem;
949 elem = top = GetUserInfo(ID, argv[1], (char *) NULL);
950 Loop(elem, PrintUserInfo);
957 /* Function Name: GetKrbmap
958 * Description: Shows user <-> Kerberos mappings
959 * Arguments: argc, argv - argv[1] contains the user login name,
960 * argv[2] contains the principal
966 GetKrbmap(argc, argv)
971 struct qelem *elem = NULL, *top;
974 if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
975 StoreInfo, (char *)&elem)) != 0) {
976 com_err(program_name, stat, " in GetKrbMap.");
980 top = elem = QueueTop(elem);
982 while (elem != NULL) {
983 char **info = (char **) elem->q_data;
984 sprintf(buf, "User: %-9s Principal: %s",
985 info[KMAP_USER], info[KMAP_PRINCIPAL]);
990 FreeQueue(QueueTop(top));
995 /* Function Name: AddKrbmap
996 * Description: Add a new user <-> Kerberos mapping
997 * Arguments: argc, argv - argv[1] contains the user login name,
998 * argv[2] contains the principal
1004 AddKrbmap(argc, argv)
1010 if (!strchr(argv[KMAP_PRINCIPAL + 1], '@')) {
1011 Put_message("Please specify a realm for the kerberos principal.");
1014 if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
1015 Scream, NULL)) != 0) {
1016 com_err(program_name, stat, " in AddKrbMap.");
1017 if (stat == MR_EXISTS)
1018 Put_message("No user or principal may have more than one mapping.");
1024 /* Function Name: DeleteKrbmap
1025 * Description: Remove a user <-> Kerberos mapping
1026 * Arguments: argc, argv - argv[1] contains the user login name,
1027 * argv[2] contains the principal
1033 DeleteKrbmap(argc, argv)
1039 if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
1040 Scream, NULL)) != 0) {
1041 com_err(program_name, stat, " in DeleteKrbMap.");
1053 sprintf(buf, "Size: %d", strlen(p));
1055 while (strlen(p) >= 8) {
1056 sprintf(buf, "%02x %02x %02x %02x %02x %02x %02x %02x",
1057 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
1061 switch (strlen(p)) {
1063 sprintf(buf, "%02x %02x %02x %02x %02x %02x %02x",
1064 p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
1067 sprintf(buf, "%02x %02x %02x %02x %02x %02x",
1068 p[0], p[1], p[2], p[3], p[4], p[5]);
1071 sprintf(buf, "%02x %02x %02x %02x %02x",
1072 p[0], p[1], p[2], p[3], p[4]);
1075 sprintf(buf, "%02x %02x %02x %02x",
1076 p[0], p[1], p[2], p[3]);
1079 sprintf(buf, "%02x %02x %02x",
1083 sprintf(buf, "%02x %02x",
1087 sprintf(buf, "%02x",