Summary: | ASTERISK-02992: [patch] Wrong flags passed to glob, and fix for solaris | ||
Reporter: | slimey (slimey) | Labels: | |
Date Opened: | 2004-12-15 02:20:31.000-0600 | Date Closed: | 2008-01-15 15:16:41.000-0600 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) patch_glob_20041215.txt ( 1) patch_glob_20041215.txt | |
Description: | In config.c, the glob call was: glob_ret = glob(fn, GLOB_NOMATCH|GLOB_BRACE, NULL, &globbuf); GLOB_NOMATCH is a return code, not an entry flag. Additionally, Solaris doesn't have GLOB_BRACE. Based on the values in glob.h, I've corrected the code thus: #ifdef SOLARIS glob_ret = glob(fn, GLOB_ERR|GLOB_MARK, NULL, &globbuf); #else glob_ret = glob(fn, GLOB_ERR|GLOB_MARK|GLOB_BRACE, NULL, &globbuf); #endif Patch attached. ****** ADDITIONAL INFORMATION ****** Disclaimer on file | ||
Comments: | By: Kevin P. Fleming (kpfleming) 2004-12-15 09:17:25.000-0600 See bug 3051... This was a mistake on my part. I had intended to change it to GLOB_NOMAGIC, but typed GLOB_NOMATCH instead, and it has not failed or caused problems on my boxes so I didn't notice. The correct fix (for non-Solaris) is to change GLOB_NOMATCH to GLOB_NOMAGIC. The intent is for the glob() call to just return the original string if it does not contain any metacharacters. By: Kevin P. Fleming (kpfleming) 2004-12-15 09:20:07.000-0600 Oh, and GLOB_MARK is unnecessary. The code that loops through the results cannot handle directories, whether they have trailing slashes or not. I can't speak to whether GLOB_ERR is really necessary or not, but it will cause the glob expansion to fail if any directories it tries to access are inaccessible, as opposed to returning all the results it can. By: slimey (slimey) 2004-12-15 09:28:52.000-0600 I thought that was probably what you intended, but I fixed the code to do exactly the same as what it did at the moment. Herewith a revised patch. By: slimey (slimey) 2004-12-15 10:02:46.000-0600 Oops. GLOB_NOMAGIC isn't there on Solaris, you need GLOB_NOCHECK instead. That'll teach me to not test it before submitting. Do you want a new patch? By: Kevin P. Fleming (kpfleming) 2004-12-15 10:43:54.000-0600 Yes, that would be nice, then Mark can apply a single patch to fix this (and also close the other bug). Do you have a disclaimer on file? It might not be needed for something this small, though. By: slimey (slimey) 2004-12-15 11:04:33.000-0600 Just reading the manpage for glob on linux, I'm wondering if GLOB_NOCHECK would have the desired effect on linux too? The two options are defined thus: GLOB_NOCHECK which means that, if no pattern matches, to return the original pattern, GLOB_NOMAGIC which means that the pattern is returned if it contains no metacharacters, I can't see a difference between the two, except that with GLOB_NOCHECK, if you pass in "fred*" and it doesn't match you'll get fred* back, whereas with GLOB_NOMAGIC you'll get no matches back. By: Mark Spencer (markster) 2004-12-15 11:04:41.000-0600 Should be fixed in CVS (both parts) By: Digium Subversion (svnbot) 2008-01-15 15:16:41.000-0600 Repository: asterisk Revision: 4453 U trunk/config.c ------------------------------------------------------------------------ r4453 | markster | 2008-01-15 15:16:41 -0600 (Tue, 15 Jan 2008) | 2 lines Fix glob issue on solaris (bug ASTERISK-2992) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=4453 |