Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
a4bc8a82
Commit
a4bc8a82
authored
1 year ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
This is exactly the sort of race condition pthread_once() is for.
parent
c831eb43
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Pipeline
#4490
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/sbbscon.c
+10
-11
10 additions, 11 deletions
src/sbbs3/sbbscon.c
with
10 additions
and
11 deletions
src/sbbs3/sbbscon.c
+
10
−
11
View file @
a4bc8a82
...
...
@@ -316,8 +316,15 @@ static void recycle_all()
}
#ifdef __unix__
pthread_once_t
setid_mutex_once
=
PTHREAD_ONCE_INIT
;
static
pthread_mutex_t
setid_mutex
;
static
BOOL
setid_mutex_initialized
=
0
;
static
void
init_setuid_mutex
(
void
)
{
pthread_mutex_init
(
&
setid_mutex
,
NULL
);
}
/**********************************************************
* Change uid of the calling process to the user if specified
* **********************************************************/
...
...
@@ -334,11 +341,7 @@ static BOOL do_seteuid(BOOL to_new)
if
(
old_uid
==
new_uid
&&
old_gid
==
new_gid
)
return
(
TRUE
);
/* do nothing */
if
(
!
setid_mutex_initialized
)
{
pthread_mutex_init
(
&
setid_mutex
,
NULL
);
setid_mutex_initialized
=
TRUE
;
}
pthread_once
(
&
setid_mutex_once
,
init_setuid_mutex
);
pthread_mutex_lock
(
&
setid_mutex
);
if
(
to_new
)
{
...
...
@@ -383,11 +386,7 @@ BOOL do_setuid(BOOL force)
if
(
old_uid
==
new_uid
&&
old_gid
==
new_gid
)
return
(
TRUE
);
/* do nothing */
if
(
!
setid_mutex_initialized
)
{
pthread_mutex_init
(
&
setid_mutex
,
NULL
);
setid_mutex_initialized
=
TRUE
;
}
pthread_once
(
&
setid_mutex_once
,
init_setuid_mutex
);
pthread_mutex_lock
(
&
setid_mutex
);
if
(
getegid
()
!=
old_gid
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment