[phodav: 1/3] Add chezdav --realm runtime flag




commit a26b47c37c0d2732cc36c3d3b82063a41c3831b0
Author: Daniel Aleksandersen <code daniel priv no>
Date:   Sun Dec 26 16:21:05 2021 +0100

    Add chezdav --realm runtime flag
    
    Sets the DIGEST authentication realm.
    
    Added documentation. Suggest reading htdigest(1).

 bin/chezdav.c   |  8 +++++---
 doc/chezdav.txt | 19 +++++++++++++++----
 2 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/bin/chezdav.c b/bin/chezdav.c
index a51942c..543c045 100644
--- a/bin/chezdav.c
+++ b/bin/chezdav.c
@@ -112,6 +112,7 @@ main (int argc, char *argv[])
   GError *error = NULL;
   GOptionContext *context;
   const gchar *path = NULL;
+  const gchar *realm = NULL;
   GMainLoop *mainloop = NULL;
 
   int version = 0;
@@ -123,6 +124,7 @@ main (int argc, char *argv[])
     { "public", 0, 0, G_OPTION_ARG_NONE, &public, N_ ("Listen on all interfaces"), NULL },
     { "path", 'P', 0, G_OPTION_ARG_FILENAME, &path, N_ ("Path to export"), NULL },
     { "htdigest", 'd', 0, G_OPTION_ARG_FILENAME, &htdigest, N_ ("Path to htdigest file"), NULL },
+    { "realm", 0, 0, G_OPTION_ARG_STRING, &realm, N_ ("DIGEST realm"), NULL },
     { "readonly", 'r', 0, G_OPTION_ARG_NONE, &readonly, N_ ("Read-only access"), NULL },
 #ifdef WITH_AVAHI
     { "no-mdns", 0, 0, G_OPTION_ARG_NONE, &nomdns, N_ ("Skip mDNS service announcement"), NULL },
@@ -166,6 +168,9 @@ main (int argc, char *argv[])
   if (!path)
       path = g_get_home_dir ();
 
+  if (!realm)
+      realm = get_realm ();
+
   mainloop = g_main_loop_new (NULL, FALSE);
 
 #ifdef G_OS_UNIX
@@ -178,20 +183,17 @@ main (int argc, char *argv[])
   if (htdigest)
     {
       SoupAuthDomain *auth;
-      gchar *realm;
       SoupServer *server;
 
       if (!g_file_get_contents (htdigest, &htdigest, NULL, &error))
         my_error (_ ("Failed to open htdigest: %s\n"), error->message);
 
-      realm = get_realm ();
       auth = soup_auth_domain_digest_new (SOUP_AUTH_DOMAIN_REALM, realm,
                                           SOUP_AUTH_DOMAIN_ADD_PATH, "/",
                                           SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK, digest_auth_callback,
                                           SOUP_AUTH_DOMAIN_DIGEST_AUTH_DATA, NULL,
                                           NULL);
       server = phodav_server_get_soup_server (dav);
-      g_free (realm);
       soup_server_add_auth_domain (server, auth);
       g_object_unref (auth);
   }
diff --git a/doc/chezdav.txt b/doc/chezdav.txt
index ea647c0..a85b73d 100644
--- a/doc/chezdav.txt
+++ b/doc/chezdav.txt
@@ -24,9 +24,6 @@ but you may specifiy a different folder with the *-P* option.
 
 OPTIONS
 -------
-*-d, --htdigest*=PATH::
-    Path to a htdigest file, to protect server with DIGEST method.
-
 *-P, --path*=PATH::
     Path to export.
 
@@ -39,6 +36,14 @@ OPTIONS
 *--public::
     Listen on all network interfaces.
 
+*-d, --htdigest*=PATH::
+    Path to a htdigest file, to secure the server with DIGEST
+    authentication.
+
+*--realm*=REALM::
+    The DIGEST realm string (must be identical to the string used in
+    the htdigest file). The default value is "USER's public share"
+    (where USER is the owner's username of the current process).
 
 *-v, --verbose*::
     Verbosely print running information.
@@ -57,6 +62,12 @@ EXIT STATUS
     Failure (syntax or usage error; unexpected error).
 
 
+SEE ALSO
+--------
+
+*htdigest*(1)
+
+
 AUTHOR
 ------
 chezdav was originally written by Marc-André Lureau.
@@ -64,7 +75,7 @@ chezdav was originally written by Marc-André Lureau.
 
 RESOURCES
 ---------
-Main web site: <http://wiki.gnome.org/phodav>
+Main web site: <https://wiki.gnome.org/phodav>
 
 
 COPYING


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]