Thread: [srvx-commits] CVS: services/src opserv.c,1.255,1.256
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2002-08-04 13:47:58
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv19097/src
Modified Files:
opserv.c
Log Message:
quash warning from previous patch (only shows gcc-2.96?)
make ?clearhost do the same check
allow ?addtrust to accept 0 as a limit meaning unlimited
Index: opserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/opserv.c,v
retrieving revision 1.255
retrieving revision 1.256
diff -C2 -r1.255 -r1.256
*** opserv.c 4 Aug 2002 01:48:39 -0000 1.255
--- opserv.c 4 Aug 2002 13:47:55 -0000 1.256
***************
*** 167,171 ****
#define OSMSG_RESERVED_NICK_ITEM "%s"
#define OSMSG_TRUSTED_LIST "List of trusted hosts:"
! #define OSMSG_HOST_IS_TRUSTED "%s (limit %lu; set %s ago by %s; expires %s: %s)"
#define OSMSG_UPTIME_STATS "Uptime: %s (%u lines processed, CPU time %.2fu/%.2fs)"
#define OSMSG_NO_LAST_WRITE "Last Database Write: Never"
--- 167,171 ----
#define OSMSG_RESERVED_NICK_ITEM "%s"
#define OSMSG_TRUSTED_LIST "List of trusted hosts:"
! #define OSMSG_HOST_IS_TRUSTED "%s (%s; set %s ago by %s; expires %s: %s)"
#define OSMSG_UPTIME_STATS "Uptime: %s (%u lines processed, CPU time %.2fu/%.2fs)"
#define OSMSG_NO_LAST_WRITE "Last Database Write: Never"
***************
*** 1533,1542 ****
{
struct trusted_host *th;
! char length[INTERVALLEN], issued[INTERVALLEN];
th = data;
if (th->issued) intervalString(issued, now - th->issued);
if (th->expires) intervalString(length, th->expires - now);
! opserv_notice(extra, OSMSG_HOST_IS_TRUSTED, key, th->limit, (th->issued ? issued : "some time"), (th->issuer ? th->issuer : "<unknown>"), (th->expires ? length : "never"), (th->reason ? th->reason : "<unknown>"));
return 0;
}
--- 1533,1543 ----
{
struct trusted_host *th;
! char length[INTERVALLEN], issued[INTERVALLEN], limit[128];
th = data;
if (th->issued) intervalString(issued, now - th->issued);
if (th->expires) intervalString(length, th->expires - now);
! if (th->limit) sprintf(limit, "limit %lu", th->limit);
! opserv_notice(extra, OSMSG_HOST_IS_TRUSTED, key, (th->limit ? limit : "no limit"), (th->issued ? issued : "some time"), (th->issuer ? th->issuer : "<unknown>"), (th->expires ? length : "never"), (th->reason ? th->reason : "<unknown>"));
return 0;
}
***************
*** 1698,1702 ****
for (n=1; n<argc; n++) {
struct userNode *un = GetUserH(argv[n]);
- char *scanhost;
if (un) {
--- 1699,1702 ----
***************
*** 1708,1717 ****
opserv_notice(user, OSMSG_ADDRESS_QUEUED, hnamebuf);
}
! } else if (getipbyname(scanhost, &addr)) {
! sockcheck_queue_address(addr);
! opserv_notice(user, OSMSG_ADDRESS_QUEUED, scanhost);
! } else {
! opserv_notice(user, OSMSG_NO_SUCH_ADDRESS, scanhost);
! }
}
return 1;
--- 1708,1720 ----
opserv_notice(user, OSMSG_ADDRESS_QUEUED, hnamebuf);
}
! } else {
! char *scanhost = argv[n];
! if (getipbyname(scanhost, &addr)) {
! sockcheck_queue_address(addr);
! opserv_notice(user, OSMSG_ADDRESS_QUEUED, scanhost);
! } else {
! opserv_notice(user, OSMSG_NO_SUCH_ADDRESS, scanhost);
! }
! }
}
return 1;
***************
*** 1720,1724 ****
static OPSERV_FUNC(cmd_clearhost)
{
! unsigned int n, i;
OPSERV_MIN_PARMS(2, false);
--- 1723,1728 ----
static OPSERV_FUNC(cmd_clearhost)
{
! unsigned int n;
! char hnamebuf[64];
OPSERV_MIN_PARMS(2, false);
***************
*** 1726,1744 ****
for (n=1; n<argc; n++) {
struct userNode *un = GetUserH(argv[n]);
! char *scanhost;
! if (!un) {
! scanhost = argv[n];
} else {
! scanhost = un->hostname;
}
!
! if ((i = sockcheck_uncache_host(scanhost)) && i != (unsigned)-1) {
! opserv_notice(user, OSMSG_HOST_CLEARED, scanhost);
! } else if (i == (unsigned)-1) {
opserv_notice(user, OSMSG_HOST_BUSY, scanhost);
! } else {
opserv_notice(user, OSMSG_HOST_NOTCLEARED, scanhost);
! }
}
return 1;
--- 1730,1750 ----
for (n=1; n<argc; n++) {
struct userNode *un = GetUserH(argv[n]);
! const char *scanhost;
! int i;
! if (un) {
! sprintf(hnamebuf, "%ld.%ld.%ld.%ld", (un->ip >> 24) & 255, (un->ip >> 16) & 255, (un->ip >> 8) & 255, un->ip & 255);
! scanhost = hnamebuf;
} else {
! scanhost = argv[n];
}
! i = sockcheck_uncache_host(scanhost);
! if (i == -1) {
opserv_notice(user, OSMSG_HOST_BUSY, scanhost);
! } else if (i == 0) {
opserv_notice(user, OSMSG_HOST_NOTCLEARED, scanhost);
! } else {
! opserv_notice(user, OSMSG_HOST_CLEARED, scanhost);
! }
}
return 1;
***************
*** 1943,1947 ****
opserv_notice(ohi->clients.list[nn], OSMSG_CLONE_WARNING);
}
! } else if (ohi->clients.used > limit) {
char *target = alloca(3+strlen(user->hostname));
sprintf(target, "*@%s", user->hostname);
--- 1949,1953 ----
opserv_notice(ohi->clients.list[nn], OSMSG_CLONE_WARNING);
}
! } else if (limit && (ohi->clients.used > limit)) {
char *target = alloca(3+strlen(user->hostname));
sprintf(target, "*@%s", user->hostname);
***************
*** 2767,2771 ****
if (!limit || (expires && (expires < now))) return 0;
! opserv_add_trusted_host(host, strtoul(limit, NULL, 0), issuer, issued, expires, reason);
return 0;
}
--- 2773,2777 ----
if (!limit || (expires && (expires < now))) return 0;
! opserv_add_trusted_host(host, (limit ? strtoul(limit, NULL, 0) : 0), issuer, issued, expires, reason);
return 0;
}
***************
*** 2915,2920 ****
char number[16];
! snprintf(number, sizeof(number), "%lu", th->limit);
! dict_insert(subobj, KEY_LIMIT, alloc_record_data_qstring(number));
if (th->expires) {
snprintf(number, sizeof(number), FMT_TIME_T, th->expires);
--- 2921,2928 ----
char number[16];
! if (th->limit) {
! snprintf(number, sizeof(number), "%lu", th->limit);
! dict_insert(subobj, KEY_LIMIT, alloc_record_data_qstring(number));
! }
if (th->expires) {
snprintf(number, sizeof(number), FMT_TIME_T, th->expires);
|