chiark / gitweb /
units: set stdout of kmsg syslogd to /dev/null
[elogind.git] / src / cryptsetup.c
index 506ce9b5c9086bf3d4fec4cd0431affc5bc139ba..f52a41b995dbe8ca4bbf253daa72ef589eea5b57 100644 (file)
@@ -31,6 +31,7 @@
 #include "util.h"
 #include "strv.h"
 #include "ask-password-api.h"
+#include "def.h"
 
 static const char *opt_type = NULL; /* LUKS1 or PLAIN */
 static char *opt_cipher = NULL;
@@ -207,6 +208,17 @@ finish:
         return mp;
 }
 
+static int help(void) {
+
+        printf("%s attach VOLUME SOURCEDEVICE [PASSWORD] [OPTIONS]\n"
+               "%s detach VOLUME\n\n"
+               "Attaches or detaches an encrypted block device.\n",
+               program_invocation_short_name,
+               program_invocation_short_name);
+
+        return 0;
+}
+
 int main(int argc, char *argv[]) {
         int r = EXIT_FAILURE;
         struct crypt_device *cd = NULL;
@@ -214,6 +226,11 @@ int main(int argc, char *argv[]) {
         const char *cipher = NULL, *cipher_mode = NULL, *hash = NULL, *name = NULL;
         char *description = NULL, *name_buffer = NULL, *mount_point = NULL;
 
+        if (argc <= 1) {
+                help();
+                return EXIT_SUCCESS;
+        }
+
         if (argc < 3) {
                 log_error("This program requires at least two arguments.");
                 return EXIT_FAILURE;
@@ -292,7 +309,10 @@ int main(int argc, char *argv[]) {
                 if (opt_readonly)
                         flags |= CRYPT_ACTIVATE_READONLY;
 
-                until = now(CLOCK_MONOTONIC) + (opt_timeout > 0 ? opt_timeout : 60 * USEC_PER_SEC);
+                if (opt_timeout > 0)
+                        until = now(CLOCK_MONOTONIC) + opt_timeout;
+                else
+                        until = 0;
 
                 opt_tries = opt_tries > 0 ? opt_tries : 3;
                 opt_key_size = (opt_key_size > 0 ? opt_key_size : 256);
@@ -387,6 +407,8 @@ int main(int argc, char *argv[]) {
                                 }
                         }
 
+                        k = 0;
+
                         if (!opt_type || streq(opt_type, CRYPT_LUKS1))
                                 k = crypt_load(cd, CRYPT_LUKS1, NULL);