[BACK]Return to tcfsrmuser.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tcfs

Diff for /src/usr.bin/tcfs/Attic/tcfsrmuser.c between version 1.4 and 1.5

version 1.4, 2000/06/19 20:35:48 version 1.5, 2000/06/19 22:42:29
Line 31 
Line 31 
   -v          Makes the output a little more verbose\n";    -v          Makes the output a little more verbose\n";
   
 int  int
 rmuser_main (int argn, char *argv[])  rmuser_main(int argn, char *argv[])
 {  {
         int have_user = FALSE;          int have_user = FALSE;
         int be_verbose = FALSE;          int be_verbose = FALSE;
Line 43 
Line 43 
          * Going to check the arguments           * Going to check the arguments
          */           */
   
          if ((user = (char *) malloc(LOGIN_NAME_MAX + 1)) == NULL)           if ((user = (char *)malloc(LOGIN_NAME_MAX + 1)) == NULL)
                  err(1, NULL);                   err(1, NULL);
   
          while ((val=getopt (argn, argv, "l:hv"))!=EOF)           while ((val = getopt(argn, argv, "l:hv")) != EOF)
                  switch (val) {                   switch (val) {
                         case 'l':                  case 'l':
                                 strlcpy (user, optarg, LOGIN_NAME_MAX + 1);                          strlcpy(user, optarg, LOGIN_NAME_MAX + 1);
                                 have_user = TRUE;                          have_user = TRUE;
                                 break;                          break;
                   case 'h':
                         case 'h':                          show_usage(rmuser_usage, argv[0]);
                                 show_usage (rmuser_usage, argv[0]);                          exit(OK);
                                 exit (OK);                          break;
                                 break;                  case 'v':
                           be_verbose = TRUE;
                         case 'v':                          break;
                                 be_verbose = TRUE;                  default:
                                 break;                          fprintf(stderr, "Try %s --help for more information.\n", argv[0]);
                           exit(ER_UNKOPT);
                         default:                          break;
                                 fprintf (stderr, "Try %s --help for more information.\n", argv[0]);  
                                 exit (ER_UNKOPT);  
                                 break;  
                 }                  }
   
         if (argn-optind)          if (argn - optind)
                 tcfs_error (ER_UNKOPT, NULL);                  tcfs_error(ER_UNKOPT, NULL);
   
         /*          /*
          * Here we don't have to drop root privileges because only root           * Here we don't have to drop root privileges because only root
Line 79 
Line 76 
         if (!have_user) {          if (!have_user) {
                 int len;                  int len;
   
                 printf ("Username to remove from TCFS database: ");                  printf("Username to remove from TCFS database: ");
                 fgets (user, LOGIN_NAME_MAX + 1, stdin);                  fgets(user, LOGIN_NAME_MAX + 1, stdin);
                 len = strlen(user) - 2;                  len = strlen(user) - 2;
                 if (len < 0)                  if (len < 0)
                         exit (1);                          exit(1);
                 user[len] = user[len] == '\n' ? 0 : user[len];                  user[len] = user[len] == '\n' ? 0 : user[len];
         }          }
   
         if (be_verbose)          if (be_verbose)
                 printf ("Deleting the entry for user %s from the TCFS database...\n", user);                  printf("Deleting the entry for user %s from the TCFS database...\n", user);
   
         /*          /*
          * Deleting an entry from the key database           * Deleting an entry from the key database
          */           */
         if (!tcfspwdbr_new (&user_info))          if (!tcfspwdbr_new(&user_info))
                 tcfs_error (ER_MEM, NULL);                  tcfs_error(ER_MEM, NULL);
   
         if (!tcfspwdbr_edit (&user_info, F_USR, user))          if (!tcfspwdbr_edit(&user_info, F_USR, user))
                 tcfs_error (ER_MEM, NULL);                  tcfs_error(ER_MEM, NULL);
   
         if (!tcfs_putpwnam (user, user_info, U_DEL))          if (!tcfs_putpwnam(user, user_info, U_DEL))
                 tcfs_error (ER_CUSTOM, "Error: cannot remove user.");                  tcfs_error(ER_CUSTOM, "Error: cannot remove user.");
   
         if (be_verbose)          if (be_verbose)
                 printf ("User entry removed with success.\n");                  printf("User entry removed with success.\n");
   
         tcfs_error (OK, NULL);          tcfs_error(OK, NULL);
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5