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

Diff for /src/usr.bin/tcfs/Attic/tcfsputkey.c between version 1.6 and 1.7

version 1.6, 2000/06/19 20:35:48 version 1.7, 2000/06/19 22:42:28
Line 36 
Line 36 
 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;
Line 48 
Line 48 
         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;
Line 79 
Line 79 
                 }                  }
         }          }
         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);
Line 87 
Line 87 
         }          }
   
         if (havefsname) {          if (havefsname) {
                 es=tcfs_getfspath(fslabel,fspath);                  es = tcfs_getfspath(fslabel, fspath);
                 havename = TRUE;                  havename = TRUE;
         }          }
   
Line 95 
Line 95 
                 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))
Line 163 
Line 163 
   
         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);
 }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7