summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2014-05-18 08:25:40 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2014-05-18 08:25:40 (GMT)
commitbc0eeb7706bf5ba3d89f7f5e3563827c3981cc70 (patch) (unidiff)
tree5ba01fa967b924d32d8520f041f5f73b7d2cd6bc
parent9087acb001afd6fefa0fe4f2e4fbdcb3ae524e02 (diff)
downloadanubis-bc0eeb7706bf5ba3d89f7f5e3563827c3981cc70.tar.gz
anubis-bc0eeb7706bf5ba3d89f7f5e3563827c3981cc70.tar.bz2
Support for MySQL options file.
* NEWS: Document the use of MySQL options file. * doc/anubis.texi: Document all anubisusr options. Describe the use of MySQL options file. * src/mysql.c (mysql_db_open): Use MySQL options file. Two new URL parameters: options-file and options-group. * src/usr.opt: New option --tls-priorities.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--NEWS9
-rw-r--r--doc/anubis.texi99
-rw-r--r--src/mysql.c23
-rw-r--r--src/usr.opt7
4 files changed, 117 insertions, 21 deletions
diff --git a/NEWS b/NEWS
index 7775aea..16f46b2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
1GNU Anubis NEWS -- history of user-visible changes. 2014-05-16 1GNU Anubis NEWS -- history of user-visible changes. 2014-05-18
2Copyright (C) 2001-2014 The Anubis Team. 2Copyright (C) 2001-2014 The Anubis Team.
3 3
4See the end of file for copying conditions. 4See the end of file for copying conditions.
@@ -71,6 +71,13 @@ END
71By default Scheme's standard error and output ports are redirected to 71By default Scheme's standard error and output ports are redirected to
72syslog, using priorities `err' and `warning' correspondingly. 72syslog, using priorities `err' and `warning' correspondingly.
73 73
74* MySQL options file
75
76When using MySQL for Anubis user database, the database parameters and
77access credentials are read from the file /etc/my.cnf, section
78"anubis". Additionally, two URL parameters are provided:
79"options-file", which sets the name of the options file, and
80"options-group", which sets the name of the group.
74 81
75 82
76* Version 4.1.1, 2008-12-20 83* Version 4.1.1, 2008-12-20
diff --git a/doc/anubis.texi b/doc/anubis.texi
index 2167225..eec5cfc 100644
--- a/doc/anubis.texi
+++ b/doc/anubis.texi
@@ -609,45 +609,75 @@ given by @acronym{URL} parameters. All of them have reasonable
609default values, so you'll have to specify only those parameters that 609default values, so you'll have to specify only those parameters that
610differ from the default. The following parameters are defined: 610differ from the default. The following parameters are defined:
611 611
612@table @var 612@table @option
613@item @var{port}=@var{number} 613@item port=@var{number}
614Specifies port number the database server is listening on. 614Specifies port number the database server is listening on.
615If it is not given, the behavior depends on the value of 615If it is not given, the behavior depends on the value of the
616@var{socket} parameter (see below). If @var{socket} is not present, the 616@option{socket} parameter (see below). If @option{socket} is not present, the
617program will use the default port number for the given protocol 617program will use the default port number for the given protocol
618(i.e. 3306 for @samp{mysql} and 5432 for @samp{pgsql}. 618(i.e. 3306 for @samp{mysql} and 5432 for @samp{pgsql}.
619 619
620@item @var{socket}=@var{string} 620@item socket=@var{string}
621Specifies the UNIX file name of the socket to connect to. This 621Specifies the UNIX file name of the socket to connect to. This
622parameter cannot be used together with @var{port} (see above). 622parameter cannot be used together with @option{port} (see above).
623 623
624@item @var{bufsize}=@var{number} 624@item bufsize=@var{number}
625Sets length of the buffer for storing SQL queries. Default is 625Sets length of the buffer for storing SQL queries. Default is
6261024 bytes. 6261024 bytes.
627 627
628@item @var{table}=@var{string} 628@item table=@var{string}
629Specifies name of the database table with the authentication 629Specifies name of the database table with the authentication
630data. Default is @samp{users}. 630data. Default is @samp{users}.
631 631
632@item @var{authid}=@var{string} 632@item authid=@var{string}
633Specifies the name of a column in @var{table} which holds 633Specifies the name of a column in @option{table} which holds
634@samp{AUTHID} value. Default is @samp{authid}. 634@samp{AUTHID} value. Default is @samp{authid}.
635 635
636@item @var{passwd}=@var{string} 636@item passwd=@var{string}
637Specifies the name of a column in @var{table} which holds 637Specifies the name of a column in @option{table} which holds
638the user password. Default is @samp{passwd}. 638the user password. Default is @samp{passwd}.
639 639
640@item @var{account}=@var{string} 640@item account=@var{string}
641Specifies the name of a column in @var{table} which holds 641Specifies the name of a column in @option{table} which holds
642the name of system account to be used for this @samp{AUTHID}. Default 642the name of system account to be used for this @samp{AUTHID}. Default
643is @samp{account}. 643is @samp{account}.
644 644
645@item @var{rcfile}=@var{string} 645@item rcfile=@var{string}
646Specifies the name of a column in @var{table} which holds 646Specifies the name of a column in @option{table} which holds
647the path to the user's configuration file. Default is @samp{rcfile}. 647the path to the user's configuration file. Default is @samp{rcfile}.
648 648
649@FIXME{An example, please.} 649@FIXME{An example, please.}
650@end table
651
652@cindex options file, MySQL
653@findex my.cnf
654@findex /etc/my.cnf
655When using a MySQL database (@samp{mysql://}), database parameters and
656access credentials are first read from the file @file{/etc/my.cnf}, if
657it exists. This file called @dfn{option file} in @samp{MySQL} parlance
658@ifhtml
659(see @uref{http://dev.mysql.com/doc/refman/5.0/en/option-files.html,
660option files}).
661@end ifhtml
662@ifnothtml
663(@pxref{option-files, Using Option Files,,mysql,MySQL Manual})
664@end ifnothtml
665is organized in groups, each group beginning with the group name in
666square brackets on a separate line. Within a group, each non-empty
667line consists of a MySQL option name, optionally followed by an equal
668sign and the value. By default, the values from the @samp{anubis}
669group are read.
670
671Two additional parameters are provided to fine-tune this behavior:
650 672
673@table @option
674@item options-file=@var{file}
675Read options from @var{file} instead of @file{/etc/my.cnf}. An
676empty value (@samp{options-file=}), disables using the options file.
677
678@item options-group=@var{name}
679Set the name of the group in the MySQL configuration file, from
680which to read configuration options.
651@end table 681@end table
652 682
653@node Managing the Database 683@node Managing the Database
@@ -953,11 +983,46 @@ found, it will prompt you to supply them.
953Use the SASL mechanism @var{mech}. Give this option several times 983Use the SASL mechanism @var{mech}. Give this option several times
954to set a list of allowed mechanisms. 984to set a list of allowed mechanisms.
955 985
986@item --file=@var{file}
987@itemx -f @var{file}
988Sets the user configuration file name (default is @file{.anubisrc}).
989
990@item --netrc+@var{file}
991@itemx -n @var{file}
992Sets the name of the automatic login configuration file (default is
993@file{.netrc}).
994
956@item -v 995@item -v
957@itemx --verbose 996@itemx --verbose
958Verbose output. Multiple options increase verbosity. Maximum verbosity 997Verbose output. Multiple options increase verbosity. Maximum verbosity
959level is 3. 998level is 3.
999@end table
1000
1001Options controlling encryption:
960 1002
1003@table @option
1004@item --disable-tls
1005@itemx -d
1006Disable the use of TLS encryption.
1007
1008@item --tls-cafile=@var{file}
1009@itemx -C @var{file}
1010Sets the name of certificate authority file to use when verifying the
1011server certificate.
1012
1013@item --tls-priorities=@var{list}
1014Sets cipher suite preferences to use. The @var{list} argument may
1015contain a single initial keyword or be a colon-separated list of TLS
1016keywords. The description of TLS keywords is well beyond the scope of
1017this document. Please refer to @ref{Priority Strings,Priority
1018Strings,,gnutls,GnuTLS Manual}, for a detailed discussion.
1019
1020Default priority list is @samp{NORMAL}.
1021@end table
1022
1023Informational options:
1024
1025@table @option
961@item --version 1026@item --version
962Display program version number and exit. 1027Display program version number and exit.
963 1028
@@ -1579,6 +1644,8 @@ contain a single initial keyword or be a colon-separated list of TLS
1579keywords. The description of TLS keywords is well beyond the scope of 1644keywords. The description of TLS keywords is well beyond the scope of
1580this document. Please refer to @ref{Priority Strings,Priority 1645this document. Please refer to @ref{Priority Strings,Priority
1581Strings,,gnutls,GnuTLS Manual}, for a detailed discussion. 1646Strings,,gnutls,GnuTLS Manual}, for a detailed discussion.
1647
1648Default priority list is @samp{NORMAL}.
1582@end deffn 1649@end deffn
1583 1650
1584@deffn Option ssl-cert @var{file-name} 1651@deffn Option ssl-cert @var{file-name}
diff --git a/src/mysql.c b/src/mysql.c
index 676618a..81ea62c 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -123,8 +123,8 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
123 const char *passwd = anubis_url_get_arg (url, "passwd"); 123 const char *passwd = anubis_url_get_arg (url, "passwd");
124 const char *user = anubis_url_get_arg (url, "account"); 124 const char *user = anubis_url_get_arg (url, "account");
125 const char *rcfile = anubis_url_get_arg (url, "rcfile"); 125 const char *rcfile = anubis_url_get_arg (url, "rcfile");
126 const char *portstr = anubis_url_get_arg (url, "port"); 126 const char *s;
127 const char *s = anubis_url_get_arg (url, "bufsize"); 127 char *optfile;
128 int port = 0; 128 int port = 0;
129 size_t bufsize = 1024; 129 size_t bufsize = 1024;
130 struct mysql_db_data *mdata; 130 struct mysql_db_data *mdata;
@@ -141,6 +141,7 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
141 if (!rcfile) 141 if (!rcfile)
142 rcfile = "rcfile"; 142 rcfile = "rcfile";
143 143
144 s = anubis_url_get_arg (url, "bufsize");
144 if (s) 145 if (s)
145 { 146 {
146 char *p; 147 char *p;
@@ -152,10 +153,11 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
152 } 153 }
153 } 154 }
154 155
155 if (portstr) 156 s = anubis_url_get_arg (url, "port");
157 if (s)
156 { 158 {
157 char *p; 159 char *p;
158 port = strtoul (portstr, &p, 10); 160 port = strtoul (s, &p, 10);
159 if (*p) 161 if (*p)
160 { 162 {
161 *errp = sql_open_error_text (ERR_BADPORT); 163 *errp = sql_open_error_text (ERR_BADPORT);
@@ -169,6 +171,19 @@ mysql_db_open (void **dp, ANUBIS_URL * url, enum anubis_db_mode mode,
169 mdata = xmalloc (sizeof (*mdata)); 171 mdata = xmalloc (sizeof (*mdata));
170 amp->data = mdata; 172 amp->data = mdata;
171 mysql_init (&mdata->mysql); 173 mysql_init (&mdata->mysql);
174
175 s = anubis_url_get_arg (url, "options-file");
176 if (!s) {
177 if (access ("/etc/my.cnf", F_OK) == 0)
178 s = "/etc/my.cnf";
179 }
180
181 if (s && *s) {
182 mysql_options (&mdata->mysql, MYSQL_READ_DEFAULT_FILE, s);
183 mysql_options(&mdata->mysql, MYSQL_READ_DEFAULT_GROUP,
184 s ? s : "anubis");
185 }
186
172 if (!mysql_real_connect (&mdata->mysql, 187 if (!mysql_real_connect (&mdata->mysql,
173 url->host, url->user, url->passwd, 188 url->host, url->user, url->passwd,
174 url->path, port, 189 url->path, port,
diff --git a/src/usr.opt b/src/usr.opt
index 72ab222..fa9d859 100644
--- a/src/usr.opt
+++ b/src/usr.opt
@@ -37,6 +37,13 @@ BEGIN
37#endif 37#endif
38END 38END
39 39
40OPTION(tls-priorities,,PRIO,Set TLS priorities)
41BEGIN
42#ifdef HAVE_TLS
43 secure.prio = optarg;
44#endif
45END
46
40OPTION(file,f,FILE, 47OPTION(file,f,FILE,
41 Set user configuration file name.) 48 Set user configuration file name.)
42BEGIN 49BEGIN

Return to:

Send suggestions and report system problems to the System administrator.