111
/**************************************************************************
112
Change user and database
113
**************************************************************************/
115
int drizzleclient_cli_read_change_user_result(DRIZZLE *drizzle)
119
pkt_length= drizzleclient_cli_safe_read(drizzle);
121
if (pkt_length == packet_error)
127
bool drizzleclient_change_user(DRIZZLE *drizzle, const char *user,
128
const char *passwd, const char *db)
130
char buff[USERNAME_LENGTH+SCRAMBLED_PASSWORD_CHAR_LENGTH+NAME_LEN+2];
134
/* Use an empty string instead of NULL. */
141
/* Store user into the buffer */
142
end= strncpy(end, user, USERNAME_LENGTH) + USERNAME_LENGTH + 1;
144
/* write scrambled password according to server capabilities */
148
*end++= SCRAMBLE_LENGTH;
149
end+= SCRAMBLE_LENGTH;
153
*end++= '\0'; /* empty password */
154
/* Add database if needed */
155
end= strncpy(end, db ? db : "", NAME_LEN) + NAME_LEN + 1;
157
/* Add character set number. */
158
if (drizzle->server_capabilities & CLIENT_SECURE_CONNECTION)
160
int2store(end, (uint16_t) 45); // utf8mb4 number from mystrings/ctype-utf8.c
164
/* Write authentication package */
165
(void)simple_command(drizzle,COM_CHANGE_USER, (unsigned char*) buff, (uint32_t) (end-buff), 1);
167
rc= (*drizzle->methods->read_change_user_result)(drizzle);
171
/* Free old connect information */
175
free(drizzle->passwd);
179
/* alloc new connect information */
180
drizzle->user= strdup(user);
181
drizzle->passwd= strdup(passwd);
182
drizzle->db= db ? strdup(db) : 0;
188
111
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
189
112
struct passwd *getpwuid(uid_t);
190
113
char* getlogin(void);