1 /* $NetBSD: os.c,v 1.8 2014/12/10 04:37:52 christos Exp $ */
4 * Copyright (C) 2004-2011, 2013, 2014 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-2002 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: os.c,v 1.107 2011/03/02 00:02:54 marka Exp */
27 #include <sys/types.h> /* dev_t FreeBSD 2.1 */
33 #include <grp.h> /* Required for initgroups() on IRIX. */
44 #include <isc/buffer.h>
46 #include <isc/print.h>
47 #include <isc/resource.h>
48 #include <isc/result.h>
49 #include <isc/strerror.h>
50 #include <isc/string.h>
52 #include <named/main.h>
55 #include <named/ns_smf_globals.h>
58 static char *pidfile
= NULL
;
59 static int devnullfd
= -1;
62 #define ISC_FACILITY LOG_DAEMON
66 * If there's no <linux/capability.h>, we don't care about <sys/prctl.h>
68 #ifndef HAVE_LINUX_CAPABILITY_H
69 #undef HAVE_SYS_PRCTL_H
74 * (T) HAVE_LINUXTHREADS
75 * (C) HAVE_SYS_CAPABILITY_H (or HAVE_LINUX_CAPABILITY_H)
76 * (P) HAVE_SYS_PRCTL_H
77 * The possible cases are:
78 * none: setuid() normally
80 * C: setuid() normally, drop caps (keep CAP_SETUID)
81 * T+C: no setuid(), drop caps (don't keep CAP_SETUID)
82 * T+C+P: setuid() early, drop caps (keep CAP_SETUID)
83 * C+P: setuid() normally, drop caps (keep CAP_SETUID)
88 * caps = BIND_SERVICE + CHROOT + SETGID
89 * if ((T && C && P) || !T)
94 * if (T && C && P && -u)
101 * if (C && (P || !-u))
102 * caps = BIND_SERVICE
106 * It will be nice when Linux threads work properly with setuid().
109 #ifdef HAVE_LINUXTHREADS
110 static pid_t mainpid
= 0;
113 static struct passwd
*runas_pw
= NULL
;
114 static isc_boolean_t done_setuid
= ISC_FALSE
;
115 static int dfd
[2] = { -1, -1 };
117 #ifdef HAVE_LINUX_CAPABILITY_H
119 static isc_boolean_t non_root
= ISC_FALSE
;
120 static isc_boolean_t non_root_caps
= ISC_FALSE
;
122 #ifdef HAVE_SYS_CAPABILITY_H
123 #include <sys/capability.h>
125 #ifdef HAVE_LINUX_TYPES_H
126 #include <linux/types.h>
129 * We define _LINUX_FS_H to prevent it from being included. We don't need
130 * anything from it, and the files it includes cause warnings with 2.2
131 * kernels, and compilation failures (due to conflicts between <linux/string.h>
132 * and <string.h>) on 2.3 kernels.
135 #include <linux/capability.h>
139 #include <asm/unistd.h> /* Slackware 4.0 needs this. */
140 #endif /* __NR_capset */
141 #define SYS_capset __NR_capset
142 #endif /* SYS_capset */
143 #endif /* HAVE_SYS_CAPABILITY_H */
145 #ifdef HAVE_SYS_PRCTL_H
146 #include <sys/prctl.h> /* Required for prctl(). */
149 * If the value of PR_SET_KEEPCAPS is not in <sys/prctl.h>, define it
150 * here. This allows setuid() to work on systems running a new enough
151 * kernel but with /usr/include/linux pointing to "standard" kernel
154 #ifndef PR_SET_KEEPCAPS
155 #define PR_SET_KEEPCAPS 8
158 #endif /* HAVE_SYS_PRCTL_H */
161 #define SETCAPS_FUNC "cap_set_proc "
163 typedef unsigned int cap_t
;
164 #define SETCAPS_FUNC "syscall(capset) "
165 #endif /* HAVE_LIBCAP */
168 linux_setcaps(cap_t caps
) {
170 struct __user_cap_header_struct caphead
;
171 struct __user_cap_data_struct cap
;
173 char strbuf
[ISC_STRERRORSIZE
];
175 if ((getuid() != 0 && !non_root_caps
) || non_root
)
178 memset(&caphead
, 0, sizeof(caphead
));
179 caphead
.version
= _LINUX_CAPABILITY_VERSION
;
181 memset(&cap
, 0, sizeof(cap
));
182 cap
.effective
= caps
;
183 cap
.permitted
= caps
;
187 if (cap_set_proc(caps
) < 0) {
189 if (syscall(SYS_capset
, &caphead
, &cap
) < 0) {
191 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
192 ns_main_earlyfatal(SETCAPS_FUNC
"failed: %s:"
193 " please ensure that the capset kernel"
194 " module is loaded. see insmod(8)",
200 #define SET_CAP(flag) \
202 cap_flag_value_t curval; \
204 err = cap_get_flag(curcaps, capval, CAP_PERMITTED, &curval); \
205 if (err != -1 && curval) { \
206 err = cap_set_flag(caps, CAP_EFFECTIVE, 1, &capval, CAP_SET); \
208 isc__strerror(errno, strbuf, sizeof(strbuf)); \
209 ns_main_earlyfatal("cap_set_proc failed: %s", strbuf); \
212 err = cap_set_flag(caps, CAP_PERMITTED, 1, &capval, CAP_SET); \
214 isc__strerror(errno, strbuf, sizeof(strbuf)); \
215 ns_main_earlyfatal("cap_set_proc failed: %s", strbuf); \
218 } while (/*CONSTCOND*/0)
222 if (caps == NULL) { \
223 isc__strerror(errno, strbuf, sizeof(strbuf)); \
224 ns_main_earlyfatal("cap_init failed: %s", strbuf); \
226 curcaps = cap_get_proc(); \
227 if (curcaps == NULL) { \
228 isc__strerror(errno, strbuf, sizeof(strbuf)); \
229 ns_main_earlyfatal("cap_get_proc failed: %s", strbuf); \
231 } while (/*CONSTCOND*/0)
236 } while (/*CONSTCOND*/0)
238 #define SET_CAP(flag) do { caps |= (1 << (flag)); } while (/*CONSTCOND*/0)
239 #define INIT_CAP do { caps = 0; } while (/*CONSTCOND*/0)
240 #endif /* HAVE_LIBCAP */
243 linux_initialprivs(void) {
248 char strbuf
[ISC_STRERRORSIZE
];
253 * We don't need most privileges, so we drop them right away.
254 * Later on linux_minprivs() will be called, which will drop our
255 * capabilities to the minimum needed to run the server.
260 * We need to be able to bind() to privileged ports, notably port 53!
262 SET_CAP(CAP_NET_BIND_SERVICE
);
265 * We need chroot() initially too.
267 SET_CAP(CAP_SYS_CHROOT
);
269 #if defined(HAVE_SYS_PRCTL_H) || !defined(HAVE_LINUXTHREADS)
271 * We can setuid() only if either the kernel supports keeping
272 * capabilities after setuid() (which we don't know until we've
273 * tried) or we're not using threads. If either of these is
274 * true, we want the setuid capability.
280 * Since we call initgroups, we need this.
285 * Without this, we run into problems reading a configuration file
286 * owned by a non-root user and non-world-readable on startup.
288 SET_CAP(CAP_DAC_READ_SEARCH
);
291 * XXX We might want to add CAP_SYS_RESOURCE, though it's not
292 * clear it would work right given the way linuxthreads work.
293 * XXXDCL But since we need to be able to set the maximum number
294 * of files, the stack size, data size, and core dump size to
295 * support named.conf options, this is now being added to test.
297 SET_CAP(CAP_SYS_RESOURCE
);
300 * We need to be able to set the ownership of the containing
301 * directory of the pid file when we create it.
313 linux_minprivs(void) {
318 char strbuf
[ISC_STRERRORSIZE
];
324 * Drop all privileges except the ability to bind() to privileged
327 * It's important that we drop CAP_SYS_CHROOT. If we didn't, it
328 * chroot() could be used to escape from the chrooted area.
331 SET_CAP(CAP_NET_BIND_SERVICE
);
334 * XXX We might want to add CAP_SYS_RESOURCE, though it's not
335 * clear it would work right given the way linuxthreads work.
336 * XXXDCL But since we need to be able to set the maximum number
337 * of files, the stack size, data size, and core dump size to
338 * support named.conf options, this is now being added to test.
340 SET_CAP(CAP_SYS_RESOURCE
);
349 #ifdef HAVE_SYS_PRCTL_H
351 linux_keepcaps(void) {
352 char strbuf
[ISC_STRERRORSIZE
];
354 * Ask the kernel to allow us to keep our capabilities after we
358 if (prctl(PR_SET_KEEPCAPS
, 1, 0, 0, 0) < 0) {
359 if (errno
!= EINVAL
) {
360 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
361 ns_main_earlyfatal("prctl() failed: %s", strbuf
);
364 non_root_caps
= ISC_TRUE
;
371 #endif /* HAVE_LINUX_CAPABILITY_H */
375 setup_syslog(const char *progname
) {
380 options
|= LOG_NDELAY
;
382 openlog(isc_file_basename(progname
), options
, ISC_FACILITY
);
386 ns_os_init(const char *progname
) {
387 setup_syslog(progname
);
388 #ifdef HAVE_LINUX_CAPABILITY_H
389 linux_initialprivs();
391 #ifdef HAVE_LINUXTHREADS
395 signal(SIGXFSZ
, SIG_IGN
);
400 ns_os_daemonize(void) {
402 char strbuf
[ISC_STRERRORSIZE
];
404 if (pipe(dfd
) == -1) {
405 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
406 ns_main_earlyfatal("pipe(): %s", strbuf
);
411 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
412 ns_main_earlyfatal("fork(): %s", strbuf
);
417 * Wait for the child to finish loading for the first time.
418 * This would be so much simpler if fork() worked once we
419 * were multi-threaded.
424 n
= read(dfd
[0], &buf
, 1);
427 } while (n
== -1 && errno
== EINTR
);
436 #ifdef HAVE_LINUXTHREADS
440 if (setsid() == -1) {
441 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
442 ns_main_earlyfatal("setsid(): %s", strbuf
);
446 * Try to set stdin, stdout, and stderr to /dev/null, but press
447 * on even if it fails.
449 * XXXMLG The close() calls here are unneeded on all but NetBSD, but
450 * are harmless to include everywhere. dup2() is supposed to close
451 * the FD if it is in use, but unproven-pthreads-0.16 is broken
452 * and will end up closing the wrong FD. This will be fixed eventually,
453 * and these calls will be removed.
455 if (devnullfd
!= -1) {
456 if (devnullfd
!= STDIN_FILENO
) {
457 (void)close(STDIN_FILENO
);
458 (void)dup2(devnullfd
, STDIN_FILENO
);
460 if (devnullfd
!= STDOUT_FILENO
) {
461 (void)close(STDOUT_FILENO
);
462 (void)dup2(devnullfd
, STDOUT_FILENO
);
464 if (devnullfd
!= STDERR_FILENO
) {
465 (void)close(STDERR_FILENO
);
466 (void)dup2(devnullfd
, STDERR_FILENO
);
472 ns_os_started(void) {
476 * Signal to the parent that we started successfully.
478 if (dfd
[0] != -1 && dfd
[1] != -1) {
479 if (write(dfd
[1], &buf
, 1) != 1)
480 ns_main_earlyfatal("unable to signal parent that we "
481 "otherwise started successfully.");
483 dfd
[0] = dfd
[1] = -1;
488 ns_os_opendevnull(void) {
489 devnullfd
= open("/dev/null", O_RDWR
, 0);
493 ns_os_closedevnull(void) {
494 if (devnullfd
!= STDIN_FILENO
&&
495 devnullfd
!= STDOUT_FILENO
&&
496 devnullfd
!= STDERR_FILENO
) {
503 all_digits(const char *s
) {
507 if (!isdigit((*s
)&0xff))
515 ns_os_chroot(const char *root
) {
516 char strbuf
[ISC_STRERRORSIZE
];
522 if (chroot(root
) < 0) {
523 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
524 ns_main_earlyfatal("chroot(): %s", strbuf
);
527 ns_main_earlyfatal("chroot(): disabled");
529 if (chdir("/") < 0) {
530 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
531 ns_main_earlyfatal("chdir(/): %s", strbuf
);
534 /* Set ns_smf_chroot flag on successful chroot. */
541 ns_os_inituserinfo(const char *username
) {
542 char strbuf
[ISC_STRERRORSIZE
];
543 if (username
== NULL
)
546 if (all_digits(username
))
547 runas_pw
= getpwuid((uid_t
)atoi(username
));
549 runas_pw
= getpwnam(username
);
552 if (runas_pw
== NULL
)
553 ns_main_earlyfatal("user '%s' unknown", username
);
556 if (initgroups(runas_pw
->pw_name
, runas_pw
->pw_gid
) < 0) {
557 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
558 ns_main_earlyfatal("initgroups(): %s", strbuf
);
565 ns_os_changeuser(void) {
566 char strbuf
[ISC_STRERRORSIZE
];
567 if (runas_pw
== NULL
|| done_setuid
)
570 done_setuid
= ISC_TRUE
;
572 #ifdef HAVE_LINUXTHREADS
573 #ifdef HAVE_LINUX_CAPABILITY_H
575 ns_main_earlyfatal("-u with Linux threads not supported: "
576 "requires kernel support for "
577 "prctl(PR_SET_KEEPCAPS)");
579 ns_main_earlyfatal("-u with Linux threads not supported: "
580 "no capabilities support or capabilities "
581 "disabled at build time");
585 if (setgid(runas_pw
->pw_gid
) < 0) {
586 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
587 ns_main_earlyfatal("setgid(): %s", strbuf
);
590 if (setuid(runas_pw
->pw_uid
) < 0) {
591 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
592 ns_main_earlyfatal("setuid(): %s", strbuf
);
595 #if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_DUMPABLE)
597 * Restore the ability of named to drop core after the setuid()
598 * call has disabled it.
600 if (prctl(PR_SET_DUMPABLE
,1,0,0,0) < 0) {
601 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
602 ns_main_earlywarning("prctl(PR_SET_DUMPABLE) failed: %s",
606 #if defined(HAVE_LINUX_CAPABILITY_H) && !defined(HAVE_LINUXTHREADS)
612 ns_os_adjustnofile(void) {
613 #ifdef HAVE_LINUXTHREADS
615 isc_resourcevalue_t newvalue
;
618 * Linux: max number of open files specified by one thread doesn't seem
619 * to apply to other threads on Linux.
621 newvalue
= ISC_RESOURCE_UNLIMITED
;
623 result
= isc_resource_setlimit(isc_resource_openfiles
, newvalue
);
624 if (result
!= ISC_R_SUCCESS
)
625 ns_main_earlywarning("couldn't adjust limit on open files");
630 ns_os_minprivs(void) {
631 #ifdef HAVE_SYS_PRCTL_H
635 #ifdef HAVE_LINUXTHREADS
636 ns_os_changeuser(); /* Call setuid() before threads are started */
639 #if defined(HAVE_LINUX_CAPABILITY_H) && defined(HAVE_LINUXTHREADS)
645 safe_open(const char *filename
, mode_t mode
, isc_boolean_t append
) {
649 if (stat(filename
, &sb
) == -1) {
652 } else if ((sb
.st_mode
& S_IFREG
) == 0) {
658 fd
= open(filename
, O_WRONLY
|O_CREAT
|O_APPEND
, mode
);
660 if (unlink(filename
) < 0 && errno
!= ENOENT
)
662 fd
= open(filename
, O_WRONLY
|O_CREAT
|O_EXCL
, mode
);
668 cleanup_pidfile(void) {
670 if (pidfile
!= NULL
) {
672 if (n
== -1 && errno
!= ENOENT
)
673 ns_main_earlywarning("unlink '%s': failed", pidfile
);
680 mkdirpath(char *filename
, void (*report
)(const char *, ...)) {
681 char *slash
= strrchr(filename
, '/');
682 char strbuf
[ISC_STRERRORSIZE
];
685 if (slash
!= NULL
&& slash
!= filename
) {
689 if (stat(filename
, &sb
) == -1) {
690 if (errno
!= ENOENT
) {
691 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
692 (*report
)("couldn't stat '%s': %s", filename
,
696 if (mkdirpath(filename
, report
) == -1)
699 * Handle "//", "/./" and "/../" in path.
701 if (!strcmp(slash
+ 1, "") ||
702 !strcmp(slash
+ 1, ".") ||
703 !strcmp(slash
+ 1, "..")) {
707 mode
= S_IRUSR
| S_IWUSR
| S_IXUSR
; /* u=rwx */
708 mode
|= S_IRGRP
| S_IXGRP
; /* g=rx */
709 mode
|= S_IROTH
| S_IXOTH
; /* o=rx */
710 if (mkdir(filename
, mode
) == -1) {
711 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
712 (*report
)("couldn't mkdir '%s': %s", filename
,
716 if (runas_pw
!= NULL
&&
717 chown(filename
, runas_pw
->pw_uid
,
718 runas_pw
->pw_gid
) == -1) {
719 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
720 (*report
)("couldn't chown '%s': %s", filename
,
734 setperms(uid_t uid
, gid_t gid
) {
735 char strbuf
[ISC_STRERRORSIZE
];
736 #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID)
739 #if !defined(HAVE_SETEUID) && defined(HAVE_SETRESUID)
742 #if defined(HAVE_SETEGID)
743 if (getegid() != gid
&& setegid(gid
) == -1) {
744 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
745 ns_main_earlywarning("unable to set effective gid to %ld: %s",
748 #elif defined(HAVE_SETRESGID)
749 if (getresgid(&tmpg
, &oldgid
, &tmpg
) == -1 || oldgid
!= gid
) {
750 if (setresgid(-1, gid
, -1) == -1) {
751 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
752 ns_main_earlywarning("unable to set effective "
753 "gid to %d: %s", gid
, strbuf
);
758 #if defined(HAVE_SETEUID)
759 if (geteuid() != uid
&& seteuid(uid
) == -1) {
760 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
761 ns_main_earlywarning("unable to set effective uid to %ld: %s",
764 #elif defined(HAVE_SETRESUID)
765 if (getresuid(&tmpu
, &olduid
, &tmpu
) == -1 || olduid
!= uid
) {
766 if (setresuid(-1, uid
, -1) == -1) {
767 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
768 ns_main_earlywarning("unable to set effective "
769 "uid to %d: %s", uid
, strbuf
);
776 ns_os_openfile(const char *filename
, mode_t mode
, isc_boolean_t switch_user
) {
777 char strbuf
[ISC_STRERRORSIZE
], *f
;
782 * Make the containing directory if it doesn't exist.
784 f
= strdup(filename
);
786 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
787 ns_main_earlywarning("couldn't strdup() '%s': %s",
791 if (mkdirpath(f
, ns_main_earlywarning
) == -1) {
797 if (switch_user
&& runas_pw
!= NULL
) {
798 #ifndef HAVE_LINUXTHREADS
799 gid_t oldgid
= getgid();
801 /* Set UID/GID to the one we'll be running with eventually */
802 setperms(runas_pw
->pw_uid
, runas_pw
->pw_gid
);
804 fd
= safe_open(filename
, mode
, ISC_FALSE
);
806 #ifndef HAVE_LINUXTHREADS
807 /* Restore UID/GID to root */
809 #endif /* HAVE_LINUXTHREADS */
812 #ifndef HAVE_LINUXTHREADS
813 fd
= safe_open(filename
, mode
, ISC_FALSE
);
815 ns_main_earlywarning("Required root "
816 "permissions to open "
819 ns_main_earlywarning("Could not open "
822 ns_main_earlywarning("Please check file and "
823 "directory permissions "
824 "or reconfigure the filename.");
825 #else /* HAVE_LINUXTHREADS */
826 ns_main_earlywarning("Could not open "
828 ns_main_earlywarning("Please check file and "
829 "directory permissions "
830 "or reconfigure the filename.");
831 #endif /* HAVE_LINUXTHREADS */
834 fd
= safe_open(filename
, mode
, ISC_FALSE
);
838 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
839 ns_main_earlywarning("could not open file '%s': %s",
844 fp
= fdopen(fd
, "w");
846 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
847 ns_main_earlywarning("could not fdopen() file '%s': %s",
855 ns_os_writepidfile(const char *filename
, isc_boolean_t first_time
) {
858 char strbuf
[ISC_STRERRORSIZE
];
859 void (*report
)(const char *, ...);
862 * The caller must ensure any required synchronization.
865 report
= first_time
? ns_main_earlyfatal
: ns_main_earlywarning
;
869 if (filename
== NULL
)
872 pidfile
= strdup(filename
);
873 if (pidfile
== NULL
) {
874 isc__strerror(errno
, strbuf
, sizeof(strbuf
));
875 (*report
)("couldn't strdup() '%s': %s", filename
, strbuf
);
879 lockfile
= ns_os_openfile(filename
, S_IRUSR
|S_IWUSR
|S_IRGRP
|S_IROTH
,
881 if (lockfile
== NULL
) {
885 #ifdef HAVE_LINUXTHREADS
890 if (fprintf(lockfile
, "%ld\n", (long)pid
) < 0) {
891 (*report
)("fprintf() to pid file '%s' failed", filename
);
892 (void)fclose(lockfile
);
896 if (fflush(lockfile
) == EOF
) {
897 (*report
)("fflush() to pid file '%s' failed", filename
);
898 (void)fclose(lockfile
);
902 (void)fclose(lockfile
);
906 ns_os_shutdown(void) {
912 ns_os_gethostname(char *buf
, size_t len
) {
915 n
= gethostname(buf
, len
);
916 return ((n
== 0) ? ISC_R_SUCCESS
: ISC_R_FAILURE
);
920 next_token(char **stringp
, const char *delim
) {
924 res
= strsep(stringp
, delim
);
927 } while (*res
== '\0');
932 ns_os_shutdownmsg(char *command
, isc_buffer_t
*text
) {
939 /* Skip the command name. */
940 ptr
= next_token(&input
, " \t");
944 ptr
= next_token(&input
, " \t");
948 if (strcmp(ptr
, "-p") != 0)
951 #ifdef HAVE_LINUXTHREADS
957 n
= snprintf((char *)isc_buffer_used(text
),
958 isc_buffer_availablelength(text
),
959 "pid: %ld", (long)pid
);
960 /* Only send a message if it is complete. */
961 if (n
> 0 && n
< isc_buffer_availablelength(text
))
962 isc_buffer_add(text
, n
);