summaryrefslogtreecommitdiff
path: root/src/irmd/main.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-10-06 20:52:51 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-10-06 21:21:07 +0200
commitffdfca4bdf98b571d6a472b1501c3b696807f558 (patch)
tree2d6d040eef0dd6aa88c03a082e469c54a51531d5 /src/irmd/main.c
parent7dcacfbc94386e155650aaaa1a8f56cfb6fc53f9 (diff)
downloadouroboros-ffdfca4bdf98b571d6a472b1501c3b696807f558.tar.gz
ouroboros-ffdfca4bdf98b571d6a472b1501c3b696807f558.zip
irmd: Add option to print version
This adds the --version option to the IRMd. With this option it will print the version of Ouroboros to stdout and exit. Checking the version does not require root privileges. Also fixes calling log functions before log_init() and after log_fini().
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r--src/irmd/main.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 84c55e93..99a34af2 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -2272,8 +2272,10 @@ static int irm_init(void)
static void usage(void)
{
- log_err("Usage: irmd \n\n"
- " [--stdout (Print to stdout instead of logs)]\n");
+ printf("Usage: irmd \n"
+ " [--stdout (Log to stdout instead of system log)]\n"
+ " [--version (Print version number and exit)]\n"
+ "\n");
}
int main(int argc,
@@ -2289,11 +2291,6 @@ int main(int argc,
sigaddset(&sigset, SIGHUP);
sigaddset(&sigset, SIGPIPE);
- if (geteuid() != 0) {
- log_err("IPC Resource Manager must be run as root.");
- exit(EXIT_FAILURE);
- }
-
argc--;
argv++;
while (argc > 0) {
@@ -2301,12 +2298,22 @@ int main(int argc,
use_stdout = true;
argc--;
argv++;
+ } else if (strcmp(*argv, "--version") == 0) {
+ printf("Ouroboros version %d.%d\n",
+ OUROBOROS_VERSION_MAJOR,
+ OUROBOROS_VERSION_MINOR);
+ exit(EXIT_SUCCESS);
} else {
usage();
exit(EXIT_FAILURE);
}
}
+ if (geteuid() != 0) {
+ printf("IPC Resource Manager must be run as root.\n");
+ exit(EXIT_FAILURE);
+ }
+
/* Init sig_act. */
memset(&sig_act, 0, sizeof sig_act);
@@ -2369,10 +2376,10 @@ int main(int argc,
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
- log_fini();
-
log_info("Bye.");
+ log_fini();
+
exit(EXIT_SUCCESS);
fail_acceptor: