authselect-1.0.3-1: rebase to 1.0.3
This commit is contained in:
parent
3a1e8613fe
commit
4114f8da60
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@
|
||||
/authselect-1.0.tar.gz
|
||||
/authselect-1.0.1.tar.gz
|
||||
/authselect-1.0.2.tar.gz
|
||||
/authselect-1.0.3.tar.gz
|
||||
|
||||
@ -1,221 +0,0 @@
|
||||
From 7cadfbf00aed1ba88bf593b02ee5946ba5f54bde Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
||||
Date: Wed, 28 Nov 2018 13:45:33 +0100
|
||||
Subject: [PATCH 1/3] util: remove duplicate values correctly in
|
||||
string_array_del_value
|
||||
|
||||
---
|
||||
src/lib/util/string_array.c | 27 ++++--
|
||||
src/tests/test_util_string_array.c | 146 ++++++++++++++++++++++++++++-
|
||||
2 files changed, 163 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/lib/util/string_array.c b/src/lib/util/string_array.c
|
||||
index e56d66bdcce7c8a1cf99f9b91068614c4b8d3d81..a8afa5ab8edbb26d6f946619f9ce0b83c511bb8c 100644
|
||||
--- a/src/lib/util/string_array.c
|
||||
+++ b/src/lib/util/string_array.c
|
||||
@@ -140,24 +140,33 @@ string_array_add_value(char **array, const char *value, bool unique)
|
||||
char **
|
||||
string_array_del_value(char **array, const char *value)
|
||||
{
|
||||
- bool found = false;
|
||||
- int i;
|
||||
+ size_t count;
|
||||
+ size_t pos;
|
||||
+ size_t i;
|
||||
|
||||
- if (!string_array_has_value(array, value)) {
|
||||
- return array;
|
||||
+ if (array == NULL) {
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
- for (i = 0; array[i] != NULL; i++) {
|
||||
- if (strcmp(value, array[i]) == 0) {
|
||||
+ count = string_array_count(array);
|
||||
+ for (i = 0; i < count; i++) {
|
||||
+ if (strcmp(array[i], value) == 0) {
|
||||
free(array[i]);
|
||||
- found = true;
|
||||
+ array[i] = NULL;
|
||||
}
|
||||
+ }
|
||||
|
||||
- if (found) {
|
||||
- array[i] = array[i + 1];
|
||||
+ for (i = 0, pos = 0; i < count; i++) {
|
||||
+ if (array[i] != NULL) {
|
||||
+ array[pos] = array[i];
|
||||
+ pos++;
|
||||
}
|
||||
}
|
||||
|
||||
+ for (; pos < count; pos++) {
|
||||
+ array[pos] = NULL;
|
||||
+ }
|
||||
+
|
||||
return array;
|
||||
}
|
||||
|
||||
diff --git a/src/tests/test_util_string_array.c b/src/tests/test_util_string_array.c
|
||||
index 4f6812e9396f04bbbfb72bda8a9022501f074faf..249cb96acea3c4feac910702572cafb1025d9496 100644
|
||||
--- a/src/tests/test_util_string_array.c
|
||||
+++ b/src/tests/test_util_string_array.c
|
||||
@@ -32,11 +32,155 @@ void test_string_array_create(void **state)
|
||||
string_array_free(array);
|
||||
}
|
||||
|
||||
+void test_string_array_del_value__single(void **state)
|
||||
+{
|
||||
+ char **array;
|
||||
+ const char *values[] = {"1", "2", "3", "4", "5", NULL};
|
||||
+ const char *expected[] = {"1", "3", "4", "5", NULL};
|
||||
+ int i;
|
||||
+
|
||||
+ array = string_array_create(10);
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ /* Fill array. */
|
||||
+ for (i = 0; values[i] != NULL; i++) {
|
||||
+ array = string_array_add_value(array, values[i], false);
|
||||
+ assert_non_null(array);
|
||||
+ assert_non_null(array[i]);
|
||||
+ }
|
||||
+ assert_null(array[i]);
|
||||
+
|
||||
+ /* Delete value. */
|
||||
+ array = string_array_del_value(array, "2");
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ /* Test values. */
|
||||
+ for (i = 0; expected[i] != NULL; i++) {
|
||||
+ assert_non_null(array[i]);
|
||||
+ assert_string_equal(array[i], expected[i]);
|
||||
+ }
|
||||
+ assert_null(array[i]);
|
||||
+
|
||||
+ string_array_free(array);
|
||||
+}
|
||||
+
|
||||
+void test_string_array_del_value__single_repeated(void **state)
|
||||
+{
|
||||
+ char **array;
|
||||
+ const char *values[] = {"1", "2", "2", "3", "2", "4", "2", "5", NULL};
|
||||
+ const char *expected[] = {"1", "3", "4", "5", NULL};
|
||||
+ int i;
|
||||
+
|
||||
+ array = string_array_create(10);
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ /* Fill array. */
|
||||
+ for (i = 0; values[i] != NULL; i++) {
|
||||
+ array = string_array_add_value(array, values[i], false);
|
||||
+ assert_non_null(array);
|
||||
+ assert_non_null(array[i]);
|
||||
+ }
|
||||
+ assert_null(array[i]);
|
||||
+
|
||||
+ /* Delete value. */
|
||||
+ array = string_array_del_value(array, "2");
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ /* Test values. */
|
||||
+ for (i = 0; expected[i] != NULL; i++) {
|
||||
+ assert_non_null(array[i]);
|
||||
+ assert_string_equal(array[i], expected[i]);
|
||||
+ }
|
||||
+ assert_null(array[i]);
|
||||
+
|
||||
+ string_array_free(array);
|
||||
+}
|
||||
+
|
||||
+void test_string_array_del_value__multiple(void **state)
|
||||
+{
|
||||
+ char **array;
|
||||
+ const char *values[] = {"1", "2", "3", "4", "5", NULL};
|
||||
+ const char *expected[] = {"1", "4", NULL};
|
||||
+ int i;
|
||||
+
|
||||
+ array = string_array_create(10);
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ /* Fill array. */
|
||||
+ for (i = 0; values[i] != NULL; i++) {
|
||||
+ array = string_array_add_value(array, values[i], false);
|
||||
+ assert_non_null(array);
|
||||
+ assert_non_null(array[i]);
|
||||
+ }
|
||||
+ assert_null(array[i]);
|
||||
+
|
||||
+ /* Delete value. */
|
||||
+ array = string_array_del_value(array, "2");
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ array = string_array_del_value(array, "3");
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ array = string_array_del_value(array, "5");
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ /* Test values. */
|
||||
+ for (i = 0; expected[i] != NULL; i++) {
|
||||
+ assert_non_null(array[i]);
|
||||
+ assert_string_equal(array[i], expected[i]);
|
||||
+ }
|
||||
+ assert_null(array[i]);
|
||||
+
|
||||
+ string_array_free(array);
|
||||
+}
|
||||
+
|
||||
+void test_string_array_del_value__multiple_repeated(void **state)
|
||||
+{
|
||||
+ char **array;
|
||||
+ const char *values[] = {"1", "2", "2", "3", "3", "2", "4", "2", "5", "5", NULL};
|
||||
+ const char *expected[] = {"1", "4", NULL};
|
||||
+ int i;
|
||||
+
|
||||
+ array = string_array_create(10);
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ /* Fill array. */
|
||||
+ for (i = 0; values[i] != NULL; i++) {
|
||||
+ array = string_array_add_value(array, values[i], false);
|
||||
+ assert_non_null(array);
|
||||
+ assert_non_null(array[i]);
|
||||
+ }
|
||||
+ assert_null(array[i]);
|
||||
+
|
||||
+ /* Delete value. */
|
||||
+ array = string_array_del_value(array, "2");
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ array = string_array_del_value(array, "3");
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ array = string_array_del_value(array, "5");
|
||||
+ assert_non_null(array);
|
||||
+
|
||||
+ /* Test values. */
|
||||
+ for (i = 0; expected[i] != NULL; i++) {
|
||||
+ assert_non_null(array[i]);
|
||||
+ assert_string_equal(array[i], expected[i]);
|
||||
+ }
|
||||
+ assert_null(array[i]);
|
||||
+
|
||||
+ string_array_free(array);
|
||||
+}
|
||||
+
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
|
||||
const struct CMUnitTest tests[] = {
|
||||
- cmocka_unit_test(test_string_array_create)
|
||||
+ cmocka_unit_test(test_string_array_create),
|
||||
+ cmocka_unit_test(test_string_array_del_value__single),
|
||||
+ cmocka_unit_test(test_string_array_del_value__single_repeated),
|
||||
+ cmocka_unit_test(test_string_array_del_value__multiple),
|
||||
+ cmocka_unit_test(test_string_array_del_value__multiple_repeated)
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
--
|
||||
2.17.2
|
||||
@ -1,149 +0,0 @@
|
||||
From 137a80790f2a81b9b405717579a1682f36f8655f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
||||
Date: Wed, 28 Nov 2018 13:59:51 +0100
|
||||
Subject: [PATCH 2/3] util: do not return value from string_array_del_value
|
||||
|
||||
It is not needed.
|
||||
---
|
||||
src/lib/authselect.c | 9 ++-------
|
||||
src/lib/util/string_array.c | 6 +++---
|
||||
src/lib/util/string_array.h | 2 +-
|
||||
src/tests/test_util_string_array.c | 28 ++++++++--------------------
|
||||
4 files changed, 14 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/src/lib/authselect.c b/src/lib/authselect.c
|
||||
index e0b8b1246b0e7139494d90cca4e0ebed3eb66376..0f8d4a8b6d0b0faef81daf176486108ed0ea74db 100644
|
||||
--- a/src/lib/authselect.c
|
||||
+++ b/src/lib/authselect.c
|
||||
@@ -179,7 +179,7 @@ authselect_apply_changes(void)
|
||||
WARN("Profile feature [%s] is no longer supported, removing it...",
|
||||
features[i]);
|
||||
|
||||
- features = string_array_del_value(features, features[i]);
|
||||
+ string_array_del_value(features, features[i]);
|
||||
i--;
|
||||
}
|
||||
|
||||
@@ -247,15 +247,10 @@ authselect_feature_disable(const char *feature)
|
||||
return ret;
|
||||
}
|
||||
|
||||
- features = string_array_del_value(features, feature);
|
||||
- if (features == NULL) {
|
||||
- ret = ENOMEM;
|
||||
- goto done;
|
||||
- }
|
||||
+ string_array_del_value(features, feature);
|
||||
|
||||
ret = authselect_activate(profile_id, (const char **)features, false);
|
||||
|
||||
-done:
|
||||
string_array_free(features);
|
||||
free(profile_id);
|
||||
|
||||
diff --git a/src/lib/util/string_array.c b/src/lib/util/string_array.c
|
||||
index a8afa5ab8edbb26d6f946619f9ce0b83c511bb8c..e8871dc067fbf3d461d1ee9579813ddc81eef676 100644
|
||||
--- a/src/lib/util/string_array.c
|
||||
+++ b/src/lib/util/string_array.c
|
||||
@@ -137,7 +137,7 @@ string_array_add_value(char **array, const char *value, bool unique)
|
||||
return string_array_add_value_safe(array, value, strlen(value), unique);
|
||||
}
|
||||
|
||||
-char **
|
||||
+void
|
||||
string_array_del_value(char **array, const char *value)
|
||||
{
|
||||
size_t count;
|
||||
@@ -145,7 +145,7 @@ string_array_del_value(char **array, const char *value)
|
||||
size_t i;
|
||||
|
||||
if (array == NULL) {
|
||||
- return NULL;
|
||||
+ return;
|
||||
}
|
||||
|
||||
count = string_array_count(array);
|
||||
@@ -167,7 +167,7 @@ string_array_del_value(char **array, const char *value)
|
||||
array[pos] = NULL;
|
||||
}
|
||||
|
||||
- return array;
|
||||
+ return;
|
||||
}
|
||||
|
||||
char **
|
||||
diff --git a/src/lib/util/string_array.h b/src/lib/util/string_array.h
|
||||
index ba9760b5d66a9619ca8edea5e3418c5cfbbec929..5842db174563982528e20354138ef5792346fb37 100644
|
||||
--- a/src/lib/util/string_array.h
|
||||
+++ b/src/lib/util/string_array.h
|
||||
@@ -115,7 +115,7 @@ string_array_add_value(char **array, const char *value, bool unique);
|
||||
*
|
||||
* @return Array without the value.
|
||||
*/
|
||||
-char **
|
||||
+void
|
||||
string_array_del_value(char **array, const char *value);
|
||||
|
||||
/**
|
||||
diff --git a/src/tests/test_util_string_array.c b/src/tests/test_util_string_array.c
|
||||
index 249cb96acea3c4feac910702572cafb1025d9496..ad76f8b190b823210b5e30ae828dce6518596e3b 100644
|
||||
--- a/src/tests/test_util_string_array.c
|
||||
+++ b/src/tests/test_util_string_array.c
|
||||
@@ -51,8 +51,7 @@ void test_string_array_del_value__single(void **state)
|
||||
assert_null(array[i]);
|
||||
|
||||
/* Delete value. */
|
||||
- array = string_array_del_value(array, "2");
|
||||
- assert_non_null(array);
|
||||
+ string_array_del_value(array, "2");
|
||||
|
||||
/* Test values. */
|
||||
for (i = 0; expected[i] != NULL; i++) {
|
||||
@@ -83,8 +82,7 @@ void test_string_array_del_value__single_repeated(void **state)
|
||||
assert_null(array[i]);
|
||||
|
||||
/* Delete value. */
|
||||
- array = string_array_del_value(array, "2");
|
||||
- assert_non_null(array);
|
||||
+ string_array_del_value(array, "2");
|
||||
|
||||
/* Test values. */
|
||||
for (i = 0; expected[i] != NULL; i++) {
|
||||
@@ -115,14 +113,9 @@ void test_string_array_del_value__multiple(void **state)
|
||||
assert_null(array[i]);
|
||||
|
||||
/* Delete value. */
|
||||
- array = string_array_del_value(array, "2");
|
||||
- assert_non_null(array);
|
||||
-
|
||||
- array = string_array_del_value(array, "3");
|
||||
- assert_non_null(array);
|
||||
-
|
||||
- array = string_array_del_value(array, "5");
|
||||
- assert_non_null(array);
|
||||
+ string_array_del_value(array, "2");
|
||||
+ string_array_del_value(array, "3");
|
||||
+ string_array_del_value(array, "5");
|
||||
|
||||
/* Test values. */
|
||||
for (i = 0; expected[i] != NULL; i++) {
|
||||
@@ -153,14 +146,9 @@ void test_string_array_del_value__multiple_repeated(void **state)
|
||||
assert_null(array[i]);
|
||||
|
||||
/* Delete value. */
|
||||
- array = string_array_del_value(array, "2");
|
||||
- assert_non_null(array);
|
||||
-
|
||||
- array = string_array_del_value(array, "3");
|
||||
- assert_non_null(array);
|
||||
-
|
||||
- array = string_array_del_value(array, "5");
|
||||
- assert_non_null(array);
|
||||
+ string_array_del_value(array, "2");
|
||||
+ string_array_del_value(array, "3");
|
||||
+ string_array_del_value(array, "5");
|
||||
|
||||
/* Test values. */
|
||||
for (i = 0; expected[i] != NULL; i++) {
|
||||
--
|
||||
2.17.2
|
||||
@ -1,26 +0,0 @@
|
||||
From 7a9bc11d444220fdb63f6538c5c8a9fe88454520 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
||||
Date: Fri, 30 Nov 2018 11:51:38 +0100
|
||||
Subject: [PATCH 3/3] util: fix buffer error in textfile_copy()
|
||||
|
||||
Resolves:
|
||||
https://github.com/pbrezina/authselect/issues/123
|
||||
---
|
||||
src/lib/util/textfile.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/lib/util/textfile.c b/src/lib/util/textfile.c
|
||||
index 7ee5df677b519f2433d9dfa235ad72551f7ded67..3394042eaf0db9508675cbd0aedc0cc13ea6546c 100644
|
||||
--- a/src/lib/util/textfile.c
|
||||
+++ b/src/lib/util/textfile.c
|
||||
@@ -249,7 +249,7 @@ textfile_copy(const char *source,
|
||||
/* eof not error */
|
||||
}
|
||||
|
||||
- bytes_written = fwrite(buf, sizeof(char), sizeof(buf), fdest);
|
||||
+ bytes_written = fwrite(buf, sizeof(char), bytes_read, fdest);
|
||||
if (bytes_written != bytes_read) {
|
||||
if (ferror(fdest) != 0) {
|
||||
ret = EIO;
|
||||
--
|
||||
2.17.2
|
||||
@ -1,6 +1,6 @@
|
||||
Name: authselect
|
||||
Version: 1.0.2
|
||||
Release: 4%{?dist}
|
||||
Version: 1.0.3
|
||||
Release: 1%{?dist}
|
||||
Summary: Configures authentication and identity sources from supported profiles
|
||||
URL: https://github.com/pbrezina/authselect
|
||||
|
||||
@ -12,10 +12,6 @@ Source1: translations.tar.gz
|
||||
|
||||
%global makedir %{_builddir}/%{name}-%{version}
|
||||
|
||||
Patch0001: 0001-util-remove-duplicate-values-correctly-in-string_arr.patch
|
||||
Patch0002: 0002-util-do-not-return-value-from-string_array_del_value.patch
|
||||
Patch0003: 0003-util-fix-buffer-error-in-textfile_copy.patch
|
||||
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: automake
|
||||
BuildRequires: findutils
|
||||
@ -28,6 +24,7 @@ BuildRequires: gettext-devel
|
||||
BuildRequires: po4a
|
||||
BuildRequires: %{_bindir}/a2x
|
||||
BuildRequires: libcmocka-devel >= 1.0.0
|
||||
BuildRequires: libselinux-devel
|
||||
Requires: authselect-libs%{?_isa} = %{version}-%{release}
|
||||
Suggests: sssd
|
||||
Suggests: samba-winbind
|
||||
@ -45,6 +42,7 @@ supported by authselect.
|
||||
|
||||
%package libs
|
||||
Summary: Utility library used by the authselect tool
|
||||
Requires: libselinux
|
||||
# Required by scriptlets
|
||||
Requires: coreutils
|
||||
Requires: findutils
|
||||
@ -264,6 +262,9 @@ sed -i -E '/^\w+=$/d' %{_sysconfdir}/security/pwquality.conf.d/10-authconfig-pwq
|
||||
exit 0
|
||||
|
||||
%changelog
|
||||
* Tue Feb 26 2019 Pavel Březina <pbrezina@redhat.com> - 1.0.3-1
|
||||
- Rebase to 1.0.3
|
||||
|
||||
* Tue Feb 26 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.0.2-4
|
||||
- Use %ghost for files owned by authselect
|
||||
|
||||
|
||||
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (authselect-1.0.2.tar.gz) = 7e79601e45e2582a430838f6b7a88c44ccb09ad84b739e0802ffa74f9f59b7a846d8f597cace4d05ddb4c51494b8ae08e2f6581df52327b37d8321d05e0604f7
|
||||
SHA512 (authselect-1.0.3.tar.gz) = f27bf640e59bd398dcc73731681110fd4e45abeac5a970e51246e13056dd1c3a77de4c15b2a526624ce282bbd2a00ca6072ee4fdeea7ef7bce4cb5c94e61a8de
|
||||
|
||||
Loading…
Reference in New Issue
Block a user