MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / API_ROUTINE isc_add_user

Function API_ROUTINE isc_add_user

src/yvalve/alt.cpp:849–910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847} // anonymous namespace
848
849ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS* status, const USER_SEC_DATA* input_user_data)
850{
851/**************************************
852 *
853 * i s c _ a d d _ u s e r
854 *
855 **************************************
856 *
857 * Functional description
858 * Adds a user to the server's security
859 * database.
860 * Return 0 if the user was added
861 *
862 * Return > 0 if any error occurs.
863 *
864 **************************************/
865 Auth::UserData userInfo;
866 userInfo.op = Auth::ADD_OPER;
867 Firebird::LocalStatus s;
868 Firebird::CheckStatusWrapper statusWrapper(&s);
869
870 if (input_user_data->user_name)
871 {
872 Firebird::string work = input_user_data->user_name;
873 if (work.length() > USERNAME_LENGTH) {
874 return user_error(status, isc_usrname_too_long);
875 }
876
877 Firebird::string::size_type l = work.find(' ');
878 if (l != Firebird::string::npos) {
879 work.resize(l);
880 }
881
882 userInfo.user.set(&statusWrapper, work.c_str());
883 Firebird::check(&statusWrapper);
884 userInfo.user.setEntered(&statusWrapper, 1);
885 Firebird::check(&statusWrapper);
886 }
887 else {
888 return user_error(status, isc_usrname_required);
889 }
890
891 if (input_user_data->password)
892 {
893 userInfo.pass.set(&statusWrapper, input_user_data->password);
894 Firebird::check(&statusWrapper);
895 userInfo.pass.setEntered(&statusWrapper, 1);
896 Firebird::check(&statusWrapper);
897 }
898 else {
899 return user_error(status, isc_password_required);
900 }
901
902 copyField(userInfo.u, input_user_data->uid, input_user_data->sec_flags & sec_uid_spec);
903 copyField(userInfo.g, input_user_data->gid, input_user_data->sec_flags & sec_gid_spec);
904 copyField(userInfo.group, input_user_data->group_name, input_user_data->sec_flags & sec_group_name_spec);
905 copyField(userInfo.first, input_user_data->first_name, input_user_data->sec_flags & sec_first_name_spec);
906 copyField(userInfo.middle, input_user_data->middle_name, input_user_data->sec_flags & sec_middle_name_spec);

Callers

nothing calls this directly

Calls 10

user_errorFunction · 0.85
copyFieldFunction · 0.85
executeSecurityCommandFunction · 0.85
checkFunction · 0.50
lengthMethod · 0.45
findMethod · 0.45
resizeMethod · 0.45
setMethod · 0.45
c_strMethod · 0.45
setEnteredMethod · 0.45

Tested by

no test coverage detected