Ticket #176 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

RRD server mode fails (chroot)

Reported by: human Owned by: oetiker
Priority: major Milestone:
Component: misc Version: 1.3dev
Keywords: Cc: berni@…

Description

Not sure whether this is a packaging problem or a rrdtool bug... I've opened a Debian bug as well ( http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=496847)

After upgrading from rrdtool 1.2.28 to rrdtool 1.3.1 the RRD server mode does not work anymore, it claims that chroot failed with errno=2.

rrdtool 1.2.28:

# rrdtool - /tmp
?
RRDtool 1.2.28  Copyright 1997-2008 by Tobias Oetiker <tobi@oetiker.ch>
[...]

rrdtool 1.3.1:

# rrdtool - /tmp
ERROR: can't change root to '/tmp' errno=2
#

Last calls in strace:

chroot("/tmp")                          = 0
write(2, "ERROR: can\'t change root to \'/tm"..., 43ERROR: can't change root
to '/tmp' errno=2

Attachments

chroot-fix.patch Download (0.9 KB) - added by human 2 years ago.
Proposed patch

Change History

Changed 2 years ago by human

The code doesn't appear to be changed between 1.2 and 1.3 (apart of indentation)

chroot(argv[2]); 
if (errno != 0) { 
    fprintf(stderr, 
         "ERROR: can't change root to '%s' errno=%d\n", 
         argv[2], errno); 
[...]

If I understand chroot(2) correctly errno is set only if an error occured (chroot(...) != 0). I guess errno is set from a previous syscall and incorrectly evaluated here. Same is true for the chdir() call a few lines below.

The attached patch fixes the problem for me.

Changed 2 years ago by human

Proposed patch

Changed 2 years ago by human

  • cc berni@… added

Changed 2 years ago by oetiker

  • status changed from new to closed
  • resolution set to fixed

Berni,

thanks ! indeed, that code is just broken. Did some more fixing while I was at it: r1471. cheers tobi

Changed 2 years ago by oetiker

fixed in 1.2 branche too r1472

Note: See TracTickets for help on using tickets.

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.