Replace obsolete getpass function
This commit is contained in:
parent
aa5540e027
commit
1c753c010f
61
replace-getpass.patch
Normal file
61
replace-getpass.patch
Normal file
@ -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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
+#include <termios.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
@@ -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) {
|
@ -1,6 +1,6 @@
|
|||||||
Name: wsmancli
|
Name: wsmancli
|
||||||
Version: 2.6.0
|
Version: 2.6.0
|
||||||
Release: 18%{?dist}
|
Release: 19%{?dist}
|
||||||
License: BSD
|
License: BSD
|
||||||
Url: http://www.openwsman.org/
|
Url: http://www.openwsman.org/
|
||||||
# You can get this tarball here:
|
# You can get this tarball here:
|
||||||
@ -15,6 +15,7 @@ BuildRequires: autoconf automake libtool
|
|||||||
Requires: openwsman curl
|
Requires: openwsman curl
|
||||||
Patch0: missing-pthread-symbols.patch
|
Patch0: missing-pthread-symbols.patch
|
||||||
Patch1: http-unauthorized-improve.patch
|
Patch1: http-unauthorized-improve.patch
|
||||||
|
Patch2: replace-getpass.patch
|
||||||
Summary: WS-Management-Command line Interface
|
Summary: WS-Management-Command line Interface
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -25,6 +26,7 @@ systems using Web Services Management protocol.
|
|||||||
%setup -q
|
%setup -q
|
||||||
%patch0 -p1
|
%patch0 -p1
|
||||||
%patch1 -p1 -b .http-unauthorized-improve
|
%patch1 -p1 -b .http-unauthorized-improve
|
||||||
|
%patch2 -p1 -b .replace-getpass
|
||||||
cp -fp %SOURCE1 %SOURCE2 %SOURCE3 .;
|
cp -fp %SOURCE1 %SOURCE2 %SOURCE3 .;
|
||||||
|
|
||||||
%build
|
%build
|
||||||
@ -43,6 +45,9 @@ make DESTDIR=%{buildroot} install
|
|||||||
%doc COPYING README AUTHORS
|
%doc COPYING README AUTHORS
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* 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-18
|
||||||
- Improve handling of HTTP 401 Unauthorized
|
- Improve handling of HTTP 401 Unauthorized
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user