A BUGNOTE has been added to this bug.
======================================================================
http://www.dbmail.org/mantis/bug_view_advanced_page.php?bug_id=0000118
======================================================================
Reported By:                seanc
Assigned To:                
======================================================================
Project:                    DBMail
Bug ID:                     118
Category:                   Command-Line programs (dbmail-users, dbmail-util)
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     acknowledged
======================================================================
Date Submitted:             15-Nov-04 10:55 CET
Last Modified:              19-Jan-05 11:56 CET
======================================================================
Summary:                    dbmail-users -c [EMAIL PROTECTED] -W
Description: 
The -W flag to dbmail-users doesn't work.
======================================================================

----------------------------------------------------------------------
 aaron - 15-Nov-04 11:58 CET 
----------------------------------------------------------------------
Try the arguments in reverse. Let me know if that fixes it.

If it does, apply the patch and let me know if that fixes it, too.

If both are true, it's a subtle and stupid FreeBSD extension to POSIX
getopt.

----------------------------------------------------------------------
 seanc - 15-Nov-04 12:11 CET 
----------------------------------------------------------------------
Reversing the options results in an error:

% dbmail-users -a [EMAIL PROTECTED] -W
Opening connection to database...
Opening connection to authentication...
Ok. Connected
Adding user [EMAIL PROTECTED] with password type ,0 bytes mailbox limit and
clientid 0... Ok, user added id [9]
Adding INBOX for new user
Ok. added
Done
% dbmail-users -c [EMAIL PROTECTED] -W
Opening connection to database...
Opening connection to authentication...
Ok. Connected
Performing changes for user [EMAIL PROTECTED]
Done
% dbmail-users -Wc [EMAIL PROTECTED] -W
*** dbmail-users ***
Use this program to manage your DBMail users.
See the man page for more info. Modes of operation:

     -a user   add a user
     -d user   delete a user
     -c user   change details for a user
     -e user   empty all mailboxes for a user
     -l uspec  list information for matching users
     -x alias  create an external forwarding address

Summary of options for all modes:
     -w passwd specify user's password on the command line
     -W [file] read from a file or prompt for a user's password
     -p pwtype password type may be one of the following:
               plaintext, crypt, md5-hash, md5-digest,
               crypt-raw, md5-hash-raw, md5-digest-raw
     -P [file] pull encrypted password from the shadow file
     -u user   new username (only useful for -c, change)
     -g client assign the user to a client
     -m max    set the maximum mail quota in <bytes>B,
               <kbytes>K, or <mbytes>M, default in bytes
               specify 0 to remove any mail quota limits
     -s alia.. adds a list of recipient aliases
     -S alia.. removes a list of recipient aliases (wildcards supported)
     -t fwds.. adds a list of deliver-to forwards
     -T fwds.. removes a list of deliver-to forwards (wildcards
supported)

Common options for all DBMail utilities:
     -f file   specify an alternative config file
     -q        quietly skip interactive prompts
               use twice to suppress error messages
     -v        verbose details
     -V        show the version
     -h        show this help message
Exit 1
% dbmail-users -cW [EMAIL PROTECTED] -W
Opening connection to database...
Opening connection to authentication...
Ok. Connected
Error: user [W] does not exist.
Command failed.
Exit 255
% dbmail-users -cW [EMAIL PROTECTED]
Opening connection to database...
Opening connection to authentication...
Ok. Connected
Error: user [W] does not exist.
Command failed.

I tried futzing with getopt()'s format and removing the double colons and
replacing it with single colons, as well as applying the patch: none of
the above worked.  The differences between glibc and BSD's getopt()
wouldn't change the outcome of this.

----------------------------------------------------------------------
 aaron - 15-Nov-04 12:14 CET 
----------------------------------------------------------------------
Sorry, I'm shooting for this:

dbmail-users -W -c [EMAIL PROTECTED]

----------------------------------------------------------------------
 seanc - 15-Nov-04 12:22 CET 
----------------------------------------------------------------------
I tried both of the following:

% dbmail-users -W -c [EMAIL PROTECTED]
% dbmail-users -Wc [EMAIL PROTECTED]
% dbmail-users -c [EMAIL PROTECTED] -W

And none of them work.

----------------------------------------------------------------------
 aaron - 15-Nov-04 12:33 CET 
----------------------------------------------------------------------
Hrmm...

Well, it Works for Me (TM). I'll see about playing with DBMail on a BSD
machine to try and duplicate the problem.

----------------------------------------------------------------------
 ilja - 24-Nov-04 15:58 CET 
----------------------------------------------------------------------
this will get more attention after the release of dbmail 2.0.1

----------------------------------------------------------------------
 aaron - 25-Nov-04 10:41 CET 
----------------------------------------------------------------------
On an OpenBSD machine, I can confirm that the BSD version of getopt() is
really, really picky. So dbmail-users -Wc bob fails, as does dbmail-users
-W -c bob. The only one that works is dbmail-users -c bob -W.

That aside, I am properly prompted for a password on OpenBSD.

Guess I'll have to dig up a FreeBSD machine to test this on, too.

Incidentally, I'm testing 2.0.1 right now. You're on HEAD. I'm 99% sure
that the two are identical in user.c, but I'll have to check...

----------------------------------------------------------------------
 aaron - 07-Jan-05 12:09 CET 
----------------------------------------------------------------------
Diagnosis: FreeBSD getopt() does not support optional arguments, i.e. those
followed by :: in the optstring specification.

Proposed Solution: Include an implementation of GNU getopt, and add an
autoconf test to use it when the system getopt() doesn't understand
optional arguments. Hopefully someone already has the testcase written...

Workaround: This works for me on the FreeBSD 4.8 at SourceForge's Compile
Farm...

dbmail-users -c joe -W ""

The double quotes create a zero-length argument, which is perfect, because
dbmail-users tests both for a valid optarg pointer and a string of some
length at that address before using it as the password.

----------------------------------------------------------------------
 aaron - 08-Jan-05 05:29 CET 
----------------------------------------------------------------------
Here's the replacement getopt we can use on BSD systems. Now we just need a
testcase to put into autoconf. Since FreeBSD appears to lack getopt_long
(which is quite GNUish) it could be as simple as testing for getopt_long,
and using our own getopt if that's not found. Someone with FreeBSD 5.x
should confirm that it also lacks getopt_long and/or has support for
optional arguments (:: in optstring).

http://www.geocities.com/ResearchTriangle/Node/9405/my_getopt-1.4.txt

----------------------------------------------------------------------
 aaron - 19-Jan-05 11:56 CET 
----------------------------------------------------------------------
Added Ben Sittler's my_getopt and tests to acinclude.m4 that activate it if
necessary. Needs testing on BSD systems -- FreeBSD is acutely affected, and
should be working now, while OpenBSD was mildly affected but should also be
totally GNU working.

Bug History
Date Modified  Username       Field                    Change              
======================================================================
15-Nov-04 10:55seanc          New Bug                                      
15-Nov-04 11:58aaron          Bugnote Added: 0000352                       
15-Nov-04 11:59aaron          File Added: user-reset.diff                    
15-Nov-04 12:11seanc          Bugnote Added: 0000353                       
15-Nov-04 12:14aaron          Bugnote Added: 0000354                       
15-Nov-04 12:22seanc          Bugnote Added: 0000355                       
15-Nov-04 12:33aaron          Bugnote Added: 0000356                       
24-Nov-04 15:58ilja           Bugnote Added: 0000370                       
24-Nov-04 15:58ilja           Status                   new => acknowledged 
25-Nov-04 10:41aaron          Bugnote Added: 0000379                       
07-Jan-05 12:09aaron          Bugnote Added: 0000490                       
08-Jan-05 05:29aaron          Bugnote Added: 0000491                       
19-Jan-05 11:56aaron          Bugnote Added: 0000552                       
======================================================================

Reply via email to