]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/svn/help-cmd.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / svn / help-cmd.c
1 /*
2  * help-cmd.c -- Provide help
3  *
4  * ====================================================================
5  *    Licensed to the Apache Software Foundation (ASF) under one
6  *    or more contributor license agreements.  See the NOTICE file
7  *    distributed with this work for additional information
8  *    regarding copyright ownership.  The ASF licenses this file
9  *    to you under the Apache License, Version 2.0 (the
10  *    "License"); you may not use this file except in compliance
11  *    with the License.  You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  *    Unless required by applicable law or agreed to in writing,
16  *    software distributed under the License is distributed on an
17  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  *    KIND, either express or implied.  See the License for the
19  *    specific language governing permissions and limitations
20  *    under the License.
21  * ====================================================================
22  */
23
24 /* ==================================================================== */
25
26
27 \f
28 /*** Includes. ***/
29
30 #include "svn_hash.h"
31 #include "svn_string.h"
32 #include "svn_config.h"
33 #include "svn_error.h"
34 #include "svn_version.h"
35 #include "cl.h"
36
37 #include "svn_private_config.h"
38
39 \f
40 /*** Code. ***/
41
42 /* This implements the `svn_opt_subcommand_t' interface. */
43 svn_error_t *
44 svn_cl__help(apr_getopt_t *os,
45              void *baton,
46              apr_pool_t *pool)
47 {
48   svn_cl__opt_state_t *opt_state = NULL;
49   svn_stringbuf_t *version_footer = NULL;
50
51   /* xgettext: the %s is for SVN_VER_NUMBER. */
52   char help_header_template[] =
53   N_("usage: svn <subcommand> [options] [args]\n"
54      "Subversion command-line client, version %s.\n"
55      "Type 'svn help <subcommand>' for help on a specific subcommand.\n"
56      "Type 'svn --version' to see the program version and RA modules\n"
57      "  or 'svn --version --quiet' to see just the version number.\n"
58      "\n"
59      "Most subcommands take file and/or directory arguments, recursing\n"
60      "on the directories.  If no arguments are supplied to such a\n"
61      "command, it recurses on the current directory (inclusive) by default.\n"
62      "\n"
63      "Available subcommands:\n");
64
65   char help_footer[] =
66   N_("Subversion is a tool for version control.\n"
67      "For additional information, see http://subversion.apache.org/\n");
68
69   char *help_header =
70     apr_psprintf(pool, _(help_header_template), SVN_VER_NUMBER);
71
72   const char *ra_desc_start
73     = _("The following repository access (RA) modules are available:\n\n");
74
75   if (baton)
76     {
77       svn_cl__cmd_baton_t *const cmd_baton = baton;
78 #ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE
79       /* Windows never actually stores plaintext passwords, it
80          encrypts the contents using CryptoAPI. ...
81
82          ... If CryptoAPI is available ... but it should be on all
83          versions of Windows that are even remotely interesting two
84          days before the scheduled end of the world, when this comment
85          is being written. */
86 #  ifndef WIN32
87       svn_boolean_t store_auth_creds =
88         SVN_CONFIG_DEFAULT_OPTION_STORE_AUTH_CREDS;
89       svn_boolean_t store_passwords =
90         SVN_CONFIG_DEFAULT_OPTION_STORE_PASSWORDS;
91       svn_boolean_t store_plaintext_passwords = FALSE;
92       svn_config_t *cfg;
93
94       if (cmd_baton->ctx->config)
95         {
96           cfg = svn_hash_gets(cmd_baton->ctx->config,
97                               SVN_CONFIG_CATEGORY_CONFIG);
98           if (cfg)
99             {
100               SVN_ERR(svn_config_get_bool(cfg, &store_auth_creds,
101                                           SVN_CONFIG_SECTION_AUTH,
102                                           SVN_CONFIG_OPTION_STORE_AUTH_CREDS,
103                                           store_auth_creds));
104               SVN_ERR(svn_config_get_bool(cfg, &store_passwords,
105                                           SVN_CONFIG_SECTION_AUTH,
106                                           SVN_CONFIG_OPTION_STORE_PASSWORDS,
107                                           store_passwords));
108             }
109           cfg = svn_hash_gets(cmd_baton->ctx->config,
110                               SVN_CONFIG_CATEGORY_SERVERS);
111           if (cfg)
112             {
113               const char *value;
114               SVN_ERR(svn_config_get_yes_no_ask
115                       (cfg, &value,
116                        SVN_CONFIG_SECTION_GLOBAL,
117                        SVN_CONFIG_OPTION_STORE_PLAINTEXT_PASSWORDS,
118                        SVN_CONFIG_DEFAULT_OPTION_STORE_PLAINTEXT_PASSWORDS));
119               if (0 == svn_cstring_casecmp(value, SVN_CONFIG_TRUE))
120                 store_plaintext_passwords = TRUE;
121             }
122         }
123
124       if (store_plaintext_passwords && store_auth_creds && store_passwords)
125         {
126           version_footer = svn_stringbuf_create(
127               _("WARNING: Plaintext password storage is enabled!\n\n"),
128               pool);
129           svn_stringbuf_appendcstr(version_footer, ra_desc_start);
130         }
131 #  endif /* !WIN32 */
132 #endif /* !SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE */
133
134       opt_state = cmd_baton->opt_state;
135     }
136
137   if (!version_footer)
138     version_footer = svn_stringbuf_create(ra_desc_start, pool);
139   SVN_ERR(svn_ra_print_modules(version_footer, pool));
140
141   return svn_opt_print_help4(os,
142                              "svn",   /* ### erm, derive somehow? */
143                              opt_state ? opt_state->version : FALSE,
144                              opt_state ? opt_state->quiet : FALSE,
145                              opt_state ? opt_state->verbose : FALSE,
146                              version_footer->data,
147                              help_header,   /* already gettext()'d */
148                              svn_cl__cmd_table,
149                              svn_cl__options,
150                              svn_cl__global_options,
151                              _(help_footer),
152                              pool);
153 }