version 1.8, 2000/06/19 22:42:28 |
version 1.9, 2000/06/19 23:06:25 |
|
|
|
|
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 |
{ |
{ |
|
|
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); |
|
|
|
|
#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; |
} |
} |
|
|
|
|
|
|
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; |
} |
} |
|
|
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); |
} |
} |
|
|
|
|
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]; |
|
|
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); |
|
|
|
|
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); |
|
|
|
|
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"); |
|
|
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); |
|
|
|
|
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--; |
} |
} |