Skip to content
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

gpg: Check is_selinux_enabled() before trying to label #313

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions librepo/gpg_gpgme.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ lr_gpg_ensure_socket_dir_exists()
int old_default_context_was_retrieved = 0;
struct selabel_handle *labeling_handle = NULL;

/* A purpose of this piece of code is to deal with applications whose
* security policy overrides a file context for temporary files but don't
* know that librepo executes GnuPG which expects a default file context. */
if (0 == getfscreatecon(&old_default_context)) {
old_default_context_was_retrieved = 1;
} else {
g_debug("Failed to retrieve a default SELinux context");
}
labeling_handle = selabel_open(SELABEL_CTX_FILE, NULL, 0);
if (labeling_handle == NULL) {
g_debug("Failed to open a SELinux labeling handle: %s", strerror(errno));
if (is_selinux_enabled()) {
/* A purpose of this piece of code is to deal with applications whose
* security policy overrides a file context for temporary files but don't
* know that librepo executes GnuPG which expects a default file context. */
if (0 == getfscreatecon(&old_default_context)) {
old_default_context_was_retrieved = 1;
} else {
g_debug("Failed to retrieve a default SELinux context");
}
labeling_handle = selabel_open(SELABEL_CTX_FILE, NULL, 0);
if (labeling_handle == NULL) {
g_debug("Failed to open a SELinux labeling handle: %s", strerror(errno));
}
}
#endif

Expand Down
Loading