summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_serverlistdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-19 15:15:09 -0800
committerJeremy Allison <jra@samba.org>2007-11-19 15:15:09 -0800
commit9a41314ce8582875e0ec59efb670279f39b42ce3 (patch)
tree8d32fb934b30f4080673338460029b489d4d6e2d /source3/nmbd/nmbd_serverlistdb.c
parent551f9e7a6ccfefa48674f3b6a857485c60dfc2eb (diff)
downloadsamba-9a41314ce8582875e0ec59efb670279f39b42ce3.tar.gz
samba-9a41314ce8582875e0ec59efb670279f39b42ce3.tar.bz2
samba-9a41314ce8582875e0ec59efb670279f39b42ce3.zip
Remove pstring from nmbd.
Jeremy. (This used to be commit a317f70c229f7730279eaa323f7ebfd499257f76)
Diffstat (limited to 'source3/nmbd/nmbd_serverlistdb.c')
-rw-r--r--source3/nmbd/nmbd_serverlistdb.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/source3/nmbd/nmbd_serverlistdb.c b/source3/nmbd/nmbd_serverlistdb.c
index 5ac4888365..349c3f4df3 100644
--- a/source3/nmbd/nmbd_serverlistdb.c
+++ b/source3/nmbd/nmbd_serverlistdb.c
@@ -289,17 +289,19 @@ void write_browse_list_entry(XFILE *fp, const char *name, uint32 rec_type,
}
void write_browse_list(time_t t, bool force_write)
-{
+{
struct subnet_record *subrec;
struct work_record *work;
struct server_record *servrec;
- pstring fname,fnamenew;
+ char *fname;
+ char *fnamenew;
uint32 stype;
int i;
XFILE *fp;
bool list_changed = force_write;
static time_t lasttime = 0;
-
+ TALLOC_CTX *ctx = talloc_tos();
+
/* Always dump if we're being told to by a signal. */
if(force_write == False) {
if (!lasttime)
@@ -311,7 +313,7 @@ void write_browse_list(time_t t, bool force_write)
lasttime = t;
dump_workgroups(force_write);
-
+
for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) {
if(subrec->work_changed) {
list_changed = True;
@@ -323,22 +325,32 @@ void write_browse_list(time_t t, bool force_write)
return;
updatecount++;
-
- pstrcpy(fname,lp_lockdir());
+
+ fname = talloc_strdup(ctx, lp_lockdir());
+ if (!fname) {
+ return;
+ }
trim_char(fname,'\0' ,'/');
- pstrcat(fname,"/");
- pstrcat(fname,SERVER_LIST);
- pstrcpy(fnamenew,fname);
- pstrcat(fnamenew,".");
-
+ fname = talloc_asprintf_append(fname,
+ "/%s",
+ SERVER_LIST);
+ if (!fname) {
+ return;
+ }
+ fnamenew = talloc_asprintf(ctx, "%s.",
+ fname);
+ if (!fnamenew) {
+ return;
+ }
+
fp = x_fopen(fnamenew,O_WRONLY|O_CREAT|O_TRUNC, 0644);
-
+
if (!fp) {
DEBUG(0,("write_browse_list: Can't open file %s. Error was %s\n",
fnamenew,strerror(errno)));
return;
- }
-
+ }
+
/*
* Write out a record for our workgroup. Use the record from the first
* subnet.
@@ -355,7 +367,7 @@ void write_browse_list(time_t t, bool force_write)
SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT|SV_TYPE_LOCAL_LIST_ONLY,
work->local_master_browser_name, work->work_group);
- /*
+ /*
* We need to do something special for our own names.
* This is due to the fact that we may be a local master browser on
* one of our broadcast subnets, and a domain master on the unicast
@@ -378,7 +390,7 @@ void write_browse_list(time_t t, bool force_write)
write_browse_list_entry(fp, my_netbios_names(i), stype,
string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_workgroup());
}
-
+
for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) {
subrec->work_changed = False;
@@ -399,7 +411,7 @@ void write_browse_list(time_t t, bool force_write)
/* We have already written our names here. */
if(is_myname(servrec->serv.name))
- continue;
+ continue;
serv_type = write_this_server_name(subrec, work, servrec);
if(serv_type) {
@@ -409,8 +421,8 @@ void write_browse_list(time_t t, bool force_write)
}
}
}
- }
-
+ }
+
x_fclose(fp);
unlink(fname);
chmod(fnamenew,0644);