From 2201fd6d9ff41506c1bc60d677ae268a1de42fbc Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Tue, 26 Sep 2006 03:22:28 +0000 Subject: [PATCH] getcellunix-use-stdio-again-20060925 i have no idea why this is so ugly. put it back to something like how it was. --- src/auth/cellconfig.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index eba0ac4ee0..8a16ea1c9e 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -478,28 +478,22 @@ GetCellUnix(struct afsconf_dir *adir) { int rc; char tbuffer[256]; - int fd; + char *p; + afsconf_FILE *fp; strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE, NULL); - fd = open(tbuffer, O_RDONLY, 0); - if (fd < 0) { - return -1; - } else { - int sz; - - memset(tbuffer, 0, 256); - sz = read(fd, tbuffer, 255); - close(fd); - if (sz > 0) { - char *p = strchr(tbuffer, '\n'); - if (p) - *p = '\0'; - - adir->cellName = (char *)malloc(sz + 1); - memset(adir->cellName, 0, sz+1); - strncpy(adir->cellName, tbuffer, sz); - } + fp = fopen(tbuffer, "r"); + if (fp == 0) { + return -1; } + rc = fgets(tbuffer, 256, fp); + fclose(fp); + + p = strchr(tbuffer, '\n'); + if (p) + *p = '\0'; + + adir->cellName = strdup(tbuffer); return 0; }