File tree Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -5404,25 +5404,33 @@ static int init_server_components()
5404
5404
(void ) mi_log (1 );
5405
5405
5406
5406
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY)
5407
- if (locked_in_memory && ! getuid () )
5407
+ if (locked_in_memory)
5408
5408
{
5409
- if (setreuid ((uid_t )-1 , 0 ) == -1 )
5410
- { // this should never happen
5411
- sql_perror (" setreuid" );
5412
- unireg_abort (1 );
5409
+ int error;
5410
+ if (user_info)
5411
+ {
5412
+ DBUG_ASSERT (!getuid ());
5413
+ if (setreuid ((uid_t ) -1 , 0 ) == -1 )
5414
+ {
5415
+ sql_perror (" setreuid" );
5416
+ unireg_abort (1 );
5417
+ }
5418
+ error= mlockall (MCL_CURRENT);
5419
+ set_user (mysqld_user, user_info);
5413
5420
}
5414
- if (mlockall (MCL_CURRENT))
5421
+ else
5422
+ error= mlockall (MCL_CURRENT);
5423
+
5424
+ if (error)
5415
5425
{
5416
5426
if (global_system_variables.log_warnings )
5417
5427
sql_print_warning (" Failed to lock memory. Errno: %d\n " ,errno);
5418
5428
locked_in_memory= 0 ;
5419
5429
}
5420
- if (user_info)
5421
- set_user (mysqld_user, user_info);
5422
5430
}
5423
- else
5431
+ #else
5432
+ locked_in_memory= 0 ;
5424
5433
#endif
5425
- locked_in_memory=0 ;
5426
5434
5427
5435
ft_init_stopwords ();
5428
5436
Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ PrivateNetwork=false
42
42
User=mysql
43
43
Group=mysql
44
44
45
+ # To allow memlock to be used as non-root user if set in configuration
46
+ CapabilityBoundingSet=CAP_IPC_LOCK
47
+
45
48
# Execute pre and post scripts as root, otherwise it does it as User=
46
49
PermissionsStartOnly=true
47
50
Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ PrivateNetwork=false
49
49
User=mysql
50
50
Group=mysql
51
51
52
+ # To allow memlock to be used as non-root user if set in configuration
53
+ CapabilityBoundingSet=CAP_IPC_LOCK
54
+
52
55
# Execute pre and post scripts as root, otherwise it does it as User=
53
56
PermissionsStartOnly=true
54
57
You can’t perform that action at this time.
0 commit comments