Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 61699 Details for
Bug 53954
Support for kernel PPPoE in the RC scripts
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
support for pap/chap-secrets automatic editing
functions.new (text/plain), 2.64 KB, created by
Alin Năstac (RETIRED)
on 2005-06-21 22:49:56 UTC
(
hide
)
Description:
support for pap/chap-secrets automatic editing
Filename:
MIME Type:
Creator:
Alin Năstac (RETIRED)
Created:
2005-06-21 22:49:56 UTC
Size:
2.64 KB
patch
obsolete
># void escape_regex_string_param(char* param) ># ># Escape special regex characters >function escape_regex_string_param() { > local escaped_result=$@ > escaped_result=${escaped_result//./[.]} > #cannot proper escape / char because of /.../ filters; replace it with "any char" > escaped_result=${escaped_result//\//.} > escaped_result=${escaped_result//\*/[\*]} > escaped_result=${escaped_result//\\/\\\\} > echo $escaped_result >} > ># bool update_secrets_file(char* filepath, char* username, char* remotename, char* password) ># ># Add/update PAP/CHAP authentication information >function update_secrets_file() { > local filepath=${1} username=${2} remotename=${3} password=${4} > if [[ ! -f ${filepath} ]]; then > touch ${filepath} && \ > chmod 0600 ${filepath} || \ > return 1 > fi > > #escape username and remotename, used in following sed calls > local regex_username=$(escape_regex_string_param ${username}) > local regex_remotename=$(escape_regex_string_param ${remotename}) > local regex_password=${password//\\/\\\\} > > #read old password, including " chars > #for being able to distinct when we need to add or update auth info > local old_password=$( > sed -e "/^[ \t]*\"\?${regex_username}\"\?[ \t]*${regex_remotename}[ \t]*\".*\"[ \t]*\$/\ > {s/^[ \t]*\"\?${regex_username}\"\?[ \t]*${regex_remotename}[ \t]*\(\".*\"\)[ \t]*\$/\1/;q;};\ > d;" \ > ${filepath} > ) > > if [[ -z "${old_password}" ]]; then > regex_username=${username//\\/\\\\} > regex_remotename=${remotename//\\/\\\\} > sed -i -e "\$a\"${regex_username}\" ${regex_remotename} \"${regex_password}\"" ${filepath} > ewarn "Authentication info has been added to ${filepath}" > elif [[ "\"${password}\"" != "${old_password}" ]]; then > #find an unused char for s command separator > local i test sep="" > for i in '/' ':' ';' ',' '|' '~' '!' '@' '%' '-' '_' '=' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I'; do > eval test=\$\{regex_username/\${i}/\} > if [[ "${test}" != "${regex_username}" ]]; then > continue > fi > eval test=\$\{regex_remotename/\${i}/\} > if [[ "${test}" != "${regex_remotename}" ]]; then > continue > fi > eval test=\$\{regex_password/\${i}/\} > if [[ "${test}" != "${regex_password}" ]]; then > continue > fi > sep=${i} > break > done > if [[ -z "${sep}" ]]; then > eerror "Failed to update authentication info in ${filepath} - unable to find unused separator for s sed command" > return 1 > fi > sed -i -e "/^[ \t]*\"\?${regex_username}\"\?[ \t]*${regex_remotename}[ \t]*\".*\"[ \t]*\$/\ > {s${sep}^\([ \t]*\"\?${regex_username}\"\?[ \t]*${regex_remotename}[ \t]*\"\).*\(\"[ \t]*\)\$${sep}\1${regex_password}\2${sep};q;};" \ > ${filepath} > ewarn "Authentication info has been updated in ${filepath}" > fi > return 0 >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 53954
:
61462
|
61517
|
61518
|
61523
|
61597
|
61598
|
61599
|
61600
|
61699
|
61844
|
61849
|
62051
|
62083
|
62109
|
62123
|
62124
|
62377
|
62505
|
62508