GETDOMAINNAME(3)
π GETDOMAINNAME(3) β bestie's guide to the host's NIS domain name β¨
Okay so this one's from the Standard C Library (libc, -lc) and it's literally about getting and setting the NIS domain name of the current host. Two functions, one mission. Let's get into it π
β¨ SYNOPSIS β¨
#include <unistd.h>
int
getdomainname(char *name, int namelen);
int
setdomainname(const char *name, int namelen);
π¦ DESCRIPTION π¦
So getdomainname() is the one that reads β it hands you back the standard NIS domain name for the current host, exactly as it was previously set by setdomainname(). You pass in namelen to tell it how big your name array is, okay? And the returned name is null-terminated unless you didn't give it enough room. No cap π
Then there's setdomainname(), the one that writes β it sets the NIS domain name of the host machine to be name, which has length namelen.
β οΈ Real talk: this call is restricted to the super-user, and it's normally used only when the system is bootstrapped. So like, not your everyday vibe. π₯
π RETURN VALUES π
Slay on success β the value 0 comes back.
Otherwise you get -1, and the global variable errno gets set to tell you what went wrong. π
π©· ERRORS π©·
These are the errors these calls might throw at you, bestie:
[EFAULT]β thenameornamelenargument gave an invalid address. Rude of them ngl π[EPERM]β the caller tried to set the hostname and was not the super-user. Permission denied, main character behavior only π
β SEE ALSO β
Go read those too, iykyk π
πΈ HISTORY πΈ
The getdomainname() function appeared in 4.2BSD. Vintage icon behavior π°οΈπ
π BUGS π
Domain names are limited to MAXHOSTNAMELEN (from <sys/param.h>) characters, and currently that's 256. So don't be out here writing a novel as your domain name, okay? π
sign-off π«Ά β this page came from Debian, dated May 6, 1994, and honestly it's been serving ever since. Stay iconic, and go set a domain name (only if you're root) πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1983, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms