summaryrefslogtreecommitdiff
path: root/comsat/comsat.c
diff options
context:
space:
mode:
Diffstat (limited to 'comsat/comsat.c')
-rw-r--r--comsat/comsat.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/comsat/comsat.c b/comsat/comsat.c
index f317fa698..cee474572 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -15,12 +15,13 @@
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#include "comsat.h"
#include "mailutils/syslog.h"
#include "mailutils/cli.h"
#include "mailutils/sockaddr.h"
+#include "mailutils/alloc.h"
#ifndef PATH_DEV
# define PATH_DEV "/dev"
#endif
#ifndef PATH_TTY_PFX
# define PATH_TTY_PFX PATH_DEV
@@ -56,23 +57,42 @@ typedef struct utmp UTMP;
#endif
#define MAX_TTY_SIZE (sizeof (PATH_TTY_PFX) + sizeof (((UTMP*)0)->ut_line))
const char *program_version = "comsatd (" PACKAGE_STRING ")";
-int test_mode;
+char *test_mode;
char *biffrc = BIFF_RC;
mu_m_server_t server;
static void
set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt,
char const *arg)
{
mu_m_server_set_mode (server, MODE_INTERACTIVE);
}
-
+
+static void
+set_test_mode (struct mu_parseopt *po, struct mu_option *opt,
+ char const *arg)
+{
+ if (arg)
+ {
+ if (arg[0] != '/')
+ {
+ test_mode = mu_make_file_name (mu_getcwd (), arg);
+ if (!test_mode)
+ mu_alloc_die ();
+ }
+ else
+ test_mode = mu_strdup (arg);
+ }
+ else
+ test_mode = mu_strdup ("/dev/tty");
+}
+
static void
set_daemon_mode (struct mu_parseopt *po, struct mu_option *opt,
char const *arg)
{
mu_m_server_set_mode (server, MODE_DAEMON);
if (arg)
@@ -94,15 +114,15 @@ set_foreground (struct mu_parseopt *po, struct mu_option *opt,
char const *arg)
{
mu_m_server_set_foreground (server, 1);
}
static struct mu_option comsat_options[] = {
- { "test", 't', NULL, MU_OPTION_DEFAULT,
- N_("run in test mode"),
- mu_c_bool, &test_mode },
+ { "test", 't', N_("FILE"), MU_OPTION_ARG_OPTIONAL,
+ N_("run in test mode; use FILE as tty (default: /dev/tty)"),
+ mu_c_string, &test_mode, set_test_mode },
{ "foreground", 0, NULL, MU_OPTION_DEFAULT,
N_("remain in foreground"),
mu_c_bool, NULL, set_foreground },
{ "inetd", 'i', NULL, MU_OPTION_DEFAULT,
N_("run in inetd mode"),
mu_c_bool, NULL, set_inetd_mode },
@@ -602,13 +622,13 @@ main (int argc, char **argv)
exit (1);
}
mu_normalize_path (biffrc);
free (cwd);
}
- notify_user (user, "/dev/tty", argv[0], argv[1]);
+ notify_user (user, test_mode, argv[0], argv[1]);
exit (0);
}
mu_stdstream_strerr_setup (mu_log_syslog ?
MU_STRERR_SYSLOG : MU_STRERR_STDERR);

Return to:

Send suggestions and report system problems to the System administrator.