From f2137dc28d167092a00f075ec628db32fd26de79 Mon Sep 17 00:00:00 2001 From: remoof Date: Sat, 17 Jul 2021 18:29:39 +0200 Subject: [PATCH] Add version and usage if no arguments are given. --- rdo.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rdo.c b/rdo.c index 0fb1162..bcb1862 100644 --- a/rdo.c +++ b/rdo.c @@ -9,6 +9,8 @@ #include #include "sessions.h" +#define VERSION "1.2" + void getconf(FILE* fp, const char* entry, char* result, size_t len_result) { char* line = NULL; size_t len = 0; @@ -49,8 +51,11 @@ int main(int argc, char** argv) { char username[64], wrong_pw_sleep[64], session_ttl[64], password[128]; unsigned int sleep_ms, tries, ts_ttl; - if (argc < 2) - errx(1, "Please specify a program to run"); + if (argc == 1) { + printf("RootDO version: %s\n\n", VERSION); + printf("Usage: %s [command]\n", argv[0]); + return 0; + } int ruid = getuid(); if (ruid == 0)