Merge lp:~brianaker/drizzle/bug786515-elliot into lp:drizzle/7.0

Proposed by Brian Aker on 2011-05-23
Status: Merged
Approved by: Brian Aker on 2011-05-23
Approved revision: 2247
Merged at revision: 2245
Proposed branch: lp:~brianaker/drizzle/bug786515-elliot
Merge into: lp:drizzle/7.0
Diff against target: 282 lines (+91/-12)
9 files modified
client/drizzle.cc (+5/-2)
client/drizzledump.cc (+5/-2)
client/drizzleimport.cc (+5/-2)
client/include.am (+1/-0)
client/user_detect.h (+62/-0)
plugin/console/console.cc (+5/-1)
plugin/haildb/plugin.ini (+3/-0)
plugin/schema_dictionary/tests/r/data_dictionary.result (+4/-4)
plugin/session_dictionary/sessions.cc (+1/-1)
To merge this branch: bzr merge lp:~brianaker/drizzle/bug786515-elliot
Reviewer Review Type Date Requested Status
Drizzle Developers 2011-05-23 Pending
Review via email: mp+62030@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/drizzle.cc'
2--- client/drizzle.cc 2011-03-14 11:43:13 +0000
3+++ client/drizzle.cc 2011-05-23 20:42:40 +0000
4@@ -154,6 +154,8 @@
5 #include <boost/scoped_ptr.hpp>
6 #include <drizzled/program_options/config_file.h>
7
8+#include "user_detect.h"
9+
10 using namespace std;
11 namespace po=boost::program_options;
12 namespace dpo=drizzled::program_options;
13@@ -1474,7 +1476,8 @@
14 _("Automatic limit for rows in a join when using --safe-updates"))
15 ;
16 #ifndef DRIZZLE_ADMIN_TOOL
17- const char* unix_user= getlogin();
18+ UserDetect *detected_user= new UserDetect();
19+ const char* shell_user= detected_user->getUser();
20 #endif
21 po::options_description client_options(_("Options specific to the client"));
22 client_options.add_options()
23@@ -1487,7 +1490,7 @@
24 #ifdef DRIZZLE_ADMIN_TOOL
25 ("user,u", po::value<string>(&current_user)->default_value("root"),
26 #else
27- ("user,u", po::value<string>(&current_user)->default_value((unix_user ? unix_user : "")),
28+ ("user,u", po::value<string>(&current_user)->default_value(shell_user ? shell_user : ""),
29 #endif
30 _("User for login if not current user."))
31 ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
32
33=== modified file 'client/drizzledump.cc'
34--- client/drizzledump.cc 2011-03-04 23:41:25 +0000
35+++ client/drizzledump.cc 2011-05-23 20:42:40 +0000
36@@ -48,6 +48,8 @@
37 #include "drizzledump_mysql.h"
38 #include "drizzledump_drizzle.h"
39
40+#include "user_detect.h"
41+
42 using namespace std;
43 using namespace drizzled;
44 namespace po= boost::program_options;
45@@ -533,7 +535,8 @@
46 _("Do not make a UTF8 connection to MySQL, use if you have UTF8 data in a non-UTF8 table"))
47 ;
48
49- const char* unix_user= getlogin();
50+ UserDetect *detected_user= new UserDetect();
51+ const char* shell_user= detected_user->getUser();
52
53 po::options_description client_options(_("Options specific to the client"));
54 client_options.add_options()
55@@ -543,7 +546,7 @@
56 _("Password to use when connecting to server. If password is not given it's solicited on the tty."))
57 ("port,p", po::value<uint32_t>(&opt_drizzle_port)->default_value(0),
58 _("Port number to use for connection."))
59- ("user,u", po::value<string>(&current_user)->default_value((unix_user ? unix_user : "")),
60+ ("user,u", po::value<string>(&current_user)->default_value((shell_user ? shell_user : "")),
61 _("User for login if not current user."))
62 ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
63 _("The protocol of connection (mysql or drizzle)."))
64
65=== modified file 'client/drizzleimport.cc'
66--- client/drizzleimport.cc 2011-03-03 22:12:08 +0000
67+++ client/drizzleimport.cc 2011-05-23 20:42:40 +0000
68@@ -31,6 +31,8 @@
69 #include <drizzled/gettext.h>
70 #include <drizzled/configmake.h>
71
72+#include "user_detect.h"
73+
74 namespace po= boost::program_options;
75 using namespace std;
76 using namespace drizzled;
77@@ -397,7 +399,8 @@
78 "Load files in parallel. The argument is the number of threads to use for loading data (default is 4.")
79 ;
80
81- const char* unix_user= getlogin();
82+ UserDetect *detected_user= new UserDetect();
83+ const char* shell_user= detected_user->getUser();
84
85 po::options_description client_options("Options specific to the client");
86 client_options.add_options()
87@@ -409,7 +412,7 @@
88 "Port number to use for connection")
89 ("protocol", po::value<string>(&opt_protocol)->default_value("mysql"),
90 "The protocol of connection (mysql or drizzle).")
91- ("user,u", po::value<string>(&current_user)->default_value((unix_user ? unix_user : "")),
92+ ("user,u", po::value<string>(&current_user)->default_value((shell_user ? shell_user : "")),
93 "User for login if not current user.")
94 ;
95
96
97=== modified file 'client/include.am'
98--- client/include.am 2011-02-21 13:59:06 +0000
99+++ client/include.am 2011-05-23 20:42:40 +0000
100@@ -58,6 +58,7 @@
101 client/statement.h \
102 client/stats.h \
103 client/thread_context.h \
104+ client/user_detect.h \
105 client/wakeup.h
106
107 client_drizzle_SOURCES= client/drizzle.cc client/linebuffer.cc
108
109=== added file 'client/user_detect.h'
110--- client/user_detect.h 1970-01-01 00:00:00 +0000
111+++ client/user_detect.h 2011-05-23 20:42:40 +0000
112@@ -0,0 +1,62 @@
113+/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
114+ * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
115+ *
116+ * Copyright (C) 2011 Andrew Hutchings
117+ *
118+ * This program is free software; you can redistribute it and/or modify
119+ * it under the terms of the GNU General Public License as published by
120+ * the Free Software Foundation; version 2 of the License.
121+ *
122+ * This program is distributed in the hope that it will be useful,
123+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
124+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
125+ * GNU General Public License for more details.
126+ *
127+ * You should have received a copy of the GNU General Public License
128+ * along with this program; if not, write to the Free Software
129+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
130+ */
131+
132+#ifndef CLIENT_USER_DETECT_H
133+#define CLIENT_USER_DETECT_H
134+
135+#include <unistd.h>
136+#include <pwd.h>
137+#include <cstring>
138+
139+class UserDetect
140+{
141+ public:
142+ const char* getUser() { return user; }
143+
144+ UserDetect() :
145+ user(NULL)
146+ {
147+ long pw_len= sysconf(_SC_GETPW_R_SIZE_MAX);
148+ struct passwd pw_struct;
149+ struct passwd* pw_tmp_struct;
150+ char *pw_buffer= new char[pw_len];
151+
152+ if (getpwuid_r(geteuid(), &pw_struct, pw_buffer, pw_len, &pw_tmp_struct) != 0)
153+ {
154+ user= NULL;
155+ }
156+ else
157+ {
158+ user= new char[strlen(pw_struct.pw_name)];
159+ strcpy(user, pw_struct.pw_name);
160+ }
161+
162+ delete[] pw_buffer;
163+ }
164+
165+ ~UserDetect()
166+ {
167+ delete[] user;
168+ }
169+
170+ private:
171+ char* user;
172+};
173+
174+#endif /* CLIENT_USER_DETECT_H */
175
176=== modified file 'plugin/console/console.cc'
177--- plugin/console/console.cc 2011-03-14 15:00:51 +0000
178+++ plugin/console/console.cc 2011-05-23 20:42:40 +0000
179@@ -27,6 +27,8 @@
180
181 #include <boost/program_options.hpp>
182
183+#include <client/user_detect.h>
184+
185 using namespace std;
186 using namespace drizzled;
187
188@@ -386,8 +388,10 @@
189 context("debug",
190 po::value<bool>(&debug_enabled)->default_value(false)->zero_tokens(),
191 N_("Turn on extra debugging."));
192+ UserDetect *detected_user= new UserDetect();
193+ const char* shell_user= detected_user->getUser();
194 context("username",
195- po::value<string>(),
196+ po::value<string>()->default_value(shell_user ? shell_user : ""),
197 N_("User to use for auth."));
198 context("password",
199 po::value<string>(),
200
201=== modified file 'plugin/haildb/plugin.ini'
202--- plugin/haildb/plugin.ini 2011-01-17 18:38:57 +0000
203+++ plugin/haildb/plugin.ini 2011-05-23 20:42:40 +0000
204@@ -6,3 +6,6 @@
205 build_conditional="x${ac_cv_libhaildb}" = "xyes"
206 ldflags=${LTLIBHAILDB}
207 testsuite=disable
208+load_by_default=no
209+static=no
210+disabled=yes
211
212=== modified file 'plugin/schema_dictionary/tests/r/data_dictionary.result'
213--- plugin/schema_dictionary/tests/r/data_dictionary.result 2011-02-23 18:20:55 +0000
214+++ plugin/schema_dictionary/tests/r/data_dictionary.result 2011-05-23 20:42:40 +0000
215@@ -420,7 +420,6 @@
216 SCOREBOARD_SIZE
217 SEGID
218 SEQUENCE_IN_INDEX
219-SESION_USERNAME
220 SESSION_CATALOG
221 SESSION_HOST
222 SESSION_ID
223@@ -428,6 +427,7 @@
224 SESSION_ID
225 SESSION_ID
226 SESSION_SCHEMA
227+SESSION_USERNAME
228 SORTLEN
229 SPACE
230 SPACE
231@@ -978,11 +978,11 @@
232 DATA_DICTIONARY SESSIONS IS_CONSOLE
233 DATA_DICTIONARY SESSIONS IS_INTERACTIVE
234 DATA_DICTIONARY SESSIONS QUERY
235-DATA_DICTIONARY SESSIONS SESION_USERNAME
236 DATA_DICTIONARY SESSIONS SESSION_CATALOG
237 DATA_DICTIONARY SESSIONS SESSION_HOST
238 DATA_DICTIONARY SESSIONS SESSION_ID
239 DATA_DICTIONARY SESSIONS SESSION_SCHEMA
240+DATA_DICTIONARY SESSIONS SESSION_USERNAME
241 DATA_DICTIONARY SESSIONS STATE
242 DATA_DICTIONARY SESSION_STATEMENTS VARIABLE_NAME
243 DATA_DICTIONARY SESSION_STATEMENTS VARIABLE_VALUE
244@@ -1770,11 +1770,11 @@
245 SESSIONS DATA_DICTIONARY IS_CONSOLE
246 SESSIONS DATA_DICTIONARY IS_INTERACTIVE
247 SESSIONS DATA_DICTIONARY QUERY
248-SESSIONS DATA_DICTIONARY SESION_USERNAME
249 SESSIONS DATA_DICTIONARY SESSION_CATALOG
250 SESSIONS DATA_DICTIONARY SESSION_HOST
251 SESSIONS DATA_DICTIONARY SESSION_ID
252 SESSIONS DATA_DICTIONARY SESSION_SCHEMA
253+SESSIONS DATA_DICTIONARY SESSION_USERNAME
254 SESSIONS DATA_DICTIONARY STATE
255 SESSION_STATEMENTS DATA_DICTIONARY VARIABLE_NAME
256 SESSION_STATEMENTS DATA_DICTIONARY VARIABLE_VALUE
257@@ -2353,11 +2353,11 @@
258 SESSIONS DATA_DICTIONARY IS_CONSOLE
259 SESSIONS DATA_DICTIONARY IS_INTERACTIVE
260 SESSIONS DATA_DICTIONARY QUERY
261-SESSIONS DATA_DICTIONARY SESION_USERNAME
262 SESSIONS DATA_DICTIONARY SESSION_CATALOG
263 SESSIONS DATA_DICTIONARY SESSION_HOST
264 SESSIONS DATA_DICTIONARY SESSION_ID
265 SESSIONS DATA_DICTIONARY SESSION_SCHEMA
266+SESSIONS DATA_DICTIONARY SESSION_USERNAME
267 SESSIONS DATA_DICTIONARY STATE
268 SESSION_STATEMENTS DATA_DICTIONARY VARIABLE_NAME
269 SESSION_STATEMENTS DATA_DICTIONARY VARIABLE_VALUE
270
271=== modified file 'plugin/session_dictionary/sessions.cc'
272--- plugin/session_dictionary/sessions.cc 2011-02-23 17:21:37 +0000
273+++ plugin/session_dictionary/sessions.cc 2011-05-23 20:42:40 +0000
274@@ -42,7 +42,7 @@
275 plugin::TableFunction("DATA_DICTIONARY", "SESSIONS")
276 {
277 add_field("SESSION_ID", plugin::TableFunction::NUMBER, 0, false);
278- add_field("SESION_USERNAME", 16);
279+ add_field("SESSION_USERNAME", 16);
280 add_field("SESSION_HOST", NI_MAXHOST);
281 add_field("SESSION_CATALOG", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH, false);
282 add_field("SESSION_SCHEMA", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH, true);

Subscribers

People subscribed via source and target branches