summaryrefslogtreecommitdiffstats
path: root/login-utils/login.c
diff options
context:
space:
mode:
authorKarel Zak2012-10-19 16:27:29 +0200
committerKarel Zak2012-10-19 16:27:29 +0200
commitf0196a13af2d58cd4f48ba0817c568ace4795cdc (patch)
tree3187a4757944265f96f46555cb73f944fb61a0b0 /login-utils/login.c
parentinclude/xalloc: add xgethostname() (diff)
downloadkernel-qcow2-util-linux-f0196a13af2d58cd4f48ba0817c568ace4795cdc.tar.gz
kernel-qcow2-util-linux-f0196a13af2d58cd4f48ba0817c568ace4795cdc.tar.xz
kernel-qcow2-util-linux-f0196a13af2d58cd4f48ba0817c568ace4795cdc.zip
login: stop using MAXHOSTNAMELEN
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/login.c')
-rw-r--r--login-utils/login.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/login-utils/login.c b/login-utils/login.c
index 8ae5266f1..f37718753 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -109,7 +109,7 @@ struct login_context {
char vcsan[VCS_PATH_MAX];
#endif
- char thishost[MAXHOSTNAMELEN + 1]; /* this machine */
+ char *thishost; /* this machine */
char *thisdomain; /* this machine domain */
char *hostname; /* remote machine */
char hostaddress[16]; /* remote address */
@@ -209,13 +209,13 @@ static void __attribute__ ((__noreturn__)) sleepexit(int eval)
static const char *get_thishost(struct login_context *cxt, const char **domain)
{
- if (!*cxt->thishost) {
- if (gethostname(cxt->thishost, sizeof(cxt->thishost))) {
+ if (!cxt->thishost) {
+ cxt->thishost = xgethostname();
+ if (!cxt->thishost) {
if (domain)
*domain = NULL;
return NULL;
}
- cxt->thishost[sizeof(cxt->thishost) -1] = '\0';
cxt->thisdomain = strchr(cxt->thishost, '.');
if (cxt->thisdomain)
*cxt->thisdomain++ = '\0';