[BACK]Return to ssh-add.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/ssh-add.c between version 1.42 and 1.43

version 1.42, 2001/06/26 04:59:59 version 1.43, 2001/06/27 06:26:36
Line 195 
Line 195 
         printf("    -D            : delete all identities\n");          printf("    -D            : delete all identities\n");
         printf("    -s reader_num : add key in the smartcard in reader_num.\n");          printf("    -s reader_num : add key in the smartcard in reader_num.\n");
         printf("    -e reader_num : remove key in the smartcard in reader_num.\n");          printf("    -e reader_num : remove key in the smartcard in reader_num.\n");
         exit (1);  
 }  }
   
 int  int
 main(int argc, char **argv)  main(int argc, char **argv)
 {  {
           extern char *optarg;
           extern int optind;
         AuthenticationConnection *ac = NULL;          AuthenticationConnection *ac = NULL;
         struct passwd *pw;          struct passwd *pw;
         char buf[1024];          char buf[1024];
         int no_files = 1;          int i, ch, deleting = 0, sc_reader_num = -1;
         int i;  
         int deleting = 0;  
         int sc_mode = 0;  
         int sc_reader_num = 0;  
   
         SSLeay_add_all_algorithms();          SSLeay_add_all_algorithms();
   
Line 218 
Line 215 
                 fprintf(stderr, "Could not open a connection to your authentication agent.\n");                  fprintf(stderr, "Could not open a connection to your authentication agent.\n");
                 exit(1);                  exit(1);
         }          }
         for (i = 1; i < argc; i++) {          while ((ch = getopt(argc, argv, "lLdDe:s:")) != -1) {
                 if ((strcmp(argv[i], "-l") == 0) ||                  switch (ch) {
                     (strcmp(argv[i], "-L") == 0)) {                  case 'l':
                         list_identities(ac, argv[i][1] == 'l' ? 1 : 0);                  case 'L':
                         /* Don't default-add/delete if -l. */                          list_identities(ac, ch == 'l' ? 1 : 0);
                         no_files = 0;                          goto done;
                         continue;                          break;
                 }                  case 'd':
                 if (strcmp(argv[i], "-d") == 0) {  
                         deleting = 1;                          deleting = 1;
                         continue;                          break;
                 }                  case 'D':
                 if (strcmp(argv[i], "-D") == 0) {  
                         delete_all(ac);                          delete_all(ac);
                         no_files = 0;                          goto done;
                         continue;                          break;
                 }                  case 's':
                 if (strcmp(argv[i], "-s") == 0) {                          sc_reader_num = atoi(optarg);
                         sc_mode = 1;                          break;
                         deleting = 0;                  case 'e':
                         i++;  
                         if (i >= argc)  
                                 usage();  
                         sc_reader_num = atoi(argv[i]);  
                         continue;  
                 }  
                 if (strcmp(argv[i], "-e") == 0) {  
                         sc_mode = 1;  
                         deleting = 1;                          deleting = 1;
                         i++;                          sc_reader_num = atoi(optarg);
                         if (i >= argc)                          break;
                                 usage();                  default:
                         sc_reader_num = atoi(argv[i]);                          usage();
                         continue;                          exit(1);
                           break;
                 }                  }
                 if (sc_mode == 1)  
                         update_card(ac, !deleting, sc_reader_num);  
                 no_files = 0;  
                 if (deleting)  
                         delete_file(ac, argv[i]);  
                 else  
                         add_file(ac, argv[i]);  
         }          }
         if (sc_mode == 1) {          argc -= optind;
           argv += optind;
           if (sc_reader_num != -1) {
                 update_card(ac, !deleting, sc_reader_num);                  update_card(ac, !deleting, sc_reader_num);
                 ssh_close_authentication_connection(ac);                  goto done;
                 exit(0);  
         }          }
         if (no_files) {          if (argc == 0) {
                 pw = getpwuid(getuid());                  pw = getpwuid(getuid());
                 if (!pw) {                  if (!pw) {
                         fprintf(stderr, "No user found with uid %u\n",                          fprintf(stderr, "No user found with uid %u\n",
Line 279 
Line 261 
                         delete_file(ac, buf);                          delete_file(ac, buf);
                 else                  else
                         add_file(ac, buf);                          add_file(ac, buf);
           } else {
                   for (i = 0; i < argc; i++) {
                           if (deleting)
                                   delete_file(ac, argv[i]);
                           else
                                   add_file(ac, argv[i]);
                   }
         }          }
         clear_pass();          clear_pass();
   
   done:
         ssh_close_authentication_connection(ac);          ssh_close_authentication_connection(ac);
         exit(0);          exit(0);
 }  }

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43