mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 00:03:03 +01:00
Cleaned isc_dpb_sys_user_name and related things
This commit is contained in:
parent
36a6501e0f
commit
8b4d53703d
@ -331,7 +331,7 @@ const TEXT* ISC_get_host(Firebird::string& host)
|
||||
}
|
||||
|
||||
#ifdef UNIX
|
||||
bool ISC_get_user(Firebird::string* name, int* id, int* group, const TEXT* user_string)
|
||||
bool ISC_get_user(Firebird::string* name, int* id, int* group)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -348,40 +348,14 @@ bool ISC_get_user(Firebird::string* name, int* id, int* group, const TEXT* user_
|
||||
TEXT user_name[256];
|
||||
const TEXT* p = 0;
|
||||
|
||||
if (user_string && *user_string)
|
||||
{
|
||||
const TEXT* q = user_string;
|
||||
char* un = user_name;
|
||||
while ((*un = *q++) && *un != '.')
|
||||
++un;
|
||||
*un = 0;
|
||||
p = user_name;
|
||||
egid = euid = -1;
|
||||
#ifdef TRUST_CLIENT_VERIFICATION
|
||||
if (*q)
|
||||
{
|
||||
egid = atoi(q);
|
||||
while (*q && (*q != '.'))
|
||||
q++;
|
||||
if (*q == '.')
|
||||
{
|
||||
q++;
|
||||
euid = atoi(q);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
euid = (SLONG) geteuid();
|
||||
egid = (SLONG) getegid();
|
||||
const struct passwd* password = getpwuid(euid);
|
||||
if (password)
|
||||
p = password->pw_name;
|
||||
else
|
||||
{
|
||||
euid = (SLONG) geteuid();
|
||||
egid = (SLONG) getegid();
|
||||
const struct passwd* password = getpwuid(euid);
|
||||
if (password)
|
||||
p = password->pw_name;
|
||||
else
|
||||
p = "";
|
||||
endpwent();
|
||||
}
|
||||
p = "";
|
||||
endpwent();
|
||||
|
||||
if (name)
|
||||
*name = p;
|
||||
@ -398,7 +372,7 @@ bool ISC_get_user(Firebird::string* name, int* id, int* group, const TEXT* user_
|
||||
|
||||
|
||||
#ifdef WIN_NT
|
||||
bool ISC_get_user(Firebird::string* name, int* id, int* group, const TEXT* /*user_string*/)
|
||||
bool ISC_get_user(Firebird::string* name, int* id, int* group)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
|
@ -29,7 +29,7 @@
|
||||
bool ISC_check_process_existence(SLONG);
|
||||
TEXT* ISC_get_host(TEXT *, USHORT);
|
||||
const TEXT* ISC_get_host(Firebird::string&);
|
||||
bool ISC_get_user(Firebird::string*, int*, int*, const TEXT*);
|
||||
bool ISC_get_user(Firebird::string*, int*, int*);
|
||||
SLONG ISC_set_prefix(const TEXT*, const TEXT*);
|
||||
|
||||
// Does not add word "Database" in the beginning like gds__log_status
|
||||
|
@ -456,9 +456,8 @@ public:
|
||||
ULONG dpb_flags; // to OR'd with dbb_flags
|
||||
|
||||
// here begin compound objects
|
||||
// for constructor to work properly dpb_sys_user_name
|
||||
// for constructor to work properly dpb_user_name
|
||||
// MUST be FIRST
|
||||
string dpb_sys_user_name;
|
||||
string dpb_user_name;
|
||||
AuthReader::AuthBlock dpb_auth_block;
|
||||
string dpb_role_name;
|
||||
@ -477,7 +476,7 @@ public:
|
||||
DatabaseOptions()
|
||||
{
|
||||
memset(this, 0,
|
||||
reinterpret_cast<char*>(&this->dpb_sys_user_name) - reinterpret_cast<char*>(this));
|
||||
reinterpret_cast<char*>(&this->dpb_user_name) - reinterpret_cast<char*>(this));
|
||||
}
|
||||
|
||||
void get(const UCHAR*, USHORT, bool&);
|
||||
@ -4877,10 +4876,6 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
|
||||
dpb_dbkey_scope = (USHORT) rdr.getInt();
|
||||
break;
|
||||
|
||||
case isc_dpb_sys_user_name:
|
||||
getString(rdr, dpb_sys_user_name);
|
||||
break;
|
||||
|
||||
case isc_dpb_sql_role_name:
|
||||
getString(rdr, dpb_role_name);
|
||||
break;
|
||||
@ -6283,9 +6278,7 @@ static void getUserInfo(UserId& user, const DatabaseOptions& options)
|
||||
}
|
||||
else
|
||||
{
|
||||
string s(options.dpb_sys_user_name);
|
||||
ISC_utf8ToSystem(s);
|
||||
wheel = ISC_get_user(&name, &id, &group, s.nullStr());
|
||||
wheel = ISC_get_user(&name, &id, &group);
|
||||
ISC_systemToUtf8(name);
|
||||
if (id == 0)
|
||||
{
|
||||
|
@ -833,7 +833,7 @@ Service::Service(const TEXT* service_name, USHORT spb_length, const UCHAR* spb_d
|
||||
// we have embedded service connection, check environment and unix OS auth
|
||||
if (!fb_utils::readenv(ISC_USER, svc_username))
|
||||
{
|
||||
if (ISC_get_user(&svc_username, NULL, NULL, NULL))
|
||||
if (ISC_get_user(&svc_username, NULL, NULL))
|
||||
{
|
||||
svc_username = SYSDBA_USER_NAME;
|
||||
}
|
||||
|
@ -886,7 +886,6 @@ void API_ROUTINE isc_set_login(const UCHAR** dpb, SSHORT* dpb_size)
|
||||
case isc_dpb_version1:
|
||||
continue;
|
||||
|
||||
case isc_dpb_sys_user_name:
|
||||
case isc_dpb_user_name:
|
||||
user_seen = true;
|
||||
break;
|
||||
@ -2127,7 +2126,7 @@ void setLogin(Firebird::ClumpletWriter& dpb)
|
||||
if (!(dpb.find(isc_dpb_trusted_auth) || dpb.find(isc_dpb_address_path)))
|
||||
{
|
||||
Firebird::string username;
|
||||
if (fb_utils::readenv(ISC_USER, username) && !dpb.find(isc_dpb_sys_user_name))
|
||||
if (fb_utils::readenv(ISC_USER, username))
|
||||
{
|
||||
setTag(dpb, isc_dpb_user_name, username.c_str());
|
||||
}
|
||||
|
@ -1397,7 +1397,6 @@ ISC_STATUS API_ROUTINE GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
|
||||
UCHAR tag = newDpb.getClumpTag();
|
||||
switch (tag)
|
||||
{
|
||||
case isc_dpb_sys_user_name:
|
||||
case isc_dpb_user_name:
|
||||
case isc_dpb_password:
|
||||
case isc_dpb_sql_role_name:
|
||||
|
@ -371,7 +371,6 @@ static Firebird::GlobalPtr<PortsCleanup> inet_ports;
|
||||
rem_port* INET_analyze(const Firebird::PathName& file_name,
|
||||
ISC_STATUS* status_vector,
|
||||
const TEXT* node_name,
|
||||
const TEXT* user_string,
|
||||
bool uv_flag,
|
||||
Firebird::ClumpletReader &dpb)
|
||||
{
|
||||
@ -403,7 +402,7 @@ rem_port* INET_analyze(const Firebird::PathName& file_name,
|
||||
int eff_gid;
|
||||
int eff_uid;
|
||||
|
||||
ISC_get_user(&buffer, &eff_uid, &eff_gid, user_string);
|
||||
ISC_get_user(&buffer, &eff_uid, &eff_gid);
|
||||
user_id.insertString(CNCT_user, buffer);
|
||||
|
||||
ISC_get_host(buffer);
|
||||
|
@ -31,7 +31,7 @@ namespace Firebird
|
||||
class ClumpletReader;
|
||||
}
|
||||
|
||||
rem_port* INET_analyze(const Firebird::PathName&, ISC_STATUS*, const TEXT*, const TEXT*,
|
||||
rem_port* INET_analyze(const Firebird::PathName&, ISC_STATUS*, const TEXT*,
|
||||
bool, Firebird::ClumpletReader&);
|
||||
rem_port* INET_connect(const TEXT*, struct packet*, ISC_STATUS*, USHORT, Firebird::ClumpletReader*);
|
||||
rem_port* INET_reconnect(SOCKET, ISC_STATUS*);
|
||||
|
@ -337,7 +337,7 @@ int CLIB_ROUTINE main( int argc, char** argv)
|
||||
#ifndef DEV_BUILD
|
||||
Firebird::string user_name; // holds the user name
|
||||
// check user id
|
||||
ISC_get_user(&user_name, NULL, NULL, NULL);
|
||||
ISC_get_user(&user_name, NULL, NULL);
|
||||
|
||||
if (user_name != "root" &&
|
||||
user_name != FIREBIRD_USER_NAME &&
|
||||
|
@ -101,12 +101,11 @@ namespace {
|
||||
// for both services and databases attachments
|
||||
struct ParametersSet
|
||||
{
|
||||
UCHAR dummy_packet_interval, user_name, sys_user_name,
|
||||
UCHAR dummy_packet_interval, user_name,
|
||||
password, password_enc, address_path, process_id, process_name;
|
||||
};
|
||||
const ParametersSet dpbParam = {isc_dpb_dummy_packet_interval,
|
||||
isc_dpb_user_name,
|
||||
isc_dpb_sys_user_name,
|
||||
isc_dpb_password,
|
||||
isc_dpb_password_enc,
|
||||
isc_dpb_address_path,
|
||||
@ -114,7 +113,6 @@ namespace {
|
||||
isc_dpb_process_name};
|
||||
const ParametersSet spbParam = {isc_spb_dummy_packet_interval,
|
||||
isc_spb_user_name,
|
||||
isc_spb_sys_user_name,
|
||||
isc_spb_password,
|
||||
isc_spb_password_enc,
|
||||
isc_spb_address_path,
|
||||
@ -125,8 +123,8 @@ namespace {
|
||||
static Rvnt* add_event(rem_port*);
|
||||
static void add_other_params(rem_port*, ClumpletWriter&, const ParametersSet&);
|
||||
static void add_working_directory(ClumpletWriter&, const PathName&);
|
||||
static rem_port* analyze(PathName&, ISC_STATUS*, const TEXT*, bool, ClumpletReader&, PathName&, bool);
|
||||
static rem_port* analyze_service(PathName&, ISC_STATUS*, const TEXT*, bool, ClumpletReader&, bool);
|
||||
static rem_port* analyze(PathName&, ISC_STATUS*, bool, ClumpletReader&, PathName&, bool);
|
||||
static rem_port* analyze_service(PathName&, ISC_STATUS*, bool, ClumpletReader&, bool);
|
||||
static bool batch_gds_receive(rem_port*, struct rmtque *, ISC_STATUS *, USHORT);
|
||||
static bool batch_dsql_fetch(rem_port*, struct rmtque *, ISC_STATUS *, USHORT);
|
||||
static bool check_response(Rdb*, PACKET *);
|
||||
@ -138,7 +136,7 @@ static void dequeue_receive(rem_port*);
|
||||
static THREAD_ENTRY_DECLARE event_thread(THREAD_ENTRY_PARAM);
|
||||
static ISC_STATUS fetch_blob(ISC_STATUS*, Rsr*, USHORT, UCHAR*, USHORT, USHORT, UCHAR*);
|
||||
static Rvnt* find_event(rem_port*, SLONG);
|
||||
static bool get_new_dpb(ClumpletWriter&, string&, const ParametersSet&);
|
||||
static bool get_new_dpb(ClumpletWriter&, const ParametersSet&);
|
||||
#ifdef UNIX
|
||||
static bool get_single_user(ClumpletReader&);
|
||||
#endif
|
||||
@ -298,14 +296,11 @@ static ISC_STATUS remloop_att(ISC_STATUS* user_status,
|
||||
}
|
||||
#endif
|
||||
|
||||
string user_string;
|
||||
const bool user_verification = get_new_dpb(newDpb, user_string, dpbParam);
|
||||
|
||||
const TEXT* us = user_string.hasData() ? user_string.c_str() : NULL;
|
||||
const bool user_verification = get_new_dpb(newDpb, dpbParam);
|
||||
|
||||
PathName expanded_name(filename);
|
||||
PathName node_name;
|
||||
rem_port* port = analyze(expanded_name, user_status, us, user_verification,
|
||||
rem_port* port = analyze(expanded_name, user_status, user_verification,
|
||||
newDpb, node_name, loopback);
|
||||
|
||||
if (!port)
|
||||
@ -873,13 +868,11 @@ static ISC_STATUS remloop_create(ISC_STATUS* user_status,
|
||||
}
|
||||
#endif
|
||||
|
||||
string user_string;
|
||||
const bool user_verification = get_new_dpb(newDpb, user_string, dpbParam);
|
||||
const TEXT* us = user_string.hasData() ? user_string.c_str() : NULL;
|
||||
const bool user_verification = get_new_dpb(newDpb, dpbParam);
|
||||
|
||||
PathName expanded_name(filename);
|
||||
PathName node_name;
|
||||
rem_port* port = analyze(expanded_name, user_status, us, user_verification,
|
||||
rem_port* port = analyze(expanded_name, user_status, user_verification,
|
||||
newDpb, node_name, loopback);
|
||||
|
||||
if (!port) {
|
||||
@ -3897,12 +3890,10 @@ static ISC_STATUS remloop_svc(ISC_STATUS* user_status,
|
||||
{
|
||||
ClumpletWriter newSpb(ClumpletReader::spbList, MAX_DPB_SIZE,
|
||||
reinterpret_cast<const UCHAR*>(spb), spb_length);
|
||||
string user_string;
|
||||
|
||||
const bool user_verification = get_new_dpb(newSpb, user_string, spbParam);
|
||||
const TEXT* us = user_string.hasData() ? user_string.c_str() : NULL;
|
||||
const bool user_verification = get_new_dpb(newSpb, spbParam);
|
||||
|
||||
rem_port* port = analyze_service(expanded_name, user_status, us,
|
||||
rem_port* port = analyze_service(expanded_name, user_status,
|
||||
user_verification, newSpb, loopback);
|
||||
|
||||
if (!port) {
|
||||
@ -4692,7 +4683,6 @@ static void add_working_directory(ClumpletWriter& dpb, const PathName& node_name
|
||||
|
||||
static rem_port* analyze(PathName& file_name,
|
||||
ISC_STATUS* status_vector,
|
||||
const TEXT* user_string,
|
||||
bool uv_flag,
|
||||
ClumpletReader& dpb,
|
||||
PathName& node_name,
|
||||
@ -4744,7 +4734,7 @@ static rem_port* analyze(PathName& file_name,
|
||||
node_name = INET_LOCALHOST;
|
||||
}
|
||||
return INET_analyze(file_name, status_vector,
|
||||
node_name.c_str(), user_string, uv_flag, dpb);
|
||||
node_name.c_str(), uv_flag, dpb);
|
||||
}
|
||||
|
||||
// We have a local connection string. If it's a file on a network share,
|
||||
@ -4769,7 +4759,7 @@ static rem_port* analyze(PathName& file_name,
|
||||
if (ISC_analyze_nfs(expanded_name, node_name))
|
||||
{
|
||||
port = INET_analyze(expanded_name, status_vector,
|
||||
node_name.c_str(), user_string, uv_flag, dpb);
|
||||
node_name.c_str(), uv_flag, dpb);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -4799,7 +4789,7 @@ static rem_port* analyze(PathName& file_name,
|
||||
if (!port)
|
||||
{
|
||||
port = INET_analyze(file_name, status_vector,
|
||||
INET_LOCALHOST, user_string, uv_flag, dpb);
|
||||
INET_LOCALHOST, uv_flag, dpb);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4809,7 +4799,6 @@ static rem_port* analyze(PathName& file_name,
|
||||
|
||||
static rem_port* analyze_service(PathName& service_name,
|
||||
ISC_STATUS* status_vector,
|
||||
const TEXT* user_string,
|
||||
bool uv_flag,
|
||||
ClumpletReader& spb,
|
||||
bool loopback)
|
||||
@ -4859,7 +4848,7 @@ static rem_port* analyze_service(PathName& service_name,
|
||||
node_name = INET_LOCALHOST;
|
||||
}
|
||||
return INET_analyze(service_name, status_vector,
|
||||
node_name.c_str(), user_string, uv_flag, spb);
|
||||
node_name.c_str(), uv_flag, spb);
|
||||
}
|
||||
|
||||
if (!loopback)
|
||||
@ -4889,7 +4878,7 @@ static rem_port* analyze_service(PathName& service_name,
|
||||
if (!port)
|
||||
{
|
||||
port = INET_analyze(service_name, status_vector,
|
||||
INET_LOCALHOST, user_string, uv_flag, spb);
|
||||
INET_LOCALHOST, uv_flag, spb);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5546,7 +5535,7 @@ static Rvnt* find_event( rem_port* port, SLONG id)
|
||||
}
|
||||
|
||||
|
||||
static bool get_new_dpb(ClumpletWriter& dpb, string& user_string, const ParametersSet& par)
|
||||
static bool get_new_dpb(ClumpletWriter& dpb, const ParametersSet& par)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -5584,16 +5573,6 @@ static bool get_new_dpb(ClumpletWriter& dpb, string& user_string, const Paramete
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dpb.find(par.sys_user_name))
|
||||
{
|
||||
dpb.getString(user_string);
|
||||
dpb.deleteClumplet();
|
||||
}
|
||||
else
|
||||
{
|
||||
user_string.erase();
|
||||
}
|
||||
|
||||
return dpb.find(par.user_name);
|
||||
}
|
||||
|
||||
@ -5811,7 +5790,6 @@ static bool init(ISC_STATUS* user_status,
|
||||
{
|
||||
// Do not check isc_dpb_trusted_auth here. It's just bytes.
|
||||
case isc_dpb_org_filename:
|
||||
case isc_dpb_sys_user_name:
|
||||
case isc_dpb_user_name:
|
||||
case isc_dpb_password:
|
||||
case isc_dpb_sql_role_name:
|
||||
|
@ -143,7 +143,7 @@ rem_port* WNET_analyze(const Firebird::PathName& file_name,
|
||||
Firebird::string buffer;
|
||||
Firebird::ClumpletWriter user_id(Firebird::ClumpletReader::UnTagged, MAX_DPB_SIZE);
|
||||
|
||||
ISC_get_user(&buffer, 0, 0, 0);
|
||||
ISC_get_user(&buffer, 0, 0);
|
||||
buffer.lower();
|
||||
user_id.insertString(CNCT_user, buffer);
|
||||
|
||||
|
@ -212,7 +212,7 @@ rem_port* XNET_analyze(const Firebird::PathName& file_name,
|
||||
Firebird::string buffer;
|
||||
Firebird::ClumpletWriter user_id(Firebird::ClumpletReader::UnTagged, MAX_DPB_SIZE);
|
||||
|
||||
ISC_get_user(&buffer, 0, 0, 0);
|
||||
ISC_get_user(&buffer, 0, 0);
|
||||
buffer.lower();
|
||||
user_id.insertString(CNCT_user, buffer);
|
||||
|
||||
|
@ -134,7 +134,7 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
||||
|
||||
// check user id
|
||||
Firebird::string user_name; // holds the user name
|
||||
ISC_get_user(&user_name, NULL, NULL, NULL);
|
||||
ISC_get_user(&user_name, NULL, NULL);
|
||||
|
||||
if (user_name != INTERBASE_USER && user_name != "root" && user_name != FIREBIRD_USER &&
|
||||
user_name != INTERBASE_USER_SHORT)
|
||||
|
Loading…
Reference in New Issue
Block a user