diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 2000-06-19 22:42:30 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 2000-06-19 22:42:30 +0000 |
commit | 86c00b230b2edb5f31c3feff302c91fb0000bf26 (patch) | |
tree | 5ef86a945bb5ac53b3fcf29334cfaa7539d48fe5 /usr.bin/tcfs | |
parent | 1abef89558453935167b734f3edda32d8a73ab1a (diff) |
KNF
Diffstat (limited to 'usr.bin/tcfs')
-rw-r--r-- | usr.bin/tcfs/tcfs_dbmaint.c | 296 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfs_flags.c | 12 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfs_getfspath.c | 20 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfs_getstatus.c | 4 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfs_keymaint.c | 68 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsaddgroup.c | 203 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsadduser.c | 42 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfserrors.c | 63 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsflag.c | 10 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsgenkey.c | 50 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsmng.c | 4 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsputkey.c | 56 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsrmgroup.c | 48 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsrmkey.c | 16 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsrmuser.c | 69 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsrun.c | 14 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfstat.c | 16 | ||||
-rw-r--r-- | usr.bin/tcfs/tcfsuse.c | 4 | ||||
-rw-r--r-- | usr.bin/tcfs/unix_auth.c | 14 |
19 files changed, 508 insertions, 501 deletions
diff --git a/usr.bin/tcfs/tcfs_dbmaint.c b/usr.bin/tcfs/tcfs_dbmaint.c index a127123161e..5a30e5e207b 100644 --- a/usr.bin/tcfs/tcfs_dbmaint.c +++ b/usr.bin/tcfs/tcfs_dbmaint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfs_dbmaint.c,v 1.6 2000/06/19 20:35:47 fgsch Exp $ */ +/* $OpenBSD: tcfs_dbmaint.c,v 1.7 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -30,7 +30,7 @@ #define PERM_SECURE (S_IRUSR|S_IWUSR) int -tcfspwdbr_new (tcfspwdb **new) +tcfspwdbr_new(tcfspwdb **new) { *new = (tcfspwdb *)calloc(1, sizeof(tcfspwdb)); @@ -41,7 +41,7 @@ tcfspwdbr_new (tcfspwdb **new) } int -tcfsgpwdbr_new (tcfsgpwdb **new) +tcfsgpwdbr_new(tcfsgpwdb **new) { *new = (tcfsgpwdb *)calloc(1, sizeof(tcfsgpwdb)); @@ -52,179 +52,179 @@ tcfsgpwdbr_new (tcfsgpwdb **new) } int -tcfspwdbr_edit (tcfspwdb **tmp, int flags,...) +tcfspwdbr_edit (tcfspwdb **tmp, int flags, ...) { va_list argv; char *d; if (!*tmp) - if (!tcfspwdbr_new (tmp)) - return 0; + if (!tcfspwdbr_new(tmp)) + return (0); - va_start (argv, flags); + va_start(argv, flags); if (flags & F_USR) { - d = va_arg (argv, char *); - strcpy ((*tmp)->user, d); + d = va_arg(argv, char *); + strcpy((*tmp)->user, d); } if (flags & F_PWD) { - d = va_arg (argv, char *); - strcpy ((*tmp)->upw, d); + d = va_arg(argv, char *); + strcpy((*tmp)->upw, d); } - va_end (argv); - return 1; + va_end(argv); + return (1); } int -tcfsgpwdbr_edit (tcfsgpwdb **tmp, int flags,...) +tcfsgpwdbr_edit(tcfsgpwdb **tmp, int flags, ...) { va_list argv; char *d; if (!*tmp) - if (!tcfsgpwdbr_new (tmp)) - return 0; + if (!tcfsgpwdbr_new(tmp)) + return (0); - va_start (argv, flags); + va_start(argv, flags); if (flags & F_USR) { - d = va_arg (argv, char *); - strcpy ((*tmp)->user, d); + d = va_arg(argv, char *); + strcpy((*tmp)->user, d); } if (flags & F_GKEY) { - d = va_arg (argv, char *); - strcpy ((*tmp)->gkey, d); + d = va_arg(argv, char *); + strcpy((*tmp)->gkey, d); } if (flags & F_GID) { gid_t d; - d = va_arg (argv, gid_t); + d = va_arg(argv, gid_t); (*tmp)->gid = d; } if (flags & F_MEMBERS) { int d; - d = va_arg (argv, int); + d = va_arg(argv, int); (*tmp)->n = d; } if (flags & F_THRESHOLD) { int d; - d = va_arg (argv, int); + d = va_arg(argv, int); (*tmp)->soglia = d; } - va_end (argv); + va_end(argv); return (1); } int -tcfspwdbr_read (tcfspwdb *t, int flags,...) +tcfspwdbr_read(tcfspwdb *t, int flags, ...) { va_list argv; char *d; - va_start (argv, flags); + va_start(argv, flags); if (flags & F_USR) { - d = va_arg (argv, char *); - memset (d, 0, UserLen); - strcpy (d, t->user); + d = va_arg(argv, char *); + memset(d, 0, UserLen); + strcpy(d, t->user); } if (flags & F_PWD) { - d = va_arg (argv, char *); - memset (d, 0, PassLen); - strcpy (d, t->upw); + d = va_arg(argv, char *); + memset(d, 0, PassLen); + strcpy(d, t->upw); } - va_end (argv); - return 0; + va_end(argv); + return (0); } int -tcfsgpwdbr_read (tcfsgpwdb *t, int flags,...) +tcfsgpwdbr_read(tcfsgpwdb *t, int flags, ...) { va_list argv; char *d; - va_start (argv, flags); + va_start(argv, flags); if (flags & F_USR) { - d = va_arg (argv, char *); - strcpy (d, t->user); + d = va_arg(argv, char *); + strcpy(d, t->user); } if (flags & F_GKEY) { - d = va_arg (argv, char *); - strcpy (d, t->gkey); + d = va_arg(argv, char *); + strcpy(d, t->gkey); } if (flags & F_GID) { gid_t *d; - d = va_arg (argv, gid_t *); - memcpy (d, &t->gid, sizeof (gid_t)); + d = va_arg(argv, gid_t *); + memcpy(d, &t->gid, sizeof (gid_t)); } /* Incomplete... */ - va_end (argv); - return 0; + va_end(argv); + return (0); } void -tcfspwdbr_dispose (tcfspwdb *t) +tcfspwdbr_dispose(tcfspwdb *t) { - free ((void *)t); + free((void *)t); } void -tcfsgpwdbr_dispose (tcfsgpwdb *t) +tcfsgpwdbr_dispose(tcfsgpwdb *t) { - free ((void *)t); + free((void *)t); } tcfspwdb * -tcfs_getpwnam (char *user, tcfspwdb **dest) +tcfs_getpwnam(char *user, tcfspwdb **dest) { DB *pdb; DBT srchkey, r; if (!*dest) - if (!tcfspwdbr_new (dest)) - return NULL; + if (!tcfspwdbr_new(dest)) + return (NULL); - pdb = dbopen (TCFSPWDB, O_RDONLY, 0, DB_HASH, NULL); + pdb = dbopen(TCFSPWDB, O_RDONLY, 0, DB_HASH, NULL); if (!pdb) - return NULL; + return (NULL); srchkey.data = user; - srchkey.size = (int) strlen (user); + srchkey.size = (int)strlen(user); if (pdb->get(pdb, &srchkey, &r, 0)) { pdb->close(pdb); - return 0; + return (0); } if (r.size != sizeof(tcfspwdb)) { fprintf(stderr, "db: incorrect record size: %d != %d\n", r.size, sizeof(tcfspwdb)); pdb->close(pdb); - return 0; + return (0); } - memcpy (*dest, r.data, sizeof (tcfspwdb)); + memcpy(*dest, r.data, sizeof(tcfspwdb)); - pdb->close (pdb); + pdb->close(pdb); - return (tcfspwdb *)*dest; + return ((tcfspwdb *)*dest); } tcfsgpwdb * -tcfs_ggetpwnam (char *user, gid_t gid, tcfsgpwdb **dest) +tcfs_ggetpwnam(char *user, gid_t gid, tcfsgpwdb **dest) { DB *pdb; DBT srchkey, r; @@ -232,52 +232,52 @@ tcfs_ggetpwnam (char *user, gid_t gid, tcfsgpwdb **dest) int res; if (!*dest) - if (!tcfsgpwdbr_new (dest)) - return NULL; + if (!tcfsgpwdbr_new(dest)) + return (NULL); - pdb = dbopen (TCFSGPWDB, O_RDONLY, 0, DB_HASH, NULL); + pdb = dbopen(TCFSGPWDB, O_RDONLY, 0, DB_HASH, NULL); if (!pdb) - return NULL; + return (NULL); key = (char*)calloc(strlen(user)+4/*gid lenght*/+1/*null*/,sizeof(char)); if (!key) - return NULL; + return (NULL); - sprintf (key, "%s\33%d\0", user, (int)gid); + sprintf(key, "%s\33%d\0", user, (int)gid); srchkey.data = key; - srchkey.size = (int)strlen (key); + srchkey.size = (int)strlen(key); if ((res = pdb->get(pdb, &srchkey, &r, 0))) { if (res == -1) perror("dbget"); - pdb->close (pdb); + pdb->close(pdb); return (NULL); } - memcpy (*dest, r.data, sizeof (tcfsgpwdb)); + memcpy(*dest, r.data, sizeof(tcfsgpwdb)); - pdb->close (pdb); + pdb->close(pdb); return (*dest); } int -tcfs_putpwnam (char *user, tcfspwdb *src, int flags) +tcfs_putpwnam(char *user, tcfspwdb *src, int flags) { DB *pdb; static DBT srchkey, d; int open_flag = 0, res; open_flag = O_RDWR|O_EXCL; - if (access (TCFSPWDB, F_OK) < 0) + if (access(TCFSPWDB, F_OK) < 0) open_flag |= O_CREAT; - pdb = dbopen (TCFSPWDB, open_flag, PERM_SECURE, DB_HASH, NULL); + pdb = dbopen(TCFSPWDB, open_flag, PERM_SECURE, DB_HASH, NULL); if (!pdb) - return 0; + return (0); srchkey.data = user; - srchkey.size = (int)strlen (user); + srchkey.size = (int)strlen(user); if (flags != U_DEL) { d.data = (char *)src; @@ -285,22 +285,22 @@ tcfs_putpwnam (char *user, tcfspwdb *src, int flags) if (pdb->put(pdb, &srchkey, &d, 0) == -1) { fprintf(stderr, "db: put failed\n"); - pdb->close (pdb); - return 0; + pdb->close(pdb); + return (0); } - } else if ((res = pdb->del (pdb, &srchkey, 0))) { + } else if ((res = pdb->del(pdb, &srchkey, 0))) { fprintf(stderr, "db: del failed: %s\n", res == -1 ? "error" : "not found"); - pdb->close (pdb); - return 0; + pdb->close(pdb); + return (0); } - pdb->close (pdb); - return 1; + pdb->close(pdb); + return (1); } int -tcfs_gputpwnam (char *user, tcfsgpwdb *src, int flags) +tcfs_gputpwnam(char *user, tcfsgpwdb *src, int flags) { DB *pdb; static DBT srchkey, d; @@ -308,49 +308,49 @@ tcfs_gputpwnam (char *user, tcfsgpwdb *src, int flags) char *key; open_flag = O_RDWR|O_EXCL; - if (access (TCFSGPWDB, F_OK) < 0) + if (access(TCFSGPWDB, F_OK) < 0) open_flag |= O_CREAT; - pdb = dbopen (TCFSGPWDB, open_flag, PERM_SECURE, DB_HASH, NULL); + pdb = dbopen(TCFSGPWDB, open_flag, PERM_SECURE, DB_HASH, NULL); if (!pdb) { perror("dbopen"); - return 0; + return (0); } - key = (char *) calloc (strlen(src->user) + 4 + 1, sizeof(char)); - sprintf (key, "%s\33%d\0", src->user, src->gid); + key = (char *)calloc(strlen(src->user) + 4 + 1, sizeof(char)); + sprintf(key, "%s\33%d\0", src->user, src->gid); srchkey.data = key; - srchkey.size = strlen (key); + srchkey.size = strlen(key); if (flags != U_DEL) { d.data = (char *)src; d.size = sizeof(tcfsgpwdb); - if (pdb->put (pdb, &srchkey, &d, 0) == -1) { + if (pdb->put(pdb, &srchkey, &d, 0) == -1) { fprintf(stderr, "db: put failed\n"); - pdb->close (pdb); - return 0; + pdb->close(pdb); + return (0); } - } else if (pdb->del (pdb, &srchkey, 0)) { + } else if (pdb->del(pdb, &srchkey, 0)) { fprintf(stderr, "db: del failed\n"); - pdb->close (pdb); - return 0; + pdb->close(pdb); + return (0); } - pdb->close (pdb); - return 1; + pdb->close(pdb); + return (1); } int -tcfs_rmgroup (gid_t gid) +tcfs_rmgroup(gid_t gid) { DB *gdb; DBT dbkey; gdb = dbopen(TCFSGPWDB, O_RDWR|O_EXCL, PERM_SECURE, DB_HASH, NULL); if (!gdb) - return 0; + return (0); if (gdb->seq(gdb, &dbkey, NULL, R_FIRST)) dbkey.data = NULL; @@ -361,15 +361,14 @@ tcfs_rmgroup (gid_t gid) tmp = (char*)calloc(1024, sizeof(char)); sprintf(tmp, "\33%d\0", gid); - if (strstr (dbkey.data, tmp)) { + if (strstr(dbkey.data, tmp)) { if (gdb->del(gdb, &dbkey, 0)) { - gdb->close (gdb); - - free (tmp); - return 0; + gdb->close(gdb); + free(tmp); + return (0); } } - free (tmp); + free(tmp); if (gdb->seq(gdb, &dbkey, NULL, R_NEXT)) { gdb->close(gdb); @@ -377,65 +376,65 @@ tcfs_rmgroup (gid_t gid) } } - gdb->close (gdb); + gdb->close(gdb); return (1); } int -tcfs_group_chgpwd (char *user, gid_t gid, char *old, char *new) +tcfs_group_chgpwd(char *user, gid_t gid, char *old, char *new) { tcfsgpwdb *group_info = NULL; unsigned char *key; key = (unsigned char *)calloc(UUGKEYSIZE + 1, sizeof (char)); if (!key) - return 0; + return (0); - if (!tcfs_decrypt_key (old, group_info->gkey, key, GKEYSIZE)) - return 0; + if (!tcfs_decrypt_key(old, group_info->gkey, key, GKEYSIZE)) + return (0); - if (!tcfs_encrypt_key (new, key, GKEYSIZE, group_info->gkey, + if (!tcfs_encrypt_key(new, key, GKEYSIZE, group_info->gkey, UUGKEYSIZE + 1)) - return 0; + return (0); - if (!tcfs_gputpwnam (user, group_info, U_CHG)) - return 0; + if (!tcfs_gputpwnam(user, group_info, U_CHG)) + return (0); - free (group_info); - free (key); + free(group_info); + free(key); - return 1; + return (1); } int -tcfs_chgpwd (char *user, char *old, char *new) +tcfs_chgpwd(char *user, char *old, char *new) { - tcfspwdb *user_info=NULL; + tcfspwdb *user_info = NULL; unsigned char *key; key = (unsigned char*)calloc(UUKEYSIZE + 1, sizeof(char)); - if (!tcfs_getpwnam (user, &user_info)) - return 0; + if (!tcfs_getpwnam(user, &user_info)) + return (0); - if (!tcfs_decrypt_key (old, user_info->upw, key, KEYSIZE)) - return 0; + if (!tcfs_decrypt_key(old, user_info->upw, key, KEYSIZE)) + return (0); - if (!tcfs_encrypt_key (new, key, KEYSIZE, user_info->upw, UUKEYSIZE + 1)) - return 0; + if (!tcfs_encrypt_key(new, key, KEYSIZE, user_info->upw, UUKEYSIZE + 1)) + return (0); - if (!tcfs_putpwnam (user, user_info, U_CHG)) - return 0; + if (!tcfs_putpwnam(user, user_info, U_CHG)) + return (0); - free (user_info); - free (key); + free(user_info); + free(key); - return 1; + return (1); } int -tcfs_chgpassword (char *user, char *old, char *new) +tcfs_chgpassword(char *user, char *old, char *new) { int error1=0; DB *gpdb; @@ -444,22 +443,22 @@ tcfs_chgpassword (char *user, char *old, char *new) ckey = (unsigned char*)calloc(UUGKEYSIZE + 1, sizeof(char)); if (!ckey) - return 0; + return (0); - gpdb = dbopen (TCFSGPWDB, O_RDWR|O_EXCL, PERM_SECURE, DB_HASH, NULL); + gpdb = dbopen(TCFSGPWDB, O_RDWR|O_EXCL, PERM_SECURE, DB_HASH, NULL); if (!gpdb) - return 0; + return (0); - error1 = tcfs_chgpwd (user, old, new); + error1 = tcfs_chgpwd(user, old, new); if (!error1) - return 0; + return (0); /* Reencrypt group shares */ if (gpdb->seq(gpdb, &key, NULL, R_FIRST)) key.data = NULL; while (key.data) { - if (strncmp (user, key.data, strlen(user))) { + if (strncmp(user, key.data, strlen(user))) { if (gpdb->seq(gpdb, &key, NULL, R_NEXT)) key.data = NULL; continue; @@ -467,24 +466,23 @@ tcfs_chgpassword (char *user, char *old, char *new) gpdb->get(gpdb, &key, &found, 0); - if (!tcfs_decrypt_key (old, ((tcfsgpwdb *)found.data)->gkey, ckey, GKEYSIZE)) - return 0; - - if (!tcfs_encrypt_key (new, ckey, GKEYSIZE, ((tcfsgpwdb *)found.data)->gkey, UUGKEYSIZE + 1)) - return 0; + if (!tcfs_decrypt_key(old, ((tcfsgpwdb *)found.data)->gkey, ckey, GKEYSIZE)) + return (0); - if (gpdb->put (gpdb, &key, &found, 0)) { - free (ckey); + if (!tcfs_encrypt_key(new, ckey, GKEYSIZE, ((tcfsgpwdb *)found.data)->gkey, UUGKEYSIZE + 1)) + return (0); - gpdb->close (gpdb); + if (gpdb->put(gpdb, &key, &found, 0)) { + free(ckey); + gpdb->close(gpdb); return (0); } - free (ckey); + free(ckey); if (gpdb->seq(gpdb, &key, NULL, R_NEXT)) - key.data = NULL; + key.data = NULL; } - return 1; + return (1); } diff --git a/usr.bin/tcfs/tcfs_flags.c b/usr.bin/tcfs/tcfs_flags.c index de7ec5392a0..3b4416b5dfa 100644 --- a/usr.bin/tcfs/tcfs_flags.c +++ b/usr.bin/tcfs/tcfs_flags.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfs_flags.c,v 1.3 2000/06/19 20:35:47 fgsch Exp $ */ +/* $OpenBSD: tcfs_flags.c,v 1.4 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -36,11 +36,12 @@ tcfs_getflags(int fd) tcfs_flags r; struct stat s; - if (fstat(fd,&s) < 0) { + if (fstat(fd, &s) < 0) { r.flag = -1; } else r.flag = s.st_flags; - return r; + + return (r); } @@ -48,11 +49,12 @@ tcfs_flags tcfs_setflags(int fd, tcfs_flags x) { tcfs_flags r, n; + r = tcfs_getflags(fd); if (r.flag == -1) { r.flag = -1; - return r; + return (r); } n = x; @@ -63,5 +65,5 @@ tcfs_setflags(int fd, tcfs_flags x) r.flag = -1; } - return r; + return (r); } diff --git a/usr.bin/tcfs/tcfs_getfspath.c b/usr.bin/tcfs/tcfs_getfspath.c index 07f12a76d41..08e9998a793 100644 --- a/usr.bin/tcfs/tcfs_getfspath.c +++ b/usr.bin/tcfs/tcfs_getfspath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfs_getfspath.c,v 1.2 2000/06/19 20:35:47 fgsch Exp $ */ +/* $OpenBSD: tcfs_getfspath.c,v 1.3 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -20,20 +20,20 @@ #define WHITESPACE " \t\r\n" int -tcfs_label_getcipher (char *label) +tcfs_label_getcipher(char *label) { int ciphernum; - if (tcfs_get_label (label, NULL, &ciphernum)) - return ciphernum; + if (tcfs_get_label(label, NULL, &ciphernum)) + return (ciphernum); return (-1); } int -tcfs_getfspath (char *label2search, char *path) +tcfs_getfspath(char *label2search, char *path) { - return tcfs_get_label (label2search, path, NULL); + return (tcfs_get_label(label2search, path, NULL)); } int @@ -43,15 +43,15 @@ tcfs_get_label(char *label2search, char *path, int *ciphernumber) char *label, *line, *p, *tag, *mountpoint, *cipherfield; int found = 0; - if ((fp = fopen(_PATH_FSTAB,"r")) == NULL) + if ((fp = fopen(_PATH_FSTAB, "r")) == NULL) return (0); - if ((line = calloc(1024, sizeof(char))) == NULL) + if ((line = (char *)malloc(1024)) == NULL) goto out; while (!feof(fp) && !found) { p = line; - fgets (p, 1024, fp); + fgets(p, 1024, fp); p = p + strspn(p, WHITESPACE); while (!found) { strsep(&p, WHITESPACE); /* device */ @@ -96,7 +96,7 @@ tcfs_get_label(char *label2search, char *path, int *ciphernumber) } free(line); out: - fclose (fp); + fclose(fp); return found; } diff --git a/usr.bin/tcfs/tcfs_getstatus.c b/usr.bin/tcfs/tcfs_getstatus.c index 2da704a4f0c..2fbb195cd48 100644 --- a/usr.bin/tcfs/tcfs_getstatus.c +++ b/usr.bin/tcfs/tcfs_getstatus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfs_getstatus.c,v 1.2 2000/06/19 20:35:47 fgsch Exp $ */ +/* $OpenBSD: tcfs_getstatus.c,v 1.3 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -35,7 +35,7 @@ tcfs_getstatus(char *filesystem, struct tcfs_status *st) return (-1); x.cmd = TCFS_GET_STATUS; - i = tcfs_callfunction(filesystem,&x); + i = tcfs_callfunction(filesystem, &x); *st = x.st; return (i); } diff --git a/usr.bin/tcfs/tcfs_keymaint.c b/usr.bin/tcfs/tcfs_keymaint.c index f57c86dabab..5e6d34d9422 100644 --- a/usr.bin/tcfs/tcfs_keymaint.c +++ b/usr.bin/tcfs/tcfs_keymaint.c @@ -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 @@ tcfs_verify_fs(char *fs) ret = statfs(fs, &buf); if (ret) - return 0; + return (0); if (!strcmp("tcfs", buf.f_fstypename)) return (1); @@ -49,8 +49,9 @@ int 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 @@ tcfs_callfunction(char *filesystem, struct tcfs_args *arg) } 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 @@ tcfs_decrypt_key (char *pwd, u_char *t, u_char *tk, int tklen) 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 @@ tcfs_encrypt_key (char *pw, u_char *key, int klen, u_char *ek, int eklen) 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 @@ tcfs_user_enable(char *filesystem, uid_t user, u_char *key) 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 @@ tcfs_user_disable(char *filesystem, uid_t user) 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 @@ tcfs_proc_enable(char *filesystem, uid_t user, pid_t pid, char *key) 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 @@ tcfs_proc_disable(char *filesystem, uid_t user, pid_t pid) 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 @@ tcfs_group_enable(char *filesystem, uid_t uid, gid_t gid, 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 @@ int tcfs_group_disable(char *filesystem, uid_t uid, gid_t gid) a.cmd = TCFS_RM_GIDKEY; a.user = uid; a.group = gid; - return tcfs_callfunction(filesystem,&a); + + return (tcfs_callfunction(filesystem, &a)); } diff --git a/usr.bin/tcfs/tcfsaddgroup.c b/usr.bin/tcfs/tcfsaddgroup.c index 6761b0c81c2..b8a16ce8c87 100644 --- a/usr.bin/tcfs/tcfsaddgroup.c +++ b/usr.bin/tcfs/tcfsaddgroup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsaddgroup.c,v 1.7 2000/06/19 21:23:44 fgsch Exp $ */ +/* $OpenBSD: tcfsaddgroup.c,v 1.8 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -54,37 +54,37 @@ union bobbit }; int -tcfsgetuid (char *login) +tcfsgetuid(char *login) { struct passwd *entry; setpwent(); while ((entry = getpwent()) != NULL) { - if (strcmp (login, entry->pw_name) == 0) - return entry->pw_uid; + if (strcmp(login, entry->pw_name) == 0) + return (entry->pw_uid); } endpwent(); free(entry); - return -1; + return (-1); } void -gencoeff (void) +gencoeff(void) { int i, j; - for (i = 0; i < KEYSIZE; i++){ - for (j = 1; j < threshold; j++){ + for (i = 0; i < KEYSIZE; i++) { + for (j = 1; j < threshold; j++) { coeff[j][i] = arc4random(); } } } unsigned char * -gengrpkey (char *login) +gengrpkey(char *login) { int x1, i, j, k=0; unsigned int x; @@ -95,77 +95,78 @@ gengrpkey (char *login) res = (unsigned char*)calloc(KEYSIZE + KEYSIZE/8, sizeof(char)); if (!res) - tcfs_error (ER_MEM, NULL); + tcfs_error(ER_MEM, NULL); x1 = tcfsgetuid(login); x = (x1 % 257); #ifdef DEBUG_TCFS - printf ("La chiave utente di %u e':\n", x); + printf("La chiave utente di %u e':\n", x); #endif for (i = 0; i < KEYSIZE; i++) { tmp = 0; for (j = 1; j < threshold; j++) { - tmp += (eleva(x1,j,257)*coeff[j][i]) % 257; + tmp += (eleva(x1, j, 257) * coeff[j][i]) % 257; #ifdef DEBUG_TCFS - printf ("x1= %u\tj=%d\tcoeff[%d][%d]=%u\ttmp=%u\tchiave: ", x1, j, j, i, coeff[j][i], tmp); + printf("x1= %u\tj=%d\tcoeff[%d][%d]=%u\ttmp=%u\tchiave: ", x1, j, j, i, coeff[j][i], tmp); #endif - } + } + tmp += (unsigned int)S[i]; tmp %= 257; - memcpy (res+k++, &tmp, 1); + memcpy(res+k++, &tmp, 1); #ifdef DEBUG_TCFS - printf ("%u\n", *(res+k-1)); + printf("%u\n", *(res+k-1)); #endif - switch (i % 8){ - case 0: - obits.bf.b1=tmp>>8; - break; - case 1: - obits.bf.b2=tmp>>8; - break; - case 2: - obits.bf.b3=tmp>>8; - break; - case 3: - obits.bf.b4=tmp>>8; - break; - case 4: - obits.bf.b5=tmp>>8; - break; - case 5: - obits.bf.b6=tmp>>8; - break; - case 6: - obits.bf.b7=tmp>>8; - break; - case 7: - obits.bf.b8=tmp>>8; - break; + switch (i % 8) { + case 0: + obits.bf.b1=tmp>>8; + break; + case 1: + obits.bf.b2=tmp>>8; + break; + case 2: + obits.bf.b3=tmp>>8; + break; + case 3: + obits.bf.b4=tmp>>8; + break; + case 4: + obits.bf.b5=tmp>>8; + break; + case 5: + obits.bf.b6=tmp>>8; + break; + case 6: + obits.bf.b7=tmp>>8; + break; + case 7: + obits.bf.b8=tmp>>8; + break; } - if ((i%8) == 7) { + if ((i % 8) == 7) { res[k] = obits.byte; k++; #ifdef DEBUG_TCFS - printf ("%u\n", res[k-1]); + printf("%u\n", res[k-1]); #endif - obits.byte=0; + obits.byte = 0; } } /* res[KEYSIZE]=obits.byte; */ - return res; + return (res); } int -addgroup_main (int argn, char *argv[]) +addgroup_main(int argn, char *argv[]) { int val; gid_t gid; @@ -177,7 +178,7 @@ addgroup_main (int argn, char *argv[]) /* * Going to check the arguments */ - while ((val = getopt (argn, argv, "vg:m:t:h")) != EOF) + while ((val = getopt(argn, argv, "vg:m:t:h")) != EOF) switch (val) { case 'm': members = atoi(optarg); @@ -190,9 +191,9 @@ addgroup_main (int argn, char *argv[]) group_id = getgrnam(optarg); 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; } have_gid = TRUE; @@ -202,18 +203,18 @@ addgroup_main (int argn, char *argv[]) have_threshold = TRUE; break; case 'h': - show_usage (addgroup_usage, argv[0]); - exit (OK); + show_usage(addgroup_usage, argv[0]); + exit(OK); case 'v': be_verbose = TRUE; break; default: - fprintf (stderr, "Try %s --help for more information.\n", argv[0]); - exit (ER_UNKOPT); + fprintf(stderr, "Try %s --help for more information.\n", argv[0]); + exit(ER_UNKOPT); } if (argn-optind) - tcfs_error (ER_UNKOPT, NULL); + tcfs_error(ER_UNKOPT, NULL); if (!have_gid) { char *buff = NULL; @@ -221,10 +222,10 @@ addgroup_main (int argn, char *argv[]) buff = (char*)calloc(2048, sizeof(char)); 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: "); - fgets (buff, 2048, stdin); + printf("Group id [or name] of the TCFS group to add to the database: "); + fgets(buff, 2048, stdin); len = strlen(buff) - 1; buff[len] = buff[len] == '\n' ? 0 : buff[len]; gid = atoi(buff); @@ -234,27 +235,27 @@ addgroup_main (int argn, char *argv[]) group_id = getgrnam(buff); if (!group_id) - tcfs_error (ER_CUSTOM, "Nonexistent group."); + tcfs_error(ER_CUSTOM, "Nonexistent group."); gid = group_id->gr_gid; } if (gid <= 0) - tcfs_error (ER_CUSTOM, "A positive ID please!"); + tcfs_error(ER_CUSTOM, "A positive ID please!"); - free (buff); + free(buff); } if (!have_members) { char *buff = NULL; int len; - buff=(char*)calloc(2048, sizeof(char)); + buff = (char*)calloc(2048, sizeof(char)); if (!buff) - tcfs_error (ER_MEM, NULL); + tcfs_error(ER_MEM, NULL); - printf ("Number of members for the TCFS group ID #%d: ", gid); - fgets (buff, 2048, stdin); + printf("Number of members for the TCFS group ID #%d: ", gid); + fgets(buff, 2048, stdin); len = strlen(buff) - 1; buff[len] = buff[len] == '\n' ? 0 : buff[len]; members = atoi(buff); @@ -268,34 +269,34 @@ addgroup_main (int argn, char *argv[]) buff = (char*)calloc(2048, sizeof(char)); if (!buff) - tcfs_error (ER_MEM, NULL); + tcfs_error(ER_MEM, NULL); - printf ("Threshold for the TCFS group ID #%d: ", gid); - fgets (buff, 2048, stdin); + printf("Threshold for the TCFS group ID #%d: ", gid); + fgets(buff, 2048, stdin); len = strlen(buff) - 1; buff[len] = buff[len] == '\n' ? 0 : buff[len]; threshold = atoi(buff); - free (buff); + free(buff); } if (members < 2) - tcfs_error (ER_CUSTOM, "At least two members!"); + tcfs_error(ER_CUSTOM, "At least two members!"); if (threshold > members || threshold <= 0) - tcfs_error (ER_CUSTOM, "The threshold must be no greater than the number of members and greater than zero!"); + tcfs_error(ER_CUSTOM, "The threshold must be no greater than the number of members and greater than zero!"); S = gentcfskey(); #ifdef DEBUG_TCFS { int i; - printf ("La chiave segreta e':\n"); + printf("La chiave segreta e':\n"); - for (i=0;i<KEYSIZE;i++) - printf ("%u:", S[i]); + for (i = 0; i < KEYSIZE; i++) + printf("%u:", S[i]); - printf ("\n"); + printf("\n"); } #endif @@ -320,17 +321,17 @@ addgroup_main (int argn, char *argv[]) group_info[members-1]->n = members; group_info[members-1]->soglia = threshold; - if (!unix_auth (&user, &passwd, FALSE)) { - fprintf (stderr, "Invalid password or the user does not exist.\n"); + if (!unix_auth(&user, &passwd, FALSE)) { + fprintf(stderr, "Invalid password or the user does not exist.\n"); continue; } - if (tcfs_ggetpwnam (user, gid, &tmp)) + if (tcfs_ggetpwnam(user, gid, &tmp)) tcfs_error(ER_CUSTOM, "Group already exists."); while (tmpmemb > members) { - if (!strcmp (user, group_info[tmpmemb-1]->user)) { - fprintf (stderr, "User already present into the group.\n"); + if (!strcmp(user, group_info[tmpmemb-1]->user)) { + fprintf(stderr, "User already present into the group.\n"); cont = 1; break; } @@ -340,31 +341,31 @@ addgroup_main (int argn, char *argv[]) if (cont) 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) - tcfs_error (ER_MEM, NULL); + tcfs_error(ER_MEM, NULL); cryptedkey = (unsigned char*)calloc(UUGKEYSIZE, sizeof(char)); if (!cryptedkey) - tcfs_error (ER_MEM, NULL); + tcfs_error(ER_MEM, NULL); - memcpy (newkey, gengrpkey (user), GKEYSIZE); + memcpy(newkey, gengrpkey(user), GKEYSIZE); newkey[GKEYSIZE] = '\0'; /* * Encrypt the just generated key with the user password */ - if (!tcfs_encrypt_key (passwd, newkey, GKEYSIZE, - cryptedkey, UUGKEYSIZE)) - tcfs_error (ER_MEM, NULL); + if (!tcfs_encrypt_key(passwd, newkey, GKEYSIZE, cryptedkey, + UUGKEYSIZE)) + tcfs_error(ER_MEM, NULL); - free (newkey); + free(newkey); - strlcpy (group_info[members - 1]->gkey, cryptedkey, - GKEYSIZE + 1); - free (cryptedkey); + strlcpy(group_info[members - 1]->gkey, cryptedkey, + GKEYSIZE + 1); + free(cryptedkey); members--; } @@ -373,25 +374,25 @@ addgroup_main (int argn, char *argv[]) while (members) { 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]->user); - if (!tcfs_gputpwnam (group_info[members-1]->user, + if (!tcfs_gputpwnam(group_info[members-1]->user, group_info[members-1], U_NEW)) { /* 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) - 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--; } - tcfs_error (ER_CUSTOM, "\nAll group keys generated."); + tcfs_error(ER_CUSTOM, "\nAll group keys generated."); - return 0; + return (0); } @@ -399,14 +400,14 @@ int eleva(int x, int y, int z) { int mask = 0x80000000; - int res = 1,i; + int res = 1, i; for (i = 0; i < 32; i++) { - res = (res*res)%z; + res = (res * res) % z; if (y & mask) - res = (x*res)%z; + res = (x * res) % z; mask = mask >> 1; } - return res; + return (res); } diff --git a/usr.bin/tcfs/tcfsadduser.c b/usr.bin/tcfs/tcfsadduser.c index 10dfab3f761..d0fd5fb5a94 100644 --- a/usr.bin/tcfs/tcfsadduser.c +++ b/usr.bin/tcfs/tcfsadduser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsadduser.c,v 1.3 2000/06/19 21:31:30 fgsch Exp $ */ +/* $OpenBSD: tcfsadduser.c,v 1.4 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -31,7 +31,7 @@ Add an user entry to the TCFS database. -v Makes the output a little more verbose\n"; int -adduser_main (int argn, char *argv[]) +adduser_main(int argn, char *argv[]) { char val; int have_user = FALSE, be_verbose = FALSE; @@ -44,26 +44,26 @@ adduser_main (int argn, char *argv[]) while ((val = getopt(argn, argv, "g:l:hv"))!=EOF) switch (val) { case 'l': - strlcpy (user, optarg, sizeof(user)); + strlcpy(user, optarg, sizeof(user)); have_user = 1; break; case 'h': - show_usage (adduser_usage, argv[0]); - exit (OK); + show_usage(adduser_usage, argv[0]); + exit(OK); break; case 'v': be_verbose = TRUE; break; default: - fprintf (stderr, + fprintf(stderr, "Try %s --help for more information.\n", argv[0]); - exit (ER_UNKOPT); + exit(ER_UNKOPT); break; } - if (argn-optind) - tcfs_error (ER_UNKOPT, NULL); + if (argn - optind) + tcfs_error(ER_UNKOPT, NULL); /* * Here we don't have to drop root privileges because only root @@ -71,28 +71,28 @@ adduser_main (int argn, char *argv[]) * However we can do better. Maybe in next versions. */ if (!have_user) { - printf ("Username to add to TCFS database: "); - fgets (user, sizeof(user), stdin); - user[strlen(user)-1] = '\0'; + printf("Username to add to TCFS database: "); + fgets(user, sizeof(user), stdin); + user[strlen(user) - 1] = '\0'; } if (be_verbose) - printf ("Creating a new entry for user %s in the TCFS database...\n", user); + printf("Creating a new entry for user %s in the TCFS database...\n", user); /* * Creating a new entry into the key database */ - if (!tcfspwdbr_new (&user_info)) - tcfs_error (ER_MEM, NULL); + if (!tcfspwdbr_new(&user_info)) + tcfs_error(ER_MEM, NULL); - if (!tcfspwdbr_edit (&user_info, F_USR, user)) - tcfs_error (ER_MEM, NULL); + if (!tcfspwdbr_edit(&user_info, F_USR, user)) + tcfs_error(ER_MEM, NULL); - if (!tcfs_putpwnam (user, user_info, U_NEW)) - tcfs_error (ER_CUSTOM, "Error: cannot add user."); + if (!tcfs_putpwnam(user, user_info, U_NEW)) + tcfs_error(ER_CUSTOM, "Error: cannot add user."); if (be_verbose) - printf ("User entry created with success.\n"); + printf("User entry created with success.\n"); - tcfs_error (OK, NULL); + tcfs_error(OK, NULL); } diff --git a/usr.bin/tcfs/tcfserrors.c b/usr.bin/tcfs/tcfserrors.c index 9e459665e7f..50e1cf15ae6 100644 --- a/usr.bin/tcfs/tcfserrors.c +++ b/usr.bin/tcfs/tcfserrors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfserrors.c,v 1.4 2000/06/19 20:35:47 fgsch Exp $ */ +/* $OpenBSD: tcfserrors.c,v 1.5 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -31,42 +31,41 @@ static char *tcfs_errors_strings[]= "ioctl error while getting key counter." }; -void tcfs_error (int error_type, char *custom_message) +void tcfs_error(int error_type, char *custom_message) { - if (error_type!=ER_CUSTOM && error_type!=OK) - fprintf (stderr, "Error: "); + if (error_type != ER_CUSTOM && error_type != OK) + fprintf(stderr, "Error: "); - switch (error_type) - { - case ER_AUTH: - case ER_MEM: - case ER_TCFS: - case ER_PERM: - case ER_ENABLE: - case ER_DISABLE: - case ER_COUNT: - case ER_USER: - case OK: - fprintf (stderr, "%s\n", tcfs_errors_strings[error_type]); - exit (error_type); - case ER_CUSTOM: - fprintf (stderr, "%s\n", custom_message); - exit (1); - case ER_UNKOPT: - if (custom_message) - fprintf (stderr, "%s: %s\n", tcfs_errors_strings[error_type], custom_message); - else - fprintf (stderr, "%s\n", tcfs_errors_strings[error_type]); + switch (error_type) { + case ER_AUTH: + case ER_MEM: + case ER_TCFS: + case ER_PERM: + case ER_ENABLE: + case ER_DISABLE: + case ER_COUNT: + case ER_USER: + case OK: + fprintf(stderr, "%s\n", tcfs_errors_strings[error_type]); + exit(error_type); + case ER_CUSTOM: + fprintf(stderr, "%s\n", custom_message); + exit(1); + case ER_UNKOPT: + if (custom_message) + fprintf(stderr, "%s: %s\n", tcfs_errors_strings[error_type], custom_message); + else + fprintf(stderr, "%s\n", tcfs_errors_strings[error_type]); - exit (error_type); - break; /* Useless code */ - default: - fprintf (stderr, "internal error.\n"); - exit (1); + exit(error_type); + break; /* Useless code */ + default: + fprintf(stderr, "internal error.\n"); + exit(1); } } -void show_usage (char *fmt, char *arg) +void show_usage(char *fmt, char *arg) { - printf (fmt, arg); + printf(fmt, arg); } diff --git a/usr.bin/tcfs/tcfsflag.c b/usr.bin/tcfs/tcfsflag.c index 22b689d9758..e19f96d60e8 100644 --- a/usr.bin/tcfs/tcfsflag.c +++ b/usr.bin/tcfs/tcfsflag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsflag.c,v 1.4 2000/06/19 20:35:48 fgsch Exp $ */ +/* $OpenBSD: tcfsflag.c,v 1.5 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -29,7 +29,7 @@ #include "tcfsdefines.h" tcfs_flags tcfs_getflags(int); -tcfs_flags tcfs_setflags(int,tcfs_flags); +tcfs_flags tcfs_setflags(int, tcfs_flags); int flags_main(int argc, char *argv[]) @@ -42,12 +42,12 @@ flags_main(int argc, char *argv[]) setuid(getuid()); if (argc < 3) { - fprintf (stderr, "tcfsflags [op]{r,x,g} file\n" + fprintf(stderr, "tcfsflags [op]{r,x,g} file\n" "\t op can either be + or -.\n\n"); exit(1); } - fd = open(argv[2],O_RDONLY); + fd = open(argv[2], O_RDONLY); if (!fd) { fprintf(stderr, "open failed\n"); exit(1); @@ -55,7 +55,7 @@ flags_main(int argc, char *argv[]) i = tcfs_getflags(fd); if (i.flag == -1) { - fprintf(stderr,"getflags error\n"); + fprintf(stderr, "getflags error\n"); close(fd); exit(1); } diff --git a/usr.bin/tcfs/tcfsgenkey.c b/usr.bin/tcfs/tcfsgenkey.c index 19132a7509b..a244b17f150 100644 --- a/usr.bin/tcfs/tcfsgenkey.c +++ b/usr.bin/tcfs/tcfsgenkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsgenkey.c,v 1.5 2000/06/19 20:35:48 fgsch Exp $ */ +/* $OpenBSD: tcfsgenkey.c,v 1.6 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -26,7 +26,7 @@ Generate a TCFS key adding it to the user entry into the TCFS database. -h Shows this help\n"; int -genkey_main (int argn, char *argv[]) +genkey_main(int argn, char *argv[]) { int val; char *user, *passwd; @@ -41,67 +41,67 @@ genkey_main (int argn, char *argv[]) switch (val) { case 'h': show_usage(genkey_usage, argv[0]); - exit (OK); + exit(OK); break; /* Useless code */ default: - fprintf (stderr, "Try %s --help for more information.\n", argv[0]); - exit (ER_UNKOPT); + fprintf(stderr, "Try %s --help for more information.\n", argv[0]); + exit(ER_UNKOPT); break; } if (argn - optind) - tcfs_error (ER_UNKOPT, NULL); + tcfs_error(ER_UNKOPT, NULL); /* * Must be root to do all this stuff */ if (geteuid()) - tcfs_error (ER_CUSTOM, "I don't have root privileges!"); + tcfs_error(ER_CUSTOM, "I don't have root privileges!"); /* * Authenticate user */ - if (!unix_auth (&user, &passwd, TRUE)) - tcfs_error (ER_CUSTOM, "Who are you?!"); + if (!unix_auth(&user, &passwd, TRUE)) + tcfs_error(ER_CUSTOM, "Who are you?!"); - if (!tcfs_getpwnam (user, &user_info)) - tcfs_error (ER_CUSTOM, "You do not have an entry in the TCFS key database."); + if (!tcfs_getpwnam(user, &user_info)) + tcfs_error(ER_CUSTOM, "You do not have an entry in the TCFS key database."); if (strlen(user_info->upw)) - tcfs_error (ER_CUSTOM,"You already have a TCFS key."); + tcfs_error(ER_CUSTOM, "You already have a TCFS key."); /* * Generate a new key for the user. */ - newkey = gentcfskey (); + newkey = gentcfskey(); /* * Encrypt the generated key with user password */ cryptedkey = (char*)calloc(UUKEYSIZE + 1, sizeof(char)); if (!cryptedkey) - tcfs_error (ER_MEM, NULL); + tcfs_error(ER_MEM, NULL); - if (!tcfs_encrypt_key (passwd, newkey, KEYSIZE, cryptedkey, UUKEYSIZE + 1)) - tcfs_error (ER_MEM, NULL); + if (!tcfs_encrypt_key(passwd, newkey, KEYSIZE, cryptedkey, UUKEYSIZE + 1)) + tcfs_error(ER_MEM, NULL); /* * Update TCFS key database */ - if (!tcfspwdbr_new (&userinfo)) - tcfs_error (ER_MEM, NULL); + if (!tcfspwdbr_new(&userinfo)) + tcfs_error(ER_MEM, NULL); - if (!tcfspwdbr_edit (&userinfo, F_USR|F_PWD, user, cryptedkey)) - tcfs_error (ER_MEM, NULL); + if (!tcfspwdbr_edit(&userinfo, F_USR|F_PWD, user, cryptedkey)) + tcfs_error(ER_MEM, NULL); /* TODO: - if (!change && tcfs_getpwnam (user, &userinfo)) - tcfs_error (ER_CUSTOM, "Use -c to change the key."); + if (!change && tcfs_getpwnam(user, &userinfo)) + tcfs_error(ER_CUSTOM, "Use -c to change the key."); */ - if (!tcfs_putpwnam (user, userinfo, U_CHG)) - tcfs_error (ER_CUSTOM, "Error: cannot generate key."); + if (!tcfs_putpwnam(user, userinfo, U_CHG)) + tcfs_error(ER_CUSTOM, "Error: cannot generate key."); - tcfs_error (ER_CUSTOM, "\nKey succesfully generated."); + tcfs_error(ER_CUSTOM, "\nKey succesfully generated."); } diff --git a/usr.bin/tcfs/tcfsmng.c b/usr.bin/tcfs/tcfsmng.c index 576f3dce279..888a026f96a 100644 --- a/usr.bin/tcfs/tcfsmng.c +++ b/usr.bin/tcfs/tcfsmng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsmng.c,v 1.2 2000/06/19 20:35:48 fgsch Exp $ */ +/* $OpenBSD: tcfsmng.c,v 1.3 2000/06/19 22:42:28 aaron Exp $ */ /* * Copyright 2000 Niels Provos <provos@citi.umich.edu> @@ -77,5 +77,5 @@ main (int argc, char **argv) fprintf(stderr, "%s: unknown command %s\n\n", argv[0], argv[1]); usage(argv[0]); - exit (1); + exit(1); } diff --git a/usr.bin/tcfs/tcfsputkey.c b/usr.bin/tcfs/tcfsputkey.c index 6a0d619689e..5764505c794 100644 --- a/usr.bin/tcfs/tcfsputkey.c +++ b/usr.bin/tcfs/tcfsputkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsputkey.c,v 1.6 2000/06/19 20:35:48 fgsch Exp $ */ +/* $OpenBSD: tcfsputkey.c,v 1.7 2000/06/19 22:42:28 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -36,7 +36,7 @@ char *putkey_usage= int putkey_main(int argc, char *argv[]) { - char *user,*password,*tcfskey; + char *user, *password, *tcfskey; uid_t uid; gid_t gid; int es, treshold; @@ -48,7 +48,7 @@ putkey_main(int argc, char *argv[]) int isgroupkey = 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) { case 'k': def = FALSE; @@ -79,7 +79,7 @@ putkey_main(int argc, char *argv[]) } } if (argc - optind) - tcfs_error(ER_UNKOPT,NULL); + tcfs_error(ER_UNKOPT, NULL); if (havefsname && havempname) { tcfs_error(ER_CUSTOM, putkey_usage); @@ -87,7 +87,7 @@ putkey_main(int argc, char *argv[]) } if (havefsname) { - es=tcfs_getfspath(fslabel,fspath); + es = tcfs_getfspath(fslabel, fspath); havename = TRUE; } @@ -95,65 +95,65 @@ putkey_main(int argc, char *argv[]) havename = TRUE; if (!havename) - es=tcfs_getfspath("default",fspath); + es = tcfs_getfspath("default", fspath); if (!es) { - tcfs_error(ER_CUSTOM,"fs-label not found!\n"); + tcfs_error(ER_CUSTOM, "fs-label not found!\n"); exit(1); } uid = getuid(); if (isgroupkey) { - if (!unix_auth(&user,&password,TRUE)) - tcfs_error(ER_AUTH,user); + if (!unix_auth(&user, &password, TRUE)) + tcfs_error(ER_AUTH, user); if (!tcfsgpwdbr_new(&ginfo)) - tcfs_error(ER_MEM,NULL); + tcfs_error(ER_MEM, NULL); - if (!tcfs_ggetpwnam(user,gid,&ginfo)) - tcfs_error(ER_CUSTOM,"Default key non found"); + if (!tcfs_ggetpwnam(user, gid, &ginfo)) + tcfs_error(ER_CUSTOM, "Default key non found"); if (!strlen(ginfo->gkey)) - tcfs_error(ER_CUSTOM,"Invalid default key"); + tcfs_error(ER_CUSTOM, "Invalid default key"); tcfskey = (char*)malloc(UUKEYSIZE); if (!tcfskey) - tcfs_error(ER_MEM,NULL); + tcfs_error(ER_MEM, NULL); treshold = ginfo->soglia; if (!tcfs_decrypt_key(password, ginfo->gkey, tcfskey, GKEYSIZE)) 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) { - tcfs_error(ER_CUSTOM,"problems updating filesystem"); + if (es == -1) { + tcfs_error(ER_CUSTOM, "problems updating filesystem"); } exit(0); } - if(!def) { + if (!def) { tcfskey = getpass("Insert tcfs-key:"); havekey = TRUE; } else { - if(!unix_auth(&user,&password,TRUE)) - tcfs_error(ER_AUTH,user); + if (!unix_auth(&user, &password, TRUE)) + tcfs_error(ER_AUTH, user); - if(!tcfspwdbr_new(&info)) - tcfs_error(ER_MEM,NULL); + if (!tcfspwdbr_new(&info)) + tcfs_error(ER_MEM, NULL); - if(!tcfs_getpwnam(user,&info)) - tcfs_error(ER_CUSTOM,"Default key non found"); + if (!tcfs_getpwnam(user, &info)) + tcfs_error(ER_CUSTOM, "Default key non found"); - if(!strlen(info->upw)) + if (!strlen(info->upw)) tcfs_error(ER_CUSTOM, "Invalid default key"); tcfskey = (char*)malloc(UUKEYSIZE); - if(!tcfskey) + if (!tcfskey) tcfs_error(ER_MEM, NULL); if (!tcfs_decrypt_key (password, info->upw, tcfskey, KEYSIZE)) @@ -163,8 +163,8 @@ putkey_main(int argc, char *argv[]) es = tcfs_user_enable(fspath, uid, tcfskey); - if(es == -1) - tcfs_error(ER_CUSTOM,"problems updating filesystem"); + if (es == -1) + tcfs_error(ER_CUSTOM, "problems updating filesystem"); exit(0); } diff --git a/usr.bin/tcfs/tcfsrmgroup.c b/usr.bin/tcfs/tcfsrmgroup.c index 39842ee83c3..d00ca8f2f9d 100644 --- a/usr.bin/tcfs/tcfsrmgroup.c +++ b/usr.bin/tcfs/tcfsrmgroup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsrmgroup.c,v 1.5 2000/06/19 20:54:12 fgsch Exp $ */ +/* $OpenBSD: tcfsrmgroup.c,v 1.6 2000/06/19 22:42:29 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -28,7 +28,7 @@ Remove a TCFS group from the TCFS group database. -v Makes the output a little more verbose\n"; int -rmgroup_main (int argn, char *argv[]) +rmgroup_main(int argn, char *argv[]) { int val; gid_t gid; @@ -44,27 +44,27 @@ rmgroup_main (int argn, char *argv[]) if (!gid && optarg[0] != '0') { /* group name given */ struct group *group_id; - group_id=getgrnam(optarg); + group_id = getgrnam(optarg); if (!group_id) - tcfs_error (ER_CUSTOM, "Nonexistent group."); - gid=group_id->gr_gid; + tcfs_error(ER_CUSTOM, "Nonexistent group."); + gid = group_id->gr_gid; } - have_gid=TRUE; + have_gid = TRUE; break; case 'h': - show_usage (rmgroup_usage, argv[0]); - exit (OK); + show_usage(rmgroup_usage, argv[0]); + exit(OK); case 'v': - be_verbose=TRUE; + be_verbose = TRUE; break; default: - fprintf (stderr, "Try %s --help for more informations.\n", argv[0]); - exit (ER_UNKOPT); + fprintf(stderr, "Try %s --help for more informations.\n", argv[0]); + exit(ER_UNKOPT); } - if (argn-optind) - tcfs_error (ER_UNKOPT, NULL); + if (argn - optind) + tcfs_error(ER_UNKOPT, NULL); if (!have_gid) { char *buff = NULL; @@ -72,29 +72,29 @@ rmgroup_main (int argn, char *argv[]) buff = (char*)calloc(2048, sizeof(char)); if (!buff) - tcfs_error (ER_MEM, NULL); + tcfs_error(ER_MEM, NULL); - printf ("Group id of the TCFS group to remove from the database: "); - fgets (buff,2048,stdin); + printf("Group id of the TCFS group to remove from the database: "); + fgets(buff, 2048, stdin); len = strlen(buff) - 1; buff[len] = buff[len] == '\n' ? 0 : buff[len]; - gid=(gid_t)atoi(buff); + gid = (gid_t)atoi(buff); if (!gid && optarg[0] != '0') { /* group name given */ struct group *group_id; group_id = getgrnam(optarg); if (!group_id) - tcfs_error (ER_CUSTOM, "Nonexistent group."); - gid=group_id->gr_gid; + tcfs_error(ER_CUSTOM, "Nonexistent group."); + gid = group_id->gr_gid; } - if (gid <=0 ) - tcfs_error (ER_CUSTOM, "A positive ID please!"); + if (gid <= 0) + tcfs_error(ER_CUSTOM, "A positive ID please!"); - free (buff); + free(buff); } - if (!tcfs_rmgroup (gid)) - tcfs_error (ER_CUSTOM, "Wrong ID or an error as occurred.\n"); + if (!tcfs_rmgroup(gid)) + tcfs_error(ER_CUSTOM, "Wrong ID or an error as occurred.\n"); } diff --git a/usr.bin/tcfs/tcfsrmkey.c b/usr.bin/tcfs/tcfsrmkey.c index 68a230027c8..f42af67caaf 100644 --- a/usr.bin/tcfs/tcfsrmkey.c +++ b/usr.bin/tcfs/tcfsrmkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsrmkey.c,v 1.3 2000/06/19 20:35:48 fgsch Exp $ */ +/* $OpenBSD: tcfsrmkey.c,v 1.4 2000/06/19 22:42:29 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -44,7 +44,7 @@ rmkey_main(int argc, char *argv[]) int havempname = FALSE, havefsname = FALSE, isgroupkey = FALSE; int havename = FALSE, havefspath = FALSE; - while ((x = getopt(argc,argv,"f:p:g:")) != EOF) { + while ((x = getopt(argc, argv, "f:p:g:")) != EOF) { switch(x) { case 'p': havempname = TRUE; @@ -72,7 +72,7 @@ rmkey_main(int argc, char *argv[]) } } if (argc-optind) - tcfs_error(ER_UNKOPT,NULL); + tcfs_error(ER_UNKOPT, NULL); if (havefsname && havempname) { tcfs_error(ER_CUSTOM, rmkey_usage); @@ -88,26 +88,26 @@ rmkey_main(int argc, char *argv[]) havename = TRUE; if (!havename) - es = tcfs_getfspath("default",fspath); + es = tcfs_getfspath("default", fspath); if(!es) { - tcfs_error(ER_CUSTOM,"fs-label not found!\n"); + tcfs_error(ER_CUSTOM, "fs-label not found!\n"); exit(1); } uid = getuid(); if (isgroupkey) { - es = tcfs_group_disable(fspath,uid,gid); + es = tcfs_group_disable(fspath, uid, gid); if(es == -1) tcfs_error(ER_CUSTOM, "problems updating filesystem"); exit(0); } - es = tcfs_user_disable(fspath,uid); + es = tcfs_user_disable(fspath, uid); if (es == -1) - tcfs_error(ER_CUSTOM,"problems updating filesystem"); + tcfs_error(ER_CUSTOM, "problems updating filesystem"); exit(0); } diff --git a/usr.bin/tcfs/tcfsrmuser.c b/usr.bin/tcfs/tcfsrmuser.c index 8ff37e49364..bacd3f2f6e9 100644 --- a/usr.bin/tcfs/tcfsrmuser.c +++ b/usr.bin/tcfs/tcfsrmuser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsrmuser.c,v 1.4 2000/06/19 20:35:48 fgsch Exp $ */ +/* $OpenBSD: tcfsrmuser.c,v 1.5 2000/06/19 22:42:29 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -31,7 +31,7 @@ Remove an user entry from the TCFS dabatase. -v Makes the output a little more verbose\n"; int -rmuser_main (int argn, char *argv[]) +rmuser_main(int argn, char *argv[]) { int have_user = FALSE; int be_verbose = FALSE; @@ -43,33 +43,30 @@ rmuser_main (int argn, char *argv[]) * Going to check the arguments */ - if ((user = (char *) malloc(LOGIN_NAME_MAX + 1)) == NULL) + if ((user = (char *)malloc(LOGIN_NAME_MAX + 1)) == NULL) err(1, NULL); - while ((val=getopt (argn, argv, "l:hv"))!=EOF) + while ((val = getopt(argn, argv, "l:hv")) != EOF) switch (val) { - case 'l': - strlcpy (user, optarg, LOGIN_NAME_MAX + 1); - have_user = TRUE; - break; - - case 'h': - show_usage (rmuser_usage, argv[0]); - exit (OK); - break; - - case 'v': - be_verbose = TRUE; - break; - - default: - fprintf (stderr, "Try %s --help for more information.\n", argv[0]); - exit (ER_UNKOPT); - break; + case 'l': + strlcpy(user, optarg, LOGIN_NAME_MAX + 1); + have_user = TRUE; + break; + case 'h': + show_usage(rmuser_usage, argv[0]); + exit(OK); + break; + case 'v': + be_verbose = TRUE; + break; + default: + fprintf(stderr, "Try %s --help for more information.\n", argv[0]); + exit(ER_UNKOPT); + break; } - if (argn-optind) - tcfs_error (ER_UNKOPT, NULL); + if (argn - optind) + tcfs_error(ER_UNKOPT, NULL); /* * Here we don't have to drop root privileges because only root @@ -79,31 +76,31 @@ rmuser_main (int argn, char *argv[]) if (!have_user) { int len; - printf ("Username to remove from TCFS database: "); - fgets (user, LOGIN_NAME_MAX + 1, stdin); + printf("Username to remove from TCFS database: "); + fgets(user, LOGIN_NAME_MAX + 1, stdin); len = strlen(user) - 2; if (len < 0) - exit (1); + exit(1); user[len] = user[len] == '\n' ? 0 : user[len]; } if (be_verbose) - printf ("Deleting the entry for user %s from the TCFS database...\n", user); + printf("Deleting the entry for user %s from the TCFS database...\n", user); /* * Deleting an entry from the key database */ - if (!tcfspwdbr_new (&user_info)) - tcfs_error (ER_MEM, NULL); + if (!tcfspwdbr_new(&user_info)) + tcfs_error(ER_MEM, NULL); - if (!tcfspwdbr_edit (&user_info, F_USR, user)) - tcfs_error (ER_MEM, NULL); + if (!tcfspwdbr_edit(&user_info, F_USR, user)) + tcfs_error(ER_MEM, NULL); - if (!tcfs_putpwnam (user, user_info, U_DEL)) - tcfs_error (ER_CUSTOM, "Error: cannot remove user."); + if (!tcfs_putpwnam(user, user_info, U_DEL)) + tcfs_error(ER_CUSTOM, "Error: cannot remove user."); if (be_verbose) - printf ("User entry removed with success.\n"); + printf("User entry removed with success.\n"); - tcfs_error (OK, NULL); + tcfs_error(OK, NULL); } diff --git a/usr.bin/tcfs/tcfsrun.c b/usr.bin/tcfs/tcfsrun.c index 8090efd32c1..03da06748b1 100644 --- a/usr.bin/tcfs/tcfsrun.c +++ b/usr.bin/tcfs/tcfsrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcfsrun.c,v 1.4 2000/06/19 20:35:48 fgsch Exp $ */ +/* $OpenBSD: tcfsrun.c,v 1.5 2000/06/19 22:42:29 aaron Exp $ */ /* * Transparent Cryptographic File System (TCFS) for NetBSD @@ -37,18 +37,18 @@ run_main(int argc, char *argv[], char *envp[]) uid_t uid; pid_t pid; int es; - int havefspath = 0,havecmd = 0; + int havefspath = 0, havecmd = 0; uid = getuid(); - while ((x = getopt(argc,argv,"p:f:")) != EOF) { + while ((x = getopt(argc, argv, "p:f:")) != EOF) { switch(x) { case 'p': strlcpy(fspath, optarg, sizeof(fspath)); havefspath = 1; break; case 'f': - es = tcfs_getfspath(optarg,fspath); + es = tcfs_getfspath(optarg, fspath); if (!es) { fprintf(stderr, "filesystem label not found!\n"); @@ -66,7 +66,7 @@ run_main(int argc, char *argv[], char *envp[]) } if (!havefspath) { - es = tcfs_getfspath("default",fspath); + es = tcfs_getfspath("default", fspath); if (!es) exit(1); } @@ -81,7 +81,7 @@ run_main(int argc, char *argv[], char *envp[]) pid = getpid(); if (tcfs_proc_enable(fspath, uid, pid, key) != -1) { setuid(uid); - execve(cmd,argv + optind, envp); + execve(cmd, argv + optind, envp); } fprintf(stderr, "Operation failed\n"); @@ -90,7 +90,7 @@ run_main(int argc, char *argv[], char *envp[]) wait(0); - if (tcfs_proc_disable(fspath,uid,pid) == -1) { + if (tcfs_proc_disable(fspath, uid, pid) == -1) { fprintf (stderr, "Problems removing process key\n"); exit(1); } diff --git a/usr.bin/tcfs/tcfstat.c b/usr.bin/tcfs/tcfstat.c index e6195e7861d..71565335979 100644 --- a/usr.bin/tcfs/tcfstat.c +++ b/usr.bin/tcfs/tcfstat.c @@ -28,17 +28,17 @@ int stat_main(int argc, char *argv[], char *envp[]) { struct tcfs_status st; - int e,es,ok=0; + int e, es, ok=0; char filesystem[MAXPATHLEN]; - if (argc==3 && !strcmp("-p",argv[1])) { + if (argc == 3 && !strcmp("-p", argv[1])) { strlcpy(filesystem, argv[2], sizeof(filesystem)); - ok=1; + ok = 1; } if (argc == 2) { - if (!(es = tcfs_getfspath(argv[1],filesystem))) { - fprintf(stderr,"filesystem label not found!\n"); + if (!(es = tcfs_getfspath(argv[1], filesystem))) { + fprintf(stderr, "filesystem label not found!\n"); exit(1); } ok = 1; @@ -52,12 +52,12 @@ stat_main(int argc, char *argv[], char *envp[]) e = tcfs_getstatus(filesystem, &st); if (e == -1) { - fprintf(stderr,"filesystem %s not mounted\n",filesystem); + fprintf(stderr, "filesystem %s not mounted\n", filesystem); exit(1); } - printf("Status: %d; user keys: %d, group keys: %d\n",st.status, st.n_ukey, st.n_gkey); - printf("TCFS version: %d, Cipher: %s, keysize: %d, cipher version: %d\n",st.tcfs_version, st.cipher_desc, st.cipher_keysize, st.cipher_version); + printf("Status: %d; user keys: %d, group keys: %d\n", st.status, st.n_ukey, st.n_gkey); + printf("TCFS version: %d, Cipher: %s, keysize: %d, cipher version: %d\n", st.tcfs_version, st.cipher_desc, st.cipher_keysize, st.cipher_version); exit(0); } diff --git a/usr.bin/tcfs/tcfsuse.c b/usr.bin/tcfs/tcfsuse.c index cf67437ec93..db82b42dcc6 100644 --- a/usr.bin/tcfs/tcfsuse.c +++ b/usr.bin/tcfs/tcfsuse.c @@ -56,8 +56,10 @@ usage(char *name) fprintf(stderr, "Usage: %s <subcmd> [arguments]\n", name); fprintf(stderr, "Possible sub commands:"); + for (i = sizeof(subcmds)/sizeof(struct subprg) - 1; i >= 0; i--) fprintf(stderr, " %s", subcmds[i].name); + fprintf(stderr, "\n"); } @@ -79,5 +81,5 @@ main (int argc, char **argv) fprintf(stderr, "%s: unknown command %s\n\n", argv[0], argv[1]); usage(argv[0]); - exit (1); + exit(1); } diff --git a/usr.bin/tcfs/unix_auth.c b/usr.bin/tcfs/unix_auth.c index 80d8ed44e0a..6f7ea0b5f1f 100644 --- a/usr.bin/tcfs/unix_auth.c +++ b/usr.bin/tcfs/unix_auth.c @@ -23,22 +23,22 @@ #include "tcfserrors.h" int -unix_auth (char **user, char **password, int flag) +unix_auth(char **user, char **password, int flag) { char *luser, *passwd; struct passwd *passentry; - luser = (char*)calloc (LOGIN_NAME_MAX, sizeof(char)); - passwd = (char*)calloc (_PASSWORD_LEN, sizeof(char)); + luser = (char *)calloc(LOGIN_NAME_MAX, sizeof(char)); + passwd = (char *)calloc(_PASSWORD_LEN, sizeof(char)); if (!luser || !passwd) - tcfs_error (ER_MEM, NULL); + tcfs_error(ER_MEM, NULL); if (flag) { passentry = getpwuid(getuid()); strlcpy(luser, passentry->pw_name, LOGIN_NAME_MAX); } else { - printf ("Enter user: "); + printf("Enter user: "); fgets(luser, LOGIN_NAME_MAX, stdin); luser[strlen(luser)-1] = '\0'; passentry = getpwnam(luser); @@ -47,8 +47,8 @@ unix_auth (char **user, char **password, int flag) passwd = getpass("Password:"); if (passentry == NULL) { - bzero (passwd, strlen(passwd)); - return 0; + bzero(passwd, strlen(passwd)); + return (0); } if (strcmp(crypt(passwd, passentry->pw_passwd), passentry->pw_passwd)) |