summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_serverlistdb.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-11-26 09:50:33 +0100
committerVolker Lendecke <vl@samba.org>2016-12-11 11:17:24 +0100
commit8a0174dca503a6c290c7d565a6bf2c10363964a4 (patch)
treeb41c8e374f173216c027da219102abe6ec25e1c8 /source3/nmbd/nmbd_serverlistdb.c
parent899b0883c8d500545133b0bf85743525fb1452bf (diff)
downloadsamba-8a0174dca503a6c290c7d565a6bf2c10363964a4.tar.gz
nmbd: xfile->stdio
Unfortunately this is a larger patch. Doing it in small pieces would have been pretty difficult, as everybody calls everybody else. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/nmbd/nmbd_serverlistdb.c')
-rw-r--r--source3/nmbd/nmbd_serverlistdb.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/source3/nmbd/nmbd_serverlistdb.c b/source3/nmbd/nmbd_serverlistdb.c
index 43471d69e45..05dcb6c7482 100644
--- a/source3/nmbd/nmbd_serverlistdb.c
+++ b/source3/nmbd/nmbd_serverlistdb.c
@@ -248,17 +248,17 @@ static uint32_t write_this_workgroup_name( struct subnet_record *subrec,
Write out the browse.dat file.
******************************************************************/
-void write_browse_list_entry(XFILE *fp, const char *name, uint32_t rec_type,
+void write_browse_list_entry(FILE *fp, const char *name, uint32_t rec_type,
const char *local_master_browser_name, const char *description)
{
fstring tmp;
slprintf(tmp,sizeof(tmp)-1, "\"%s\"", name);
- x_fprintf(fp, "%-25s ", tmp);
- x_fprintf(fp, "%08x ", rec_type);
+ fprintf(fp, "%-25s ", tmp);
+ fprintf(fp, "%08x ", rec_type);
slprintf(tmp, sizeof(tmp)-1, "\"%s\" ", local_master_browser_name);
- x_fprintf(fp, "%-30s", tmp);
- x_fprintf(fp, "\"%s\"\n", description);
+ fprintf(fp, "%-30s", tmp);
+ fprintf(fp, "\"%s\"\n", description);
}
void write_browse_list(time_t t, bool force_write)
@@ -270,7 +270,8 @@ void write_browse_list(time_t t, bool force_write)
char *fnamenew;
uint32_t stype;
int i;
- XFILE *fp;
+ int fd;
+ FILE *fp;
bool list_changed = force_write;
static time_t lasttime = 0;
TALLOC_CTX *ctx = talloc_tos();
@@ -310,15 +311,24 @@ void write_browse_list(time_t t, bool force_write)
return;
}
- fp = x_fopen(fnamenew,O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ fd = open(fnamenew, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ if (fd == -1) {
+ DBG_ERR("Can't open file %s: %s\n", fnamenew,
+ strerror(errno));
+ talloc_free(fnamenew);
+ talloc_free(fname);
+ return;
+ }
+ fp = fdopen(fd, "w");
if (!fp) {
- DEBUG(0,("write_browse_list: Can't open file %s. Error was %s\n",
- fnamenew,strerror(errno)));
+ DBG_ERR("fdopen failed: %s\n", strerror(errno));
+ close(fd);
talloc_free(fnamenew);
talloc_free(fname);
return;
}
+ fd = -1;
/*
* Write out a record for our workgroup. Use the record from the first
@@ -328,7 +338,7 @@ void write_browse_list(time_t t, bool force_write)
if((work = find_workgroup_on_subnet(FIRST_SUBNET, lp_workgroup())) == NULL) {
DEBUG(0,("write_browse_list: Fatal error - cannot find my workgroup %s\n",
lp_workgroup()));
- x_fclose(fp);
+ fclose(fp);
talloc_free(fnamenew);
talloc_free(fname);
return;
@@ -394,7 +404,7 @@ void write_browse_list(time_t t, bool force_write)
}
}
- x_fclose(fp);
+ fclose(fp);
unlink(fname);
chmod(fnamenew,0644);
rename(fnamenew,fname);