1getdomainname(2) System Calls Manual getdomainname(2)
2
3
4
6 getdomainname, setdomainname - get/set NIS domain name
7
9 Standard C library (libc, -lc)
10
12 #include <unistd.h>
13
14 int getdomainname(char *name, size_t len);
15 int setdomainname(const char *name, size_t len);
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 getdomainname(), setdomainname():
20 Since glibc 2.21:
21 _DEFAULT_SOURCE
22 In glibc 2.19 and 2.20:
23 _DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
24 Up to and including glibc 2.19:
25 _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
26
28 These functions are used to access or to change the NIS domain name of
29 the host system. More precisely, they operate on the NIS domain name
30 associated with the calling process's UTS namespace.
31
32 setdomainname() sets the domain name to the value given in the charac‐
33 ter array name. The len argument specifies the number of bytes in
34 name. (Thus, name does not require a terminating null byte.)
35
36 getdomainname() returns the null-terminated domain name in the charac‐
37 ter array name, which has a length of len bytes. If the null-termi‐
38 nated domain name requires more than len bytes, getdomainname() returns
39 the first len bytes (glibc) or gives an error (libc).
40
42 On success, zero is returned. On error, -1 is returned, and errno is
43 set to indicate the error.
44
46 setdomainname() can fail with the following errors:
47
48 EFAULT name pointed outside of user address space.
49
50 EINVAL len was negative or too large.
51
52 EPERM The caller did not have the CAP_SYS_ADMIN capability in the user
53 namespace associated with its UTS namespace (see namespaces(7)).
54
55 getdomainname() can fail with the following errors:
56
57 EINVAL For getdomainname() under libc: name is NULL or name is longer
58 than len bytes.
59
61 On most Linux architectures (including x86), there is no getdomain‐
62 name() system call; instead, glibc implements getdomainname() as a li‐
63 brary function that returns a copy of the domainname field returned
64 from a call to uname(2).
65
67 None.
68
70 Since Linux 1.0, the limit on the length of a domain name, including
71 the terminating null byte, is 64 bytes. In older kernels, it was 8
72 bytes.
73
75 gethostname(2), sethostname(2), uname(2), uts_namespaces(7)
76
77
78
79Linux man-pages 6.05 2023-03-30 getdomainname(2)