Bug 12971 - Annoying error printed when systemd-ask-password is not found
Annoying error printed when systemd-ask-password is not found
Status: NEW
Product: CifsVFS
Classification: Unclassified
Component: user space tools
3.x
All All
: P5 minor
: ---
Assigned To: Jeff Layton
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-08-16 13:35 UTC by Andreas Hasenack
Modified: 2017-08-16 13:35 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Hasenack 2017-08-16 13:35:38 UTC
cifs-utils 6.7

When asking for a user password, mount.cifs will try to use systemd-ask-password. Since the fix for https://bugzilla.samba.org/show_bug.cgi?id=10054, it relies on popen's search of $PATH. If not found, getpass() is used as a fallback.

If systemd-ask-password isn't found, an annoying error message is printed to the terminal before the fallback is used:

ubuntu@61-b1:~$ mount /ds216/downloads
sh: 1: systemd-ask-password: not found
Password for andreas@//ds216.lowtech/downloads: <--- no "***" echoed: getpass() was used
ubuntu@61-b1:~$

Since mount.cifs is already using popen, it could silence that error with a simple shell redirection:

diff --git a/mount.cifs.c b/mount.cifs.c
index 8ca848d..33c1d95 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -1668,7 +1668,7 @@ get_password(const char *prompt, char *input, int capacity)
                FILE *ask_pass_fp = NULL;
 
                cmd = ret = NULL;
-               if (asprintf(&cmd, "systemd-ask-password \"%s\"", prompt) >= 0) {
+               if (asprintf(&cmd, "systemd-ask-password \"%s\" 2>/dev/null", prompt) >= 0) {
                        ask_pass_fp = popen (cmd, "re");
                        free (cmd);
                }