-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Further restriction of child processes capabilities (part 2) #7703
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7cd13b2
KRB5: verbosity around ccname handling
alexey-tikhonov 0fa54aa
KRB5: don't pre-create parent dir(s) of wanted DIR:/FILE:
alexey-tikhonov 46f9fef
KRB5: skip `switch_creds()` in PKINIT case
alexey-tikhonov 6d8800e
KRB5: 'fast-ccache-uid/gid' args aren't used anymore
alexey-tikhonov 983aedf
KRB5: don't require effective CAP_DAC_READ_SEARCH
alexey-tikhonov 0d7cba9
KRB5: verbosity
alexey-tikhonov ece1574
KRB5: drop cap_set*id as soon as possible
alexey-tikhonov 1b152da
KRB5: 'krb5_child' doesn't require effective capabilities
alexey-tikhonov 771ecee
become_user() moved to src/monitor
alexey-tikhonov 856ade4
KRB5: cosmetics
alexey-tikhonov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
SSSD | ||
|
||
Kerberos 5 Backend Module -- Utilities | ||
|
||
Authors: | ||
Sumit Bose <sbose@redhat.com> | ||
|
||
Copyright (C) 2009 Red Hat | ||
|
||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "util/util.h" | ||
#include <grp.h> | ||
|
||
errno_t become_user(uid_t uid, gid_t gid, bool keep_set_uid) | ||
{ | ||
uid_t cuid; | ||
int ret = EOK; | ||
|
||
DEBUG(SSSDBG_FUNC_DATA, | ||
"Trying to become user [%"SPRIuid"][%"SPRIgid"].\n", uid, gid); | ||
|
||
/* skip call if we already are the requested user */ | ||
cuid = geteuid(); | ||
if (uid == cuid) { | ||
DEBUG(SSSDBG_FUNC_DATA, "Already user [%"SPRIuid"].\n", uid); | ||
goto done; | ||
} | ||
|
||
/* drop supplementary groups first */ | ||
ret = setgroups(0, NULL); | ||
if (ret == -1) { | ||
ret = errno; | ||
DEBUG(SSSDBG_CRIT_FAILURE, | ||
"setgroups failed [%d][%s].\n", ret, strerror(ret)); | ||
goto done; | ||
} | ||
|
||
/* change GID so that root cannot be regained (changes saved GID too) */ | ||
ret = setresgid(gid, gid, gid); | ||
if (ret == -1) { | ||
ret = errno; | ||
DEBUG(SSSDBG_CRIT_FAILURE, | ||
"setresgid failed [%d][%s].\n", ret, strerror(ret)); | ||
goto done; | ||
} | ||
|
||
/* change UID so that root cannot be regained (changes saved UID too) */ | ||
/* this call also takes care of dropping CAP_SETUID, so this is a PNR */ | ||
ret = setresuid(uid, uid, (keep_set_uid ? -1 : uid)); | ||
if (ret == -1) { | ||
ret = errno; | ||
DEBUG(SSSDBG_CRIT_FAILURE, | ||
"setresuid failed [%d][%s].\n", ret, strerror(ret)); | ||
goto done; | ||
} | ||
|
||
done: | ||
sss_drop_all_caps(); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who creates it now? /run/user/$UID is created by systemd, but what if the path is different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not SSSD business -
kinit
doesn't either. See discussion in the team mail list.