error reporting in smbpasswd
Tavis Barr
tavis at mahler.econ.columbia.edu
Fri Oct 6 09:28:09 GMT 2000
On Tue, 3 Oct 2000, Gerald Carter wrote:
> Tavis,
>
> Do you have an existing patch against 2.0.7? I don't think
> smbpasswd shoudl have changed much in 2.2/HEAD.
Well, I just tried compiling 2.0.7 on my production machine (Alpha/DEC
Unix 4.0F) and discovered that by default it now overrides getpass() with
getsmbpass() using the flag REPLACE_GETPASS. So I no longer had the
getpass() error even when there was a permissions problem with /dev/tty.
(The version that gave the errors is a 1-year-old+ version of HEAD
that has enough PDC support to log people on and map unix to NT groups).
That said, I did write up a version of smbpasswd.c that has more robust
error messages than the old one, and foced off the REPLACE_GETPASS flag
to make sure it compiled correctly. I'm attaching a diff here against
2.0.7; feel free to use it if you like, it's only a few lines of code.
I only tested it against the one place where I was having problems (call
to getpass() fails) and it reported the error it was supposed to. There
are three other failure points I didn't test: Fail to get passwd from
stdin; user 0 has no user name (pathological I suppose but it will return
"you must specify a user name" instead of "out of memory" which seems at
least a little better); and finally if a non-root user has a UID but no
username (also pathological but who knows) then it will report the "you
don't exist go away" message. Anyway I'm not sure how to test for all
these situations without making my machine setup really weird. But if
you want to give it a shot feel free. :)
Cheers,
Tavis
189c189,196
< } else {
---
> if (!p) {
> fprintf(stderr,"stdin returned null password\n");
> exit(1);
> }
>
> }
>
> else {
190a198,202
> if (!p) {
> fprintf(stderr,"call to getpass() returned null password\n");
> exit(1);
> }
>
216a229,231
> /* don't need to check for non-null password here because
> get_pass should have already checked for it */
>
363c378
< if (!user_name && (pwd = sys_getpwuid(0))) {
---
> if (!user_name && (pwd = sys_getpwuid(0)) && pwd->pw_name) {
496c511
< if (pwd) {
---
> if (pwd && pwd->pw_name) {
More information about the samba-technical
mailing list