[vchkpw] Help adding user 'Service Levels'

2003-03-03 Thread Rick Romero

This is a first attempt at adding user-based Service Levels to my
setup in vpopmail.  I run vpopmail with MySQL, and so far I'm just
trying to change what html templates are displayed by qmailadmin. 
(basically, the same thing that's done for postmaster and quotas)

I've attached two patches to vpopmail-5.3.18 and qmailadmin-1.12, and I
was hoping someone could help me :)

It seems the default 'svclvl' of 0 is always used, and I'm not sure if
it's not pulled from MySQL, or if I've just done something wrong
somewhere else.  

A couple things to note:
1. I'm not a programmer :)  (What my look like good works from me, are
just modifications of other's works ;)
2. I think it's best if I change that char's to int's, but I started
with char because I added the field in MySQL as a char.  I haven't
gotten back to that part yet, afaics, it should work as is.

I'm not sure about:
 if ( row[8] != 0) strncpy(vpw.pw_svclvl, row[8],SMALL_BUFF);
in vmysql.c, row[8] should exist because I do have a clear password
(row[7]).


I haven't even thrown any basic printf's in there for debugging, so I am
REALLY at the beginning of trying to make this work.. (umm, where would
they end up?  syslog?)

So before I really start spending time on it, is anyone else interested
is this, and if so.. is there a better, more 'global' way of doing this?
I'm not very comfortable with assigning 'Service Levels' directly in the
qmailadmin code, but for my own uses it'll work just fine.

And if anyone could comment on the patches, and what I did wrong, I'd
appreciate it :)

I'm not on the qmailadmin list, so I didn't send this there.. I want to
make sure my vpopmail code looks right first :)

Thanks

Rick
--- vpopmail-5.3.18/vauth.h	Sat Apr  6 08:30:31 2002
+++ vpopmail-5.3.18-vfe/vauth.h	Sun Mar  2 19:12:15 2003
@@ -36,6 +36,7 @@
   char *pw_dir;			/* Home directory.  */
   char *pw_shell;		/* Shell program.  */
   char *pw_clear_passwd;	/* Clear password.  */
+  char *pw_svclvl;		/* Service Level */
 };
 
 int vauth_adddomain(char *);
--- vpopmail-5.3.18/vmysql.c	Mon Jan 27 10:29:15 2003
+++ vpopmail-5.3.18-vfe/vmysql.c	Sun Mar  2 19:13:13 2003
@@ -72,6 +72,7 @@
 char IDir[SMALL_BUFF];
 char IShell[SMALL_BUFF];
 char IClearPass[SMALL_BUFF];
+char Isvclvl[SMALL_BUFF];
 
 char EPass[SMALL_BUFF];
 char EGecos[SMALL_BUFF];
@@ -327,7 +328,7 @@
  uid_t myuid;
  uid_t uid;
  gid_t gid;
-
+ 
 vget_assign(domain,NULL,156,uid,gid);
 myuid = geteuid();
 if ( myuid != 0  myuid != uid ) return(NULL);
@@ -382,13 +383,15 @@
 memset(IDir, 0, sizeof(IDir));
 memset(IShell, 0, sizeof(IShell));
 memset(IClearPass, 0, sizeof(IClearPass));
-
+	memset(Isvclvl, 0, sizeof(Isvclvl));
+	
 vpw.pw_name   = IUser;
 vpw.pw_passwd = IPass;
 vpw.pw_gecos  = IGecos;
 vpw.pw_dir= IDir;
 vpw.pw_shell  = IShell;
 vpw.pw_clear_passwd  = IClearPass;
+	vpw.pw_svclvl = Isvclvl;
 
 if((row = mysql_fetch_row(res_read))) {
 strncpy(vpw.pw_name,row[0],SMALL_BUFF);
@@ -401,7 +404,8 @@
 #ifdef CLEAR_PASS
 if ( row[7] != 0 )  strncpy(vpw.pw_clear_passwd, row[7],SMALL_BUFF);
 #endif
-} else {
+		if ( row[8] != 0) strncpy(vpw.pw_svclvl, row[8],SMALL_BUFF);
+	} else {
 mysql_free_result(res_read);
 return(NULL);
 }

--- vpopmail-5.3.18/vmysql.h	Fri Jan 24 02:30:33 2003
+++ vpopmail-5.3.18-vfe/vmysql.h	Mon Mar  3 03:40:41 2003
@@ -45,6 +45,7 @@
 pw_dir char(160), \
 pw_shell char(20), \
 pw_clear_passwd char(16), \
+pw_svclvl char(5), \
 primary key (pw_name, pw_domain ) 
 #else
 #define TABLE_LAYOUT pw_name char(32) not null, \
@@ -54,6 +55,7 @@
 pw_gecos char(48), \
 pw_dir char(160), 
 pw_shell char(20), \
+pw_svclvl char(5), \	
 primary key (pw_name, pw_domain ) 
 #endif
 #else

--- qmailadmin-1.0.12/auth.c	Tue Aug  6 17:04:59 2002
+++ qmailadmin-1.0.12-vfe/auth.c	Mon Mar  3 04:27:46 2003
@@ -143,6 +143,12 @@
 
   vpw = vauth_getpw(Username, Domain);
   AdminType = NO_ADMIN;
+  ServiceLevel = 0;
+  if (strstr(vpw-pw_svclvl, 0)) {ServiceLevel = 0;}
+  if (strstr(vpw-pw_svclvl, 1)) {ServiceLevel = 1;}
+  if (strstr(vpw-pw_svclvl, 5)) {ServiceLevel = 5;}
+  if (strstr(vpw-pw_svclvl, 6)) {ServiceLevel = 6;}
+
   if ( strlen(Domain)  0 ) {
 if ( strcmp(Username,postmaster)==0 ) {
   AdminType = DOMAIN_ADMIN;
--- qmailadmin-1.0.12/qmailadmin.c	Thu Feb 27 14:38:17 2003
+++ qmailadmin-1.0.12-vfe/qmailadmin.c	Sun Mar  2 19:45:31 2003
@@ -63,6 +63,7 @@
 FILE *color_table;
 
 int AdminType;
+int ServiceLevel;
 int MaxPopAccounts;
 int MaxAliases;
 int MaxForwards;
--- qmailadmin-1.0.12/qmailadminx.h	Fri Oct 25 03:33:42 2002
+++ qmailadmin-1.0.12-vfe/qmailadminx.h	Sun Mar  2 19:43:43 2003
@@ -48,6 +48,7 @@
 
 extern int num_of_mailinglist;
 extern int AdminType;
+extern int ServiceLevel;
 extern int MaxPopAccounts;
 extern int MaxAliases;
 extern int MaxForwards;
--- qmailadmin-1.0.12/user.c	Thu Feb 27 18:19:08 2003
+++ qmailadmin-1.0.12-vfe/user.c	Mon Mar  3 04:26:02 2003
@@ -345,10 

Re: [vchkpw] Help adding user 'Service Levels'

2003-03-03 Thread Rick Romero

Whoop.. I'm a dork.  I miscounted columns, and assumed the SELECT in
vmysql.c just grabbed them all.

It's working now :)   (But if anyone is interested in more, or has any
ideas on a better way to do it, let me know)

Rick

On Mon, 2003-03-03 at 09:48, Rick Romero wrote:
 This is a first attempt at adding user-based Service Levels to my
 setup in vpopmail.  I run vpopmail with MySQL, and so far I'm just
 trying to change what html templates are displayed by qmailadmin. 
 (basically, the same thing that's done for postmaster and quotas)
 
 I've attached two patches to vpopmail-5.3.18 and qmailadmin-1.12, and I
 was hoping someone could help me :)
 
 It seems the default 'svclvl' of 0 is always used, and I'm not sure if
 it's not pulled from MySQL, or if I've just done something wrong
 somewhere else.  
 
 A couple things to note:
 1. I'm not a programmer :)  (What my look like good works from me, are
 just modifications of other's works ;)
 2. I think it's best if I change that char's to int's, but I started
 with char because I added the field in MySQL as a char.  I haven't
 gotten back to that part yet, afaics, it should work as is.
 
 I'm not sure about:
  if ( row[8] != 0) strncpy(vpw.pw_svclvl, row[8],SMALL_BUFF);
 in vmysql.c, row[8] should exist because I do have a clear password
 (row[7]).
 
 
 I haven't even thrown any basic printf's in there for debugging, so I am
 REALLY at the beginning of trying to make this work.. (umm, where would
 they end up?  syslog?)
 
 So before I really start spending time on it, is anyone else interested
 is this, and if so.. is there a better, more 'global' way of doing this?
 I'm not very comfortable with assigning 'Service Levels' directly in the
 qmailadmin code, but for my own uses it'll work just fine.
 
 And if anyone could comment on the patches, and what I did wrong, I'd
 appreciate it :)
 
 I'm not on the qmailadmin list, so I didn't send this there.. I want to
 make sure my vpopmail code looks right first :)
 
 Thanks
 
 Rick