now use the EXEC nmacro

now only do a gethostbyname() if FQDN is set
This commit is contained in:
Todd C. Miller
1994-05-29 22:36:44 +00:00
parent 7e8d543af2
commit a298a5dc48

23
sudo.c
View File

@@ -169,11 +169,7 @@ main(argc, argv)
check_user(); check_user();
log_error(ALL_SYSTEMS_GO); log_error(ALL_SYSTEMS_GO);
be_root(); be_root();
#ifdef USE_EXECV EXEC(cmnd, &Argv[1]);
execv(cmnd, (const char **) &Argv[1]);
#else /* USE_EXECV */
execvp(cmnd, (const char **) &Argv[1]);
#endif /* USE_EXECV */
perror(cmnd); /* exec failed! */ perror(cmnd); /* exec failed! */
exit(-1); exit(-1);
break; break;
@@ -271,26 +267,29 @@ static void load_globals()
/* /*
* loading the host global variable from gethostname() & gethostbyname() * load the host global variable from gethostname()
* and use gethostbyname() if we want it to be fully qualified.
*/ */
if ((gethostname(host, MAXHOSTNAMELEN))) { if ((gethostname(host, MAXHOSTNAMELEN))) {
strcpy(host, "localhost"); strcpy(host, "localhost");
log_error(GLOBAL_NO_HOSTNAME); log_error(GLOBAL_NO_HOSTNAME);
inform_user(GLOBAL_NO_HOSTNAME); inform_user(GLOBAL_NO_HOSTNAME);
#ifdef FQDN
} else { } else {
if ((h_ent = gethostbyname(host)) == NULL) if ((h_ent = gethostbyname(host)) == NULL)
log_error(GLOBAL_HOST_UNREGISTERED); log_error(GLOBAL_HOST_UNREGISTERED);
else else
strcpy(host, h_ent -> h_name); strcpy(host, h_ent -> h_name);
}
#else
}
/* /*
* We don't want to return the fully quallified name all the time... * We don't want to return the fully quallified name unless FQDN is set
*/ */
#ifndef FQDN if ((p = strchr(host, '.')))
if ((p = strchr(host, '.'))) *p = '\0';
*p = '\0'; #endif /* FQDN */
#endif
}
} }