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