summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-05-04 14:39:37 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-05-04 14:39:37 +0200
commit58e7efce3d5ac71e308e7e44176473cd66e8ad26 (patch)
treed4822587940487f2910e925990a55377e60e05bd /src/daemon
parent27e7d86db7c6c96e8da75e8e8dda6359b9e73c41 (diff)
downloadabrt-58e7efce3d5ac71e308e7e44176473cd66e8ad26.zip
abrt-58e7efce3d5ac71e308e7e44176473cd66e8ad26.tar.gz
abrt-58e7efce3d5ac71e308e7e44176473cd66e8ad26.tar.xz
move $ABRT_foo checking and setting into helper routines.
I'm sick of fixing incorrect PROGNAME defines. Now g_progname is a variable and it is set from argv[0]. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/abrt-action-save-package-data.c14
-rw-r--r--src/daemon/abrt-handle-crashdump.c16
-rw-r--r--src/daemon/abrt-server.c15
-rw-r--r--src/daemon/abrtd.c19
4 files changed, 20 insertions, 44 deletions
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index 9335099..df8de7b 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -21,8 +21,6 @@
#include "rpm.h"
#include "parse_options.h"
-#define PROGNAME "abrt-action-save-package-data"
-
// TODO: convert g_settings_foo usage to command-line switches
/**
@@ -243,15 +241,13 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
int main(int argc, char **argv)
{
- char *env_verbose = getenv("ABRT_VERBOSE");
- if (env_verbose)
- g_verbose = atoi(env_verbose);
+ abrt_init(argv);
const char *dump_dir_name = ".";
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
- PROGNAME" [-v] -d DIR\n"
+ "\b [-v] -d DIR\n"
"\n"
"Query package database and save package name, component, and description"
);
@@ -267,11 +263,7 @@ int main(int argc, char **argv)
};
/*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
- putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
-
- char *pfx = getenv("ABRT_PROG_PREFIX");
- if (pfx && string_to_bool(pfx))
- msg_prefix = PROGNAME;
+ export_abrt_envvars(0);
VERB1 log("Loading settings");
if (load_abrt_conf() != 0)
diff --git a/src/daemon/abrt-handle-crashdump.c b/src/daemon/abrt-handle-crashdump.c
index 3c3e433..d04e4fe 100644
--- a/src/daemon/abrt-handle-crashdump.c
+++ b/src/daemon/abrt-handle-crashdump.c
@@ -19,8 +19,6 @@
#include "abrtlib.h"
#include "parse_options.h"
-#define PROGNAME "abrt-handle-crashdump"
-
static const char *dump_dir_name = NULL;
//static const char *conf_filename = CONF_DIR"/abrt_event.conf";
static const char *event;
@@ -34,14 +32,12 @@ static char *do_log(char *log_line, void *param)
int main(int argc, char **argv)
{
- char *env_verbose = getenv("ABRT_VERBOSE");
- if (env_verbose)
- g_verbose = atoi(env_verbose);
+ abrt_init(argv);
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
- PROGNAME" [-vs]" /*" [-c CONFFILE]"*/ " -d DIR -e EVENT\n"
- " or: "PROGNAME" [-vs]" /*" [-c CONFFILE]"*/ " [-d DIR] -l[PFX]\n"
+ "\b [-vs]" /*" [-c CONFFILE]"*/ " -d DIR -e EVENT\n"
+ " or: \b [-vs]" /*" [-c CONFFILE]"*/ " [-d DIR] -l[PFX]\n"
"\n"
"Handles dump directory DIR according to rules in abrt_event.conf"
);
@@ -69,10 +65,8 @@ int main(int argc, char **argv)
if (!(opts & (OPT_e|OPT_l)))
show_usage_and_die(program_usage_string, program_options);
- putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
- msg_prefix = PROGNAME;
- if (opts & OPT_p)
- putenv((char*)"ABRT_PROG_PREFIX=1");
+ export_abrt_envvars(opts & OPT_p);
+
if (opts & OPT_s)
{
openlog(msg_prefix, 0, LOG_DAEMON);
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
index 53bb5fb..49b7e0c 100644
--- a/src/daemon/abrt-server.c
+++ b/src/daemon/abrt-server.c
@@ -18,8 +18,6 @@
#include "abrtlib.h"
#include "parse_options.h"
-#define PROGNAME "abrt-server"
-
/* Maximal length of backtrace. */
#define MAX_BACKTRACE_SIZE (1024*1024)
/* Amount of data received from one client for a message before reporting error. */
@@ -280,13 +278,11 @@ static void dummy_handler(int sig_unused) {}
int main(int argc, char **argv)
{
- char *env_verbose = getenv("ABRT_VERBOSE");
- if (env_verbose)
- g_verbose = atoi(env_verbose);
+ abrt_init(argv);
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
- PROGNAME" [options]"
+ "\b [options]"
);
enum {
OPT_v = 1 << 0,
@@ -304,10 +300,9 @@ int main(int argc, char **argv)
};
unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
- putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
- msg_prefix = xasprintf(PROGNAME"[%u]", getpid());
- if (opts & OPT_p)
- putenv((char*)"ABRT_PROG_PREFIX=1");
+ export_abrt_envvars(opts & OPT_p);
+
+ msg_prefix = xasprintf("%s[%u]", g_progname, getpid());
if (opts & OPT_s)
{
openlog(msg_prefix, 0, LOG_DAEMON);
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index ca0e0d2..7a1ab31 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -30,8 +30,6 @@
#include "MiddleWare.h"
#include "parse_options.h"
-#define PROGNAME "abrtd"
-
#define VAR_RUN_PIDFILE VAR_RUN"/abrtd.pid"
#define SOCKET_FILE VAR_RUN"/abrt/abrt.socket"
@@ -451,7 +449,7 @@ static void start_syslog_logging()
* Otherwise fprintf(stderr) dumps messages into random fds, etc. */
xdup2(STDIN_FILENO, STDOUT_FILENO);
xdup2(STDIN_FILENO, STDERR_FILENO);
- openlog(PROGNAME, 0, LOG_DAEMON);
+ openlog(g_progname, 0, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
putenv((char*)"ABRT_SYSLOG=1");
}
@@ -490,6 +488,8 @@ static void sanitize_dump_dir_rights()
int main(int argc, char** argv)
{
+ abrt_init(argv);
+
int parent_pid = getpid();
setlocale(LC_ALL, "");
@@ -502,12 +502,8 @@ int main(int argc, char** argv)
if (getuid() != 0)
error_msg_and_die("ABRT daemon must be run as root");
- char *env_verbose = getenv("ABRT_VERBOSE");
- if (env_verbose)
- g_verbose = atoi(env_verbose);
-
const char *program_usage_string = _(
- PROGNAME" [options]"
+ "\b [options]"
);
enum {
OPT_v = 1 << 0,
@@ -527,6 +523,8 @@ int main(int argc, char** argv)
};
unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
+ export_abrt_envvars(opts & OPT_p);
+
/* When dbus daemon starts us, it doesn't set PATH
* (I saw it set only DBUS_STARTER_ADDRESS and DBUS_STARTER_BUS_TYPE).
* In this case, set something sane:
@@ -536,10 +534,7 @@ int main(int argc, char** argv)
putenv((char*)"PATH=/usr/sbin:/usr/bin:/sbin:/bin");
unsetenv("ABRT_SYSLOG");
- putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
- msg_prefix = PROGNAME; /* for log(), error_msg() and such */
- if (opts & OPT_p)
- putenv((char*)"ABRT_PROG_PREFIX=1");
+ msg_prefix = g_progname; /* for log(), error_msg() and such */
if (opts & OPT_s)
start_syslog_logging();