authselect/SOURCES/0029-lib-remove-no-longer-supported-features-in-apply-cha.patch
2021-09-09 14:53:19 +00:00

70 lines
1.9 KiB
Diff

From 62746460cce0620a8f2150971019f0c535caa360 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Tue, 20 Nov 2018 12:07:22 +0100
Subject: [PATCH 11/15] lib: remove no longer supported features in
apply-changes
Resolves:
https://github.com/pbrezina/authselect/issues/107
---
src/lib/authselect.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/lib/authselect.c b/src/lib/authselect.c
index 1b4337e2e0eae4f298e59f90cc9c8659891e23f3..e0b8b1246b0e7139494d90cca4e0ebed3eb66376 100644
--- a/src/lib/authselect.c
+++ b/src/lib/authselect.c
@@ -145,17 +145,49 @@ done:
_PUBLIC_ int
authselect_apply_changes(void)
{
+ struct authselect_profile *profile;
char *profile_id;
char **features;
+ char **supported;
errno_t ret;
+ int i;
ret = authselect_current_configuration(&profile_id, &features);
if (ret != EOK) {
return ret;
}
+ ret = authselect_profile(profile_id, &profile);
+ if (ret != EOK) {
+ ERROR("Unable to find profile [%s] [%d]: %s",
+ profile_id, ret, strerror(ret));
+ goto done;
+ }
+
+ supported = authselect_profile_features(profile);
+ if (supported == NULL) {
+ ERROR("Unable to obtain supported features");
+ ret = ENOMEM;
+ goto done;
+ }
+
+ for (i = 0; features[i] != NULL; i++) {
+ if (string_array_has_value(supported, features[i])) {
+ continue;
+ }
+
+ WARN("Profile feature [%s] is no longer supported, removing it...",
+ features[i]);
+
+ features = string_array_del_value(features, features[i]);
+ i--;
+ }
+
ret = authselect_activate(profile_id, (const char **)features, false);
+done:
+ authselect_profile_free(profile);
+ string_array_free(supported);
string_array_free(features);
free(profile_id);
--
2.17.2