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