pull user home directory via getenv or getpwuid and stash it so we don't

need to do this everytime; with Tiago Cunha
This commit is contained in:
okan
2012-12-17 23:03:41 +00:00
parent fe44d1dfce
commit 75f65f399e
4 changed files with 15 additions and 10 deletions

6
conf.c
View File

@ -243,18 +243,14 @@ void
conf_setup(struct conf *c, const char *conf_file)
{
char conf_path[MAXPATHLEN];
char *home;
struct stat sb;
int parse = 0;
conf_init(c);
if (conf_file == NULL) {
if ((home = getenv("HOME")) == NULL)
errx(1, "No HOME directory.");
(void)snprintf(conf_path, sizeof(conf_path), "%s/%s",
home, CONFFILE);
homedir, CONFFILE);
if (stat(conf_path, &sb) == 0 && (sb.st_mode & S_IFREG))
parse = 1;