Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 134337 - pppd.sh without password and pap/chap secrets
Summary: pppd.sh without password and pap/chap secrets
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:
Depends on:
Blocks:
 
Reported: 2006-05-25 08:32 UTC by Oldrich Jedlicka
Modified: 2006-08-01 02:15 UTC (History)
1 user (show)

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


Attachments
Generating PAP/CHAP secrets independently on password (pppd-without-password.patch,560 bytes, patch)
2006-05-25 08:37 UTC, Oldrich Jedlicka
Details | Diff
Option "forcesecrets" (pppd-force-secrets-option.patch,1.30 KB, patch)
2006-05-26 03:19 UTC, Oldrich Jedlicka
Details | Diff
Variable nopassword_{ifvar}="yes" (pppd-without-password.patch,702 bytes, patch)
2006-05-26 03:23 UTC, Oldrich Jedlicka
Details | Diff
Intelligent empty password updating (pppd-empty-password.patch,3.75 KB, patch)
2006-06-01 02:40 UTC, Oldrich Jedlicka
Details | Diff
Simple patch (pppd.patch,965 bytes, patch)
2006-06-01 04:11 UTC, Roy Marples (RETIRED)
Details | Diff
Allow blank password if set (pppd-blank-password.patch,513 bytes, patch)
2006-06-01 07:14 UTC, Roy Marples (RETIRED)
Details | Diff
Intelligent password updating (pppd-part.sh,6.82 KB, text/plain)
2006-06-05 07:51 UTC, Oldrich Jedlicka
Details
pppd.sh.patch (pppd.sh.patch,553 bytes, patch)
2006-06-06 14:02 UTC, Alin Năstac (RETIRED)
Details | Diff
Patch using passwordfd plugin for sending password (pppd-passwordfd-plugin.patch,5.21 KB, patch)
2006-06-13 00:18 UTC, Oldrich Jedlicka
Details | Diff
Patch using passwordfd plugin without manual FIFO (pppd-passwordfd-plugin.patch,5.09 KB, patch)
2006-06-13 01:54 UTC, Oldrich Jedlicka
Details | Diff
better passwordfd patch (pppd.patch,5.29 KB, patch)
2006-06-13 02:34 UTC, Roy Marples (RETIRED)
Details | Diff
passwordfd plugin in pppd.sh, small cleanup (pppd-passwordfd-plugin.patch,5.61 KB, patch)
2006-06-13 03:04 UTC, Oldrich Jedlicka
Details | Diff
net.example.patch (net.example.patch,1.25 KB, patch)
2006-06-14 22:17 UTC, Alin Năstac (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oldrich Jedlicka 2006-05-25 08:32:37 UTC
It would be good to have a possibility to enter "empty" passwords for authentication in pppd. Now the PAP/CHAP secrets are regenerated, only if both username and password are enterred. My simple patch reduces this requirement to username only.

Verified with my provider who asks for CHAP and without chap-secrets there is a negative response from my pppd.

***
Without my patch:

pppd[25098]: rcvd [LCP ConfReq id=0x1 <auth chap MD5> <accomp> <pcomp> <asyncmap 0x0> <magic 0xbed58806>]
pppd[25098]: sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x504bb20c> <pcomp> <accomp>]
pppd[25098]: No auth is possible
pppd[25098]: sent [LCP ConfRej id=0x1 <auth chap MD5>]

-> CHAP authentication was rejected

***
With my patch:

pppd[27533]: rcvd [LCP ConfReq id=0x1 <auth chap MD5> <accomp> <pcomp> <asyncmap 0x0> <magic 0x5f18471e>]
pppd[27533]: sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xbf097802> <pcomp> <accomp>]
...
pppd[27533]: rcvd [CHAP Challenge id=0x0 <5995345897d8e2b31cac98dd257b92f63355b12f417c193cc2ab8c775c2a85d4679314882461>, name = "Kermit"]
pppd[27533]: sent [CHAP Response id=0x0 <6c342c2d1731523af0ecfba44452968e>, name = "internet"]
pppd[27533]: rcvd [CHAP Success id=0x0 "Congratulations!"]
pppd[27533]: CHAP authentication succeeded: Congratulations!
pppd[27533]: CHAP authentication succeeded

-> CHAP succeeded, even with the empty password. The PAP/CHAP secrets files look like this:

#client server  secret  IP addresses
"internet" ppp0 ""
Comment 1 Oldrich Jedlicka 2006-05-25 08:37:19 UTC
Created attachment 87488 [details, diff]
Generating PAP/CHAP secrets independently on password
Comment 2 Alin Năstac (RETIRED) gentoo-dev 2006-05-25 22:02:04 UTC
Hmm... Some users prefer to set their passwords manually in *.secrets file. This is accomplished by not setting any password in conf.d/net file.

Workaround: 
  - you should modify *.secrets files by hand. 
Reasons:
  - your patch break existing setups
  - using pap/chap without a password is pointless; your ISP should know better.
Comment 3 Oldrich Jedlicka 2006-05-26 03:14:51 UTC
Currently it doesn't cause that I'm not able to connect. The auth is tried twice and then the startup process continues normally. 

Well, there can be non-conflicting solution: variable nopassword_{ifvar}="yes", if you really want to have empty password for certain interface, just to make the login process happy :). The variable password_{ifvar} is still checked for the correct password.

Another solution would be to have it in pppd_{ifvar} as an option and filter this option out for the pppd command. I'm thinking about "forcesecrets" option, but it could be any better one - suggest some ;)

Again, no need to understand or change secrets file for the user, it will be handled by scripts automatically. And I think this is what was planned.

See the patches.
Comment 4 Oldrich Jedlicka 2006-05-26 03:19:50 UTC
Created attachment 87546 [details, diff]
Option "forcesecrets"

This adds a new option to pppd_{ifvar} called "forcesecrets". It will force the script to generate the line in *-secrets files. I think this is better solution than nopassword_{ifvar}.
Comment 5 Oldrich Jedlicka 2006-05-26 03:23:45 UTC
Created attachment 87547 [details, diff]
Variable nopassword_{ifvar}="yes"

This adds a check for the value of the new variable nopassword_{ifvar}. If it contains "yes", one line in *-secrets files will be generated also for no (empty) passwords.
Comment 6 Alin Năstac (RETIRED) gentoo-dev 2006-05-29 21:54:04 UTC
comment #4 : a categoric NO. pppd_${ifname} contains only pppd options.

comment #5 : I am inclined to refuse this as well (since is illogical to request chap authentication when you don't have a password), but if Roy want to apply this patch, I wouldn't mind.
Comment 7 Roy Marples (RETIRED) gentoo-dev 2006-05-30 01:48:41 UTC
OK, I'm not going to apply this one as our current behaviour I think is correct.

We should only update secret files if both username and password are supplied. After all, the conf.d/net file maybe world readable and the secrets file not, so just supplying the username means we can still have this :)

Re-open if you disagree.
Comment 8 Oldrich Jedlicka 2006-05-31 04:56:32 UTC
If there is no other way, at lease inform the user about this in net.example. I just want to prevent the confusion that I had when I entered the user name, password="" and no secrets were created (it worked some time ago).

But the note should sound like this: If you want an empty password in your chap-secrets or pap-secrets, enter the line yourself. We will not do so.

If you think about the note above, you also start thinking - why to do not allow empty passwords? I'm not my ISP and if he is happy with empty password, it is his problem, not mine (or should not be my problem).

Just the last try, if you really do not like the idea of empty passwords, just close this bug, add some user-friendly note into net.example and I promise that I will never reopen it again ;)
Comment 9 Roy Marples (RETIRED) gentoo-dev 2006-05-31 05:39:52 UTC
(In reply to comment #8)
> If there is no other way, at lease inform the user about this in net.example. I
> just want to prevent the confusion that I had when I entered the user name,
> password="" and no secrets were created (it worked some time ago).
> 
> But the note should sound like this: If you want an empty password in your
> chap-secrets or pap-secrets, enter the line yourself. We will not do so.

We already do :p

From current net.example
# PPP requires at least a username. You can optionally set a password here too
# If you don't, then it will use the password specified in /etc/ppp/*-secrets
# against the specified username

> If you think about the note above, you also start thinking - why to do not
> allow empty passwords? I'm not my ISP and if he is happy with empty password,
> it is his problem, not mine (or should not be my problem).

Well pppd does support empty passwords - we just don't make entries in the secrets file with empty passwords.

> 
> Just the last try, if you really do not like the idea of empty passwords, just
> close this bug, add some user-friendly note into net.example and I promise that
> I will never reopen it again ;)

At most I would consider a patch that adds the username with a blank password if the username does not exist in the secrets file. Would that make a good compromise?
Comment 10 Alin Năstac (RETIRED) gentoo-dev 2006-05-31 06:54:19 UTC
(In reply to comment #9)
> At most I would consider a patch that adds the username with a blank password
> if the username does not exist in the secrets file. Would that make a good
> compromise?

Only if no other {chap,pap}-secrets entries have the same username! It is important not to write such line in case one of those files already have an entry with the same username and remotename is either equal with ${iface} or is an *.
Comment 11 Oldrich Jedlicka 2006-06-01 02:40:05 UTC
Created attachment 88072 [details, diff]
Intelligent empty password updating

I like the idea from comment #10, so here is the updated patch. The password is updated (for the particular server) only in those situations:

1) Password is non-empty
2) Password is empty AND there is no password set (either on remotename or on *)

In both cases the user is informed (if in VERBOSE mode) about the result.
Comment 12 Roy Marples (RETIRED) gentoo-dev 2006-06-01 04:11:54 UTC
Created attachment 88077 [details, diff]
Simple patch

Why such a complex patch? Surely this does what is required.
Comment 13 Oldrich Jedlicka 2006-06-01 04:50:42 UTC
(In reply to comment #12)
> Why such a complex patch? Surely this does what is required.

Because your patch doesn't count line
"username" * "password"

as mentioned in comment #10.
Comment 14 Alin Năstac (RETIRED) gentoo-dev 2006-06-01 04:59:49 UTC
I've just looked in pppd source files and learn that it doesn't stop at the first match. For example, suppose you have a ppp0 link with following 2 entries in your pap-secrets:
  user * pass1
  user ppp0 pass2
In this case, the second entry is used because it doesn't contain the wildcard.

As if it isn't complicated enough, * could also be used in username.
Comment 15 Roy Marples (RETIRED) gentoo-dev 2006-06-01 05:53:18 UTC
(In reply to comment #14)
> I've just looked in pppd source files and learn that it doesn't stop at the
> first match. For example, suppose you have a ppp0 link with following 2 entries
> in your pap-secrets:
>   user * pass1
>   user ppp0 pass2

I assume that the following match as well
user * pass
user p* pass2
user pp* pass3
user ppp* pass4
user ppp0 pass5

How about this?

user [a-z][n-q][Pp][0-3] pass6

If that works then we either
1) Drop this entire idea and just don't use blank passwords - easy!
2) Try and match the regex against our interface to see if we can add a new emtpy one or not.
Comment 16 Oldrich Jedlicka 2006-06-01 06:43:55 UTC
(In reply to comment #15)
> (In reply to comment #14)
> > I've just looked in pppd source files and learn that it doesn't stop at the
> > first match. For example, suppose you have a ppp0 link with following 2 entries
> > in your pap-secrets:
> >   user * pass1
> >   user ppp0 pass2
> 
> I assume that the following match as well
> user * pass
> user p* pass2
> user pp* pass3
> user ppp* pass4
> user ppp0 pass5
> 
> How about this?
> 
> user [a-z][n-q][Pp][0-3] pass6
> 
> If that works then we either
> 1) Drop this entire idea and just don't use blank passwords - easy!
> 2) Try and match the regex against our interface to see if we can add a new
> emtpy one or not.
> 

From the MAN page of pppd (version 2.4.3-r15) the server name can contain either "*" or a name. No more complicated situations like brackets. From which version of pppd there is pattern matching of the server name?
Comment 17 Alin Năstac (RETIRED) gentoo-dev 2006-06-01 06:47:58 UTC
The wildcard cannot be used like that; you either set the field to * or you set it to the exact value.

Basically we have 4 priorities:
  0) exact name and exact remotename
  1) exact username and remotename = *
  2) username = * and exact remotename
  3) username = * and remotename = *
Entries are evaluated in order; a match cannot replace the previous match unless the new_priority < old_priority.

I think it would be best to set the password *only* if password_${iface} is defined (even if it is empty). That way we keep compatibility with previous setups.
Comment 18 Oldrich Jedlicka 2006-06-01 07:05:45 UTC
(In reply to comment #17)
> The wildcard cannot be used like that; you either set the field to * or you set
> it to the exact value.
> 
> Basically we have 4 priorities:
>   0) exact name and exact remotename
>   1) exact username and remotename = *
>   2) username = * and exact remotename
>   3) username = * and remotename = *
> Entries are evaluated in order; a match cannot replace the previous match
> unless the new_priority < old_priority.
> 
> I think it would be best to set the password *only* if password_${iface} is
> defined (even if it is empty). That way we keep compatibility with previous
> setups.
>
I will try to play with it a little bit in the evening. I found in bash MAN page, that with `declare -p variable` it should be possible to check, if the variable is defined or not.
 
However, I would like to do this (according to the described priority rules): 

* If the password_${ifvar} is set and there is no match, add new line of the 0) form
* If the password_${ifvar} is set and there is a match, add/change the line of the 0) form
Comment 19 Roy Marples (RETIRED) gentoo-dev 2006-06-01 07:14:11 UTC
Created attachment 88099 [details, diff]
Allow blank password if set

Something like this?
Comment 20 Alin Năstac (RETIRED) gentoo-dev 2006-06-01 07:21:13 UTC
(In reply to comment #19)
> Something like this?

Yeah, that's the one :)
It should be tested though.
Comment 21 Oldrich Jedlicka 2006-06-01 08:07:25 UTC
(In reply to comment #19)
> Something like this?
> 
That's incredibly cool :-) But please tell me, where is it documented? I cannot find it in bash MAN page.
Comment 22 Roy Marples (RETIRED) gentoo-dev 2006-06-01 08:24:50 UTC
(In reply to comment #21)
> (In reply to comment #19)
> > Something like this?
> > 
> That's incredibly cool :-) But please tell me, where is it documented? I cannot
> find it in bash MAN page.
> 

It's not in the bash man page - which is full of a few lies itself.
Instead I use the BASH ABS as a very good source of reference
http://www.tldp.org/LDP/abs/html/parameter-substitution.html
Comment 23 Oldrich Jedlicka 2006-06-01 08:40:01 UTC
(In reply to comment #22)
> http://www.tldp.org/LDP/abs/html/parameter-substitution.html
Thanks :-)

I will try to do some woodoo with checking the current password to match the prioritization in comment #17. Hopefully it will be as simple as ${!password-x} :-). Results tomorrow.
Comment 24 Oldrich Jedlicka 2006-06-02 02:27:34 UTC
Well, almost ready with the little-bit-hard-core (TM) sed script (not so hardcore as in bug #134254), but I now have a better idea how to do it, so no results today. I don't know if I will have time during weekend, but definitely on Monday, so look forward to see the results not later than on Tuesday :-)
Comment 25 Roy Marples (RETIRED) gentoo-dev 2006-06-02 02:58:45 UTC
(In reply to comment #24)
> Well, almost ready with the little-bit-hard-core (TM) sed script (not so
> hardcore as in bug #134254), but I now have a better idea how to do it, so no
> results today. I don't know if I will have time during weekend, but definitely
> on Monday, so look forward to see the results not later than on Tuesday :-)

What sed script is this? Does my patch not satisfy everyone?
Comment 26 Oldrich Jedlicka 2006-06-02 12:53:46 UTC
(In reply to comment #25)
> What sed script is this? Does my patch not satisfy everyone?

Your patch is perfectly ok. I was just thinking about improving the current password recognition (called "old_password") to prevent unnecessary changes to secrets file (if it was edited manually for example). However, I thought about the solution and no hardcore sed scripts are necessary.
Comment 27 Roy Marples (RETIRED) gentoo-dev 2006-06-05 07:34:30 UTC
Fixed in baselayout-1.12.1
Comment 28 Oldrich Jedlicka 2006-06-05 07:51:07 UTC
Created attachment 88440 [details]
Intelligent password updating

This file intelligently checks the current password and makes an update, if the password have been changed. It has all the logic with priorities.

It is ready to be merged with pppd.sh. It works with escaped characters (including new-lines '\n'), but not with multiline strings in secrets.

I personally think that it is necessary only if the user made more complicated changes (that are not handled by current implementation). Bugs in the current pppd.sh (but fixed in pppd-part.sh) are:

* Not able to handle comments on the same line as the secret
* Not able to handle single-quotes '
* Not able to handle \s, that is interpreted by pppd as space (maybe has other escape problems also)

If you think that this is too complicated for this job, just throw the file away. I'm happy with the solution from comment #19, so if you decide to apply only that patch, I think this bug could be closed then.
Comment 29 Roy Marples (RETIRED) gentoo-dev 2006-06-05 11:36:24 UTC
(In reply to comment #28)
> * Not able to handle comments on the same line as the secret
> * Not able to handle single-quotes '
> * Not able to handle \s, that is interpreted by pppd as space (maybe has other
> escape problems also)

I think it can if you escape things properly - iirc mrness did a thorough job testing this.

> If you think that this is too complicated for this job, just throw the file
> away. I'm happy with the solution from comment #19, so if you decide to apply
> only that patch, I think this bug could be closed then.

I think it is too complicated, and the original issue is now fixed. However, your patch can stay here as is in-case any poor soul wants it.

Thanks for your input on this :)
Comment 30 Oldrich Jedlicka 2006-06-06 01:04:21 UTC
(In reply to comment #29)
> (In reply to comment #28)
> > * Not able to handle comments on the same line as the secret
> > * Not able to handle single-quotes '
> > * Not able to handle \s, that is interpreted by pppd as space (maybe has other
> > escape problems also)
> 
> I think it can if you escape things properly - iirc mrness did a thorough job
> testing this.

This works with lines in the format

username remotename "password"

Where both user name and remote name can be enclosed by double quotes. This completely ignores the single quotes

'username' 'remotename' 'password'

The problem can arise, when you have a comment on the same line

username remotename "password" # comment

There are also some interpretation problems:

"pass\sword" pass\ word 'pass\ word' pass\sword

All the words are the same, but not for pppd.sh. What has been mentioned already is ignoring lines like

username * "password"

Current implementation is limited, but can be used for most users I think - if the user doesn't modify the file himself.
***

And a bug at the end: I tried a password

password_ppp0="pass\" word"

And it was added as

"internet" ppp0 "pass" word"

When I started the ppp0 second time, it was edited to (correct)

"internet" ppp0 "pass\" word"
Comment 31 Alin Năstac (RETIRED) gentoo-dev 2006-06-06 14:02:08 UTC
Created attachment 88559 [details, diff]
pppd.sh.patch

This patch solves the bug exposed in comment #30.

I believe we should not trouble ourselves with cases where users edit *-secrets by hand for various reasons:
 a) Entries with * are unsafe. We cannot automatically update/add such entries, knowing we could change authentication info on some other connection. Our entry key is and will be (username, iface), no * allowed!
 b) Escapes like \s within passwords are indeed treated different than ' ' even though it is all the same to pppd, but only the first time :). The same goes for simple quoted passwords.

The only real issue is that our (username, iface) key may be duplicated, which means we could add an entry that pppd don't consider it. However, it is more like a theoretical problem (face it, whoever set the password in /etc/conf.d/net, don't edit *-secrets files unless it doesn't have any other way).
Comment 32 Alin Năstac (RETIRED) gentoo-dev 2006-06-06 14:07:38 UTC
Correction : pppd.sh doesn't care at all about simple quoted fields. Roy, maybe we should replace \" with ['\"] in regex_filter and all sed command lines?
Comment 33 Roy Marples (RETIRED) gentoo-dev 2006-06-12 02:21:42 UTC
So where are we wish this then?

Could we just use the code on comment #28 to replace what we have if that works with all scenarios?
Comment 34 Alin Năstac (RETIRED) gentoo-dev 2006-06-12 04:29:46 UTC
Oldrich, can you propose a new patch?
Remember, we don't want to take into account entries with *, just want to properly detect&update normal entries, with names&remotenames optionally quoted/double-quoted. 
Quoting _must_ be right - if it is started with ", it must be closed by ".
Comments must be ignored.
Comment 35 Oldrich Jedlicka 2006-06-12 07:46:27 UTC
(In reply to comment #34)
> Oldrich, can you propose a new patch?
> Remember, we don't want to take into account entries with *, just want to
> properly detect&update normal entries, with names&remotenames optionally
> quoted/double-quoted. 
> Quoting _must_ be right - if it is started with ", it must be closed by ".
> Comments must be ignored.

Ok, I will update the patch to accept (and recognize) priority 0 entries only, with and without single/double quotes. Do you want any backslash magic, or a patch as simple as possible?
Comment 36 Alin Năstac (RETIRED) gentoo-dev 2006-06-12 07:55:11 UTC
We need at least \", \\ and \' recognized as valid escape sequences (to see in pppd source if \" is interpreted as escape even when it isn't within a double-quoted string). I prefer to read the old password using one sed command and update or add the new password using another sed command (just as is done now).
Comment 37 Roy Marples (RETIRED) gentoo-dev 2006-06-12 08:00:09 UTC
(In reply to comment #36)
> We need at least \", \\ and \' recognized as valid escape sequences (to see in
> pppd source if \" is interpreted as escape even when it isn't within a
> double-quoted string). I prefer to read the old password using one sed command
> and update or add the new password using another sed command (just as is done
> now).
> 

I on the other hand would rather see all the existing regex stuff stripped out as it's

1) hard to read and understand
2) messes up syntax highlighting on all my editors (minor niggle, but hey)

If that involves more calls to sed, grep, awk, tool of choice then I'd much rather have that instead of insane regex :)
Comment 38 Oldrich Jedlicka 2006-06-12 08:08:21 UTC
(In reply to comment #37)
> If that involves more calls to sed, grep, awk, tool of choice then I'd much
> rather have that instead of insane regex :)

The password extraction can be done in one sed line, but it would be a little bit woodoo, it has to be done on a character-by-character basis to create a complete sed script. It depends on how intelligent the script should be. If you say - I want to have everything - then ok, that is almost my script (which cannot handle multi-line fields only).

My motto: I can do impossible now, but miracles in 3 days :-)
Comment 39 Alin Năstac (RETIRED) gentoo-dev 2006-06-12 08:17:07 UTC
Well, we could drop these fancy sed commands and use passwordfd.so plugin instead, but I remember (vaguely) that my attempts to use it were unsuccessfull. How about focusing on this variant instead?
Comment 40 Oldrich Jedlicka 2006-06-12 09:11:49 UTC
(In reply to comment #39)
> Well, we could drop these fancy sed commands and use passwordfd.so plugin
> instead, but I remember (vaguely) that my attempts to use it were
> unsuccessfull. How about focusing on this variant instead?

Looks good. I will also look at it.
Comment 41 Oldrich Jedlicka 2006-06-13 00:18:03 UTC
Created attachment 89024 [details, diff]
Patch using passwordfd plugin for sending password

This patch introduces support for passwordfd plugin. 

The only problem was to open the file descriptor of our choice, I used FIFO file for it. The password is output to the FIFO and then the input from FIFO is redirected to the correct file descriptor of pppd. The file descriptor number is passed to pppd in option "passwordfd".

Enjoy :-)
Comment 42 Alin Năstac (RETIRED) gentoo-dev 2006-06-13 00:29:13 UTC
I hope there is a solution using just echo -n, without any password named pipe/file.
Comment 43 Roy Marples (RETIRED) gentoo-dev 2006-06-13 00:37:29 UTC
(In reply to comment #42)
> I hope there is a solution using just echo -n, without any password named
> pipe/file.
> 

Should be able to use stdin like so

echo -n "${password}" | s-s-d pppd ${opts} plugin passwordfd.so passwordfd 0
Comment 44 Oldrich Jedlicka 2006-06-13 00:47:31 UTC
(In reply to comment #43)
> Should be able to use stdin like so
> 
> echo -n "${password}" | s-s-d pppd ${opts} plugin passwordfd.so passwordfd 0

Not from the source files. If it daemonizes (without option nodetach/updetach), file descriptors 0, 1 and 2 are redirected to /dev/null. You can be sure only about file descriptors greater than 2 - see function detach() in pppd/main.c.
Comment 45 Oldrich Jedlicka 2006-06-13 00:50:22 UTC
(In reply to comment #42)
> I hope there is a solution using just echo -n, without any password named
> pipe/file.

I spend two hours with playing with exec and redirecting, always stopped with "bad file descriptor" error. I mainly didn't know what I was doing, so you can try it as well :-)
Comment 46 Roy Marples (RETIRED) gentoo-dev 2006-06-13 00:55:49 UTC
(In reply to comment #44)
> (In reply to comment #43)
> > Should be able to use stdin like so
> > 
> > echo -n "${password}" | s-s-d pppd ${opts} plugin passwordfd.so passwordfd 0
> 
> Not from the source files. If it daemonizes (without option nodetach/updetach),
> file descriptors 0, 1 and 2 are redirected to /dev/null. You can be sure only
> about file descriptors greater than 2 - see function detach() in pppd/main.c.
> 

Can we patch it so that if the passwordfd plugin is used AND the fd is 0 not to redirect it to /dev/null?

If not, why not just patch pppd not to redirect fd 0? After all, we are in control of the fd ....
Comment 47 Oldrich Jedlicka 2006-06-13 01:04:22 UTC
(In reply to comment #46)
> Can we patch it so that if the passwordfd plugin is used AND the fd is 0 not to
> redirect it to /dev/null?
> 
> If not, why not just patch pppd not to redirect fd 0? After all, we are in
> control of the fd ....

I do not think that patching of pppd is a good solution. We need one particular change only when our pppd.sh starts pppd, not world-wide change. Anyway, we can use perl/python script (wrapper) to do the right thing - read a password from stdin first, create a pipe, pass the parameter to pppd and let it do it's work. Or we can make our own executable to do it - example is in README.pwfd.
Comment 48 Alin Năstac (RETIRED) gentoo-dev 2006-06-13 01:07:13 UTC
I confirm we cannot use stdin for this purpose.

If I remember correctly, we could use something like:
  3< $(echo -n "${password}")
Comment 49 Oldrich Jedlicka 2006-06-13 01:29:43 UTC
(In reply to comment #48)
> If I remember correctly, we could use something like:
>   3< $(echo -n "${password}")

Maybe we can try 3< <(echo -n "${!pasword}") - again it uses one intermediate FIFO, but now it is created by BASH itself, not by the script.
Comment 50 Oldrich Jedlicka 2006-06-13 01:54:18 UTC
Created attachment 89030 [details, diff]
Patch using passwordfd plugin without manual FIFO

Now it uses ability of Bash to handle FIFO creation. Please test it as I do not have PPP0 available now.
Comment 51 Roy Marples (RETIRED) gentoo-dev 2006-06-13 02:34:38 UTC
Created attachment 89032 [details, diff]
better passwordfd patch

OK, I've tested this and it sees to work just fine.
We work out the next free fd to use, incase other scripts want todo similar tricks.

I've also cut down on the number of variables used - no need for them really.

Unless anyone says otherwise this will be committed later today.
Comment 52 Alin Năstac (RETIRED) gentoo-dev 2006-06-13 02:57:19 UTC
Please give me a chance to test it. 
I will do it tonight and post here the results.
Comment 53 Oldrich Jedlicka 2006-06-13 03:04:11 UTC
Created attachment 89034 [details, diff]
passwordfd plugin in pppd.sh, small cleanup

Small fix for comment #51 - reintroduced variable "i" and removed variables "escaped_password" and "password_redir".
Comment 54 Alin Năstac (RETIRED) gentoo-dev 2006-06-13 22:12:33 UTC
I've tested (on PPPoE) the patch submitted in comment #53. 

Works like a charm. Good job everyone!
Comment 55 Roy Marples (RETIRED) gentoo-dev 2006-06-14 01:59:00 UTC
Comitted to our svn repo - will be in baselayout-1.12.2

Thanks for this guys - we've made an ugly but of code much much much nicer :)
Comment 56 Alin Năstac (RETIRED) gentoo-dev 2006-06-14 22:17:41 UTC
Created attachment 89229 [details, diff]
net.example.patch

Please apply this against net.example. Feel free to tackle with words, but keep the sense of the new comments.
Comment 57 Roy Marples (RETIRED) gentoo-dev 2006-06-15 02:03:05 UTC
(In reply to comment #56)
> Please apply this against net.example. Feel free to tackle with words, but keep
> the sense of the new comments.
> 

I've applied the second part (updetach), but not the first part as I feel the NOTE section you added just duplicates the paragraph above it.
Comment 58 Oldrich Jedlicka 2006-06-15 02:06:38 UTC
I think it should be noted explicitly that we do not use {chap,pap}-secrets files.
Comment 59 Roy Marples (RETIRED) gentoo-dev 2006-06-15 02:08:44 UTC
(In reply to comment #58)
> I think it should be noted explicitly that we do not use {chap,pap}-secrets
> files.

We don't, but if password_ppp0 is not even set then pppd will use those files to work out a possible password.
Comment 60 Oldrich Jedlicka 2006-06-15 02:14:55 UTC
(In reply to comment #59)
> We don't, but if password_ppp0 is not even set then pppd will use those files
> to work out a possible password.

Sorry, I'm still sleeping or blind or... The note already in net.example is good.
Comment 61 Alin Năstac (RETIRED) gentoo-dev 2006-06-15 02:23:16 UTC
The current functionality requires an *unset* password_${iface} in order to use other ways to authenticate itself (i.e. secret files). I find my comment highly useful (although the exact phrase may be corrected/improved).

Why would you explain to users how to set an empty password? Isn't it obvious what they should set in this case?
Comment 62 Roy Marples (RETIRED) gentoo-dev 2006-06-15 02:27:59 UTC
(In reply to comment #61)
> The current functionality requires an *unset* password_${iface} in order to use
> other ways to authenticate itself (i.e. secret files). I find my comment highly
> useful (although the exact phrase may be corrected/improved).
> 
> Why would you explain to users how to set an empty password? Isn't it obvious
> what they should set in this case?

Here's the current text

# PPP requires at least a username. You can optionally set a password here too
# If you don't, then it will use the password specified in /etc/ppp/*-secrets
# against the specified username
#username_ppp0='user'
#password_ppp0='password'
# NOTE: You can set a blank password like so
#password_ppp0=

I think that's clear enough

Comment 63 Alin Năstac (RETIRED) gentoo-dev 2006-06-25 00:20:53 UTC
If you are waiting for my reply, there you go. 

Obviously you are right. I should have looked over all comments.
Comment 64 Roy Marples (RETIRED) gentoo-dev 2006-08-01 02:15:05 UTC
Fixed in baselayout-1.12.2