]> andersk Git - moira.git/blob - clients/moira/user.c
added user state "half enrolled"
[moira.git] / clients / moira / user.c
1 #if (!defined(lint) && !defined(SABER))
2   static char rcsid_module_c[] = "$Header$";
3 #endif lint
4
5 /*      This is the file user.c for the SMS Client, which allows a nieve
6  *      user to quickly and easily maintain most parts of the SMS database.
7  *      It Contains: Functions for manipulating user information.
8  *      
9  *      Created:        5/9/88
10  *      By:             Chris D. Peterson
11  *
12  *      $Source$
13  *      $Author$
14  *      $Header$
15  *      
16  *      Copyright 1988 by the Massachusetts Institute of Technology.
17  *
18  *      For further information on copyright and distribution 
19  *      see the file mit-copyright.h
20  */
21
22 #include <stdio.h>
23 #include <strings.h>
24 #include <sms.h>
25 #include <sms_app.h>
26 #include <menu.h>
27 #include <ctype.h>
28
29 #include "mit-copyright.h"
30 #include "defs.h"
31 #include "f_defs.h"
32 #include "globals.h"
33
34 #define LOGIN 0
35 #define UID   1
36 #define BY_NAME  2
37 #define CLASS 3
38
39 #define DEFAULT_SHELL "/bin/csh"
40 #define DEFAULT_CLASS "?"
41
42
43 /*      Function Name: UserState
44  *      Description: Convert a numeric state into a descriptive string.
45  *      Arguments: state value
46  *      Returns: pointer to statically allocated string.
47  */
48
49 static char *states[] = { "Registerable (0)",
50                           "Active (1)",
51                           "Half Registered (2)",
52                           "Deleted (3)",
53                           "Not registerable (4)",
54                           "Enrolled/Registerable (5)",
55                           "Enrolled/Not Registerable (6)",
56                           "Half Enrolled (7)" };
57
58 static char *UserState(state)
59 int state;
60 {
61     char buf[BUFSIZ];
62
63     if (state < 0 || state >= US_END) {
64         sprintf(buf, "Unknown (%d)", state);
65         return(buf);
66     }
67     return(states[state]);
68 }
69
70
71 /*      Function Name: PrintUserName
72  *      Description: Print name of a user.
73  *      Arguments: info - the information about a user.
74  *      Returns: none.
75  */
76
77 static void
78 PrintUserName(info)
79 char ** info;
80 {
81     char buf[BUFSIZ], print_buf[BUFSIZ];
82     sprintf(buf, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
83     sprintf(print_buf, "%-40s User Name: %s", buf, info[U_NAME]);
84     Put_message(print_buf);
85 }
86
87 /*      Function Name: PrintUserInfo
88  *      Description: Prints Information about a user.
89  *      Arguments: info - an argument list with the user information
90  *                          in it.
91  *      Returns: none
92  */
93
94 static void
95 PrintUserInfo(info)
96 char ** info;
97 {
98     char name[BUFSIZ], buf[BUFSIZ];
99
100     sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
101     sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name);
102     Put_message(buf);
103     sprintf(buf, "User id: %-23s Login shell %-10s Class: %s", 
104             info[U_UID], info[U_SHELL], info[U_CLASS]);
105     Put_message(buf);
106     sprintf(buf, "Account is: %-20s Encrypted MIT ID number: %s",
107             UserState(atoi(info[U_STATE])), info[U_MITID]);
108     Put_message(buf);
109     sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME],info[U_MODWITH]);
110     Put_message(buf);
111 }
112
113 /*      Function Name: SetUserDefaults
114  *      Description: Sets the default values for add user.
115  *      Arguments: info - a blank user info array of char *'s.
116  *      Returns: args - the filled info structure.
117  */
118
119 static char **
120 SetUserDefaults(info)
121 char ** info;
122 {
123     info[U_NAME] = Strsave(UNIQUE_LOGIN);
124     info[U_UID] = Strsave(UNIQUE_UID);
125     info[U_SHELL] = Strsave(DEFAULT_SHELL);
126     info[U_LAST] = Strsave(DEFAULT_NONE);
127     info[U_FIRST] = Strsave(DEFAULT_NONE);
128     info[U_MIDDLE] = Strsave(DEFAULT_NONE);
129     info[U_STATE] = Strsave(DEFAULT_NO);
130     info[U_MITID] = Strsave(DEFAULT_NONE);
131     info[U_CLASS] = Strsave(DEFAULT_CLASS);
132     info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
133     return(info);
134 }
135
136 /*      Function Name: AskUserInfo.
137  *      Description: This function askes the user for information about a 
138  *                   machine and saves it into a structure.
139  *      Arguments: info - a pointer the the structure to put the info into.
140  *                 flags - Flags asking us which info we want.
141  *      Returns: the args to pass to the query.
142  *      NOTES: the return args are not necessarily in the correct order to
143  *             use the #defined names (e.g args[UID] is not the uid anymore).
144  */
145
146 char **
147 AskUserInfo(info, name)
148 char ** info;
149 Bool name;
150 {
151     char temp_buf[BUFSIZ], *newname, *temp_ptr;
152
153     if (name) {
154         sprintf(temp_buf,"\nChanging Attributes of user %s.\n",info[U_NAME]);
155         Put_message(temp_buf);
156     } else {
157         struct qelem *elem = NULL;
158         char *argv[3];
159
160         GetValueFromUser("User's last name", &info[U_LAST]);
161         GetValueFromUser("User's first name", &info[U_FIRST]);
162         GetValueFromUser("User's middle name", &info[U_MIDDLE]);
163         argv[0] = info[U_FIRST];
164         argv[1] = info[U_LAST];
165         if (do_sms_query("get_user_by_name", 2, argv,
166                          StoreInfo, (char *) &elem) == 0) {
167             Put_message("A user by that name already exists in the database.");
168             Loop(QueueTop(elem), PrintUserInfo);
169             Loop(QueueTop(elem), FreeInfo);
170             FreeQueue(elem);
171             if (YesNoQuestion("Add new user anyway", TRUE) == FALSE)
172               return(NULL);
173         }
174     }
175     if (name) {
176         newname = Strsave(info[U_NAME]);
177         GetValueFromUser("The new login name for this user", &newname);
178     }
179     else
180         GetValueFromUser("Login name for this user", &info[U_NAME]);
181
182     GetValueFromUser("User's UID", &info[U_UID]);
183     GetValueFromUser("User's shell", &info[U_SHELL]);
184     if (name) {
185         GetValueFromUser("User's last name", &info[U_LAST]);
186         GetValueFromUser("User's first name", &info[U_FIRST]);
187         GetValueFromUser("User's middle name", &info[U_MIDDLE]);
188     }
189     while (1) {
190         int i;
191         GetValueFromUser("User's status (? for help)", &info[U_STATE]);
192         if (isdigit(info[U_STATE][0]))
193           break;
194         Put_message("Valid status numbers:");
195         for (i = 0; i < US_END; i++) {
196             sprintf(temp_buf, "  %d: %s", i, states[i]);
197             Put_message(temp_buf);
198         }
199     }
200     temp_ptr = Strsave(info[U_MITID]);
201     Put_message("User's MIT ID number (type a new unencrypted number, or keep same encryption)");
202     GetValueFromUser("", &temp_ptr);
203     if ( strcmp( temp_ptr, info[U_MITID] ) != 0) {
204         EncryptID(temp_buf, temp_ptr, info[U_FIRST], info[U_LAST]);
205         free(info[U_MITID]);
206         info[U_MITID] = Strsave(temp_buf);
207     }
208     free(temp_ptr);
209     GetTypeFromUser("User's MIT Year (class)", "class", &info[U_CLASS]);
210     
211     FreeAndClear(&info[U_MODTIME], TRUE);
212     FreeAndClear(&info[U_MODBY], TRUE);
213     FreeAndClear(&info[U_MODWITH], TRUE);
214
215 /* 
216  * Slide the newname into the #2 slot, this screws up all future references 
217  * to this list, since we slip the pointer into a info list it gets freed 
218  * when the rest of the list gets freed.
219  */
220     if (name)                   
221         SlipInNewName(info, newname);
222
223     return(info);
224 }
225
226 /*      Function Name: GetUserInfo
227  *      Description: Stores the user information in a queue.
228  *      Arguments: type - type of field given to get info, one of:
229  *                        LOGIN, UID, BY_NAME, CLASS.
230  *                 name1 - name of thing specified by type (wildcards okay)
231  *                 name2 - other name, only used in get user by first and last.
232  *                         (wildcards okay).
233  *      Returns: the first element of the queue containing the user info.
234  */
235
236 struct qelem *
237 GetUserInfo(type, name1, name2)
238 int type;
239 char *name1, *name2;
240 {
241     char * args[2];
242     register int status;
243     struct qelem * elem = NULL;
244
245     switch(type) {
246     case LOGIN:
247         args[0] = name1;
248         if ( (status = do_sms_query("get_user_by_login", 1, args,
249                                     StoreInfo, (char *) &elem)) != 0) {
250             com_err(program_name, status, 
251                     " when attempting to get_user_by_login.");
252             return (NULL);               
253         }
254         break;
255     case UID:
256         args[0] = name1;
257         if ( (status = do_sms_query("get_user_by_uid", 1, args,
258                                     StoreInfo, (char *) &elem)) != 0) {
259             com_err(program_name, status, 
260                     " when attempting to get_user_by_uid.");
261             return (NULL);      
262         }
263         break;
264     case BY_NAME:
265         args[0] = name1;
266         args[1] = name2;    
267         if ( (status = do_sms_query("get_user_by_name", 2, args,
268                                     StoreInfo, (char *) &elem)) != 0) {
269             com_err(program_name, status, 
270                     " when attempting to get_user_by_name.");
271             return (NULL);      
272         }
273         break;
274     case CLASS:
275         args[0] = name1;
276         if ( (status = do_sms_query("get_user_by_class", 1, args,
277                                     StoreInfo, (char *) &elem)) != 0) {
278             com_err(program_name, status, 
279                     " when attempting to get_user_by_class.");
280             return (NULL);      
281         }
282         break;
283     }
284     return( QueueTop(elem) );
285 }
286
287 /*      Function Name: AddNewUser
288  *      Description: Adds a new user to the database.
289  *      Arguments: none.
290  *      Returns: DM_NORMAL.
291  */
292
293 /* ARGSUSED */
294 int
295 AddNewUser()
296 {
297     register int status;
298     char ** args, *info[MAX_ARGS_SIZE];
299
300     args = AskUserInfo(SetUserDefaults(info), FALSE);
301     if (args == NULL)
302       return(DM_NORMAL);
303     if ( (status = do_sms_query("add_user", CountArgs(args), 
304                                 args, Scream, (char *) NULL)) != SMS_SUCCESS)
305         com_err(program_name, status, " in add_user");
306     else
307         Put_message("New user added to database.");
308     FreeInfo(args);
309     return(DM_NORMAL);
310 }
311
312
313 /*      Function Name: GetLoginName
314  *      Description: Asks the user for a login name and reserves
315  *                   it with kerberous.
316  *      Arguments: none.
317  *      Returns: a malloced login name for the user.
318  */
319
320 static char *
321 GetLoginName()
322 {
323     char name[BUFSIZ];
324
325     Prompt_input("Login name for this user? ", name, BUFSIZ);
326     
327     Put_message(
328               "KERBEROS code not added, did not reserve name with kerberos.");
329
330     return(Strsave(name));
331 }
332
333
334 /*      Function Name: ChooseUser
335  *      Description: Choose a user from a list and return the uid.
336  *      Arguments: top - a queue of user information.
337  *      Returns: uid - the malloced uid of the user that was chosen.
338  */
339
340 static char *
341 ChooseUser(elem)
342 struct qelem * elem;
343 {
344     while (elem != NULL) {
345         char ** info = (char **)  elem->q_data;
346         PrintUserInfo(info);
347         switch(YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE)) {
348         case TRUE:
349             return(Strsave(info[U_UID]));
350         case FALSE:
351             break;
352         default:                /* quit or ^C. */
353             return(NULL);
354         }
355         elem = elem->q_forw;
356     }
357     return(NULL);
358 }
359
360 /*      Function Name: GetUidNumberFromName
361  *      Description: Gets the users uid number, from the name.
362  *      Arguments: none.
363  *      Returns: uid - a malloced string containing the uid.
364  */
365
366 static char *
367 GetUidNumberFromName()
368 {
369     char *args[5], *uid, first[BUFSIZ], last[BUFSIZ];
370     register int status;
371     struct qelem * top = NULL;
372     
373     Prompt_input("First Name: ", first, BUFSIZ);
374     Prompt_input("Last  Name: ", last, BUFSIZ);
375
376     args[0] = first;
377     args[1] = last;
378     
379     switch (status = do_sms_query("get_user_by_name", 2, args,
380                                   StoreInfo, (char *) &top)) {
381     case SMS_SUCCESS:
382         break;
383     case SMS_NO_MATCH:
384         Put_message("There is no user in the database with that name.");
385         return(NULL);
386     default:
387         com_err(program_name, status, " in get_user_by_name.");
388         return(NULL);
389     }
390     
391     top = QueueTop(top);
392     if (QueueCount(top) == 1) /* This is a unique name. */ {
393         char ** info = (char **) top->q_data;
394         Put_message("User ID Number retrieved for the user: ");
395         Put_message("");
396         PrintUserName(info);
397         uid = Strsave(info[U_UID]);
398         FreeQueue(top);
399         return(Strsave(uid));
400     }
401
402     Put_message("That name is not unique, choose the user that you want.");
403     uid = ChooseUser(top);
404     FreeQueue(top);
405     return(uid);
406 }
407
408 /*      Function Name: SetUserPassword
409  *      Description: Set the new kerberos password for this user.
410  *      Arguments: name - kerberos principle name for this user, (login name).
411  *      Returns: none.
412  */
413
414 static void
415 SetUserPassword(name)
416 char * name;
417 {
418     name = name;                        /* make saber happy. */
419     Put_message("Kerberos password not changed, code non-existant.");
420     /* clever message to call account_admin, if this fails. */
421 }
422
423 /*      Function Name:  GiveBackLogin
424  *      Description: Gives back previously reserved kerberous principle.
425  *      Arguments: name - principle to give back.
426  *      Returns: void.
427  */
428
429 static void
430 GiveBackLogin(name)
431 char * name;
432 {
433     name = name;                        /* make saber happy. */
434     Put_message("kerberos code not implimented, name not given back.");
435     /* send mail to db maintainer if this fails. */
436 }
437
438 /*      Function Name: RegisterUser
439  *      Description: This function registers a user.
440  *      Arguments: none.
441  *      Returns: DM_NORMAL.
442  */
443
444 int
445 RegisterUser()
446 {
447     char * args[MAX_ARGS_SIZE];
448     char *login, *fstype = NULL;
449     char temp_buf[BUFSIZ];
450     register int status;
451     
452     Put_message("This function has NO kerberos support, so stange things");
453     Put_message("may happen if you use it to register a user.");
454
455     switch (YesNoQuestion("Do you know the users UID Number (y/n)", FALSE)) {
456     case TRUE:
457         Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
458         args[0] = Strsave(temp_buf);
459         break;
460     case FALSE:
461         if ( (args[0] = GetUidNumberFromName()) == NULL)
462             return(DM_NORMAL);
463         break;
464     default:
465         return(DM_NORMAL);
466     }
467
468     if ( ((login = args[1] = GetLoginName()) == NULL) ||
469         ( GetFSTypes(&fstype) == SUB_ERROR ) ) {
470         FreeInfo(args);    /* This work because the NULL temination is ok. */
471         return(DM_NORMAL);
472     }
473     args[2] = fstype;
474     args[3] = NULL;
475     
476     switch (status = do_sms_query("register_user", CountArgs(args),
477                                   args, Scream, (char *) NULL)) {
478     case SMS_SUCCESS:
479         sprintf(temp_buf, "User %s successfully registered.", login);
480         Put_message(temp_buf);
481         SetUserPassword(login);
482         break;
483     case SMS_IN_USE:
484         GiveBackLogin(login);
485         sprintf(temp_buf, "The username %s is already in use.", login);
486         Put_message(temp_buf);
487         break;
488     default:
489         com_err(program_name, status, " in register_user");
490         break;
491     }
492     FreeInfo(args);
493     return(DM_NORMAL);
494 }
495
496 /*      Function Name: RealUpdateUser
497  *      Description: actuall updates the user information.
498  *      Arguments: info - all current information for the user fields.
499  *                 junk - an UNUSED boolean.
500  *      Returns: none.
501  */
502
503 /* ARGSUSED */
504 static void
505 RealUpdateUser(info, junk)
506 char ** info;
507 Bool junk;
508 {
509     register int status;
510     char error_buf[BUFSIZ];
511     char ** args = AskUserInfo(info, TRUE);
512     
513     if ( (status = do_sms_query("update_user", CountArgs(args), 
514                                 args, Scream, (char *) NULL)) != SMS_SUCCESS) {
515         com_err(program_name, status, " in ModifyFields");
516         sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
517         Put_message(error_buf);
518     }
519 }
520
521 /*      Function Name: UpdateUser
522  *      Description: Modify some of the information about a user.
523  *      Arguments: argc, argv - login name of the user in argv[1].
524  *      Returns: DM_NORMAL.
525  */
526
527 /* ARGSUSED */
528 int
529 UpdateUser(argc, argv)
530 int argc;
531 char **argv;
532 {
533     struct qelem * elem;
534
535     elem = GetUserInfo(LOGIN, argv[1], (char *) NULL);
536     QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user");
537     
538     FreeQueue(elem);
539     return(DM_NORMAL);
540 }
541
542 /*      Function Name: RealDeactivateUser
543  *      Description: sets the user's status to 3.
544  *      Arguments: info - all current information for the user fields
545  *                 one_item - indicates the user hasn't been queried yet
546  *      Returns: none.
547  */
548
549 static void
550 RealDeactivateUser(info, one_item)
551 char ** info;
552 Bool one_item;
553 {
554     register int status;
555     char txt_buf[BUFSIZ];
556     char * qargs[2];
557
558     if (one_item) {
559         sprintf(txt_buf, "Deactivate user %s (y/n)", info[NAME]);
560         if (!YesNoQuestion(txt_buf, 2))
561             return;
562     }
563
564     qargs[0] = info[NAME];
565     qargs[1] = "3";
566     if ((status = do_sms_query("update_user_status", 2, qargs, Scream,
567                                (char *) NULL)) != SMS_SUCCESS) {
568         com_err(program_name, status, " in update_user_status");
569         sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
570         Put_message(txt_buf);
571     }
572 }
573
574
575 /*      Function Name: DeactivateUser
576  *      Description: sets the user's status to 3.
577  *      Arguments: argc, argv - login name of the user in argv[1].
578  *      Returns: DM_NORMAL.
579  */
580
581 /* ARGSUSED */
582 int
583 DeactivateUser(argc, argv)
584 int argc;
585 char **argv;
586 {
587     struct qelem * elem;
588
589     elem = GetUserInfo(LOGIN, argv[1], (char *) NULL);
590     QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user");
591     
592     FreeQueue(elem);
593     return(DM_NORMAL);
594 }
595
596
597 /* ------------------------- Top Menu ------------------------- */
598
599 /* DeleteUser() in delete.c */
600
601 /*      Function Name: DeleteUserByUid
602  *      Description: Deletes the user given a uid number.
603  *      Arguments: argc, argv - uid if user in argv[1].
604  *      Returns: DM_NORMAL.
605  *      NOTES: This just gets the username from the sms server 
606  *             and performs a DeleteUser().
607  */
608
609 int
610 DeleteUserByUid(argc, argv)
611 int argc;
612 char **argv;
613 {
614     int status;
615     struct qelem *elem = NULL;
616     char ** info;
617
618     if(!ValidName(argv[1]))
619         return(DM_NORMAL);
620     
621     if ( (status = do_sms_query("get_user_by_uid", 1, argv+1, StoreInfo,
622                                 (char * ) &elem)) != SMS_SUCCESS)
623         com_err(program_name, status, " in get_user_by_uid");
624     
625     info = (char **) elem->q_data;
626     argv[1] = info[U_NAME];
627
628     (void) DeleteUser(argc, argv);
629     return(DM_NORMAL);
630
631
632 /* ------------------------- Show User Information ------------------------- */
633
634 /*      Function Name: ShowUserByLogin
635  *      Description: Shows user information given a login name.
636  *      Arguments: argc, argv - login name in argv[1].
637  *      Returns: DM_NORMAL
638  */
639
640 /* ARGSUSED */
641 int
642 ShowUserByLogin(argc, argv)
643 int argc;
644 char *argv[];
645 {
646     struct qelem *top, *elem;
647
648     elem = top = GetUserInfo(LOGIN, argv[1], (char *) NULL);
649     Loop(elem, PrintUserInfo);
650
651     FreeQueue(top);
652     return (DM_NORMAL);
653 }
654
655 /*      Function Name: RetrieveUserByName
656  *      Description: Show information on a user give fist and/or last name.
657  *      Arguments: argc, argv - argv[1] - first name.
658  *                              argv[2] - last name.
659  *      Returns: DM_NORMAL.
660  */
661
662 /* ARGSUSED */
663 int
664 ShowUserByName(argc, argv)
665 int argc;
666 char *argv[];
667 {
668     struct qelem *top;
669     char buf[BUFSIZ];
670
671     top = GetUserInfo(BY_NAME, argv[1], argv[2]);
672
673     if (top == NULL)            /* if there was an error then return. */
674         return(DM_NORMAL);
675
676     if (!PromptWithDefault("Print full information, or just the names (f/n)?",
677                            buf, 2, "f"))
678         return(DM_NORMAL);
679
680     switch(buf[0]) {
681     case 'F':
682     case 'f':
683         Loop(top, PrintUserInfo);
684         break;
685     case 'N':
686     case 'n':
687         Loop(top, PrintUserName);
688         break;
689     }
690     
691     FreeQueue(top);
692     return (DM_NORMAL);
693 }
694
695 /*      Function Name: ShowUserByClass
696  *      Description: Shows real and login names of all users in class.
697  *      Arguments: argc, argv - argv[1] contains the class.
698  *      Returns: none.
699  */
700
701 /* ARGSUSED */
702 int
703 ShowUserByClass(argc, argv)
704 int argc;
705 char **argv;
706 {
707     struct qelem *top;
708
709     top = GetUserInfo(CLASS, argv[1], (char *) NULL);
710     Loop(top, PrintUserName);
711
712     FreeQueue(top);
713     return (DM_NORMAL);
714 }
715
716
717 /*      Function Name: GetKrbmap
718  *      Description: Shows user <-> Kerberos mappings
719  *      Arguments: argc, argv - argv[1] contains the user login name,
720  *              argv[2] contains the principal
721  *      Returns: none.
722  */
723
724 /* ARGSUSED */
725 int
726 GetKrbmap(argc, argv)
727 int argc;
728 char **argv;
729 {
730     int stat;
731     struct qelem *elem = NULL, *top;
732     char buf[BUFSIZ];
733
734     if ((stat = do_sms_query("get_kerberos_user_map", 2, &argv[1],
735                              StoreInfo, (char *)&elem)) != 0) {
736         com_err(program_name, stat, " in GetKrbMap.");
737         return(DM_NORMAL);
738     }
739
740     top = elem = QueueTop(elem);
741     Put_message("");
742     while (elem != NULL) {
743         char **info = (char **) elem->q_data;
744         sprintf(buf, "User: %-9s Principal: %s",
745                 info[KMAP_USER], info[KMAP_PRINCIPAL]);
746         Put_message(buf);
747         elem = elem->q_forw;
748     }
749
750     FreeQueue(QueueTop(top));
751     return(DM_NORMAL);
752 }
753
754
755 /*      Function Name: AddKrbmap
756  *      Description: Add a new user <-> Kerberos mapping
757  *      Arguments: argc, argv - argv[1] contains the user login name,
758  *              argv[2] contains the principal
759  *      Returns: none.
760  */
761
762 /* ARGSUSED */
763 int
764 AddKrbmap(argc, argv)
765 int argc;
766 char **argv;
767 {
768     int stat;
769
770     if (!index(argv[KMAP_PRINCIPAL + 1], '@')) {
771         Put_message("Please specify a realm for the kerberos principal.");
772         return(DM_NORMAL);
773     }
774     if ((stat = do_sms_query("add_kerberos_user_map", 2, &argv[1],
775                              Scream, NULL)) != 0) {
776         com_err(program_name, stat, " in AddKrbMap.");
777         if (stat == SMS_EXISTS)
778           Put_message("No user or principal may have more than one mapping.");
779     }
780     return(DM_NORMAL);
781 }
782
783
784 /*      Function Name: DeleteKrbmap
785  *      Description: Remove a user <-> Kerberos mapping
786  *      Arguments: argc, argv - argv[1] contains the user login name,
787  *              argv[2] contains the principal
788  *      Returns: none.
789  */
790
791 /* ARGSUSED */
792 int
793 DeleteKrbmap(argc, argv)
794 int argc;
795 char **argv;
796 {
797     int stat;
798
799     if ((stat = do_sms_query("delete_kerberos_user_map", 2, &argv[1],
800                              Scream, NULL)) != 0) {
801         com_err(program_name, stat, " in DeleteKrbMap.");
802     }
803     return(DM_NORMAL);
804 }
This page took 0.407173 seconds and 5 git commands to generate.