if motd is set in login.conf, output its contents before starting the

shell


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11217 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2002-08-23 12:11:09 +00:00
parent f5c091c294
commit 6319705d6c

View File

@@ -418,6 +418,19 @@ checknologin(void)
exit(0);
}
/* print contents of a file */
static void
show_file(const char *file)
{
FILE *f;
char buf[BUFSIZ];
if((f = fopen(file, "r")) == NULL)
return;
while (fgets(buf, sizeof(buf), f))
fputs(buf, stdout);
fclose(f);
}
/*
* Actually log in the user. `pwd' contains all the relevant
* information about the user. `ttyn' is the complete name of the tty
@@ -611,6 +624,18 @@ do_login(const struct passwd *pwd, char *tty, char *ttyn)
}
}
}
{
const char *str = login_conf_get_string("motd");
char buf[MAXPATHLEN];
if(str != NULL) {
while(strsep_copy(&str, ",", buf, sizeof(buf)) != -1) {
if(buf[0] == '\0')
continue;
show_file(buf);
}
}
}
add_env("HOME", home_dir);
add_env("USER", pwd->pw_name);
add_env("LOGNAME", pwd->pw_name);