From 773636c1c837945ad5855d86ed83ec0fa5ab8027 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 11 Mar 1996 01:16:09 +0000 Subject: [PATCH] added support for shost if FQDN --- sudo.c | 15 +++++++++++++-- sudo.h | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sudo.c b/sudo.c index 267b5dc79..2516f2c72 100644 --- a/sudo.c +++ b/sudo.c @@ -140,6 +140,9 @@ char *cmnd = NULL; char *tty = NULL; char *prompt = PASSPROMPT; char host[MAXHOSTNAMELEN + 1]; +#ifdef FQDN +char shost[MAXHOSTNAMELEN + 1]; +#endif /*FQDN */ char cwd[MAXPATHLEN + 1]; struct stat cmnd_st; extern struct interface *interfaces; @@ -454,10 +457,18 @@ static void load_globals(sudo_mode) inform_user(GLOBAL_NO_HOSTNAME); #ifdef FQDN } else { - if ((h_ent = gethostbyname(host)) == NULL) + if ((h_ent = gethostbyname(host)) == NULL) { log_error(GLOBAL_HOST_UNREGISTERED); - else + } else { strcpy(host, h_ent -> h_name); + if ((p = strchr(host, '.'))) { + *p = '\0'; + strcpy(shost, host); + *p = '.'; + } else { + strcpy(shost, host); + } + } } #else } diff --git a/sudo.h b/sudo.h index 949393d57..d96446860 100644 --- a/sudo.h +++ b/sudo.h @@ -186,6 +186,9 @@ void load_interfaces __P((void)); */ #ifndef MAIN extern char host[]; +#ifdef FQDN +extern char shost[]; +#endif /* FQDN */ extern char cwd[]; extern struct interface *interfaces; extern int num_interfaces; -- 2.40.0