commit 0be26b934a4618f1e255790be9cc6e50eb28e806 Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:58:42 2019 -0400 Package init diff --git a/0001-Fix-errors-with-Werror-format-security.patch b/0001-Fix-errors-with-Werror-format-security.patch new file mode 100644 index 0000000..eeb9efb --- /dev/null +++ b/0001-Fix-errors-with-Werror-format-security.patch @@ -0,0 +1,52 @@ +From 9317afc8bb7eec656444fc2eecfcd1ea3bfdda82 Mon Sep 17 00:00:00 2001 +From: Stephen Gallagher +Date: Wed, 15 Mar 2017 12:43:03 -0400 +Subject: [PATCH] Fix errors with -Werror=format-security + +Recent versions of the Fedora build system treat format-security +warnings as errors, resulting in failure to build. This patch +ensures that appropriate format strings are present. + +Signed-off-by: Stephen Gallagher +--- + modules/files.c | 2 +- + modules/ldap.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/modules/files.c b/modules/files.c +index 4ef0a57be9f2aad99d82abfae5204009a93e5572..6a7787e28112ba07e0fc44f2887ce1d1540af29e 100644 +--- a/modules/files.c ++++ b/modules/files.c +@@ -532,11 +532,11 @@ parse_field(const struct format_specifier *format, GValue *value, + err = NULL; + ret = lu_value_init_set_attr_from_string(value, format->attribute, + string, &err); + if (ret == FALSE) { + g_assert(err != NULL); +- g_warning(lu_strerror(err)); ++ g_warning("%s", lu_strerror(err)); + lu_error_free(&err); + } + return ret; + } + +diff --git a/modules/ldap.c b/modules/ldap.c +index ad10f7394c5735f3180cbab5bc7314301fd83ffc..02e9eb6a0cf10595d730e3dc719f2e848a3491d4 100644 +--- a/modules/ldap.c ++++ b/modules/ldap.c +@@ -670,11 +670,11 @@ lu_ldap_lookup(struct lu_module *module, + error = NULL; + ok = lu_value_init_set_attr_from_string + (&value, attr, val, &error); + if (ok == FALSE) { + g_assert(error != NULL); +- g_warning(lu_strerror(error)); ++ g_warning("%s", lu_strerror(error)); + lu_error_free(&error); + } else { + lu_ent_add_current(ent, attr, + &value); + g_value_unset(&value); +-- +2.12.0 + diff --git a/0009-Check-negative-return-of-PyList_Size.patch b/0009-Check-negative-return-of-PyList_Size.patch new file mode 100644 index 0000000..6aff0e9 --- /dev/null +++ b/0009-Check-negative-return-of-PyList_Size.patch @@ -0,0 +1,44 @@ +From 11a7ff7eeefe763be9ade949e8f2a4a2d53f6129 Mon Sep 17 00:00:00 2001 +From: Jakub Hrozek +Date: Mon, 24 Sep 2018 20:51:51 +0200 +Subject: [PATCH 09/12] Check negative return of PyList_Size + +Merges: +https://pagure.io/libuser/issue/28 + +In case of an error, PyList_Size can return a negative value. We should +check that case, also to avoid compiler warnings like: + +Error: COMPILER_WARNING: [#def41] [warning: defect not occurring in libuser-0.60-9.el7] +libuser-0.62/python/misc.c: scope_hint: In function 'libuser_admin_prompt' +libuser-0.62/python/misc.c:160:12: warning: argument 1 range [9223372036854775808, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=] +/usr/include/glib-2.0/glib/glist.h:32: included_from: Included from here. +/usr/include/glib-2.0/glib/ghash.h:33: included_from: Included from here. +/usr/include/glib-2.0/glib.h:50: included_from: Included from here. +libuser-0.62/python/misc.c:25: included_from: Included from here. +/usr/include/glib-2.0/glib/gmem.h:96:10: note: in a call to allocation function 'g_malloc0_n' declared here +--- + python/misc.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/python/misc.c b/python/misc.c +index c4ce819..fcb0ccf 100644 +--- a/python/misc.c ++++ b/python/misc.c +@@ -137,7 +137,12 @@ libuser_admin_prompt(struct libuser_admin *self, PyObject * args, + return NULL; + } + count = PyList_Size(list); +- if (count > INT_MAX) { ++ if (count < 0) { ++ PyErr_SetString(PyExc_TypeError, ++ "prompt_list has no size; probably not a list"); ++ DEBUG_EXIT; ++ return NULL; ++ } else if (count > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "too many prompts"); + DEBUG_EXIT; + return NULL; +-- +1.8.3.1 + diff --git a/0010-files.c-Init-char-name-to-NULL.patch b/0010-files.c-Init-char-name-to-NULL.patch new file mode 100644 index 0000000..a06cff6 --- /dev/null +++ b/0010-files.c-Init-char-name-to-NULL.patch @@ -0,0 +1,60 @@ +From 7acf0fad0ca468f33f86084f36251df5baf3dc94 Mon Sep 17 00:00:00 2001 +From: Jakub Hrozek +Date: Wed, 26 Sep 2018 21:01:59 +0200 +Subject: [PATCH 10/12] files.c: Init char *name to NULL + +Merges: +https://pagure.io/libuser/issue/27 + +This is mostly to silence coverity warnings. "enum lu_entity_type" has +three values and several places in the code follow logic as: + +char *name; +if ent->type == user: + name = foo() +if ent->type == group + name = bar() +g_assert(name != NULL) + +it shouldn't be possible for ent->type to be anything else but in the +odd case it is, initializing name to NULL will ensure that name will be +still NULL after the code falls through the conditions and at least the +behaviour is defined. +--- + modules/files.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/modules/files.c b/modules/files.c +index 6a7787e..8c2a282 100644 +--- a/modules/files.c ++++ b/modules/files.c +@@ -1501,7 +1501,7 @@ generic_lock(struct lu_module *module, const char *file_suffix, int field, + struct lu_ent *ent, enum lock_op op, struct lu_error **error) + { + struct editing *e; +- char *value, *new_value, *name; ++ char *value, *new_value, *name = NULL; + gboolean commit = FALSE, ret = FALSE; + + /* Get the name which keys the entries of interest in the file. */ +@@ -1561,7 +1561,7 @@ generic_is_locked(struct lu_module *module, const char *file_suffix, + int field, struct lu_ent *ent, struct lu_error **error) + { + char *filename; +- char *value, *name; ++ char *value, *name = NULL; + int fd; + gboolean ret = FALSE; + +@@ -1752,7 +1752,7 @@ generic_setpass(struct lu_module *module, const char *file_suffix, int field, + struct lu_error **error) + { + struct editing *e; +- char *value, *name; ++ char *value, *name = NULL; + gboolean ret = FALSE; + + /* Get the name of this account. */ +-- +1.8.3.1 + diff --git a/0011-merge_ent_array_duplicates-Only-use-values-if-valid.patch b/0011-merge_ent_array_duplicates-Only-use-values-if-valid.patch new file mode 100644 index 0000000..9b0a46e --- /dev/null +++ b/0011-merge_ent_array_duplicates-Only-use-values-if-valid.patch @@ -0,0 +1,56 @@ +From 8da7fc83aa3e9fd868c6a8da9261b72dae7d29e7 Mon Sep 17 00:00:00 2001 +From: Jakub Hrozek +Date: Wed, 26 Sep 2018 21:38:02 +0200 +Subject: [PATCH 11/12] merge_ent_array_duplicates: Only use values if valid + +Merges: +https://pagure.io/libuser/issue/22 + +Don't attempt to dereference a NULL pointer +--- + lib/user.c | 22 ++++++++++++++-------- + 1 file changed, 14 insertions(+), 8 deletions(-) + +diff --git a/lib/user.c b/lib/user.c +index ad2bb09..2500565 100644 +--- a/lib/user.c ++++ b/lib/user.c +@@ -691,10 +691,13 @@ merge_ent_array_duplicates(GPtrArray *array) + while (attributes != NULL) { + attr = (const char *)attributes->data; + values = lu_ent_get_current(current, attr); +- for (j = 0; j < values->n_values; j++) { +- value = g_value_array_get_nth(values, +- j); +- lu_ent_add_current(saved, attr, value); ++ if (values != NULL) { ++ for (j = 0; j < values->n_values; j++) { ++ value = g_value_array_get_nth( ++ values, ++ j); ++ lu_ent_add_current(saved, attr, value); ++ } + } + attributes = g_list_next(attributes); + } +@@ -705,10 +708,13 @@ merge_ent_array_duplicates(GPtrArray *array) + while (attributes != NULL) { + attr = (const char *)attributes->data; + values = lu_ent_get(current, attr); +- for (j = 0; j < values->n_values; j++) { +- value = g_value_array_get_nth(values, +- j); +- lu_ent_add(saved, attr, value); ++ if (values != NULL) { ++ for (j = 0; j < values->n_values; j++) { ++ value = g_value_array_get_nth( ++ values, ++ j); ++ lu_ent_add(saved, attr, value); ++ } + } + attributes = g_list_next(attributes); + } +-- +1.8.3.1 + diff --git a/0012-editing_open-close-fd-after-we-ve-established-its-va.patch b/0012-editing_open-close-fd-after-we-ve-established-its-va.patch new file mode 100644 index 0000000..5a7f29c --- /dev/null +++ b/0012-editing_open-close-fd-after-we-ve-established-its-va.patch @@ -0,0 +1,33 @@ +From e5536845298b6672a16e5866a823fcf6562c6cf3 Mon Sep 17 00:00:00 2001 +From: Jakub Hrozek +Date: Wed, 26 Sep 2018 21:15:38 +0200 +Subject: [PATCH 12/12] editing_open: close fd after we've established its + validity + +Merges: +https://pagure.io/libuser/issue/26 + +The code used to first close(fd) and only then check if it's != -1. +Reverse the logic so that the fd is only closed if valid. +--- + modules/files.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules/files.c b/modules/files.c +index 8c2a282..b8bf8a6 100644 +--- a/modules/files.c ++++ b/modules/files.c +@@ -387,9 +387,9 @@ editing_open(struct lu_module *module, const char *file_suffix, + backup_name = g_strconcat(e->filename, "-", NULL); + fd = open_and_copy_file(e->filename, backup_name, FALSE, error); + g_free (backup_name); +- close(fd); + if (fd == -1) + goto err_fscreate; ++ close(fd); + + e->new_filename = g_strconcat(e->filename, "+", NULL); + e->new_fd = open_and_copy_file(e->filename, e->new_filename, TRUE, +-- +1.8.3.1 + diff --git a/libuser-0.62.tar.xz b/libuser-0.62.tar.xz new file mode 100644 index 0000000..5ae0da6 Binary files /dev/null and b/libuser-0.62.tar.xz differ diff --git a/libuser.spec b/libuser.spec new file mode 100644 index 0000000..e32e392 --- /dev/null +++ b/libuser.spec @@ -0,0 +1,155 @@ +Name : libuser +Version : 0.62 +Release : 19 +Summary : A user and group account administration library +License : LGPLv2+ +URL : https://pagure.io/libuser +Source : http://releases.pagure.org/libuser/libuser-%{version}.tar.xz + +# Patch1 : this patch is from fedora. +Patch1 : 0001-Fix-errors-with-Werror-format-security.patch + +Patch9000: 0009-Check-negative-return-of-PyList_Size.patch +Patch9001: 0010-files.c-Init-char-name-to-NULL.patch +Patch9002: 0011-merge_ent_array_duplicates-Only-use-values-if-valid.patch +Patch9003: 0012-editing_open-close-fd-after-we-ve-established-its-va.patch + +BuildRequires: cyrus-sasl-devel, nscd, linuxdoc-tools, pam-devel, popt-devel, gcc +BuildRequires: libselinux-devel, openldap-devel, python3-devel, glib2-devel +BuildRequires: python2-devel, fakeroot, openldap-clients, openldap-servers, openssl + +%description +The libuser library implements a standardized interface for manipulating +and administering user and group accounts. The library uses pluggable +back-ends to interface to its data sources. Sample applications modeled +after those included with the shadow password suite are included. + +%package devel +Summary: Development libraries and files for %{name} +Requires: glib2-devel%{?_isa} +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +The package contains lib and header files for developing application +that use %{name} + +%package -n python2-libuser +Summary: the libuser library used for binding Python 2 +%{?python_provide:%python_provide python2-libuser} +Requires: libuser%{?_isa} = %{version}-%{release} +Provides: %{name}-python = %{version}-%{release} +Provides: %{name}-python%{?_isa} = %{version}-%{release} + +%description -n python2-libuser +The libuser library which provides a Python 2 API implements a +standardized interface for manipulating and administering user +and group accounts. + +%package python3 +Summary: the libuser library used for binding Python 3 +Requires: libuser%{?_isa} = %{version}-%{release} + +%description python3 +The libuser library which provides a Python 3 API implements a +standardized interface for manipulating and administering user +and group accounts. + +%package help +Summary: Documents files for %{name} +Requires: man, info + +%description help +Man pages and other related documents for %{name} + +%prep +%setup -qc + +pushd libuser-%{version} +%patch1 -p1 +%patch9000 -p1 +%patch9001 -p1 +%patch9002 -p1 +%patch9003 -p1 +popd + +cp -dpR libuser-%{version} python2 || : +cp -dpR python2 python3 || : +rm -rf libuser-%{version} || : + +pushd python2 +cp -pr COPYING AUTHORS NEWS README TODO docs ../ || : +popd + +%build +pushd python2 +%configure --with-ldap --with-selinux --with-html-dir=%{_prefix}/share/gtk-doc/html \ + PYTHON=%{_bindir}/python2 +make +popd + +pushd python3 +%configure --with-ldap --with-selinux --with-html-dir=%{_prefix}/share/gtk-doc/html \ + PYTHON=%{_bindir}/python3 +make +popd + +%install +make -C python3 install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p' || : +make -C python2 install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p' || : + +%find_lang %{name} + +%check + +make -C python2 check || { cat python2/test-suite.log; false; } +LC_ALL=C.UTF-8 make -C python3 check \ + || { cat python3/test-suite.log; false; } +LD_LIBRARY_PATH=$RPM_BUILD_ROOT/%{_prefix}/%{_lib}:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH +cd $RPM_BUILD_ROOT/%{python2_sitearch} +python2 -c "import libuser" +cd $RPM_BUILD_ROOT/%{python3_sitearch} +LC_ALL=C.UTF-8 python3 -c "import libuser" + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +%files -f %{name}.lang +%{!?_licensedir:%global license %%doc} +%license COPYING +%doc AUTHORS NEWS README TODO docs/*.txt +%config(noreplace) %{_sysconfdir}/libuser.conf +%attr(0755,root,root) %{_exec_prefix}/bin/* +%{_prefix}/%{_lib}/%{name}/*.so +%{_prefix}/%{_lib}/*.so.* +%dir %{_prefix}/%{_lib}/%{name} +%attr(0755,root,root) %{_exec_prefix}/sbin/* +%exclude %{_prefix}/%{_lib}/%{name}/*.la +%exclude %{_prefix}/%{_lib}/*.la + +%files -n python2-libuser +%doc python2/python/modules.txt +%{python2_sitearch}/*.so +%exclude %{python2_sitearch}/*.la + +%files python3 +%doc python3/python/modules.txt +%{python3_sitearch}/*.so +%exclude %{python3_sitearch}/*.la + +%files devel +%{_exec_prefix}/%{_lib}/*.so +%{_exec_prefix}/%{_lib}/pkgconfig/* +%{_includedir}/libuser +%{_prefix}/share/gtk-doc/html/* + +%files help +%{_mandir}/man1/* +%{_mandir}/man5/* + +%changelog +* Tue Sep 10 2019 caomeng - 0.62-19 +- Package init