xref: /openbsd-src/lib/libc/gen/getdomainname.3 (revision bfcef0862b80be7e33f3b259f0aa768556063cf3)
1.\"	$OpenBSD: getdomainname.3,v 1.29 2022/07/26 14:53:29 deraadt Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd $Mdocdate: July 26 2022 $
31.Dt GETDOMAINNAME 3
32.Os
33.Sh NAME
34.Nm getdomainname ,
35.Nm setdomainname
36.Nd get/set YP domain name of current host
37.Sh SYNOPSIS
38.In unistd.h
39.Ft int
40.Fn getdomainname "char *name" "size_t namelen"
41.Ft int
42.Fn setdomainname "const char *name" "size_t namelen"
43.Sh DESCRIPTION
44The
45.Fn getdomainname
46function returns the YP domain name for the current processor, as
47previously set by
48.Fn setdomainname .
49The parameter
50.Fa namelen
51specifies the size of the
52.Fa name
53array.
54If insufficient space is provided, the returned name is truncated.
55The returned name is always NUL terminated.
56.Pp
57.Fn setdomainname
58sets the domain name of the host machine to be
59.Fa name ,
60which has length
61.Fa namelen .
62This call is restricted to the superuser and
63is normally used only when the system is bootstrapped.
64Under normal operation once the domainname is set, it cannot be
65changed.
66.Sh RETURN VALUES
67If the call succeeds, a value of 0 is returned.
68If the call fails, a value of \-1 is returned and an error code is
69placed in the global variable
70.Va errno .
71.Sh ERRORS
72The following errors may be returned by these calls:
73.Bl -tag -width Er
74.It Bq Er EFAULT
75The
76.Fa name
77parameter gave an
78invalid address.
79.It Bq Er EPERM
80The caller tried to set the domain name and was not the superuser.
81.El
82.Sh SEE ALSO
83.Xr domainname 1 ,
84.Xr sysctl 2 ,
85.Xr gethostid 3 ,
86.Xr gethostname 3 ,
87.Xr sysctl 8 ,
88.Xr yp 8
89.Sh HISTORY
90The
91.Nm
92function call appeared in
93SunOS 3.x.
94.Sh BUGS
95Domain names are limited to
96.Dv MAXHOSTNAMELEN
97(from
98.In sys/param.h )
99characters, currently 256.
100This includes the terminating NUL character.
101.Pp
102If the buffer passed to
103.Fn getdomainname
104is too small, other operating systems may not guarantee termination with NUL.
105