I think you might want to check to see if the file exists not just if the
asprintf succeeds..
But yes I do agree this is useful functionality that I've tested quite
thoroughly...
Index: authpf.c
===================================================================
RCS file: /cvs/src/usr.sbin/authpf/authpf.c,v
retrieving revision 1.107
diff -u -r1.107 authpf.c
--- authpf.c 14 Feb 2008 01:49:17 -0000 1.107
+++ authpf.c 11 Sep 2008 12:49:09 -0000
@@ -314,10 +314,22 @@
signal(SIGQUIT, need_death);
signal(SIGTSTP, need_death);
while (1) {
+ struct stat sb;
+ char *path_message;
+
printf("\r\nHello %s. ", luser);
printf("You are authenticated from host \"%s\"\r\n", ipsrc);
setproctitle("[EMAIL PROTECTED]", luser, ipsrc);
- print_message(PATH_MESSAGE);
+
+ if (asprintf(&path_message, "%s/%s/authpf.message",
+ PATH_USER_DIR, luser) == -1)
+ do_death(1);
+ if (stat(path_message, &sb) == -1) {
+ free(path_message);
+ if ((path_message = strdup(PATH_MESSAGE)) == NULL)
+ do_death(1);
+ }
+ print_message(path_message);
while (1) {
sleep(10);
if (want_death)
--
Todd Fries .. [EMAIL PROTECTED]
_____________________________________________
| \ 1.636.410.0632 (voice)
| Free Daemon Consulting, LLC \ 1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX)
| "..in support of free software solutions." \ 250797 (FWD)
| \
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A
http://todd.fries.net/pgp.txt
Penned by Rafal Bisingier on 20080911 14:09.42, we have:
| Hi all,
|
| I do not know if this is the correct list, or even method to send
| patches, but did not found anything appropriate on the OpenBSD website.
|
| I'd like to propose a little feature enhancement for the authpf. Here
| are the details:
| - authpf can show a message to an user successfully logged in
| - this message is read from /etc/authpf/authpf.message
| - the message is the same for every user
| - i'll want to change it ;-)
|
| Below is a patch which change current behavior, so that the message is
| searched first in the /etc/authpf/USER dir, and if it's not found
| there, then the old behavior is used (so fully backward compatible).
| The patch looks very simple, but I did NOT tested it at all! Anyway it
| would be nice, if something like this make it's way into the HEAD. ;-)
|
| PS. Sorry for any language errors
|
| --
| Greetings
| Rafal Bisingier
|
|
| diff -u authpf.c.orig authpf.c
| --- authpf.c.orig 2008-09-09 17:23:43.315714111 +0200
| +++ authpf.c 2008-09-10 21:07:06.258107858 +0200
| @@ -314,10 +314,16 @@
| signal(SIGQUIT, need_death);
| signal(SIGTSTP, need_death);
| while (1) {
| + char *fn = NULL;
| printf("\r\nHello %s. ", luser);
| printf("You are authenticated from host \"%s\"\r\n",
| ipsrc); setproctitle("[EMAIL PROTECTED]", luser, ipsrc);
| - print_message(PATH_MESSAGE);
| + if (asprintf(&fn, "%s/%s/authpf.message",
| + PATH_USER_DIR, luser) == -1)
| + print_message(PATH_MESSAGE);
| + else
| + print_message(fn);
| + free(fn);
| while (1) {
| sleep(10);
| if (want_death)