version 1.6, 2000/06/19 20:35:48 |
version 1.7, 2000/06/19 22:42:28 |
|
|
int |
int |
putkey_main(int argc, char *argv[]) |
putkey_main(int argc, char *argv[]) |
{ |
{ |
char *user,*password,*tcfskey; |
char *user, *password, *tcfskey; |
uid_t uid; |
uid_t uid; |
gid_t gid; |
gid_t gid; |
int es, treshold; |
int es, treshold; |
|
|
int isgroupkey = FALSE; |
int isgroupkey = FALSE; |
int havename = FALSE, havefspath = FALSE, havekey = FALSE; |
int havename = FALSE, havefspath = FALSE, havekey = FALSE; |
|
|
while ((x = getopt(argc,argv,"kf:p:g:")) != EOF) { |
while ((x = getopt(argc, argv, "kf:p:g:")) != EOF) { |
switch(x) { |
switch(x) { |
case 'k': |
case 'k': |
def = FALSE; |
def = FALSE; |
|
|
} |
} |
} |
} |
if (argc - optind) |
if (argc - optind) |
tcfs_error(ER_UNKOPT,NULL); |
tcfs_error(ER_UNKOPT, NULL); |
|
|
if (havefsname && havempname) { |
if (havefsname && havempname) { |
tcfs_error(ER_CUSTOM, putkey_usage); |
tcfs_error(ER_CUSTOM, putkey_usage); |
|
|
} |
} |
|
|
if (havefsname) { |
if (havefsname) { |
es=tcfs_getfspath(fslabel,fspath); |
es = tcfs_getfspath(fslabel, fspath); |
havename = TRUE; |
havename = TRUE; |
} |
} |
|
|
|
|
havename = TRUE; |
havename = TRUE; |
|
|
if (!havename) |
if (!havename) |
es=tcfs_getfspath("default",fspath); |
es = tcfs_getfspath("default", fspath); |
|
|
if (!es) { |
if (!es) { |
tcfs_error(ER_CUSTOM,"fs-label not found!\n"); |
tcfs_error(ER_CUSTOM, "fs-label not found!\n"); |
exit(1); |
exit(1); |
} |
} |
|
|
uid = getuid(); |
uid = getuid(); |
|
|
if (isgroupkey) { |
if (isgroupkey) { |
if (!unix_auth(&user,&password,TRUE)) |
if (!unix_auth(&user, &password, TRUE)) |
tcfs_error(ER_AUTH,user); |
tcfs_error(ER_AUTH, user); |
|
|
if (!tcfsgpwdbr_new(&ginfo)) |
if (!tcfsgpwdbr_new(&ginfo)) |
tcfs_error(ER_MEM,NULL); |
tcfs_error(ER_MEM, NULL); |
|
|
if (!tcfs_ggetpwnam(user,gid,&ginfo)) |
if (!tcfs_ggetpwnam(user, gid, &ginfo)) |
tcfs_error(ER_CUSTOM,"Default key non found"); |
tcfs_error(ER_CUSTOM, "Default key non found"); |
|
|
if (!strlen(ginfo->gkey)) |
if (!strlen(ginfo->gkey)) |
tcfs_error(ER_CUSTOM,"Invalid default key"); |
tcfs_error(ER_CUSTOM, "Invalid default key"); |
|
|
tcfskey = (char*)malloc(UUKEYSIZE); |
tcfskey = (char*)malloc(UUKEYSIZE); |
if (!tcfskey) |
if (!tcfskey) |
tcfs_error(ER_MEM,NULL); |
tcfs_error(ER_MEM, NULL); |
|
|
treshold = ginfo->soglia; |
treshold = ginfo->soglia; |
|
|
if (!tcfs_decrypt_key(password, ginfo->gkey, tcfskey, GKEYSIZE)) |
if (!tcfs_decrypt_key(password, ginfo->gkey, tcfskey, GKEYSIZE)) |
tcfs_error(ER_CUSTOM, "Could not decrypt group key"); |
tcfs_error(ER_CUSTOM, "Could not decrypt group key"); |
|
|
es = tcfs_group_enable(fspath,uid,gid,treshold,tcfskey); |
es = tcfs_group_enable(fspath, uid, gid, treshold, tcfskey); |
|
|
if(es == -1) { |
if (es == -1) { |
tcfs_error(ER_CUSTOM,"problems updating filesystem"); |
tcfs_error(ER_CUSTOM, "problems updating filesystem"); |
} |
} |
|
|
exit(0); |
exit(0); |
} |
} |
|
|
|
|
if(!def) { |
if (!def) { |
tcfskey = getpass("Insert tcfs-key:"); |
tcfskey = getpass("Insert tcfs-key:"); |
havekey = TRUE; |
havekey = TRUE; |
} else { |
} else { |
if(!unix_auth(&user,&password,TRUE)) |
if (!unix_auth(&user, &password, TRUE)) |
tcfs_error(ER_AUTH,user); |
tcfs_error(ER_AUTH, user); |
|
|
if(!tcfspwdbr_new(&info)) |
if (!tcfspwdbr_new(&info)) |
tcfs_error(ER_MEM,NULL); |
tcfs_error(ER_MEM, NULL); |
|
|
if(!tcfs_getpwnam(user,&info)) |
if (!tcfs_getpwnam(user, &info)) |
tcfs_error(ER_CUSTOM,"Default key non found"); |
tcfs_error(ER_CUSTOM, "Default key non found"); |
|
|
if(!strlen(info->upw)) |
if (!strlen(info->upw)) |
tcfs_error(ER_CUSTOM, "Invalid default key"); |
tcfs_error(ER_CUSTOM, "Invalid default key"); |
|
|
tcfskey = (char*)malloc(UUKEYSIZE); |
tcfskey = (char*)malloc(UUKEYSIZE); |
if(!tcfskey) |
if (!tcfskey) |
tcfs_error(ER_MEM, NULL); |
tcfs_error(ER_MEM, NULL); |
|
|
if (!tcfs_decrypt_key (password, info->upw, tcfskey, KEYSIZE)) |
if (!tcfs_decrypt_key (password, info->upw, tcfskey, KEYSIZE)) |
|
|
|
|
es = tcfs_user_enable(fspath, uid, tcfskey); |
es = tcfs_user_enable(fspath, uid, tcfskey); |
|
|
if(es == -1) |
if (es == -1) |
tcfs_error(ER_CUSTOM,"problems updating filesystem"); |
tcfs_error(ER_CUSTOM, "problems updating filesystem"); |
|
|
exit(0); |
exit(0); |
} |
} |