The binary vuserinfo from 4.9.10 release of vpopmail is broken. Here is a
patch to fix it and other small glitches:

diff -urN vpopmail-4.9.10.orig/vcdb.c vpopmail-4.9.10/vcdb.c
--- vpopmail-4.9.10.orig/vcdb.c Sun Mar  4 20:45:01 2001
+++ vpopmail-4.9.10/vcdb.c      Fri Apr 13 02:39:24 2001
@@ -34,6 +34,7 @@
 #include <string.h>
 #include <pwd.h>
 #include <sys/types.h>
+#include <utime.h>
 #include <cdbmake.h>
 #include "config.h"
 #include "vpopmail.h"
@@ -1005,7 +1006,6 @@
        sprintf(tmpbuf, "%s/lastlog", pw->pw_dir);
        utime(tmpbuf, NULL);
        free(tmpbuf);
-#else
-       return(0);
 #endif
+       return(0);
 }

diff -urN vpopmail-4.9.10.orig/vuserinfo.c vpopmail-4.9.10/vuserinfo.c
--- vpopmail-4.9.10.orig/vuserinfo.c    Sun Mar  4 20:47:07 2001
+++ vpopmail-4.9.10/vuserinfo.c Fri Apr 13 03:53:18 2001
@@ -51,43 +51,48 @@
 int DisplayDir;
 int DisplayQuota;
 int DisplayAll;
+int ShowAllUsers;

 void usage();
 void get_options(int argc, char **argv);
 void display_user(struct passwd *mypw);

-int main(argc,argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
 {
- struct passwd *mypw;
- int first;
+       struct passwd *mypw;
+       int first;

-    get_options(argc,argv);
+       get_options(argc,argv);

-    if (Domain[0] != 0 ) {
-       parse_email( Email, User, Domain, MAX_BUFF);
+       if (!ShowAllUsers) {
+               parse_email( Email, User, Domain, MAX_BUFF);

-       if ( (mypw = vauth_getpw( User, Domain )) == NULL ) {
-               if ( Domain[0] == 0 || slen(Domain)==0) {
-                       printf("no such user %s@%s\n", User, DEFAULT_DOMAIN);
-               } else {
-                       printf("no such user %s@%s\n", User, Domain);
+               if (Email[0] == 0) {
+                       usage();
+                       exit(-1);
+               }
+
+               if ( (mypw = vauth_getpw( User, Domain )) == NULL ) {
+                       if ( Domain[0] == 0 || slen(Domain)==0) {
+                               printf("no such user %s@%s\n", User, DEFAULT_DOMAIN);
+                       } else {
+                               printf("no such user %s@%s\n", User, Domain);
+                       }
+                       vclose();
+                       exit(-1);
                }
-               vclose();
-               exit(-1);
-       }
-       display_user(mypw);
-       vclose();
-    } else {
-       first = 1;
-       while( (mypw=vauth_getall(Domain, first, 0))){
-               first = 0;
                display_user(mypw);
+               vclose();
+       } else {
+               first = 1;
+               while( (mypw=vauth_getall(Domain, first, 0)) ) {
+                       first = 0;
+                       display_user(mypw);
+                       printf("\n");
+               }
+               vclose();
        }
-       vclose();
-    }
-    exit(0);
+       exit(0);
 }

 void usage()
@@ -106,10 +111,10 @@

 void get_options(int argc, char **argv)
 {
- int c;
- int errflag;
- extern char *optarg;
- extern int optind;
+       int c;
+       int errflag;
+       extern char *optarg;
+       extern int optind;

        DisplayName = 0;
        DisplayPasswd = 0;
@@ -119,6 +124,7 @@
        DisplayDir = 0;
        DisplayQuota = 0;
        DisplayAll = 1;
+       ShowAllUsers = 0;

        memset(User, 0, MAX_BUFF);
        memset(Email, 0, MAX_BUFF);
@@ -129,7 +135,8 @@
                switch(c) {
                        case 'D':
                                strncpy(Domain, optarg, MAX_BUFF);
-                               break;
+                               ShowAllUsers = 1;
+                               break;
                        case 'v':
                                printf("version: %s\n", VERSION);
                                break;
@@ -162,7 +169,7 @@
                                DisplayAll = 0;
                                break;
                        case 'a':
-                               DisplayAll = 0;
+                               DisplayAll = 1;
                                break;
                        default:
                                errflag = 1;
@@ -179,51 +186,47 @@
                scopy(Email, argv[optind], MAX_BUFF);
                ++optind;
        }
-
-       if ( Email[0] == 0 ) {
-               usage();
-               exit(-1);
-       }
-
 }

 void display_user(struct passwd *mypw)
 {

-    if ( DisplayName    || DisplayAll ) printf("name:   %s\n", mypw->pw_name);
-    if ( DisplayPasswd  || DisplayAll ) printf("passwd: %s\n", mypw->pw_passwd);
-    if ( DisplayUid     || DisplayAll ) printf("uid:    %d\n", mypw->pw_uid);
-    if ( DisplayGid     || DisplayAll ) {
-       printf("gid:    %d\n", mypw->pw_gid);
-
-       if ( mypw->pw_gid == 0 )
-           printf("        all services available\n");
-       if ( mypw->pw_gid & NO_PASSWD_CHNG )
-           printf("        password can not be changed by user\n");
-       if ( mypw->pw_gid & NO_POP )
-               printf("        pop access closed\n");
-       if ( mypw->pw_gid & NO_WEBMAIL )
-               printf("        webmail access closed\n");
-       if ( mypw->pw_gid & NO_IMAP )
-               printf("        imap access closed\n");
-       if ( mypw->pw_gid & BOUNCE_MAIL )
-               printf("        mail will be bounced back to sender\n");
-       if ( mypw->pw_gid & NO_RELAY )
-               printf("        user not allowed to relay mail\n");
-       if ( mypw->pw_gid & NO_DIALUP )
-               printf("        no dialup flag has been set\n");
-       if ( mypw->pw_gid & V_USER0 )
-               printf("        user flag 0 is set\n");
-       if ( mypw->pw_gid & V_USER1 )
-               printf("        user flag 1 is set\n");
-       if ( mypw->pw_gid & V_USER2 )
-               printf("        user flag 2 is set\n");
-       if ( mypw->pw_gid & V_USER3 )
-               printf("        user flag 3 is set\n");
-
-    }
-    if ( DisplayComment || DisplayAll ) printf("gecos:  %s\n", mypw->pw_gecos);
-    if ( DisplayDir     || DisplayAll ) printf("dir:    |%s|\n", mypw->pw_dir);
-    if ( DisplayQuota   || DisplayAll ) printf("quota:  %s\n", mypw->pw_shell);
+       if ( DisplayName    || DisplayAll ) printf("name:   %s\n", mypw->pw_name);
+       if ( DisplayPasswd  || DisplayAll ) printf("passwd: %s\n", mypw->pw_passwd);
+       if ( DisplayUid     || DisplayAll ) printf("uid:    %d\n", mypw->pw_uid);
+
+       if ( DisplayGid     || DisplayAll ) {
+               printf("gid:    %d\n", mypw->pw_gid);
+
+               if ( mypw->pw_gid == 0 )
+                       printf("        all services available\n");
+               if ( mypw->pw_gid & NO_PASSWD_CHNG )
+                       printf("        password can not be changed by user\n");
+               if ( mypw->pw_gid & NO_POP )
+                       printf("        pop access closed\n");
+               if ( mypw->pw_gid & NO_WEBMAIL )
+                       printf("        webmail access closed\n");
+               if ( mypw->pw_gid & NO_IMAP )
+                       printf("        imap access closed\n");
+               if ( mypw->pw_gid & BOUNCE_MAIL )
+                       printf("        mail will be bounced back to sender\n");
+               if ( mypw->pw_gid & NO_RELAY )
+                       printf("        user not allowed to relay mail\n");
+               if ( mypw->pw_gid & NO_DIALUP )
+                       printf("        no dialup flag has been set\n");
+               if ( mypw->pw_gid & V_USER0 )
+                       printf("        user flag 0 is set\n");
+               if ( mypw->pw_gid & V_USER1 )
+                       printf("        user flag 1 is set\n");
+               if ( mypw->pw_gid & V_USER2 )
+                       printf("        user flag 2 is set\n");
+               if ( mypw->pw_gid & V_USER3 )
+                       printf("        user flag 3 is set\n");
+
+       }
+
+       if ( DisplayComment || DisplayAll ) printf("gecos:  %s\n", mypw->pw_gecos);
+       if ( DisplayDir     || DisplayAll ) printf("dir:    |%s|\n", mypw->pw_dir);
+       if ( DisplayQuota   || DisplayAll ) printf("quota:  %s\n", mypw->pw_shell);

 }

-- 
Antonio Dias

Reply via email to