MCPcopy Create free account
hub / github.com/MariaDB/server / acl_getroot

Function acl_getroot

sql/sql_acl.cc:3334–3406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3332*/
3333
3334bool acl_getroot(Security_context *sctx,
3335 const LEX_CSTRING &user, const LEX_CSTRING &host,
3336 const LEX_CSTRING &ip, const LEX_CSTRING &db)
3337{
3338 int res= 1;
3339 ACL_USER *acl_user= 0;
3340 DBUG_ENTER("acl_getroot");
3341
3342 DBUG_PRINT("enter", ("Host: '%s', Ip: '%s', User: '%s', db: '%s'",
3343 host.str, ip.str, user.str, db.str));
3344 sctx->init();
3345 sctx->user= *user.str ? user.str : NULL;
3346 sctx->host= host.str;
3347 sctx->ip= ip.str;
3348 sctx->host_or_ip= host.str ? host.str : (safe_str(ip.str));
3349
3350 if (!initialized)
3351 {
3352 /*
3353 here if mysqld's been started with --skip-grant-tables option.
3354 */
3355 sctx->skip_grants();
3356 DBUG_RETURN(FALSE);
3357 }
3358
3359 mysql_mutex_lock(&acl_cache->lock);
3360
3361 sctx->db_access= NO_ACL;
3362
3363 if (host.str[0]) // User, not Role
3364 {
3365 acl_user= find_user_wild(host, user, ip);
3366
3367 if (acl_user)
3368 {
3369 res= 0;
3370 if (ACL_DB *acl_db= acl_db_find(db.str, user.str, host.str, ip.str, FALSE))
3371 sctx->db_access= acl_db->access;
3372
3373 sctx->master_access= acl_user->access;
3374
3375 strmake_buf(sctx->priv_user, user.str);
3376
3377 if (acl_user->host.hostname)
3378 strmake_buf(sctx->priv_host, acl_user->host.hostname);
3379 }
3380 }
3381 else // Role, not User
3382 {
3383 ACL_ROLE *acl_role= find_acl_role(user, false);
3384 if (acl_role)
3385 {
3386 res= 0;
3387 if (ACL_DB *acl_db= acl_db_find(db.str, user.str, "", "", FALSE))
3388 sctx->db_access = acl_db->access;
3389
3390 sctx->master_access= acl_role->access;
3391

Callers 2

Calls 6

safe_strFunction · 0.85
find_user_wildFunction · 0.85
acl_db_findFunction · 0.85
find_acl_roleFunction · 0.85
skip_grantsMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected