| 1 |
.\" Copyright 1993 Rickard E. Faith ([email protected]) |
| 2 |
.\" |
| 3 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 4 |
.\" |
| 5 |
.\" Modified 1997-08-25 by Nicolás Lichtmaier <[email protected]> |
| 6 |
.\" Modified 2004-06-17 by Michael Kerrisk <[email protected]> |
| 7 |
.\" Modified 2008-11-27 by mtk |
| 8 |
.\" |
| 9 |
.TH getdomainname 2 2024-05-02 "Linux man-pages 6.9.1" |
| 10 |
.SH NAME |
| 11 |
getdomainname, setdomainname \- get/set NIS domain name |
| 12 |
.SH LIBRARY |
| 13 |
Standard C library |
| 14 |
.RI ( libc ", " \-lc ) |
| 15 |
.SH SYNOPSIS |
| 16 |
.nf |
| 17 |
.B #include <unistd.h> |
| 18 |
.P |
| 19 |
.BI "int getdomainname(char *" name ", size_t " len ); |
| 20 |
.BI "int setdomainname(const char *" name ", size_t " len ); |
| 21 |
.fi |
| 22 |
.P |
| 23 |
.RS -4 |
| 24 |
Feature Test Macro Requirements for glibc (see |
| 25 |
.BR feature_test_macros (7)): |
| 26 |
.RE |
| 27 |
.P |
| 28 |
.BR getdomainname (), |
| 29 |
.BR setdomainname (): |
| 30 |
.nf |
| 31 |
Since glibc 2.21: |
| 32 |
.\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 |
| 33 |
_DEFAULT_SOURCE |
| 34 |
In glibc 2.19 and 2.20: |
| 35 |
_DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500) |
| 36 |
Up to and including glibc 2.19: |
| 37 |
_BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500) |
| 38 |
.fi |
| 39 |
.SH DESCRIPTION |
| 40 |
These functions are used to access or to change the NIS domain name of the |
| 41 |
host system. |
| 42 |
More precisely, they operate on the NIS domain name associated with the calling |
| 43 |
process's UTS namespace. |
| 44 |
.P |
| 45 |
.BR setdomainname () |
| 46 |
sets the domain name to the value given in the character array |
| 47 |
.IR name . |
| 48 |
The |
| 49 |
.I len |
| 50 |
argument specifies the number of bytes in |
| 51 |
.IR name . |
| 52 |
(Thus, |
| 53 |
.I name |
| 54 |
does not require a terminating null byte.) |
| 55 |
.P |
| 56 |
.BR getdomainname () |
| 57 |
returns the null-terminated domain name in the character array |
| 58 |
.IR name , |
| 59 |
which has a length of |
| 60 |
.I len |
| 61 |
bytes. |
| 62 |
If the null-terminated domain name requires more than \fIlen\fP bytes, |
| 63 |
.BR getdomainname () |
| 64 |
returns the first \fIlen\fP bytes (glibc) or gives an error (libc). |
| 65 |
.SH RETURN VALUE |
| 66 |
On success, zero is returned. |
| 67 |
On error, \-1 is returned, and |
| 68 |
.I errno |
| 69 |
is set to indicate the error. |
| 70 |
.SH ERRORS |
| 71 |
.BR setdomainname () |
| 72 |
can fail with the following errors: |
| 73 |
.TP |
| 74 |
.B EFAULT |
| 75 |
.I name |
| 76 |
pointed outside of user address space. |
| 77 |
.TP |
| 78 |
.B EINVAL |
| 79 |
.I len |
| 80 |
was negative or too large. |
| 81 |
.TP |
| 82 |
.B EPERM |
| 83 |
The caller did not have the |
| 84 |
.B CAP_SYS_ADMIN |
| 85 |
capability in the user namespace associated with its UTS namespace (see |
| 86 |
.BR namespaces (7)). |
| 87 |
.P |
| 88 |
.BR getdomainname () |
| 89 |
can fail with the following errors: |
| 90 |
.TP |
| 91 |
.B EINVAL |
| 92 |
For |
| 93 |
.BR getdomainname () |
| 94 |
under libc: |
| 95 |
.I name |
| 96 |
is NULL or |
| 97 |
.I name |
| 98 |
is longer than |
| 99 |
.I len |
| 100 |
bytes. |
| 101 |
.SH VERSIONS |
| 102 |
On most Linux architectures (including x86), |
| 103 |
there is no |
| 104 |
.BR getdomainname () |
| 105 |
system call; instead, glibc implements |
| 106 |
.BR getdomainname () |
| 107 |
as a library function that returns a copy of the |
| 108 |
.I domainname |
| 109 |
field returned from a call to |
| 110 |
.BR uname (2). |
| 111 |
.SH STANDARDS |
| 112 |
None. |
| 113 |
.\" But they appear on most systems... |
| 114 |
.SH HISTORY |
| 115 |
Since Linux 1.0, the limit on the length of a domain name, |
| 116 |
including the terminating null byte, is 64 bytes. |
| 117 |
In older kernels, it was 8 bytes. |
| 118 |
.SH SEE ALSO |
| 119 |
.BR gethostname (2), |
| 120 |
.BR sethostname (2), |
| 121 |
.BR uname (2), |
| 122 |
.BR uts_namespaces (7) |