Author: brane
Date: Sun Dec 16 22:43:25 2012
New Revision: 1422706
URL: http://svn.apache.org/viewvc?rev=1422706&view=rev
Log:
Print a warning in "svn --version" if plaintext password storage is enabled.
* subversion/libsvn_subr/opt.c: Inlcude unistd.h on *nix.
(svn_opt__print_version_info): If plaintext password storage is
enabled, print a warning about that after the copyright notice.
* subversion/tests/cmdline/svntest/main.py
(is_plaintext_password_storage_disabled): Instead of looking for
and scanning svn_private_config.h, look for the warning emitted
by "svn --version".
Modified:
subversion/trunk/subversion/libsvn_subr/opt.c
subversion/trunk/subversion/tests/cmdline/svntest/main.py
Modified: subversion/trunk/subversion/libsvn_subr/opt.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/opt.c?rev=1422706&r1=1422705&r2=1422706&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/opt.c (original)
+++ subversion/trunk/subversion/libsvn_subr/opt.c Sun Dec 16 22:43:25 2012
@@ -34,6 +34,10 @@
#include <apr_lib.h>
#include <apr_file_info.h>
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
#include "svn_cmdline.h"
#include "svn_version.h"
#include "svn_types.h"
@@ -1121,6 +1125,24 @@ svn_opt__print_version_info(const char *
svn_version_ext_build_host(info)));
SVN_ERR(svn_cmdline_printf(pool, "%s\n", svn_version_ext_copyright(info)));
+#ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE
+ {
+ const char *warnstart = "";
+ const char *warnend = "";
+#ifndef WIN32
+ if (isatty(fileno(stdout)))
+ {
+ warnstart = "\033[1;31m";
+ warnend = "\033[0;m";
+ }
+#endif /* WIN32 */
+ SVN_ERR(svn_cmdline_printf(
+ pool,
+ _("%sWARNING: Plaintext password storage is enabled!%s\n\n"),
+ warnstart, warnend));
+ }
+#endif /* SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE */
+
if (footer)
{
SVN_ERR(svn_cmdline_printf(pool, "%s\n", footer));
Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1422706&r1=1422705&r2=1422706&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Sun Dec 16
22:43:25 2012
@@ -1234,27 +1234,16 @@ def server_enforces_date_syntax():
def server_has_atomic_revprop():
return options.server_minor_version >= 7
-# FIXME: The following should use information retreived from "svn --version"
-# However, at the time of writing this predicate, that piece of
-# information was not available from a running Subversion client.
def is_plaintext_password_storage_disabled():
- confighandle = None
try:
- predicate = re.compile(r"^\s*#\s*define\s+"
- r"SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE")
- configfile = os.path.abspath(general_wc_dir)
- for i in range(4):
- configfile = os.path.dirname(configfile)
- configfile = os.path.join(configfile, "svn_private_config.h")
- confighandle = open(configfile, 'rt')
- for line in confighandle.readlines():
+ predicate = re.compile("^[^W]*WARNING: Plaintext password storage is
enabled!")
+ code, out, err = run_svn(False, "--version")
+ for line in out:
if predicate.match(line):
- return True
+ return False
except:
- pass
- if confighandle:
- confighandle.close()
- return False
+ return False
+ return True
######################################################################