Re: /etc/defaults/services and /etc/services

看板DFBSD_submit作者時間21年前 (2005/02/11 08:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/11 (看更多)
:Hi, : :although there's an ongoing discussion about the general way of :updating system files, which will probably render my work useless, :here's the patch to have a not-to-be-edited /etc/defaults/services and :an optional /etc/services. : :getservent() now first tries to find a matching protocol name/port :number in /etc/defaults/services, and, if no match was found, reads :lines form /etc/services (if it exists). : :I also updated the getservent.5 man page to reflect these changes, but :there's carloads more in the repository. I did not make changes to :these files, since I'd first like to know if this :/etc/defaults/services stuff will be integrated or not. Once I get a :positive feedback, I'll update all the other man pages, etc. : :The patch lives here: : :http://bettlakenauszuzeln.magic-ceee.com/services.patch.gz : : :Enjoy : :--j Well, regardless of the cvs issue, I think there is a need to separate /etc/services so I definitely want to go with an adjustment to libc to support /etc/defaults/services. Your patch looks like a good first attempt. Here are some comments: * I see why you created a _PATH_ETC_SERVICES but I think in this case it makes sense not to add that #define and to simple use the original _PATH_SERVICES. To keep things similarly named change _PATH_ETC_DEFAULTS_SERVICES to, say, _PATH_DEFAULT_SERVICES. * Do not hardwire loops that index into the array. Instead do something like this define and then use it in your loops. In particular, the if (servf_count == 1) in getservent() is an example of unintentional disconnectedness between the size of the array and the termination check, using (SERVF_ARY_SIZE - 1) makes the check a lot clearer. #define SERVF_ARY_SIZE (sizeof(servf)/sizeof(servf[0])) * getservent() needs to deal with duplicates and overrides. I wonder what we should do about getservent() ... To be entirely correct and avoid confusing programs which use getservent(), we probably want to do some sort of merge. To be entirely correct we would probably want to hash the service names scanned from earlier files and skip any that are found to match in later files. That seems like a waste of memory to me but on the bright side there aren't very many programs which actually use getservent(), and the memory used by the hash would be returned at the end of the scan, so it might not be all that bad. -Matt Matthew Dillon <dillon@backplane.com>
文章代碼(AID): #122_q700 (DFBSD_submit)
討論串 (同標題文章)
文章代碼(AID): #122_q700 (DFBSD_submit)