From dc7b46bbfeac7892a0a8608739f6142b259866ee Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Mon, 28 Jun 2004 19:41:06 +0000 Subject: [PATCH] Use setproctitle(3), if available, to hide autologin password and show logged in user and whether they are playing. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@325 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- configure.ac | 2 +- dgamelaunch.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ea1b74e..cec25a7 100644 --- a/configure.ac +++ b/configure.ac @@ -77,6 +77,6 @@ AC_ARG_WITH(config-file, AC_DEFINE_UNQUOTED(DEFCONFIG, "$configfile", [Path to the default config file.]) -AC_CHECK_FUNCS([openpty setenv]) +AC_CHECK_FUNCS([openpty setenv setproctitle]) AC_CONFIG_FILES(Makefile) AC_OUTPUT diff --git a/dgamelaunch.c b/dgamelaunch.c index 036d71c..0a4da9e 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -792,6 +792,9 @@ autologin (char* user, char *pass) { loggedin = 1; snprintf (rcfilename, 80, "%srcfiles/%s.nethackrc", myconfig->dglroot, me->username); +#ifdef HAVE_SETPROCTITLE + setproctitle ("%s", me->username); +#endif } } } @@ -854,6 +857,9 @@ loginprompt (int from_ttyplay) { loggedin = 1; snprintf (rcfilename, 80, "%srcfiles/%s.nethackrc", myconfig->dglroot, me->username); +#ifdef HAVE_SETPROCTITLE + setproctitle ("%s", me->username); +#endif } else { @@ -1002,6 +1008,9 @@ newuser () loggedin = 1; snprintf (rcfilename, 80, "%srcfiles/%s.nethackrc", myconfig->dglroot, me->username); +#ifdef HAVE_SETPROCTITLE + setproctitle ("%s", me->username); +#endif if (access (rcfilename, R_OK) == -1) write_canned_rcfile (rcfilename); @@ -1701,6 +1710,9 @@ main (int argc, char** argv) size_t len = strlen(argv[optind]); memset(argv[optind++], 0, len); } +#ifdef HAVE_SETPROCTITLE + setproctitle ("(not logged in)"); +#endif create_config(); @@ -1803,6 +1815,10 @@ main (int argc, char** argv) while (!purge_stale_locks()) menuloop(); +#ifdef HAVE_SETPROCTITLE + setproctitle ("%s [playing]", me->username); +#endif + endwin (); signal(SIGWINCH, SIG_DFL); -- 2.47.3