segfault when rlm_perl used

2009-10-16 Thread Michael Chernyakhovsky
Hi,

i build FR 2.1.7 on slackware 13.0 (glibc-2.9) with perl 5.10.0.

every time, i kill radiusd, message like
radiusd[5754]: segfault at 0 ip b73e2213 sp bfb86dac error 4 in 
libc-2.9.so[b736b000+15a000]
appears in the log.

This is not good bad, but worst when radiusd crashed on run-time.
Then in logs appears message like:

Oct 13 21:58:53 rs kernel: radiusd[11441]: segfault at 20004 ip b7478636 sp 
b502bcb0 error 4 in rlm_perl-2.1.7.so[b73cb000+15b000]
Oct 14 22:09:56 rs kernel: radiusd[17687]: segfault at 8 ip b731e35d sp 
b6f61ce0 error 4 in rlm_perl-2.1.7.so[b71fd000+15b000]
Oct 14 22:14:06 rs kernel: radiusd[18374]: segfault at 8 ip b73d735d sp 
b701ace0 error 4 in rlm_perl-2.1.7.so[b72b6000+15b000]
Oct 15 18:07:58 rs kernel: radiusd[23858]: segfault at 8 ip b745935d sp 
ae89cce0 error 4 in rlm_perl-2.1.7.so[b7338000+15b000]
Oct 15 18:08:56 rs kernel: radiusd[23896]: segfault at c ip b74d400e sp 
ae919c90 error 4[b73b5000+15b000]
Oct 15 18:09:55 rs kernel: radiusd[24042]: segfault at 8 ip b736935d sp 
b07acce0 error 4 in rlm_perl-2.1.7.so[b7248000+15b000]


when i comment out all perl statement in config, any segfault
(in rlm_perl-2.1.7.so and in libc-2.9.so) disappears.


Regards,
Michael.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re[2]: segfault when rlm_perl used

2009-10-16 Thread Michael Chernyakhovsky
Здравствуйте, FreeRadius!

Вы писали 16 октября 2009 г., 18:03:17:


 On Oct 16, 2009, at 2:57 PM, Michael Chernyakhovsky wrote:

 Oct 13 21:58:53 rs kernel: radiusd[11441]: segfault at 20004 ip  
 b7478636 sp b502bcb0 error 4 in rlm_perl-2.1.7.so[b73cb000+15b000]
 Oct 14 22:09:56 rs kernel: radiusd[17687]: segfault at 8 ip b731e35d  
 sp b6f61ce0 error 4 in rlm_perl-2.1.7.so[b71fd000+15b000]
 Oct 14 22:14:06 rs kernel: radiusd[18374]: segfault at 8 ip b73d735d  
 sp b701ace0 error 4 in rlm_perl-2.1.7.so[b72b6000+15b000]
 Oct 15 18:07:58 rs kernel: radiusd[23858]: segfault at 8 ip b745935d  
 sp ae89cce0 error 4 in rlm_perl-2.1.7.so[b7338000+15b000]
 Oct 15 18:08:56 rs kernel: radiusd[23896]: segfault at c ip b74d400e  
 sp ae919c90 error 4[b73b5000+15b000]
 Oct 15 18:09:55 rs kernel: radiusd[24042]: segfault at 8 ip b736935d  
 sp b07acce0 error 4 in rlm_perl-2.1.7.so[b7248000+15b000]


 Could you include the output of gdb, as suggested in doc/bugs?

Bug 31 created: https://bugs.freeradius.org/bugzilla/show_bug.cgi?id=31



 -
 List info/subscribe/unsubscribe? See
 http://www.freeradius.org/list/users.html




-- 
С уважением,
Михаил Черняховский,
НП Магинфоцентр,
г. Магнитогорск.
тел. (3519) 49-69-00,
моб. +7 902 896 2872

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Re[2]: redundant ippools using rlm_ippool in v1.1.3

2008-09-18 Thread Michael Chernyakhovsky
Здравствуйте, FreeRadius!

Вы писали 16 сентября 2008 г., 23:23:13:

 The patch works as promised in version 1.1.3 if applied. The
 post-auth section in radiusd.conf doesn't though.

 As suggested by Michael with Kostas' patch applied you have to pass
 DEFAULT as Pool-Name check attribute in 'users'.


 You should to set Pool-Name to DEFAULT in 'users'. like this
 
  DEFAULT Huntgroup-Name == lns0x, Pool-Name := DEFAULT, 
  Post-Auth-Type := LNS0X
  Fall-Through = Yes
 
  DEFAULT Huntgroup-Name == lns0y, Pool-Name := DEFAULT, 
  Post-Auth-Type := LNS0Y
  Fall-Through = Yes

 The post-auth section as posted by me does not work:

  Post-Auth-Type LNS0X {
  redundant {
  lns0x-00
  lns0x-01
  }
  }


what about simple:
 Post-Auth-Type LNS0X {
 lns0x-00
 lns0x-01
 }

 Post-Auth-Type LNS0Y {
 lns0y-00
 lns0y-01
 }



 lns0x-01 is for unknown reasons not called. It has to be:
are lns0x-00 have no free entries?
in my case second pool used only when first does't give free ip.






-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Re[2]: rlm_detail bug when locking = yes

2006-06-20 Thread Michael Chernyakhovsky
Nicolas wrote:

 we need close outfd right before  return RLM_MODULE_FAIL; at line 236.

  or get the fixes from CVS head which solve many other problems
 in rlm_detail. (for example file renamed or unlinked by another
 program)

 Everyone will save a considerable amount of time if you could backport
 the changes from CVS to 1.1.2, run tests to check the new code, and
 send unified diff to the list.

 http://freeradius.org/radiusd/doc/DIFFS

i try to examine snapshot-20060616

btw, there are old bug in rlm_detail.c.

279:if ((outfd = open(buffer, O_WRONLY | O_APPEND | O_CREAT,
280:  inst-detailperm))  0) {
281:radlog(L_ERR, rlm_detail: Couldn't open file %s: %s,
282:   buffer, strerror(errno));
283:return RLM_MODULE_FAIL;
284:}
286:/*
287: *  If we fail to aquire the filelock in 80 tries
288: *  (approximately two seconds) we bail out.
289: */
290:if (inst-locking) {
291:lseek(outfd, 0L, SEEK_SET);
292:if (rad_lockfd_nonblock(outfd, 0)  0) {
293:close(outfd);
294:tv.tv_sec = 0;
295:tv.tv_usec = 25000;
296:select(0, NULL, NULL, NULL, tv);
297:lock_count++;
298:continue;
299:}

open() executed once. but while we failed to get lock at first try,
close(outfd) executed and all the subsequent attempts to lock file
fails

i comment line 293 out.
After this i havn't got any messages like
Error: rlm_detail: Failed to aquire filelock for 
/var/log/radius/radacct/detail, giving up
in log!

so now rlm_detail with lock=yes and radrelay all works fine.


Mike.

- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re[2]: rlm_detail bug when locking = yes

2006-06-20 Thread Michael Chernyakhovsky


 open() executed once. but while we failed to get lock at first try,
 close(outfd) executed and all the subsequent attempts to lock file
 fails
 
 i comment line 293 out.

 I don't understand why this helps. We open the file at the beginning
 of the do..while() loop, so it should be fine.

err. sorry.
source of snapshot are like to  freeradius-1.1.2
(rlm_detail.c,v1.37.2.1.2.1 2006/04/19). i miss that open() was moved
inside loop :(

 BTW if you remove the close() line 293 you're leaking one file descriptor
 each time the lock fails.
i use stable 1.1.2, not snapshot.
there open() called before do-while loop in this version.
close() executed every iteration.
so i have to comment close() in block
if (rad_lockfd_nonblock(outfd, 0)  0) {
close(outfd);
tv.tv_sec = 0;
tv.tv_usec = 25000;
select(0, NULL, NULL, NULL, tv);
lock_count++;
}
for correct work.


sorry again.

Mike.


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


rlm_detail bug when locking = yes

2006-06-16 Thread Michael Chernyakhovsky
hello, everybody.


my radius use a rlm_perl module, wich  open and write some
informations to files. also it use rlm_detail but without locking.

2 days ago i add second rlm_detail to config with option
locking = yes.
since i got 2 files with corrupted datas which accessed by rlm_perl.

i think bug is in rlm_detail.c. there is no close() after successful
open and failed filelock!

198:/*
199: *  Open  create the file, with the given permissions.
200: */
201:if ((outfd = open(buffer, O_WRONLY | O_APPEND | O_CREAT,
202:  inst-detailperm))  0) {
203:radlog(L_ERR, rlm_detail: Couldn't open file %s: %s,
204:   buffer, strerror(errno));
205:return RLM_MODULE_FAIL;
206:}
...
233:if (!locked  inst-locking  lock_count = 80) {
234:radlog(L_ERR, rlm_detail: Failed to aquire filelock for %s, 
givingup,
235:   buffer);
236:return RLM_MODULE_FAIL;
237:}

we need close outfd right before  return RLM_MODULE_FAIL; at line
236.

Mike.

- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


rlm_detail and radrelay concurrence

2006-06-15 Thread Michael Chernyakhovsky
hello, everyone

i use radrelay
there are errors in log from rlm_detail like

Error: rlm_detail: Couldn't open file /var/log/radius/radacct/detail-relay: Bad 
file descriptor

while examine rlm_detail.c i found two places in it.
first while open (create if need) detail-file (line 204 rlm_detail.c).
second while do converting the FD to FP (line 243) after aquiring
filelock of detail file.

Bad file description error appear because radrelay
can remove detail file while rad_detail trying to aquire filelock, I
think (line 655 of radrelay.c).

rlm_detail.c:
201:if ((outfd = open(buffer, O_WRONLY | O_APPEND | O_CREAT,
202:  inst-detailperm))  0) {
203:radlog(L_ERR, rlm_detail: Couldn't open file %s: %s,
204:   buffer, strerror(errno));
205:return RLM_MODULE_FAIL;
206:}
208:/*
209: *  If we're not using locking, we'll just pass straight though
210: *  the while loop.
211: *  If we fail to aquire the filelock in 80 tries (approximately
212: *  two seconds) we bail out.
213: */
214:locked = 0;
215:lock_count = 0;
216:do {
  
231:} while (!locked  inst-locking  lock_count  80);
...
239:/*
240: *  Convert the FD to FP.  The FD is no longer valid
241: *  after this operation.
242: */
243:if ((outfp = fdopen(outfd, a)) == NULL) {
244:radlog(L_ERR, rlm_detail: Couldn't open file %s: %s,
245:   buffer, strerror(errno));
246:if (inst-locking) {
247:lseek(outfd, 0L, SEEK_SET);
248:rad_unlockfd(outfd, 0);
249:DEBUG(rlm_detail: Released filelock);
250:}
251:close(outfd);
253:return RLM_MODULE_FAIL;
254:}



radrelay.c:

655:if (detail_move(r_args-detail, work) == 0) {
656:if (debug_flag  0)
657:fprintf(stderr, Moving %s to %s\n,
658:r_args-detail, work);
659:/*
660: *  rlm_detail might still write
661: *  something to detail.work if
662: *  it opens detail before it is
663: *  renamed (race condition)
664: */
665:ms_sleep(1000);
666:state = STATE_BACKLOG;
667:}
668:fpos = ftell(fp);
669:fseek(fp, 0L, SEEK_SET);
670:rad_unlockfd(fileno(fp), 0);
671:fseek(fp, fpos, SEEK_SET);


so detail_move can be called by radrelay while rad_detail already
opens detail (line 201) have outfd and try to aquire lock. after radrelay made
rad_unlockfd(fileno(fp), 0) (line 670), rlm_detail try to fdopen (line
243) and will get error.


As workaround we can give to rlm_detail recreate detail...

--- rlm_detail.c-orig   2006-06-15 12:09:43.0 +0600
+++ rlm_detail.c2006-06-15 12:22:49.0 +0600
@@ -119,6 +119,7 @@
struct stat st;
int locked;
int lock_count;
+   int opencount=0;
struct timeval  tv;
REALM   *proxy_realm;
charproxy_buffer[16];
@@ -195,6 +196,8 @@
*p = '/';
} /* else there was no directory delimiter. */

+
+reopen:
/*
 *  Open  create the file, with the given permissions.
 */
@@ -241,8 +244,9 @@
 *  after this operation.
 */
if ((outfp = fdopen(outfd, a)) == NULL) {
-   radlog(L_ERR, rlm_detail: Couldn't open file %s: %s,
-  buffer, strerror(errno));
+   radlog(L_ERR, rlm_detail: Couldn't open file %s: %s. %s,
+  buffer, strerror(errno),
+  (opencount==0)?try reopen to create:return 
MODULE_FAIL);
if (inst-locking) {
lseek(outfd, 0L, SEEK_SET);
rad_unlockfd(outfd, 0);
@@ -250,7 +254,10 @@
}
close(outfd);

-   return RLM_MODULE_FAIL;
+   if (opencount++ == 0)
+   goto reopen;
+   else
+   return RLM_MODULE_FAIL;
}

/*



btw, why to sleep 1000ms on [EMAIL PROTECTED]
how rlm_detail can write something to detail.work, while file is locked
by radreplay?


Mike.






- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html