=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tcfs/Attic/tcfs_keymaint.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- src/usr.bin/tcfs/Attic/tcfs_keymaint.c 2000/06/19 20:35:47 1.7 +++ src/usr.bin/tcfs/Attic/tcfs_keymaint.c 2000/06/19 22:42:28 1.8 @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfs_keymaint.c,v 1.7 2000/06/19 20:35:47 fgsch Exp $ */ +/* $OpenBSD: tcfs_keymaint.c,v 1.8 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -37,7 +37,7 @@ ret = statfs(fs, &buf); if (ret) - return 0; + return (0); if (!strcmp("tcfs", buf.f_fstypename)) return (1); @@ -49,8 +49,9 @@ tcfs_callfunction(char *filesystem, struct tcfs_args *arg) { int i; + if (tcfs_verify_fs(filesystem)) - i = mount("tcfs",filesystem,MNT_UPDATE,(void*)arg); + i = mount("tcfs", filesystem, MNT_UPDATE, (void*)arg); else i = -1; @@ -58,7 +59,7 @@ } int -tcfs_decrypt_key (char *pwd, u_char *t, u_char *tk, int tklen) +tcfs_decrypt_key(char *pwd, u_char *t, u_char *tk, int tklen) { char pass[_PASSWORD_LEN]; char tcfskey[2*KEYSIZE], iv[8]; @@ -66,55 +67,56 @@ int len; if (!tk) - return 0; + return (0); - strlcpy (pass, pwd, sizeof(pass)); + strlcpy(pass, pwd, sizeof(pass)); - len = uudecode ((char *)t, tcfskey, sizeof(tcfskey)); + len = uudecode((char *)t, tcfskey, sizeof(tcfskey)); if (len == -1) { fprintf(stderr, "tcfs_decrypt_key: uudecode failed\n"); - return 0; + return (0); } else if (len != tklen) { fprintf(stderr, "tcfs_decrypt_key: uudecode wrong length\n"); - return 0; + return (0); } while (strlen (pass) < 8) { char tmp[_PASSWORD_LEN]; - strcpy (tmp, pass); - strcat (tmp, pass); - strcat (pass, tmp); + + strcpy(tmp, pass); + strcat(tmp, pass); + strcat(pass, tmp); } blf_key(&ctx, pass, strlen(pass)); memset(iv, 0, sizeof(iv)); blf_cbc_decrypt(&ctx, iv, tcfskey, tklen); - memset (pass, 0, strlen (pass)); - memset (&ctx, 0, sizeof(ctx)); + memset(pass, 0, strlen(pass)); + memset(&ctx, 0, sizeof(ctx)); - memcpy (tk, tcfskey, tklen); - return 1; + memcpy(tk, tcfskey, tklen); + return (1); } int -tcfs_encrypt_key (char *pw, u_char *key, int klen, u_char *ek, int eklen) +tcfs_encrypt_key(char *pw, u_char *key, int klen, u_char *ek, int eklen) { char pass[_PASSWORD_LEN], iv[8]; blf_ctx ctx; int res; if (!ek) - return 0; + return (0); - strlcpy (pass, pw, sizeof(pass)); + strlcpy(pass, pw, sizeof(pass)); while (strlen(pass) < 8) { char tmp[_PASSWORD_LEN]; - strcpy (tmp, pass); - strcat (tmp, pass); - strcat (pass, tmp); + strcpy(tmp, pass); + strcat(tmp, pass); + strcat(pass, tmp); } blf_key(&ctx, pass, strlen(pass)); @@ -123,13 +125,13 @@ memset(&ctx, 0, sizeof(ctx)); - res = uuencode (key, klen, ek, eklen); + res = uuencode(key, klen, ek, eklen); if (res != eklen - 1) { fprintf(stderr, "tcfs_encrypt_key: uuencode length wrong\n"); return (0); } - return 1; + return (1); } int @@ -139,7 +141,8 @@ a.user = user; memcpy(a.tcfs_key, key, sizeof(a.tcfs_key)); a.cmd = TCFS_PUT_UIDKEY; - return tcfs_callfunction(filesystem,&a); + + return (tcfs_callfunction(filesystem, &a)); } int @@ -148,7 +151,8 @@ struct tcfs_args a; a.user = user; a.cmd = TCFS_RM_UIDKEY; - return tcfs_callfunction(filesystem, &a); + + return (tcfs_callfunction(filesystem, &a)); } int @@ -159,7 +163,8 @@ a.cmd = TCFS_PUT_PIDKEY; a.proc = pid; memcpy(a.tcfs_key, key, sizeof(a.tcfs_key)); - return tcfs_callfunction(filesystem, &a); + + return (tcfs_callfunction(filesystem, &a)); } int @@ -169,7 +174,8 @@ a.user = user; a.cmd = TCFS_RM_PIDKEY; a.proc = pid; - return tcfs_callfunction(filesystem, &a); + + return (tcfs_callfunction(filesystem, &a)); } int @@ -182,7 +188,8 @@ a.group = gid; a.treshold = tre; memcpy(a.tcfs_key, key, sizeof(a.tcfs_key)); - return tcfs_callfunction(filesystem,&a); + + return (tcfs_callfunction(filesystem, &a)); } int tcfs_group_disable(char *filesystem, uid_t uid, gid_t gid) @@ -191,7 +198,8 @@ a.cmd = TCFS_RM_GIDKEY; a.user = uid; a.group = gid; - return tcfs_callfunction(filesystem,&a); + + return (tcfs_callfunction(filesystem, &a)); }