Created attachment 279819 [details, diff] rc_getline-rc_service_get_value.patch (DRAFT) service_get_value strips \n for no reason IMHO. Lets take bug 372547 as example. snipped from iproute2.sh: in iproute2_post_start() it'll do: service_set_value "ip_rule" "${rules}" This is to save the current ip rules for net.ethN. So in this case the user added more than one rule which means there must be a \n per line. That works fine so far, it will be saved as expected but now, when trying to get the value again it will be stripped: from iproute2_post_stop(): local rules="$(service_get_value "ip_rule")" ... _ip_rule_runner del "${rules}" So here we get only the first rule because a) we only read max. one line and b) even if we loop through the file, \n will be stripped in each line. Thus we can't do it that way (not yet) to remove the rules. Well we could do something else in iproute2.sh but robbat2 did it on purpose. He argues that the rules could have been changed, so we need to store the same ones as used in post_start(). This makes sense to me so I played a bit with our rc_getline() function as well as rc_service_get_value. It now does a) not strip the newline in rc_getline() and b) it reads and returns more than one line if available. It still returns a char *. It requires some testing/research if we're going to apply it because it *may* break other uses of esp. rc_getline().
i dont think we should be changing rc_getline() semantics. since you basically want the contents of the file, add a new helper like "rc_getfile()" and use that. also, side notes: - xrealloc(NULL, 10) is the same as xmalloc(10), so you dont need two diff code paths there based on "value" - dont cast the return value of alloc funcs as they return (void*)
This has been fixed by the new rc_getfile() function in commit fdaf1c65cdcba2d9b83e02cc0d08fb6dbbd80a80 http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=fdaf1c65
I am closing this since it was resolved a while back and it is listed on the tracker.