[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.8 and 1.9

version 1.8, 2000/06/19 22:42:28 version 1.9, 2000/06/19 23:06:25
Line 35 
Line 35 
   
 int threshold;  int threshold;
 unsigned char coeff[KEYSIZE][256];  unsigned char coeff[KEYSIZE][256];
 unsigned char *S=NULL;          /* Pointer to a 64-bit TCFS group key */  unsigned char *S = NULL;          /* Pointer to a 64-bit TCFS group key */
   
 union bobbit  union bobbit
 {  {
Line 86 
Line 86 
 unsigned char *  unsigned char *
 gengrpkey(char *login)  gengrpkey(char *login)
 {  {
         int x1, i, j, k=0;          int x1, i, j, k = 0;
         unsigned int x;          unsigned int x;
   
         unsigned char *res = NULL;          unsigned char *res = NULL;
         unsigned int tmp;          unsigned int tmp;
         union bobbit obits;          union bobbit obits;
   
         res = (unsigned char*)calloc(KEYSIZE + KEYSIZE/8, sizeof(char));          res = (unsigned char *)calloc(KEYSIZE + KEYSIZE / 8, sizeof(char));
         if (!res)          if (!res)
                 tcfs_error(ER_MEM, NULL);                  tcfs_error(ER_MEM, NULL);
   
Line 122 
Line 122 
 #endif  #endif
                 switch (i % 8) {                  switch (i % 8) {
                 case 0:                  case 0:
                         obits.bf.b1=tmp>>8;                          obits.bf.b1 = tmp >> 8;
                         break;                          break;
                 case 1:                  case 1:
                         obits.bf.b2=tmp>>8;                          obits.bf.b2 = tmp >> 8;
                         break;                          break;
                 case 2:                  case 2:
                         obits.bf.b3=tmp>>8;                          obits.bf.b3 = tmp >> 8;
                         break;                          break;
                 case 3:                  case 3:
                         obits.bf.b4=tmp>>8;                          obits.bf.b4 = tmp >> 8;
                         break;                          break;
                 case 4:                  case 4:
                         obits.bf.b5=tmp>>8;                          obits.bf.b5 = tmp >> 8;
                         break;                          break;
                 case 5:                  case 5:
                         obits.bf.b6=tmp>>8;                          obits.bf.b6 = tmp >> 8;
                         break;                          break;
                 case 6:                  case 6:
                         obits.bf.b7=tmp>>8;                          obits.bf.b7 = tmp >> 8;
                         break;                          break;
                 case 7:                  case 7:
                         obits.bf.b8=tmp>>8;                          obits.bf.b8 = tmp >> 8;
                         break;                          break;
                 }                  }
   
Line 191 
Line 191 
   
                                 group_id = getgrnam(optarg);                                  group_id = getgrnam(optarg);
                                 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;
                         }                          }
Line 209 
Line 210 
                         be_verbose = TRUE;                          be_verbose = TRUE;
                         break;                          break;
                 default:                  default:
                         fprintf(stderr, "Try %s --help for more information.\n", argv[0]);                          fprintf(stderr,
                               "Try %s --help for more information.\n", argv[0]);
                         exit(ER_UNKOPT);                          exit(ER_UNKOPT);
                 }                  }
   
Line 220 
Line 222 
                 char *buff = NULL;                  char *buff = NULL;
                 int len;                  int len;
   
                 buff = (char*)calloc(2048, sizeof(char));                  buff = (char *)calloc(2048, sizeof(char));
                 if (!buff)                  if (!buff)
                         tcfs_error(ER_MEM, NULL);                          tcfs_error(ER_MEM, NULL);
   
                 printf("Group id [or name] of the TCFS group to add to the database: ");                  printf("Group ID (or name) of TCFS group to add to the database: ");
                 fgets(buff, 2048, stdin);                  fgets(buff, 2048, stdin);
                 len = strlen(buff) - 1;                  len = strlen(buff) - 1;
                 buff[len] = buff[len] == '\n' ? 0 : buff[len];                  buff[len] = buff[len] == '\n' ? 0 : buff[len];
Line 250 
Line 252 
                 char *buff = NULL;                  char *buff = NULL;
                 int len;                  int len;
   
                 buff = (char*)calloc(2048, sizeof(char));                  buff = (char *)calloc(2048, sizeof(char));
                 if (!buff)                  if (!buff)
                         tcfs_error(ER_MEM, NULL);                          tcfs_error(ER_MEM, NULL);
   
Line 267 
Line 269 
                 char *buff = NULL;                  char *buff = NULL;
                 int len;                  int len;
   
                 buff = (char*)calloc(2048, sizeof(char));                  buff = (char *)calloc(2048, sizeof(char));
                 if (!buff)                  if (!buff)
                         tcfs_error(ER_MEM, NULL);                          tcfs_error(ER_MEM, NULL);
   
Line 313 
Line 315 
                 char *user = NULL, *passwd = NULL;                  char *user = NULL, *passwd = NULL;
                 unsigned char *newkey = NULL, *cryptedkey = NULL;                  unsigned char *newkey = NULL, *cryptedkey = NULL;
                 tcfsgpwdb *tmp = NULL;                  tcfsgpwdb *tmp = NULL;
                 int tmpmemb = temp_members, cont=0;                  int tmpmemb = temp_members, cont = 0;
   
                 group_info[members-1] = (tcfsgpwdb *)calloc(1, sizeof(tcfsgpwdb));                  group_info[members - 1] = (tcfsgpwdb *)calloc(1,
                       sizeof(tcfsgpwdb));
   
                 group_info[members-1]->gid = gid;                  group_info[members - 1]->gid = gid;
                 group_info[members-1]->n = members;                  group_info[members - 1]->n = members;
                 group_info[members-1]->soglia = threshold;                  group_info[members - 1]->soglia = threshold;
   
                 if (!unix_auth(&user, &passwd, FALSE)) {                  if (!unix_auth(&user, &passwd, FALSE)) {
                         fprintf(stderr, "Invalid password or the user does not exist.\n");                          fprintf(stderr, "Invalid password or the user does not exist.\n");
Line 341 
Line 344 
                 if (cont)                  if (cont)
                         continue;                          continue;
   
                 strcpy(group_info[members-1]->user, user);                  strcpy(group_info[members - 1]->user, user);
   
                 newkey = (unsigned char*)calloc(GKEYSIZE + 1, 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(UUGKEYSIZE, sizeof(char));                  cryptedkey = (unsigned char *)calloc(UUGKEYSIZE, sizeof(char));
                 if (!cryptedkey)                  if (!cryptedkey)
                         tcfs_error(ER_MEM, NULL);                          tcfs_error(ER_MEM, NULL);
   
Line 375 
Line 378 
         while (members) {          while (members) {
                 if (be_verbose)                  if (be_verbose)
                         printf("Creating a new entry for group %d and user %s in the TCFS database...\n",                          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]->gid,
                                 group_info[members-1]->user);                                  group_info[members - 1]->user);
   
                 if (!tcfs_gputpwnam(group_info[members-1]->user,                  if (!tcfs_gputpwnam(group_info[members - 1]->user,
                                      group_info[members-1], U_NEW)) {                                       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.");
                 }                  }
   
                 if (be_verbose)                  if (be_verbose)
                         printf("TCFS group entry for user %s created.\n", group_info[members-1]->user);                          printf("TCFS group entry for user %s created.\n", group_info[members - 1]->user);
   
                 members--;                  members--;
         }          }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9