Skip to content

Commit

Permalink
lib/agetpass.*: agetpass(), agetpass_stdin(): Re-implement as macros
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Jan 19, 2025
1 parent 55c4128 commit 5a7b086
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
9 changes: 2 additions & 7 deletions lib/agetpass.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023, Alejandro Colomar <[email protected]>
* SPDX-License-Identifier: BSD-3-Clause
*/
// SPDX-FileCopyrightText: 2022-2025, Alejandro Colomar <[email protected]>
// SPDX-License-Identifier: BSD-3-Clause


#include <config.h>
Expand All @@ -10,7 +8,4 @@


extern inline void erase_pass(char *pass);
extern inline char *agetpass(const char *prompt);
extern inline char *agetpass_stdin();

extern inline char *agetpass_internal(const char *prompt, int flags);
26 changes: 6 additions & 20 deletions lib/agetpass.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022, Alejandro Colomar <[email protected]>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// SPDX-FileCopyrightText: 2022-2025, Alejandro Colomar <[email protected]>
// SPDX-License-Identifier: BSD-3-Clause


#ifndef SHADOW_INCLUDE_LIB_AGETPASS_H_
Expand All @@ -23,12 +20,12 @@
#endif /* WITH_LIBBSD */


inline void erase_pass(char *pass);

// Similar to getpass(3), but free of its problems.
inline char *agetpass(const char *prompt);
inline char *agetpass_stdin();
#define agetpass(prompt) agetpass_internal(prompt, RPP_REQUIRE_TTY)
#define agetpass_stdin() agetpass_internal(NULL, RPP_STDIN)


inline void erase_pass(char *pass);
ATTR_MALLOC(erase_pass)
inline char *agetpass_internal(const char *prompt, int flags);

Expand Down Expand Up @@ -67,17 +64,6 @@ agetpass_internal(const char *prompt, int flags)
return NULL;
}

inline char *
agetpass(const char *prompt)
{
return agetpass_internal(prompt, RPP_REQUIRE_TTY);
}

inline char *
agetpass_stdin()
{
return agetpass_internal(NULL, RPP_STDIN);
}

inline void
erase_pass(char *pass)
Expand Down

0 comments on commit 5a7b086

Please sign in to comment.