Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
333e3a9f
Commit
333e3a9f
authored
May 19, 2013
by
Wayne Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an implementation of getpass for systems that lack one.
parent
94073d20
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
0 deletions
+78
-0
configure.ac
configure.ac
+2
-0
getpass.c
lib/getpass.c
+72
-0
rsync.h
rsync.h
+4
-0
No files found.
configure.ac
View file @
333e3a9f
...
@@ -749,6 +749,8 @@ if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
...
@@ -749,6 +749,8 @@ if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define to 1 if you have the "socketpair" function])
AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define to 1 if you have the "socketpair" function])
fi
fi
AC_CHECK_FUNCS(getpass, , [AC_LIBOBJ(lib/getpass)])
if test x"$with_included_popt" != x"yes"; then
if test x"$with_included_popt" != x"yes"; then
AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
fi
fi
...
...
lib/getpass.c
0 → 100644
View file @
333e3a9f
/*
* An implementation of getpass for systems that lack one.
*
* Copyright (C) 2013 Roman Donchenko
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include "rsync.h"
char
*
getpass
(
const
char
*
prompt
)
{
static
char
password
[
256
];
BOOL
tty_changed
=
False
,
read_success
;
struct
termios
tty_old
,
tty_new
;
FILE
*
in
=
stdin
,
*
out
=
stderr
;
FILE
*
tty
=
fopen
(
"/dev/tty"
,
"w+"
);
if
(
tty
)
in
=
out
=
tty
;
if
(
tcgetattr
(
fileno
(
in
),
&
tty_old
)
==
0
)
{
tty_new
=
tty_old
;
tty_new
.
c_lflag
&=
~
(
ECHO
|
ISIG
);
if
(
tcsetattr
(
fileno
(
in
),
TCSAFLUSH
,
&
tty_new
)
==
0
)
tty_changed
=
True
;
}
if
(
!
tty_changed
)
fputs
(
"(WARNING: will be visible) "
,
out
);
fputs
(
prompt
,
out
);
fflush
(
out
);
read_success
=
fgets
(
password
,
sizeof
password
,
in
)
!=
NULL
;
/* Print the newline that hasn't been echoed. */
fputc
(
'\n'
,
out
);
if
(
tty_changed
)
tcsetattr
(
fileno
(
in
),
TCSAFLUSH
,
&
tty_old
);
if
(
tty
)
fclose
(
tty
);
if
(
read_success
)
{
/* Remove the trailing newline. */
size_t
password_len
=
strlen
(
password
);
if
(
password_len
&&
password
[
password_len
-
1
]
==
'\n'
)
password
[
password_len
-
1
]
=
'\0'
;
return
password
;
}
return
NULL
;
}
rsync.h
View file @
333e3a9f
...
@@ -1282,6 +1282,10 @@ const char *inet_ntop(int af, const void *src, char *dst, size_t size);
...
@@ -1282,6 +1282,10 @@ const char *inet_ntop(int af, const void *src, char *dst, size_t size);
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
);
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
);
#endif
#endif
#ifndef HAVE_GETPASS
char
*
getpass
(
const
char
*
prompt
);
#endif
#ifdef MAINTAINER_MODE
#ifdef MAINTAINER_MODE
const
char
*
get_panic_action
(
void
);
const
char
*
get_panic_action
(
void
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment