[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] implement --no-auth-cache (issue 720)

From: mark benedetto king <bking_at_inquira.com>
Date: 2002-08-16 04:29:56 CEST

On Thu, Aug 15, 2002 at 08:19:54PM +0100, Philip Martin wrote:
> > - svn_boolean_t overwrite;
> > + enum {
> > + svn_client_auth_info_write_false,
> > + svn_client_auth_info_write_true,
> > + svn_client_auth_info_write_never
> > + } overwrite;
>
> Please document what each state means/does. I can guess, but I
> shouldn't have to...
>

Okay, though I'm not sure that these comments are really that
much more informative.

Fix issue #720:

* subversion/include/svn_client.h
  (svn_client_auth_baton_t): Changed overwrite member from boolean to
  enumerated type.

* subversion/libsvn_client/auth.c
  (get_username): Respect "never" value for overwrite.
  (get_password): Respect "never" value for overwrite.

* subversion/clients/cmdline/cl.h
  (svn_cl__longopt_t): Added svn_cl__no_auth_cache_opt enum-value.
  (svn_cl__opt_state_t): Added no_auth_cache boolean.

* subversion/clients/cmdline/prompt.c
  (svn_cl__make_auth_baton): Respect "never" value for overwrite.

* subversion/clients/cmdline/main.c
  (svn_cl__options): Added --no-auth-cache long option.
  (svn_cl__cmd_table): Added --no-auth-cache option to every command that
  previously took --username and --password.
  (main): Handle --no-auth-cache option.

Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h
+++ subversion/include/svn_client.h Thu Aug 15 18:31:02 2002
@@ -127,7 +127,11 @@
   void *prompt_baton;
 
   /* if it's ok to overwrite wc auth info */
- svn_boolean_t overwrite;
+ enum {
+ svn_client_auth_info_write_false, /* not yet */
+ svn_client_auth_info_write_true, /* yes */
+ svn_client_auth_info_write_never /* don't do it */
+ } overwrite;
 
 } svn_client_auth_baton_t;
 
Index: subversion/libsvn_client/auth.c
===================================================================
--- subversion/libsvn_client/auth.c
+++ subversion/libsvn_client/auth.c Thu Aug 15 18:30:02 2002
@@ -61,7 +61,8 @@
       
       /* Since we got new totally new info, it's okay to overwrite
          any cached info in the working copy (later on). */
- ab->overwrite = TRUE;
+ if (ab->overwrite != svn_client_auth_info_write_never)
+ ab->overwrite = svn_client_auth_info_write_true;
 
       /* Store a copy of the username in the auth_baton too. */
       ab->username = apr_pstrdup (pool, *username);
@@ -78,7 +79,8 @@
 
       /* Since we got new totally new info, it's okay to overwrite
          any cached info in the working copy (later on). */
- ab->overwrite = TRUE;
+ if (ab->overwrite != svn_client_auth_info_write_never)
+ ab->overwrite = svn_client_auth_info_write_true;
     }
 
   /* Else, try to get it from file cached in working copy. */
@@ -151,7 +153,8 @@
       
       /* Since we got new totally new info, it's okay to overwrite
          any cached info in the working copy (later on). */
- ab->overwrite = TRUE;
+ if (ab->overwrite != svn_client_auth_info_write_never)
+ ab->overwrite = svn_client_auth_info_write_true;
 
       /* Store a copy of the password in the auth_baton too. */
       ab->password = apr_pstrdup (pool, *password);
@@ -168,7 +171,8 @@
       
       /* Since we got new totally new info, it's okay to overwrite
          any cached info in the working copy (later on). */
- ab->overwrite = TRUE;
+ if (ab->overwrite != svn_client_auth_info_write_never)
+ ab->overwrite = svn_client_auth_info_write_true;
     }
 
   /* Else, try to get it from file cached in working copy. */
@@ -192,7 +196,8 @@
 
           /* Since we got new totally new info, it's okay to overwrite
              any cached info in the working copy (later on). */
- ab->overwrite = TRUE;
+ if (ab->overwrite != svn_client_auth_info_write_never)
+ ab->overwrite = svn_client_auth_info_write_true;
         }
       
       /* Store a copy of the password in the auth_baton too. */
@@ -249,7 +254,7 @@
   /* Sanity check: only store auth info if the `overwrite' flag is
      set. This flag is set if the user was either prompted or
      specified new info on the commandline. */
- if (cb->auth_baton->overwrite)
+ if (cb->auth_baton->overwrite == svn_client_auth_info_write_true)
     return store_auth_info (SVN_CLIENT_AUTH_USERNAME, username,
                             cb->base_dir, cb->pool);
   else
@@ -266,7 +271,7 @@
   /* Sanity check: only store auth info if the `overwrite' flag is
      set. This flag is set if the user was either prompted or
      specified new info on the commandline. */
- if (cb->auth_baton->overwrite)
+ if (cb->auth_baton->overwrite == svn_client_auth_info_write_true)
     return store_auth_info (SVN_CLIENT_AUTH_PASSWORD, password,
                             cb->base_dir, cb->pool);
   else
Index: subversion/clients/cmdline/cl.h
===================================================================
--- subversion/clients/cmdline/cl.h
+++ subversion/clients/cmdline/cl.h Thu Aug 15 18:30:02 2002
@@ -52,7 +52,8 @@
   svn_cl__targets_opt,
   svn_cl__xml_opt,
   svn_cl__strict_opt,
- svn_cl__no_ignore_opt
+ svn_cl__no_ignore_opt,
+ svn_cl__no_auth_cache_opt
 } svn_cl__longopt_t;
 
 
@@ -91,7 +92,7 @@
   apr_array_header_t *targets; /* target list from file */ /* UTF-8! */
   svn_boolean_t xml; /* output in xml, e.g., "svn log --xml" */
   svn_boolean_t no_ignore; /* disregard default ignores & svn:ignore's */
-
+ svn_boolean_t no_auth_cache; /* do not cache authentication information */
 } svn_cl__opt_state_t;
 
 
Index: subversion/clients/cmdline/prompt.c
===================================================================
--- subversion/clients/cmdline/prompt.c
+++ subversion/clients/cmdline/prompt.c Thu Aug 15 18:30:02 2002
@@ -47,19 +47,23 @@
   auth_obj->prompt_callback = svn_cl__prompt_user;
   auth_obj->prompt_baton = NULL;
 
+ if (opt_state->no_auth_cache)
+ auth_obj->overwrite = svn_client_auth_info_write_never;
+
   if (opt_state->auth_username)
     {
       auth_obj->username = opt_state->auth_username;
- auth_obj->overwrite = TRUE;
+ if (auth_obj->overwrite != svn_client_auth_info_write_never)
+ auth_obj->overwrite = svn_client_auth_info_write_true;
     }
   if (opt_state->auth_password)
     {
       auth_obj->password = opt_state->auth_password;
- auth_obj->overwrite = TRUE;
+ if (auth_obj->overwrite != svn_client_auth_info_write_never)
+ auth_obj->overwrite = svn_client_auth_info_write_true;
     }
 
   /* Add more authentication args here as necessary... */
-
   return auth_obj;
 }
 
Index: subversion/clients/cmdline/main.c
===================================================================
--- subversion/clients/cmdline/main.c
+++ subversion/clients/cmdline/main.c Thu Aug 15 22:16:40 2002
@@ -75,6 +75,8 @@
     {"strict", svn_cl__strict_opt, 0, "use strict semantics"},
     {"no-ignore", svn_cl__no_ignore_opt, 0,
                       "disregard default and svn:ignore property ignores"},
+ {"no-auth-cache", svn_cl__no_auth_cache_opt, 0,
+ "do not cache authentication tokens"},
     {0, 0, 0}
   };
 
@@ -136,7 +138,7 @@
     " sub-directory being the basename of the URL.\n",
     {'r', 'D', 'q', 'N',
      svn_cl__auth_username_opt, svn_cl__auth_password_opt,
- svn_cl__xml_file_opt } },
+ svn_cl__no_auth_cache_opt, svn_cl__xml_file_opt } },
 
   { "cleanup", svn_cl__cleanup, {0},
     "Recursively clean up the working copy, removing locks, resuming\n"
@@ -151,7 +153,8 @@
     " the -r switch is only for use with --xml-file.\n",
     {'m', 'F', 'q', 'N', svn_cl__targets_opt,
      svn_cl__force_opt, svn_cl__auth_username_opt, svn_cl__auth_password_opt,
- svn_cl__xml_file_opt, 'r', svn_cl__msg_encoding_opt} },
+ svn_cl__no_auth_cache_opt, svn_cl__xml_file_opt, 'r',
+ svn_cl__msg_encoding_opt} },
   
   { "copy", svn_cl__copy, {"cp"},
     "Duplicate something in working copy or repos, remembering history.\n"
@@ -163,7 +166,7 @@
     " URL -> URL: complete server-side copy; used to branch & tag\n",
     {'m', 'F', 'r', 'D', 'q',
      svn_cl__auth_username_opt, svn_cl__auth_password_opt,
- svn_cl__msg_encoding_opt} },
+ svn_cl__no_auth_cache_opt, svn_cl__msg_encoding_opt} },
   
   { "delete", svn_cl__delete, {"del", "remove", "rm"},
     "Remove files and directories from version control.\n"
@@ -178,7 +181,7 @@
     " immediate commit.\n",
     {svn_cl__force_opt, 'm', 'F', 'q', svn_cl__targets_opt,
      svn_cl__auth_username_opt, svn_cl__auth_password_opt,
- svn_cl__msg_encoding_opt} },
+ svn_cl__no_auth_cache_opt, svn_cl__msg_encoding_opt} },
   
   { "diff", svn_cl__diff, {"di"},
     "display the differences between two paths.\n"
@@ -195,7 +198,8 @@
     " at revisions N and M respectively. If either N or M are\n"
     " ommitted, value of HEAD is assumed.\n",
     {'r', 'D', 'x', 'N',
- svn_cl__auth_username_opt, svn_cl__auth_password_opt} },
+ svn_cl__auth_username_opt, svn_cl__auth_password_opt,
+ svn_cl__no_auth_cache_opt} },
 
   { "export", svn_cl__export, {0},
     "export stuff.\n"
@@ -209,7 +213,8 @@
     " not under revision control will not be copied.\n\n"
     " NOTE: If PATH is omitted, the last component of the URL is used\n"
     " for the local directory name.\n",
- {'r', 'D', 'q', svn_cl__auth_username_opt, svn_cl__auth_password_opt} },
+ {'r', 'D', 'q', svn_cl__auth_username_opt, svn_cl__auth_password_opt,
+ svn_cl__no_auth_cache_opt} },
 
   { "help", svn_cl__help, {"?", "h"},
     "Display this usage message.\n"
@@ -228,7 +233,8 @@
     " directly. Otherwise, create NEW_ENTRY underneath REPOS_URL and\n"
     " begin copy there. (-r is only needed if importing to --xml-file)\n",
     {'F', 'm', 'q', 'N', svn_cl__auth_username_opt, svn_cl__auth_password_opt,
- svn_cl__xml_file_opt, 'r', svn_cl__msg_encoding_opt} },
+ svn_cl__no_auth_cache_opt, svn_cl__xml_file_opt, 'r',
+ svn_cl__msg_encoding_opt} },
  
   { "info", svn_cl__info, {0},
     "Display info about a resource.\n"
@@ -240,7 +246,8 @@
     "List directory entries of a URL.\n"
     "usage: svn list URL1 [URL2 ...]\n\n"
     " If URL is a file, just file entry will be displayed.\n",
- {'r', 'D', 'v', svn_cl__auth_username_opt, svn_cl__auth_password_opt} },
+ {'r', 'D', 'v', svn_cl__auth_username_opt, svn_cl__auth_password_opt,
+ svn_cl__no_auth_cache_opt} },
   
   { "log", svn_cl__log, {0},
     "Show the log messages for a set of revision(s) and/or file(s).\n"
@@ -260,7 +267,8 @@
     " svn log http://www.example.com/repo/project/foo.c\n"
     " svn log http://www.example.com/repo/project foo.c bar.c\n",
     {'r', 'D', 'v', svn_cl__targets_opt, svn_cl__auth_username_opt,
- svn_cl__auth_password_opt, svn_cl__strict_opt, svn_cl__xml_opt} },
+ svn_cl__auth_password_opt, svn_cl__no_auth_cache_opt,
+ svn_cl__strict_opt, svn_cl__xml_opt} },
 
   { "merge", svn_cl__merge, {0},
     "apply the differences between two paths to a working copy path.\n"
@@ -272,7 +280,8 @@
     " * WCPATH is the working-copy path that will receive the changes.\n"
     " If omitted, a default value of '.' is assumed.\n\n",
     {'r', 'D', 'N', 'q', svn_cl__force_opt,
- svn_cl__auth_username_opt, svn_cl__auth_password_opt} },
+ svn_cl__auth_username_opt, svn_cl__auth_password_opt,
+ svn_cl__no_auth_cache_opt} },
   
   { "mkdir", svn_cl__mkdir, {0},
     "Create a new directory under revision control.\n"
@@ -280,7 +289,7 @@
     " Either create NEW_DIR in working copy scheduled for addition,\n"
     " or create REPOS_URL via immediate commit.\n",
     {'m', 'F', 'q', svn_cl__auth_username_opt, svn_cl__auth_password_opt,
- svn_cl__msg_encoding_opt} },
+ svn_cl__no_auth_cache_opt, svn_cl__msg_encoding_opt} },
 
   { "move", svn_cl__move, {"mv", "rename", "ren"},
     "Move/rename something in working copy or repository.\n"
@@ -290,7 +299,8 @@
     " WC -> WC: move and schedule for addition (with history)\n"
     " URL -> URL: complete server-side rename.\n",
     {'m', 'F', 'r', 'D', 'q', svn_cl__auth_username_opt,
- svn_cl__auth_password_opt, svn_cl__force_opt, svn_cl__msg_encoding_opt} },
+ svn_cl__auth_password_opt, svn_cl__no_auth_cache_opt, svn_cl__force_opt,
+ svn_cl__msg_encoding_opt} },
   
   { "propdel", svn_cl__propdel, {"pdel"},
     "Remove property PROPNAME on files and directories.\n"
@@ -381,14 +391,14 @@
     " M 965 687 joe ./buildcheck.sh\n",
     { 'u', 'v', 'N', 'q',
       svn_cl__auth_username_opt, svn_cl__auth_password_opt,
- svn_cl__no_ignore_opt } },
+ svn_cl__no_auth_cache_opt, svn_cl__no_ignore_opt } },
   
   { "switch", svn_cl__switch, {"sw"},
     "Update working copy to mirror a new URL\n"
     "usage: switch REPOS_URL [TARGET]\n\n"
     " Note: this is the way to move a working copy to a new branch.\n",
     { 'r', 'D', 'N', 'q', svn_cl__auth_username_opt,
- svn_cl__auth_password_opt} },
+ svn_cl__auth_password_opt, svn_cl__no_auth_cache_opt} },
  
   { "update", svn_cl__update, {"up"},
     "Bring changes from the repository into the working copy.\n"
@@ -405,7 +415,8 @@
     " C Conflict\n"
     " G Merged\n",
     {'r', 'D', 'N', 'q', svn_cl__auth_username_opt,
- svn_cl__auth_password_opt, svn_cl__xml_file_opt} },
+ svn_cl__auth_password_opt, svn_cl__no_auth_cache_opt,
+ svn_cl__xml_file_opt} },
 
   { NULL, NULL, {0}, NULL, {0} }
 };
@@ -1095,6 +1106,9 @@
       case svn_cl__no_ignore_opt:
         opt_state.no_ignore = TRUE;
         break;
+ case svn_cl__no_auth_cache_opt:
+ opt_state.no_auth_cache = TRUE;
+ break;
       case 'x':
         err = svn_utf_cstring_to_utf8 (&opt_state.extensions, opt_arg,
                                        NULL, pool);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Aug 16 04:36:11 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.