1GETDOMAINNAME(2)           Linux Programmer's Manual          GETDOMAINNAME(2)
2
3
4

NAME

6       getdomainname, setdomainname - get/set NIS domain name
7

SYNOPSIS

9       #include <unistd.h>
10
11       int getdomainname(char *name, size_t len);
12       int setdomainname(const char *name, size_t len);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       getdomainname(), setdomainname():
17           Since glibc 2.21:
18               _DEFAULT_SOURCE
19           In glibc 2.19 and 2.20:
20               _DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
21           Up to and including glibc 2.19:
22               _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
23

DESCRIPTION

25       These  functions are used to access or to change the NIS domain name of
26       the host system.  More precisely, they operate on the NIS  domain  name
27       associated with the calling process's UTS namespace.
28
29       setdomainname()  sets the domain name to the value given in the charac‐
30       ter array name.  The len argument specifies  the  number  of  bytes  in
31       name.  (Thus, name does not require a terminating null byte.)
32
33       getdomainname()  returns the null-terminated domain name in the charac‐
34       ter array name, which has a length of len bytes.   If  the  null-termi‐
35       nated domain name requires more than len bytes, getdomainname() returns
36       the first len bytes (glibc) or gives an error (libc).
37

RETURN VALUE

39       On success, zero is returned.  On error, -1 is returned, and  errno  is
40       set to indicate the error.
41

ERRORS

43       setdomainname() can fail with the following errors:
44
45       EFAULT name pointed outside of user address space.
46
47       EINVAL len was negative or too large.
48
49       EPERM  The caller did not have the CAP_SYS_ADMIN capability in the user
50              namespace associated with its UTS namespace (see namespaces(7)).
51
52       getdomainname() can fail with the following errors:
53
54       EINVAL For getdomainname() under libc: name is NULL or name  is  longer
55              than len bytes.
56

CONFORMING TO

58       POSIX does not specify these calls.
59

NOTES

61       Since  Linux  1.0,  the limit on the length of a domain name, including
62       the terminating null byte, is 64 bytes.  In older  kernels,  it  was  8
63       bytes.
64
65       On  most  Linux  architectures  (including x86), there is no getdomain‐
66       name() system call; instead, glibc implements getdomainname() as a  li‐
67       brary  function  that  returns  a copy of the domainname field returned
68       from a call to uname(2).
69

SEE ALSO

71       gethostname(2), sethostname(2), uname(2), uts_namespaces(7)
72

COLOPHON

74       This page is part of release 5.13 of the Linux  man-pages  project.   A
75       description  of  the project, information about reporting bugs, and the
76       latest    version    of    this    page,    can     be     found     at
77       https://www.kernel.org/doc/man-pages/.
78
79
80
81Linux                             2021-03-22                  GETDOMAINNAME(2)
Impressum