Subject: pkg/11633: [rkb] librep trips over mkdir(2) with trailing slash failure
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rafal@mediaone.net>
List: netbsd-bugs
Date: 12/04/2000 12:07:14
>Number: 11633
>Category: pkg
>Synopsis: librep trips over mkdir(2) with trailing slash failure
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Dec 04 12:07:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:
>Release: pkgsrc CVS'ed 12/03/00 23:00EST
>Organization:
Highly unlikely
>Environment:
System: NetBSD cyclops.metatel.office 1.5L NetBSD 1.5L (CYCLOPS.4MB) #4: Mon Dec 4 00:08:38 EST 2000 root@cyclops.metatel.office:/extra/src-current/sys/arch/i386/compile/CYCLOPS.4MB i386
Architecture: i386
Machine: i386
>Description:
librep's rep_make_directory (which is the C worker invoked by the lisp
`make-directory' function), falls over if passed a directory ending
with a slash [see the thread on mkdir(2)'s behaviour on the lists in
the recent past for the complete story 8-)].
Unfortunately, librep and its' users tend to do the following:
(make-directory (file-name-directory "/etc/passwd"))
Which ends up calling (make-directory "/etc/"), and this ends up
failing.
This is particularly nasty in the sawfish window manger, which beeps
at you everytime it fails to create the ~/.sawfish/ directory for its
configuration data. It generally isn't clear where the beeping is
coming from and it's annoying as hell.
>How-To-Repeat:
Build sawfish and its' dependencies. Run sawfish for the first time
and try and change some of the configuration. Notice that each time
you invoke the WM in some manner something beeps your PC speaker.
Turn off all the sound-related options and find that it's still
beeping...
Consider opening up the PC and ripping out the speaker.
Finally, ktruss the sawfish process and notice it's failing to create
~/.sawfish/. Once it's created by hand the beeping stops... And there
was much rejoicing!
Put 2 and 3 together to get 42 and figure the beeping on your speaker
must be caused by the mkdir(2) failure!
>Fix:
Add the following patch to librep's patches:
--- src/unix_files.c.orig Mon Dec 4 14:32:31 2000
+++ src/unix_files.c Mon Dec 4 14:38:06 2000
@@ -286,6 +286,12 @@
repv
rep_make_directory(repv dir)
{
+ int len = rep_STRING_LEN(dir);
+
+ /* Trim trailing '/' to mkdir(2) since some OSes fail the call otherwise */
+ if (*(rep_STR(dir) + len - 1) == '/')
+ dir = rep_string_dupn(rep_STR(dir), len - 1);
+
if(mkdir(rep_STR(dir), S_IRWXU | S_IRWXG | S_IRWXO) == 0)
return Qt;
else
>Release-Note:
>Audit-Trail:
>Unformatted: