#include <user_management_commands.h>
Inheritance diagram for Add_user_cmd:


Public Member Functions | |
| Add_user_cmd () | |
| virtual int | execute () |
Definition at line 83 of file user_management_commands.h.
| Add_user_cmd::Add_user_cmd | ( | ) | [inline] |
| int Add_user_cmd::execute | ( | ) | [virtual] |
Implements User_management_cmd.
Definition at line 215 of file user_management_commands.cc.
References User_map::add_user(), ERR_CAN_NOT_READ_PASSWORD, ERR_CAN_NOT_READ_USER_NAME, ERR_OK, ERR_OUT_OF_MEMORY, ERR_USER_ALREADY_EXISTS, User_map::find_user(), get_password(), get_user_name(), load_password_file(), save_password_file(), and LEX_STRING::str.
00216 { 00217 LEX_STRING user_name; 00218 const char *password; 00219 00220 User_map user_map; 00221 User *new_user; 00222 00223 int err_code; 00224 00225 if (get_user_name(&user_name)) 00226 return ERR_CAN_NOT_READ_USER_NAME; 00227 00228 /* Load the password file. */ 00229 00230 if ((err_code= load_password_file(&user_map)) != ERR_OK) 00231 return err_code; 00232 00233 /* Check that the user does not exist. */ 00234 00235 if (user_map.find_user(&user_name)) 00236 { 00237 fprintf(stderr, "Error: user '%s' already exists.\n", 00238 (const char *) user_name.str); 00239 return ERR_USER_ALREADY_EXISTS; 00240 } 00241 00242 /* Add the user. */ 00243 00244 if (!(password= get_password())) 00245 return ERR_CAN_NOT_READ_PASSWORD; 00246 00247 if (!(new_user= new User(&user_name, password))) 00248 return ERR_OUT_OF_MEMORY; 00249 00250 if (user_map.add_user(new_user)) 00251 { 00252 delete new_user; 00253 return ERR_OUT_OF_MEMORY; 00254 } 00255 00256 /* Save the password file. */ 00257 00258 return save_password_file(&user_map); 00259 }
Here is the call graph for this function:

1.4.7

