Skip to content

Commit

Permalink
iwebadmin role based access using vlimits (#40)
Browse files Browse the repository at this point in the history
01. user.c, autorespond.c, user.c: removed limits.c, limits.h
02. auth.[c,h]: added struct passwd argument to set_admin_type function, avoid extra call to sql_getpw
03. autorespond.h, dotqmail.h, forward.h, html.h, iwebadmin.h, iwebadminx.h, mailinglist.h, printh.h, show.h, template.h, user.h, util.h: prevent multiple inclusion of header file
04. command.c, iwebadmin.c: added role based access/delegation using vlimits
05. common.c: iweb_exit() - flush outut before exit
06. configure.ac: removed depcrated macros
07. iwebadmin.c: refactored code
08. Makefile.am: enabled auto dependency tracking
09. template.c: removed uneccessary output on descriptor 2
  • Loading branch information
mbhangui committed May 30, 2024
1 parent ce38504 commit fad6b94
Show file tree
Hide file tree
Showing 28 changed files with 723 additions and 426 deletions.
20 changes: 1 addition & 19 deletions iwebadmin-x/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ iwebadmin_DEPENDENCIES=$(COMMONDEPENDENCIES)

COMMONSOURCES=iwebadmin.c alias.c autorespond.c forward.c mailinglist.c \
user.c util.c printh.c auth.c template.c \
command.c show.c cgi.c limits.c dotqmail.c \
command.c show.c cgi.c dotqmail.c \
common.c iwebadmin.h iwebadminx.h

iwebadmin_SOURCES=$(COMMONSOURCES)
Expand Down Expand Up @@ -52,22 +52,6 @@ edit = sed \
-e 's|@email\@|'"`cat conf-email`"'|g' \
-e 's,@prefix\@,$(prefix),g'

iwebadmin.o: config.h iwebadmin.h
alias.o: config.h iwebadmin.h iwebadmin.h
autorespond.o: config.h iwebadmin.h iwebadmin.h
forward.o: config.h iwebadmin.h iwebadminx.h
mailinglist.o: config.h iwebadmin.h iwebadminx.h
user.o: config.h iwebadmin.h iwebadminx.h
util.o: config.h iwebadmin.h iwebadminx.h
printh.o: printh.h
auth.o: config.h iwebadmin.h iwebadminx.h
template.o: config.h iwebadmin.h iwebadminx.h
command.o: iwebadmin.h iwebadminx.h
show.o: config.h iwebadmin.h iwebadminx.h
cgi.o: config.h iwebadmin.h iwebadminx.h
limits.o: config.h iwebadmin.h iwebadminx.h
dotqmail.o: config.h iwebadmin.h iwebadminx.h

iwebadmin.spec: iwebadmin.spec.in conf-version conf-release doc/ChangeLog conf-email
(cat $@.in;./catChangeLog --spec doc/ChangeLog) | $(edit)> $@
iwebadmin.changes: doc/ChangeLog conf-version conf-release conf-email
Expand Down Expand Up @@ -125,5 +109,3 @@ install-data-hook:
$(INSTALL_DATA) README-hooks.md $(DESTDIR)@docdir@/README-hooks.md || exit 1
$(INSTALL_DATA) COPYING $(DESTDIR)@docdir@/COPYING || exit 1
$(INSTALL_DATA) AUTHORS $(DESTDIR)@docdir@/AUTHORS || exit 1

AUTOMAKE_OPTIONS = foreign no-dependencies
5 changes: 1 addition & 4 deletions iwebadmin-x/alias.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: alias.c,v 1.12 2024-05-17 16:17:42+05:30 mbhangui Exp mbhangui $
* $Id: alias.c,v 1.13 2024-05-30 22:51:32+05:30 Cprogrammer Exp mbhangui $
* Copyright (C) 1999-2004 Inter7 Internet Technologies, Inc.
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -53,7 +53,6 @@
#include "iwebadminx.h"
#include "dotqmail.h"
#include "html.h"
#include "limits.h"
#include "util.h"
#include "printh.h"
#include "show.h"
Expand Down Expand Up @@ -564,7 +563,6 @@ adddotqmail()
char strnum[FMT_ULONG];

count_forwards();
load_limits();
if (MaxForwards != -1 && CurForwards >= MaxForwards) {
copy_status_mesg(html_text[157]);
if (!stralloc_append(&StatusMessage, " ") ||
Expand Down Expand Up @@ -593,7 +591,6 @@ adddotqmailnow()
iweb_exit(PERM_FAILURE);
}
count_forwards();
load_limits();
if (MaxForwards != -1 && CurForwards >= MaxForwards) {
copy_status_mesg(html_text[157]);
if (!stralloc_append(&StatusMessage, " ") ||
Expand Down
18 changes: 5 additions & 13 deletions iwebadmin-x/auth.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: auth.c,v 1.8 2023-07-28 22:27:59+05:30 Cprogrammer Exp mbhangui $
* $Id: auth.c,v 1.9 2024-05-30 22:51:54+05:30 Cprogrammer Exp mbhangui $
* Copyright (C) 1999-2004 Inter7 Internet Technologies, Inc.
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -196,24 +196,16 @@ auth_user_domain(const char *ip_addr, struct passwd *pw)
}

void
set_admin_type()
set_admin_type(struct passwd *pw)
{
struct passwd *vpw = NULL;

vpw = sql_getpw(Username.s, Domain.s);
AdminType = NO_ADMIN;
if (Domain.len) {
if (!str_diffn(Username.s, "postmaster", Username.len))
AdminType = DOMAIN_ADMIN;
#ifdef VQPASSWD_HAS_PW_FLAGS
else
if (vpw->pw_flags & QA_ADMIN)
#else
else
if (vpw->pw_gid & QA_ADMIN)
#endif
if (pw->pw_gid & QA_ADMIN)
AdminType = DOMAIN_ADMIN;
else
AdminType = USER_ADMIN;
}
} else
AdminType = NO_ADMIN;
}
7 changes: 5 additions & 2 deletions iwebadmin-x/auth.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: auth.h,v 1.2 2024-05-17 16:18:52+05:30 Cprogrammer Exp mbhangui $
* $Id: auth.h,v 1.3 2024-05-30 22:54:25+05:30 Cprogrammer Exp mbhangui $
* Copyright (C) 1999-2004 Inter7 Internet Technologies, Inc.
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -17,6 +17,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/

#ifndef _AUTH_H
#define _AUTH_H
void auth_system(const char *ip_addr, struct passwd *pw);
void auth_user_domain(const char *ip_addr, struct passwd *pw);
void set_admin_type();
void set_admin_type(struct passwd *pw);
#endif
5 changes: 1 addition & 4 deletions iwebadmin-x/autorespond.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: autorespond.c,v 1.18 2024-05-17 16:17:42+05:30 mbhangui Exp mbhangui $
* $Id: autorespond.c,v 1.19 2024-05-30 22:55:32+05:30 Cprogrammer Exp mbhangui $
* Copyright (C) 1999-2004 Inter7 Internet Technologies, Inc.
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -39,7 +39,6 @@
#include <open.h>
#endif
#include "autorespond.h"
#include "limits.h"
#include "printh.h"
#include "iwebadmin.h"
#include "iwebadminx.h"
Expand Down Expand Up @@ -134,7 +133,6 @@ addautorespond()
iweb_exit(PERM_FAILURE);
}
count_autoresponders();
load_limits();
if (MaxAutoResponders != -1 && CurAutoResponders >= MaxAutoResponders) {
out(html_text[158]);
out(" ");
Expand Down Expand Up @@ -163,7 +161,6 @@ addautorespondnow()
iweb_exit(PERM_FAILURE);
}
count_autoresponders();
load_limits();
if (MaxAutoResponders != -1 && CurAutoResponders >= MaxAutoResponders) {
out(html_text[158]);
out(" ");
Expand Down
6 changes: 5 additions & 1 deletion iwebadmin-x/autorespond.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: autorespond.h,v 1.2 2024-05-17 16:20:51+05:30 mbhangui Exp mbhangui $
* $Id: autorespond.h,v 1.3 2024-05-30 22:55:38+05:30 Cprogrammer Exp mbhangui $
* Copyright (C) 1999-2004 Inter7 Internet Technologies, Inc.
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -17,6 +17,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/

#ifndef _AUTORESPOND_H
#define _AUTORESPOND_H
#include <time.h>

void addautorespond();
Expand All @@ -28,3 +30,5 @@ void modautorespond();
void modautorespondnow();
void show_autoresponders(const char *user, const char *dom, time_t mytime);
void show_autorespond_line(const char *user, const char *dom, time_t mytime, const char *dir);

#endif
Loading

0 comments on commit fad6b94

Please sign in to comment.