diff --git a/.gitignore b/.gitignore index 6318edf..f285c56 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ -/wsmancli-2.8.0.tar.gz +wsmancli-2.2.3.tar.bz2 +/wsmancli-2.2.4.tar.bz2 +/wsmancli-2.2.5.tar.bz2 +/wsmancli-2.2.7.1.tar.bz2 +/wsmancli-2.3.0.tar.bz2 +/v2.3.1.tar.gz +/wsmancli-2.6.0.tar.gz diff --git a/http-unauthorized-improve.patch b/http-unauthorized-improve.patch new file mode 100644 index 0000000..1199eb9 --- /dev/null +++ b/http-unauthorized-improve.patch @@ -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) { diff --git a/replace-getpass.patch b/replace-getpass.patch new file mode 100644 index 0000000..eb25fe3 --- /dev/null +++ b/replace-getpass.patch @@ -0,0 +1,61 @@ +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 2023-01-09 11:46:15.771553135 +0100 ++++ wsmancli-2.6.0/src/wsman.c 2023-01-09 11:54:13.968830290 +0100 +@@ -40,6 +40,7 @@ + #include + #include + #include ++#include + + #ifdef HAVE_UNISTD_H + #include +@@ -57,6 +58,8 @@ + extern char *getpass (const char *__prompt); + #endif + ++#define BASE_LEN 21 ++ + static long int server_port = 0; + static char *cainfo = NULL; + static char *cert = NULL; +@@ -498,6 +501,10 @@ request_usr_pwd( WsManClient *client, ws + char *pw; + char user[21]; + char *p; ++ char c; ++ int len = BASE_LEN; ++ int pos = 0; ++ struct termios term; + + /* + * fprintf(stdout,"Authentication failed, please retry\n"); +@@ -560,8 +567,28 @@ request_usr_pwd( WsManClient *client, ws + } + + /* but always ask for the password !? */ +- pw = (char *)getpass("Password: "); ++ /* set no echo */ ++ tcgetattr(1, &term); ++ term.c_lflag &= ~ECHO; ++ tcsetattr(1, TCSANOW, &term); ++ /* get pass */ ++ pw = (char*) u_malloc(sizeof(char) * len); ++ pw[0] = '\0'; ++ printf("Password: "); ++ fflush(stdout); ++ while ((c = fgetc(stdin)) != '\n') { ++ pw[pos++] = (char) c; ++ if (pos >= len) { ++ len += BASE_LEN; ++ pw = realloc(pw, len); ++ } ++ } ++ pw[pos] = '\0'; + *password = u_strdup_printf ("%s", pw); ++ u_free(pw); ++ /* set echo back again */ ++ term.c_lflag |= ECHO; ++ tcsetattr(1, TCSANOW, &term); + + /* make backup, *password will become free'd when next try of http-auth fails */ + if (*password) { diff --git a/sources b/sources index 93ee21a..bcc0165 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (wsmancli-2.8.0.tar.gz) = 61f1fa57ba8106c8e9b0d96296e99e1dc04eb3a2468630aa73c594e6403bfed3cc0946bc4fd633176fda50eeb24a1c3d2cec9697b11d9b5c6a4016eef050b86c +df418d6d78160fd4f88f890a8953907a wsmancli-2.6.0.tar.gz diff --git a/wsmancli.spec b/wsmancli.spec index 11b2292..b467c30 100644 --- a/wsmancli.spec +++ b/wsmancli.spec @@ -1,7 +1,7 @@ Name: wsmancli -Version: 2.8.0 -Release: 4%{?dist} -License: BSD-3-Clause +Version: 2.6.0 +Release: 20%{?dist} +License: BSD Url: http://www.openwsman.org/ # You can get this tarball here: # https://github.com/Openwsman/wsmancli/archive/v%%{version}.tar.gz @@ -14,6 +14,8 @@ 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 +Patch2: replace-getpass.patch Summary: WS-Management-Command line Interface %description @@ -22,7 +24,9 @@ systems using Web Services Management protocol. %prep %setup -q -%autopatch -p1 +%patch0 -p1 +%patch1 -p1 -b .http-unauthorized-improve +%patch2 -p1 -b .replace-getpass cp -fp %SOURCE1 %SOURCE2 %SOURCE3 .; %build @@ -41,36 +45,6 @@ make DESTDIR=%{buildroot} install %doc COPYING README AUTHORS %changelog -* Fri Jul 17 2026 Fedora Release Engineering - 2.8.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild - -* Sat Jan 17 2026 Fedora Release Engineering - 2.8.0-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild - -* Fri Jul 25 2025 Fedora Release Engineering - 2.8.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Tue Apr 08 2025 Vitezslav Crhonek - 2.8.0-1 -- Update to wsmancli-2.8.0 - -* Sun Jan 19 2025 Fedora Release Engineering - 2.6.2-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - -* Sat Jul 20 2024 Fedora Release Engineering - 2.6.2-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - -* Sat Jan 27 2024 Fedora Release Engineering - 2.6.2-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Sat Jul 22 2023 Fedora Release Engineering - 2.6.2-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Fri May 19 2023 Vitezslav Crhonek - 2.6.2-1 -- Update to wsmancli-2.6.2 - -* Tue Apr 25 2023 Vitezslav Crhonek - 2.6.0-21 -- SPDX migration - * Sat Jan 21 2023 Fedora Release Engineering - 2.6.0-20 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild