From: Ralph Corderoy Date: Sat, 22 Oct 2016 18:18:15 +0000 (+0100) Subject: Alter netrc permissions error message to match code. Add test. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/ab8d647663ca0c59d6aaf3870d99edeea3a27a6c Alter netrc permissions error message to match code. Add test. The code wants `go=', but the error message, and FAQ, said to clear read permission from group and other. Add test to inc/test-pop as that is the existing netrc test location, but it might be better in its own test file as other tests for netrc parsing could be added. --- diff --git a/docs/FAQ b/docs/FAQ index ce12eaa5..066fbb94 100644 --- a/docs/FAQ +++ b/docs/FAQ @@ -2008,8 +2008,8 @@ Date: Mon, 1 May 1995 00:00:00 -0800 inc: -noaudit -norpop -noapop -host cuckoo - Add the following to ~/.netrc and ensure it is readable only by you - (e.g., chmod 600 .netrc): + Add the following to ~/.netrc and ensure it [grants no permissions to + group or other] (e.g., chmod 600 .netrc): machine cuckoo.domain.name login joeuser password secret diff --git a/sbr/ruserpass.c b/sbr/ruserpass.c index f5fc6bd8..43784d52 100644 --- a/sbr/ruserpass.c +++ b/sbr/ruserpass.c @@ -107,8 +107,8 @@ ruserpass(const char *host, char **aname, char **apass, int flags) (stb.st_mode & 077) != 0) { /* We make this a fatal error to force the user to correct it. */ - advise(NULL, "Error - file %s must not be world or " - "group readable.", credentials_file); + advise(NULL, "group or other permissions, %#o, " + "forbidden: %s", stb.st_mode, credentials_file); adios(NULL, "Remove password or correct file " "permissions."); } diff --git a/test/inc/test-pop b/test/inc/test-pop index 0ae80293..db21c31d 100755 --- a/test/inc/test-pop +++ b/test/inc/test-pop @@ -70,6 +70,14 @@ Date: Tuesday, 19 Dec 2006 4:15:16 -0500 Dude, nmh is totally brutal. EOM +# Check netrc's permissions test +pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" '' '' "$testmessage"` +chmod g=w,o=x $netrc +run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport" \ + "inc: group or other permissions, 0100621, forbidden: $netrc +inc: Remove password or correct file permissions." +chmod go= $netrc + pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \ "$TESTUSER" "$TESTPASS" "$testmessage"`