summaryrefslogtreecommitdiff
path: root/usr.bin/tcfs/tcfs_dbmaint.c
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2000-06-19 03:23:05 +0000
committerNiels Provos <provos@cvs.openbsd.org>2000-06-19 03:23:05 +0000
commit9404661d822ea85af4072644f968a515269ae525 (patch)
treeb0bff22121d4fb7a08293d59f052d7247d8e5dd4 /usr.bin/tcfs/tcfs_dbmaint.c
parent7a9c4bc37db7ac8d036e00322d50ec91a1bfc88a (diff)
fix a couple of bugs. dont clobber tcfspwdb when adding group entries.
do the fgets correctly until aaron gets to them.
Diffstat (limited to 'usr.bin/tcfs/tcfs_dbmaint.c')
-rw-r--r--usr.bin/tcfs/tcfs_dbmaint.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/tcfs/tcfs_dbmaint.c b/usr.bin/tcfs/tcfs_dbmaint.c
index b7b0004a223..d368ecc030b 100644
--- a/usr.bin/tcfs/tcfs_dbmaint.c
+++ b/usr.bin/tcfs/tcfs_dbmaint.c
@@ -229,6 +229,7 @@ tcfs_ggetpwnam (char *user, gid_t gid, tcfsgpwdb **dest)
DB *pdb;
DBT srchkey, r;
char *key, *buf;
+ int res;
if (!*dest)
if (!tcfsgpwdbr_new (dest))
@@ -243,10 +244,12 @@ tcfs_ggetpwnam (char *user, gid_t gid, tcfsgpwdb **dest)
return NULL;
sprintf (key, "%s\33%d\0", user, (int)gid);
- srchkey.data=key;
- srchkey.size=(int)strlen (key);
+ srchkey.data = key;
+ srchkey.size = (int)strlen (key);
- if (pdb->get(pdb, &srchkey, &r, 0)) {
+ if ((res = pdb->get(pdb, &srchkey, &r, 0))) {
+ if (res == -1)
+ perror("dbget");
pdb->close (pdb);
return (NULL);
}
@@ -306,12 +309,14 @@ tcfs_gputpwnam (char *user, tcfsgpwdb *src, int flags)
char *tmp;
open_flag = O_RDWR|O_EXCL;
- if (access (TCFSPWDB, F_OK) < 0)
+ if (access (TCFSGPWDB, F_OK) < 0)
open_flag |= O_CREAT;
- pdb = dbopen (TCFSPWDB, open_flag, PERM_SECURE, DB_HASH, NULL);
- if (!pdb)
+ pdb = dbopen (TCFSGPWDB, open_flag, PERM_SECURE, DB_HASH, NULL);
+ if (!pdb) {
+ perror("dbopen");
return 0;
+ }
key = (char *) calloc (strlen(src->user) + 4 + 1, sizeof(char));
sprintf (key, "%s\33%d\0", src->user, src->gid);