BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000116 [uClibc] Other major always 02-18-05 11:49 04-15-05 21:00
Reporter dicksnippe View Status public  
Assigned To uClibc
Priority normal Resolution open  
Status closed   Product Version 0.9.27
Summary 0000116: mkstemp fails in chroot environment because /dev/[u]random might not be available
Description In the latest uClibc (0.9.27) there's an issue with any recent rsync version:

rsync might chroot to any directory (basically whatever is configured as "path" option in /etc/rsyncd.conf) before it starts doing it's thing. During execution rsync calls mkstemp (or mktemp) inside a chrooted environment.

The uClibc environment of mkstemp/mktemp tries to read /dev/urandom (or /dev/random) to generate random contents for the .XXXXXX part of its argument.
In a chrooted environment /dev/[u]random might not be available.
Because of this the mkstemp call fails and returns "-1" and rsync fails and
issues something along the lines of:
 rsync: mkstemp ".tmp.XXXXXX" (in <module>) failed: File exists (17)

imho this is a bug in uClibc and not in rsync. mkstemp should not depend on
/dev/[u]random. Perhaps, instead it should fall back (like glibc) on
gettimeofday(2) and getpid(2) for providing randomness instead of failing.

PS: uClibc and busybox are great! We (= isp) use them to build an initrd environment to boot +/- 200 servers. uClibc+busybox have decimated the
time we need to install a new server from a week to 5 minutes! Please keep up the good work.
Additional Information Attached is an extremely simple minded program to show the unwanted behaviour:

# gcc -static -Wall -o mkstemp mkstemp.c
# cp mkstemp /tmp
# chroot /tmp ./mkstemp /foo.XXXXXX
mkstemp: File exists

Similar behaviour can be shown for mktemp.
Attached Files  mkstemp.c [^] (223 bytes) 02-18-05 11:49

- Relationships

- Notes
(0000052)
vapier
02-21-05 00:53

down in libc/misc/internals/tempname.c, we could modify fillrand() to use something stupid like gettimeofday() as a fallback for when /dev/urandom and /dev/random are unavailable ...
 
(0000148)
vapier
04-15-05 21:00

added back in the gettimeofday / getpid code as a fall back for when reading the random nodes in /dev/ fail
 

- Issue History
Date Modified Username Field Change
02-18-05 11:49 dicksnippe New Issue
02-18-05 11:49 dicksnippe File Added: mkstemp.c
02-21-05 00:53 vapier Note Added: 0000052
02-21-05 00:53 vapier Issue Monitored: vapier
03-16-05 11:56 andersen Assigned To andersen => uClibc
04-15-05 21:00 vapier Status assigned => closed
04-15-05 21:00 vapier Note Added: 0000148


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker