version 1.7, 2000/06/19 20:35:47 |
version 1.8, 2000/06/19 22:42:28 |
|
|
ret = statfs(fs, &buf); |
ret = statfs(fs, &buf); |
|
|
if (ret) |
if (ret) |
return 0; |
return (0); |
|
|
if (!strcmp("tcfs", buf.f_fstypename)) |
if (!strcmp("tcfs", buf.f_fstypename)) |
return (1); |
return (1); |
|
|
tcfs_callfunction(char *filesystem, struct tcfs_args *arg) |
tcfs_callfunction(char *filesystem, struct tcfs_args *arg) |
{ |
{ |
int i; |
int i; |
|
|
if (tcfs_verify_fs(filesystem)) |
if (tcfs_verify_fs(filesystem)) |
i = mount("tcfs",filesystem,MNT_UPDATE,(void*)arg); |
i = mount("tcfs", filesystem, MNT_UPDATE, (void*)arg); |
else |
else |
i = -1; |
i = -1; |
|
|
|
|
} |
} |
|
|
int |
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 pass[_PASSWORD_LEN]; |
char tcfskey[2*KEYSIZE], iv[8]; |
char tcfskey[2*KEYSIZE], iv[8]; |
|
|
int len; |
int len; |
|
|
if (!tk) |
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) { |
if (len == -1) { |
fprintf(stderr, "tcfs_decrypt_key: uudecode failed\n"); |
fprintf(stderr, "tcfs_decrypt_key: uudecode failed\n"); |
return 0; |
return (0); |
} else if (len != tklen) { |
} else if (len != tklen) { |
fprintf(stderr, "tcfs_decrypt_key: uudecode wrong length\n"); |
fprintf(stderr, "tcfs_decrypt_key: uudecode wrong length\n"); |
return 0; |
return (0); |
} |
} |
|
|
while (strlen (pass) < 8) { |
while (strlen (pass) < 8) { |
char tmp[_PASSWORD_LEN]; |
char tmp[_PASSWORD_LEN]; |
strcpy (tmp, pass); |
|
strcat (tmp, pass); |
strcpy(tmp, pass); |
strcat (pass, tmp); |
strcat(tmp, pass); |
|
strcat(pass, tmp); |
} |
} |
|
|
blf_key(&ctx, pass, strlen(pass)); |
blf_key(&ctx, pass, strlen(pass)); |
memset(iv, 0, sizeof(iv)); |
memset(iv, 0, sizeof(iv)); |
blf_cbc_decrypt(&ctx, iv, tcfskey, tklen); |
blf_cbc_decrypt(&ctx, iv, tcfskey, tklen); |
|
|
memset (pass, 0, strlen (pass)); |
memset(pass, 0, strlen(pass)); |
memset (&ctx, 0, sizeof(ctx)); |
memset(&ctx, 0, sizeof(ctx)); |
|
|
memcpy (tk, tcfskey, tklen); |
memcpy(tk, tcfskey, tklen); |
return 1; |
return (1); |
} |
} |
|
|
int |
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]; |
char pass[_PASSWORD_LEN], iv[8]; |
blf_ctx ctx; |
blf_ctx ctx; |
int res; |
int res; |
|
|
if (!ek) |
if (!ek) |
return 0; |
return (0); |
|
|
strlcpy (pass, pw, sizeof(pass)); |
strlcpy(pass, pw, sizeof(pass)); |
|
|
while (strlen(pass) < 8) { |
while (strlen(pass) < 8) { |
char tmp[_PASSWORD_LEN]; |
char tmp[_PASSWORD_LEN]; |
|
|
strcpy (tmp, pass); |
strcpy(tmp, pass); |
strcat (tmp, pass); |
strcat(tmp, pass); |
strcat (pass, tmp); |
strcat(pass, tmp); |
} |
} |
|
|
blf_key(&ctx, pass, strlen(pass)); |
blf_key(&ctx, pass, strlen(pass)); |
|
|
|
|
memset(&ctx, 0, sizeof(ctx)); |
memset(&ctx, 0, sizeof(ctx)); |
|
|
res = uuencode (key, klen, ek, eklen); |
res = uuencode(key, klen, ek, eklen); |
if (res != eklen - 1) { |
if (res != eklen - 1) { |
fprintf(stderr, "tcfs_encrypt_key: uuencode length wrong\n"); |
fprintf(stderr, "tcfs_encrypt_key: uuencode length wrong\n"); |
return (0); |
return (0); |
} |
} |
|
|
return 1; |
return (1); |
} |
} |
|
|
int |
int |
|
|
a.user = user; |
a.user = user; |
memcpy(a.tcfs_key, key, sizeof(a.tcfs_key)); |
memcpy(a.tcfs_key, key, sizeof(a.tcfs_key)); |
a.cmd = TCFS_PUT_UIDKEY; |
a.cmd = TCFS_PUT_UIDKEY; |
return tcfs_callfunction(filesystem,&a); |
|
|
return (tcfs_callfunction(filesystem, &a)); |
} |
} |
|
|
int |
int |
|
|
struct tcfs_args a; |
struct tcfs_args a; |
a.user = user; |
a.user = user; |
a.cmd = TCFS_RM_UIDKEY; |
a.cmd = TCFS_RM_UIDKEY; |
return tcfs_callfunction(filesystem, &a); |
|
|
return (tcfs_callfunction(filesystem, &a)); |
} |
} |
|
|
int |
int |
|
|
a.cmd = TCFS_PUT_PIDKEY; |
a.cmd = TCFS_PUT_PIDKEY; |
a.proc = pid; |
a.proc = pid; |
memcpy(a.tcfs_key, key, sizeof(a.tcfs_key)); |
memcpy(a.tcfs_key, key, sizeof(a.tcfs_key)); |
return tcfs_callfunction(filesystem, &a); |
|
|
return (tcfs_callfunction(filesystem, &a)); |
} |
} |
|
|
int |
int |
|
|
a.user = user; |
a.user = user; |
a.cmd = TCFS_RM_PIDKEY; |
a.cmd = TCFS_RM_PIDKEY; |
a.proc = pid; |
a.proc = pid; |
return tcfs_callfunction(filesystem, &a); |
|
|
return (tcfs_callfunction(filesystem, &a)); |
} |
} |
|
|
int |
int |
|
|
a.group = gid; |
a.group = gid; |
a.treshold = tre; |
a.treshold = tre; |
memcpy(a.tcfs_key, key, sizeof(a.tcfs_key)); |
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) |
int tcfs_group_disable(char *filesystem, uid_t uid, gid_t gid) |
|
|
a.cmd = TCFS_RM_GIDKEY; |
a.cmd = TCFS_RM_GIDKEY; |
a.user = uid; |
a.user = uid; |
a.group = gid; |
a.group = gid; |
return tcfs_callfunction(filesystem,&a); |
|
|
return (tcfs_callfunction(filesystem, &a)); |
} |
} |
|
|
|
|