1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

chasquid-util: Print errors to stderr

To make it more difficult to accidentally supress errors, or mistake them
for legitimate output, print errors to stderr.
This commit is contained in:
Alberto Bertogli
2024-03-04 19:29:24 +00:00
parent 8e1fd52442
commit b0877f0866
2 changed files with 7 additions and 6 deletions

View File

@@ -96,9 +96,10 @@ func main() {
} }
} }
// Fatalf prints the given message, then exits the program with an error code. // Fatalf prints the given message to stderr, then exits the program with an
// error code.
func Fatalf(s string, arg ...interface{}) { func Fatalf(s string, arg ...interface{}) {
fmt.Printf(s+"\n", arg...) fmt.Fprintf(os.Stderr, s+"\n", arg...)
os.Exit(1) os.Exit(1)
} }

View File

@@ -40,7 +40,7 @@ if ! r user-add denied@domain --receive_only > /dev/null; then
fi fi
check_userdb check_userdb
if r user-add xxx@domain --password=passwd --receive_only > /dev/null; then if r user-add xxx@domain --password=passwd --receive_only > /dev/null 2>&1; then
echo user-add --password --receive_only worked echo user-add --password --receive_only worked
exit 1 exit 1
fi fi
@@ -50,12 +50,12 @@ if ! r authenticate user@domain --password=passwd > /dev/null; then
exit 1 exit 1
fi fi
if r authenticate user@domain --password=abcd > /dev/null; then if r authenticate user@domain --password=abcd > /dev/null 2>&1; then
echo authenticate with bad password worked echo authenticate with bad password worked
exit 1 exit 1
fi fi
if r authenticate denied@domain --password=abcd > /dev/null; then if r authenticate denied@domain --password=abcd > /dev/null 2>&1; then
echo authenticate on a no-submission user worked echo authenticate on a no-submission user worked
exit 1 exit 1
fi fi
@@ -82,7 +82,7 @@ if ! r user-remove user@domain > /dev/null; then
fi fi
check_userdb check_userdb
if r authenticate user@domain --password=passwd > /dev/null; then if r authenticate user@domain --password=passwd > /dev/null 2>&1; then
echo authenticate for removed user worked echo authenticate for removed user worked
exit 1 exit 1
fi fi