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

Diff for /src/usr.bin/tcfs/Attic/tcfsaddgroup.c between version 1.1 and 1.2

version 1.1, 2000/06/18 22:07:24 version 1.2, 2000/06/19 03:23:04
Line 222 
Line 222 
   
                 printf ("Group id [or name] of the TCFS group to add to the database: ");                  printf ("Group id [or name] of the TCFS group to add to the database: ");
                 fgets (buff, 2048, stdin);                  fgets (buff, 2048, stdin);
                 len = strlen(buff) - 2;                  len = strlen(buff) - 1;
                 buff[len] = buff[len] == '\n' ? 0 : buff[len];                  buff[len] = buff[len] == '\n' ? 0 : buff[len];
                 gid = atoi(buff);                  gid = atoi(buff);
   
Line 233 
Line 233 
                         if (!group_id)                          if (!group_id)
                                 tcfs_error (ER_CUSTOM, "Nonexistent group.");                                  tcfs_error (ER_CUSTOM, "Nonexistent group.");
   
                         gid=group_id->gr_gid;                          gid = group_id->gr_gid;
                 }                  }
   
                 if (gid <= 0)                  if (gid <= 0)
Line 252 
Line 252 
   
                 printf ("Number of members for the TCFS group ID #%d: ", gid);                  printf ("Number of members for the TCFS group ID #%d: ", gid);
                 fgets (buff, 2048, stdin);                  fgets (buff, 2048, stdin);
                 len = strlen(buff) - 2;                  len = strlen(buff) - 1;
                 buff[len] = buff[len] == '\n' ? 0 : buff[len];                  buff[len] = buff[len] == '\n' ? 0 : buff[len];
                 members = atoi(buff);                  members = atoi(buff);
   
Line 269 
Line 269 
   
                 printf ("Threshold for the TCFS group ID #%d: ", gid);                  printf ("Threshold for the TCFS group ID #%d: ", gid);
                 fgets (buff, 2048, stdin);                  fgets (buff, 2048, stdin);
                 len = strlen(buff) - 2;                  len = strlen(buff) - 1;
                 buff[len] = buff[len] == '\n' ? 0 : buff[len];                  buff[len] = buff[len] == '\n' ? 0 : buff[len];
                 threshold = atoi(buff);                  threshold = atoi(buff);
   
Line 339 
Line 339 
   
                 strcpy (group_info[members-1]->user, user);                  strcpy (group_info[members-1]->user, user);
   
                 newkey = (unsigned char*)calloc(KEYSIZE*2, sizeof (char));                  newkey = (unsigned char*)calloc(GKEYSIZE + 1, sizeof (char));
                 if (!newkey)                  if (!newkey)
                         tcfs_error (ER_MEM, NULL);                          tcfs_error (ER_MEM, NULL);
   
                 cryptedkey = (unsigned char*)calloc(UUKEYSIZE, sizeof(char));                  cryptedkey = (unsigned char*)calloc(UUGKEYSIZE, sizeof(char));
                 if (!cryptedkey)                  if (!cryptedkey)
                         tcfs_error (ER_MEM, NULL);                          tcfs_error (ER_MEM, NULL);
   
                 memcpy (newkey, gengrpkey (user), KEYSIZE + KEYSIZE/8);                  memcpy (newkey, gengrpkey (user), GKEYSIZE);
                 newkey[KEYSIZE + KEYSIZE/8] = '\0';                  newkey[GKEYSIZE] = '\0';
 #ifdef DEBUG_TCFS  
                 {  
                         int i;  
   
                         printf ("%s newkey: ", user);  
                         for (i = 0;i <= KEYSIZE; i++)  
                                 printf ("%u:", newkey[i]);  
                         printf ("\n");  
                 }  
 #endif  
   
                 /*                  /*
                  * Encrypt the just generated key with the user password                   * Encrypt the just generated key with the user password
                  */                   */
                 if (!tcfs_encrypt_key (user, passwd, newkey, cryptedkey, GROUPKEY))                  if (!tcfs_encrypt_key (user, passwd, newkey, cryptedkey, GROUPKEY))
                         tcfs_error (ER_MEM, NULL);                          tcfs_error (ER_MEM, NULL);
   
 #ifdef DEBUG_TCFS  
                 {  
                         unsigned char *key;  
                         int i;  
   
                         key=(unsigned char *)calloc(UUKEYSIZE, sizeof(char));  
                         if (!tcfs_decrypt_key (user, passwd, cryptedkey, key, GROUPKEY))  
                                 exit (0);  
   
                         printf ("%s key: ", user);  
                         for (i=0;i<=KEYSIZE;i++)  
                                 printf ("%u:", key[i]);  
                         printf ("\n");  
   
                         free (key);  
                 }  
 #endif  
   
                 free (newkey);                  free (newkey);
   
                 strcpy (group_info[members-1]->gkey, cryptedkey);                  strlcpy (group_info[members - 1]->gkey, cryptedkey,
                            GKEYSIZE + 1);
                 free (cryptedkey);                  free (cryptedkey);
   
                 members--;                  members--;
         }          }
   
         members=temp_members;          members = temp_members;
   
         while (members) {          while (members) {
                 if (be_verbose)                  if (be_verbose)
                         printf ("Creating a new entry for user %s in the TCFS database...\n", group_info[members-1]->user);                          printf ("Creating a new entry for group %d and user %s in the TCFS database...\n",
                                   group_info[members-1]->gid,
                                   group_info[members-1]->user);
   
                 if (!tcfs_gputpwnam (group_info[members-1]->user, group_info[members-1], U_NEW)) {                  if (!tcfs_gputpwnam (group_info[members-1]->user,
                                        group_info[members-1], U_NEW)) {
                                 /* TODO: Remove the group entries saved before */                                  /* TODO: Remove the group entries saved before */
                         tcfs_error (ER_CUSTOM, "Error: cannot add a user to the group.");                          tcfs_error (ER_CUSTOM, "Error: cannot add a user to the group.");
                 }                  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2