[Dovecot] 'Doveadm user' could use better error codes
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
- -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
The error codes for' doveadm user' should be improved to avoid error handling workarounds when scripting commands:
$ doveadm user doveadm user [-a <userdb socket path>] [-x <auth info>] <user mask> […] $ echo $? 1 $ doveadm user foo userdb lookup: user foo doesn't exist $ echo $? 0
Please compare to ID output:
$ id foo id: foo: No such user $ echo $? 1
Regards Thomas
- -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iEYEARECAAYFAk0Z6FkACgkQ+meF/S97aXgxnQCfWk1ECdMoCewbr1O6lAkdksoH 324AoLCTg0dFmFhumEkM936irpcG7YF5 =wuwz
- -----END PGP SIGNATURE----- -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iEYEARECAAYFAk0Z6HQACgkQ+meF/S97aXgGdACfawa02hZxk71CjIsj64sW0xXv CW8AoJRQZLFi4QwbvcDg6rzqzUv/3mE8 =Rt1O -----END PGP SIGNATURE-----
On 28-12-10 14:39, Thomas Leuxner wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
- -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
The error codes for' doveadm user' should be improved to avoid error handling workarounds when scripting commands:
$ doveadm user doveadm user [-a<userdb socket path>] [-x<auth info>]<user mask> […] $ echo $? 1 $ doveadm user foo userdb lookup: user foo doesn't exist $ echo $? 0
Please compare to ID output:
$ id foo id: foo: No such user $ echo $? 1
Regards Thomas
- -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iEYEARECAAYFAk0Z6FkACgkQ+meF/S97aXgxnQCfWk1ECdMoCewbr1O6lAkdksoH 324AoLCTg0dFmFhumEkM936irpcG7YF5 =wuwz
- -----END PGP SIGNATURE----- -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iEYEARECAAYFAk0Z6HQACgkQ+meF/S97aXgGdACfawa02hZxk71CjIsj64sW0xXv CW8AoJRQZLFi4QwbvcDg6rzqzUv/3mE8 =Rt1O -----END PGP SIGNATURE-----
It behaves just as 'man doveadm' promisses.....
EXIT STATUS doveadm will exit with one of the following values:
0 Selected command was executed successful.
>0 Command failed in some way.
So, this seems to be correct!
Am 28.12.2010 um 15:23 schrieb dovecot:
It behaves just as 'man doveadm' promisses.....
EXIT STATUS doveadm will exit with one of the following values:
0 Selected command was executed successful.
0 Command failed in some way.
So, this seems to be correct!
When a user is not found it should throw an error, and not act innocent - exiting with '0' :)
$ id foo id: foo: No such user $ echo $? 1
On 28-12-10 15:23, dovecot wrote:
On 28-12-10 14:39, Thomas Leuxner wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
- -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
The error codes for' doveadm user' should be improved to avoid error handling workarounds when scripting commands:
$ doveadm user doveadm user [-a<userdb socket path>] [-x<auth info>]<user mask> […] $ echo $? 1 $ doveadm user foo userdb lookup: user foo doesn't exist $ echo $? 0
Please compare to ID output:
$ id foo id: foo: No such user $ echo $? 1
Regards Thomas
- -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iEYEARECAAYFAk0Z6FkACgkQ+meF/S97aXgxnQCfWk1ECdMoCewbr1O6lAkdksoH 324AoLCTg0dFmFhumEkM936irpcG7YF5 =wuwz
- -----END PGP SIGNATURE----- -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iEYEARECAAYFAk0Z6HQACgkQ+meF/S97aXgGdACfawa02hZxk71CjIsj64sW0xXv CW8AoJRQZLFi4QwbvcDg6rzqzUv/3mE8 =Rt1O -----END PGP SIGNATURE-----
It behaves just as 'man doveadm' promisses.....
EXIT STATUS doveadm will exit with one of the following values:
0 Selected command was executed successful.
0 Command failed in some way.
So, this seems to be correct!
SYNOPSIS doveadm [-Dv] user [-a userdb_socket_path] [-x auth_info] user ...
if you do a $ doveadm user $ echo $? 1
This is because you missed one needed parameter ('<user>')
$ doveadm user dovecot userdb: dovecot system_groups_user: dovecot uid : 114 gid : 114 home : /usr/local/lib/dovecot $ echo $? 0
Now its informing you of the uid and gid for the user 'dovecot', and because of that returning 0.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 28.12.2010 um 15:34 schrieb dovecot:
$ doveadm user dovecot userdb: dovecot system_groups_user: dovecot uid : 114 gid : 114 home : /usr/local/lib/dovecot $ echo $? 0
Nothing new, used a similar example in my first mail. Now try with a non-existent user and tell me what it should come up with? (*drum roll*)
-----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iEYEARECAAYFAk0Z9ksACgkQ+meF/S97aXhntwCgjjmO+gGIsoub/V09KvEkhGmu luoAnA3K8NIk9MGcMkNcdP1iCaTMOnos =ikRL -----END PGP SIGNATURE-----
On 28-12-10 15:37, Thomas Leuxner wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 28.12.2010 um 15:34 schrieb dovecot:
$ doveadm user dovecot userdb: dovecot system_groups_user: dovecot uid : 114 gid : 114 home : /usr/local/lib/dovecot $ echo $? 0 Nothing new, used a similar example in my first mail. Now try with a non-existent user and tell me what it should come up with? (*drum roll*)
-----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iEYEARECAAYFAk0Z9ksACgkQ+meF/S97aXhntwCgjjmO+gGIsoub/V09KvEkhGmu luoAnA3K8NIk9MGcMkNcdP1iCaTMOnos =ikRL -----END PGP SIGNATURE-----
$ doveadm user abcd userdb lookup: user abcd doesn't exist $ echo $? 0 Based on the output of '0', the "Selected command was executed successful."
And it is informing you that a user with the name 'abcd' doent exist....
But, indeed, it would be better to return an error in this case
dovecot, the whole point of his original email is to return a useful error code for the purpose of scripting. :) always returning 0 for both valid and invalid usernames isn't helpful
-d
On 28-12-10 16:07, David Ford wrote:
dovecot, the whole point of his original email is to return a useful error code for the purpose of scripting. :) always returning 0 for both valid and invalid usernames isn't helpful
-d
OK,
But the original mail show an invalid use of the doveadm command 'doveadm user', which correctly produced a return-value of '1'
And a correclty formed command 'doveadm user foo', which correctly returned '0'
At the end of 'man doveadm-user' it says: "REPORTING BUGS Report bugs, including doveconf -n output, to the Dovecot Mailing List dovecot@dovecot.org."
While i think this is a change-request, and not a bug, i still wonder what the output of 'dovecot -n' will help in this case ;-)
-- Luuk
On Tue, 2010-12-28 at 14:39 +0100, Thomas Leuxner wrote:
$ doveadm user foo userdb lookup: user foo doesn't exist $ echo $? 0
How about: http://hg.dovecot.org/dovecot-2.0/rev/c9b3716e56f7
Am 30.12.2010 um 10:53 schrieb Timo Sirainen:
On Tue, 2010-12-28 at 14:39 +0100, Thomas Leuxner wrote:
$ doveadm user foo userdb lookup: user foo doesn't exist $ echo $? 0
How about: http://hg.dovecot.org/dovecot-2.0/rev/c9b3716e56f7
Looking good. Thanks.
participants (4)
-
David Ford
-
dovecot
-
Thomas Leuxner
-
Timo Sirainen