Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 121665 - baselayout-1.12* pppd net module : chat_ppp0 content needs escaping
Summary: baselayout-1.12* pppd net module : chat_ppp0 content needs escaping
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2006-02-05 07:50 UTC by Alin Năstac (RETIRED)
Modified: 2006-02-16 02:14 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
escape chat params (pppd.patch,311 bytes, patch)
2006-02-06 10:48 UTC, Alin Năstac (RETIRED)
Details | Diff
requote properly (pppd-chat-requote.patch,341 bytes, patch)
2006-02-07 02:50 UTC, Roy Marples (RETIRED)
Details | Diff
requote in functions.sh (requote.patch,502 bytes, patch)
2006-02-07 04:54 UTC, Roy Marples (RETIRED)
Details | Diff
Requote even better (requote.patch,1003 bytes, patch)
2006-02-07 08:56 UTC, Roy Marples (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alin Năstac (RETIRED) gentoo-dev 2006-02-05 07:50:47 UTC
Seems we need to escape double quote chars in chat_${iface} array. Also, it wouldn't hurt to escape $ and \ as well.

Look at http://forums.gentoo.org/viewtopic-t-414472.html for an example where escaping is needed.
Comment 1 Roy Marples (RETIRED) gentoo-dev 2006-02-06 02:54:55 UTC
I assume you're referring to the documentation in net.example rather than the pppd module?
Comment 2 Alin Năstac (RETIRED) gentoo-dev 2006-02-06 04:16:09 UTC
Nope, I'm reffering to the pppd module's code.
We launch pppd by using eval, remember?
Comment 3 Roy Marples (RETIRED) gentoo-dev 2006-02-06 04:23:37 UTC
pppd modules does not define anything chat - it merely references the chat variables. So if it needs to be escaped then this has to happen in the user config.

If I'm wrong then either explain more clearly or submit a patch
Comment 4 Alin Năstac (RETIRED) gentoo-dev 2006-02-06 10:48:01 UTC
Created attachment 79049 [details, diff]
escape chat params

This is what I had in mind.
With this patch, chat params containing '," or \ are passed correctly on command line.

The only problem is $ sign, for which I cannot find the proper escape sequence.
Can you help me with this?
Comment 5 Roy Marples (RETIRED) gentoo-dev 2006-02-07 02:50:18 UTC
Created attachment 79096 [details, diff]
requote properly

This patch should do the trick - we do the same thing in rc-daemon.sh and I see no difference here.

However, I also have no means of testing it! What do you think?
Comment 6 Roy Marples (RETIRED) gentoo-dev 2006-02-07 04:54:15 UTC
Created attachment 79107 [details, diff]
requote in functions.sh

Of course, you'll need the fixed requote function in /sbin/functions.sh too ;)
Comment 7 Alin Năstac (RETIRED) gentoo-dev 2006-02-07 04:56:44 UTC
I'll test it in a few hours, when I return home.
Comment 8 Roy Marples (RETIRED) gentoo-dev 2006-02-07 08:56:31 UTC
Created attachment 79132 [details, diff]
Requote even better

New patch, no longer needs a patch to functions.sh
Comment 9 Alin Năstac (RETIRED) gentoo-dev 2006-02-07 10:18:46 UTC
your patch works, but it has the same flaw - don't handle $ signs.
the connect command line is particularly hard to escape. because parameters are interpreted in cascade: eval command => pppd => chat

if you don't think it will be a problem, we can leave it as is. the important chars (quotes) are passed correctly to the chat program.
Comment 10 Roy Marples (RETIRED) gentoo-dev 2006-02-07 11:05:02 UTC
Handles $ signs perfectly as far as I can tell.

Could you post a specfic chat_ppp0=( ... ) config and the output of
cat /proc/$(pidof pppd)/cmdline && echo

where you think it's failing?
Comment 11 Alin Năstac (RETIRED) gentoo-dev 2006-02-07 12:37:48 UTC
you're right, it works!

I've been fooled by the fact that $ is a metacharacter in chat scripts. I quote from man chat:
ENVIRONMENT VARIABLES
       Environment variables are available within chat scripts, if  the -E option was specified  in  the
       command  line.  The  metacharacter $ is used to introduce the name of the environment variable to
       substitute. If the substition fails, because the requested environment variable is not set, noth-
       ing is replaced for the variable.
Comment 12 Roy Marples (RETIRED) gentoo-dev 2006-02-07 12:43:29 UTC
Cool. Patch is in svn and will be in pre16
Comment 13 Roy Marples (RETIRED) gentoo-dev 2006-02-16 02:14:30 UTC
Fixed in baselayout-1.12.0_pre16