Compare commits

...

No commits in common. "c10s" and "c8s" have entirely different histories.
c10s ... c8s

7 changed files with 143 additions and 78 deletions

View File

@ -1 +0,0 @@
1

2
.gitignore vendored
View File

@ -1 +1 @@
/wsmancli-2.6.2.tar.gz
/wsmancli-2.6.0.tar.gz

View File

@ -1,6 +1,6 @@
--- !Policy
product_versions:
- rhel-10
- rhel-8
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional}

View File

@ -0,0 +1,127 @@
diff -up wsmancli-2.6.0/src/wsman.c.orig wsmancli-2.6.0/src/wsman.c
--- wsmancli-2.6.0/src/wsman.c.orig 2015-06-11 10:50:04.000000000 +0200
+++ wsmancli-2.6.0/src/wsman.c 2022-07-19 09:09:48.518951546 +0200
@@ -63,7 +63,11 @@ static char *cert = NULL;
static char *sslkey = NULL;
static char *endpoint = NULL;
static char *username = NULL;
+static char *username_given = NULL; /* copy of either the username from env or cmdline*/
+static char *username_prev = NULL; /* input username to request_usr_pwd() when called last time */
static char *password = NULL;
+static char *password_given = NULL; /* copy of either the password from env or cmdline */
+static char *password_prev = NULL; /* input password to request_usr_pwd() when called last time */
static char *server = "localhost";
static char *agent = NULL;
static char *url_path = NULL;
@@ -495,28 +499,79 @@ request_usr_pwd( WsManClient *client, ws
char user[21];
char *p;
- fprintf(stdout,"Authentication failed, please retry\n");
- /*
- fprintf(stdout, "%s authentication is used\n",
- wsmc_transport_get_auth_name( auth));
- */
- printf("User name: ");
- fflush(stdout);
- if ( (p = fgets(user, 20, stdin) ) != NULL )
- {
-
- if (strchr(user, '\n'))
- (*(strchr(user, '\n'))) = '\0';
- *username = u_strdup_printf ("%s", user);
- } else {
- *username = NULL;
+ /*
+ * fprintf(stdout,"Authentication failed, please retry\n");
+ *
+ * this message shall not be printed by this function as it cannot decide on the
+ * reason it was called for. It does not control the authentication process.
+ * wsmc_handler is better suited for such a decision making.
+ */
+
+ if (username_given) {
+ if (password_given) {
+ /* Initially provided combination of password and username is not valid.
+ * Request user to type both. Here I assume, that wsmc_handler called back to
+ * this function after trying a first authentication using these credentials.
+ */
+ } else {
+ /* Initially no password was provided => no authentication tried during first
+ * iteration of while loop in wsmc_handler. Check previously typed credentials
+ */
+ if (username_prev) {
+ /* This is a second call of this function, assuming only wsmc_handler is using it
+ * as a callback function. Therefore, there must have been a previous attempt to
+ * authenticate, but this previous combination of username and password did not
+ * lead to a successful authentication. Request new credentials, username_prev will
+ * be set each time after user has provided a username.
+ */
+ } else {
+ /* First time wsmc_handler calls back to this function. No password given on the
+ * command line or via the environment variable. Therefore wsmc_handler cannot
+ * have tried http authentication. A username was given on the command line or
+ * via an environment variable. And the user wants us to try this name at least
+ * at first. So, let's do him a favour and use it. When we are called back again,
+ * we will ask the user to provide a new name or the same, but a different password.
+ */
+ *username = u_strdup(username_given);
+ }
+ }
+ }
+
+ if (*username == NULL) {
+ printf("User name: ");
+ fflush(stdout);
+ if ( (p = fgets(user, 20, stdin) ) != NULL )
+ {
+ if (strchr(user, '\n'))
+ (*(strchr(user, '\n'))) = '\0';
+ *username = u_strdup_printf ("%s", user);
+ } else {
+ *username = NULL;
+ }
+ }
+
+ /* after successfull receipt of a new username, store a copy at username_prev */
+ if (*username) {
+ if ( username_prev ) {
+ u_free(username_prev);
+ username_prev = NULL;
+ }
+ username_prev = u_strdup(*username);
}
+ /* but always ask for the password !? */
pw = (char *)getpass("Password: ");
*password = u_strdup_printf ("%s", pw);
-}
-
+ /* make backup, *password will become free'd when next try of http-auth fails */
+ if (*password) {
+ if (password_prev) {
+ u_free(password_prev);
+ password_prev = NULL;
+ }
+ password_prev = u_strdup(*password);
+ }
+}
static void
wsman_options_set_properties(client_opt_t *options)
@@ -647,6 +702,14 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
+ /* save copies of username or password when given on the command line or via environment variables */
+ if ( username != NULL ) {
+ username_given = u_strdup(username);
+ }
+ if ( password != NULL ) {
+ password_given = u_strdup(password);
+ }
+
filename = (char *) config_file;
if (filename) {

View File

@ -1,15 +0,0 @@
---
summary: Tier1 plan for wsmancli
discover:
how: fmf
url: https://pkgs.devel.redhat.com/git/tests/wsmancli
ref: master
filter: tier:1
execute:
how: tmt
adjust:
enabled: false
when: distro == centos-stream or distro == fedora

View File

@ -1 +1 @@
SHA512 (wsmancli-2.6.2.tar.gz) = 9b1c99b18d2f9f6125a48bb4639ffa970b67fd4ac2dae401a0b9205ab7a0650ebd77737ce386761143aedefd18a59b92407a63831568ca5597e92281df8414b0
SHA512 (wsmancli-2.6.0.tar.gz) = 40f69dfefd5cfc9c1d137c5c58bd0e84e1bb460ecb6770e1c56b023477f7521769f04e041682686d267796477704c7465d437f6fdb4068268a51d1136d5c8a56

View File

@ -1,19 +1,19 @@
Name: wsmancli
Version: 2.6.2
Release: 5%{?dist}
License: BSD-3-Clause
Version: 2.6.0
Release: 11%{?dist}
License: BSD
Url: http://www.openwsman.org/
# You can get this tarball here:
# https://github.com/Openwsman/wsmancli/archive/v%%{version}.tar.gz
# https://github.com/Openwsman/wsmancli/archive/v%{version}.tar.gz
Source: wsmancli-%{version}.tar.gz
Source1: COPYING
Source2: README
Source3: AUTHORS
BuildRequires: make
BuildRequires: openwsman-devel >= 2.1.0 pkgconfig curl-devel
BuildRequires: autoconf automake libtool
Requires: openwsman curl
Patch0: missing-pthread-symbols.patch
Patch1: http-unauthorized-improve.patch
Summary: WS-Management-Command line Interface
%description
@ -22,7 +22,8 @@ systems using Web Services Management protocol.
%prep
%setup -q
%autopatch -p1
%patch0 -p1
%patch1 -p1 -b .http-unauthorized-improve
cp -fp %SOURCE1 %SOURCE2 %SOURCE3 .;
%build
@ -41,60 +42,13 @@ make DESTDIR=%{buildroot} install
%doc COPYING README AUTHORS
%changelog
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 2.6.2-5
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* Tue Feb 14 2023 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.6.0-11
- Add gating.yml, bump version
Related: #2105316
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 2.6.2-4
- Bump release for June 2024 mass rebuild
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Fri May 19 2023 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.6.2-1
- Update to wsmancli-2.6.2
* Tue Apr 25 2023 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.6.0-21
- SPDX migration
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-20
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Tue Jan 10 2023 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.6.0-19
- Replace obsolete getpass function
* Thu Sep 08 2022 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.6.0-18
* Thu Sep 08 2022 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.6.0-9
- Improve handling of HTTP 401 Unauthorized
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Tue Mar 09 2021 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.6.0-14
- Rebuild because of soname change in openswman
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Resolves: #2105316
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild