1
1
/* status.c - Allow control of a running server using a socket
3
3
Copyright (C) 2000, 2001 Thomas Moestl
4
Copyright (C) 2002, 2003, 2004, 2005 Paul A. Rombouts
6
This file is part of the pdnsd package.
8
pdnsd is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2, or (at your option)
13
pdnsd is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with pdsnd; see the file COPYING. If not, write to
20
the Free Software Foundation, 59 Temple Place - Suite 330,
21
Boston, MA 02111-1307, USA. */
4
Copyright (C) 2002, 2003, 2004, 2005, 2007 Paul A. Rombouts
6
This file is part of the pdnsd package.
8
pdnsd is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 3 of the License, or
11
(at your option) any later version.
13
pdnsd is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with pdnsd; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
23
23
#include <config.h>
131
131
if(!read_short(fh,&count)) return 0;
132
132
if(count==(uint16_t)(~0)) {*res=NULL; return -1;}
133
133
if(!(buf=malloc(count+1))) return 0;
135
135
while(nread<count) {
136
int m=read(fh,buf+nread,count-nread);
136
ssize_t m=read(fh,buf+nread,count-nread);
137
137
if(m<=0) {free(buf); return 0;}
152
152
static int read_domain(int fh, char *buf, int buflen)
157
157
/* PDNSD_ASSERT(buflen>0, "bad read_domain call"); */
158
158
if(!read_short(fh,&count)) return 0;
160
160
if(count >=buflen) return 0;
162
162
while(nread<count) {
163
int m=read(fh,buf+nread,count-nread);
163
ssize_t m=read(fh,buf+nread,count-nread);
164
164
if(m<=0) return 0;
168
/* if(count==0 || buf[count-1]!='.') {
169
if(count==0 || buf[count-1]!='.') {
169
170
if(count+1>=buflen) return 0;
170
171
buf[count]='.'; buf[count+1]=0;
414
uint16_t tp,flags,nadr=0;
413
415
unsigned char name[256],buf[256],dbuf[260];
417
unsigned char *adrbuf=NULL;
415
419
DEBUG_MSG("Received ADD command.\n");
416
420
if (!read_short(rs,&tp))
431
if (read(rs,dbuf,sizeof(struct in_addr))!=sizeof(struct in_addr))
433
435
sz=sizeof(struct in_addr);
437
goto read_adress_list;
437
if (read(rs,dbuf,sizeof(struct in6_addr))!=sizeof(struct in6_addr))
439
439
sz=sizeof(struct in6_addr);
442
if (!read_short(rs,&nadr))
443
goto incomplete_command;
446
adrbufsz= nadr * (size_t)sz;
447
adrbuf= malloc(adrbufsz);
452
while(nread<adrbufsz) {
453
ssize_t m=read(rs,adrbuf+nread,adrbufsz-nread);
454
if(m<=0) {free(adrbuf); goto bad_arg;}
444
461
if (read_domain(rs, charp buf, sizeof(buf))<=0)
465
if (!init_cent(¢, name, 0, 0, flags DBG1))
482
if (!init_cent(¢, name, 0, 0, flags DBG1)) {
466
484
goto out_of_memory;
467
if (!add_cent_rr(¢,tp,ttl,0,CF_LOCAL,sz,dbuf DBG1)) {
487
unsigned char *adrp; int i;
488
for(adrp=adrbuf,i=0; i<nadr; adrp += sz,++i) {
489
if (!add_cent_rr(¢,tp,ttl,0,CF_LOCAL,sz,adrp DBG1)) {
490
free_cent(¢ DBG1);
497
else if (!add_cent_rr(¢,tp,ttl,0,CF_LOCAL,sz,dbuf DBG1)) {
468
498
free_cent(¢ DBG1);
469
499
goto out_of_memory;