[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#988: Solution to pty allocation problem



Hi.  I have invested a non-trivial amount of thought into this problem :-)
and I think I have found a solution that works and that avoids all
race conditions.  It involves three small suid-root binaries that
have to be called according to a certain recipe.  (An example is 
provided).  The caller does not need _any_ special privileges.
Thus, xterm could be patched to not need to run as root, and 
script could be made spy-proof.  (And an ancient bug report
could be closed :)

The tar.gz is only 133 lines, uuencoded, so I'll just append it
to the mail.  There is a manpage inside the archive.

If there is agreement that this approach is a Good Idea, I will create
a getpty package from it and supply patches for xterm to use it.

Richard Braakman
<dark@xs4all.nl>

begin 600 pty.tar.gz
M'XL(`#!5^S,``^T\_7/;-K+Y-?PK4+]K+:6R+,FVG(\Z]US'3CR7VGF6,[E.
MDO%0)"3Q0I$\DK*M7O/^]ML/``0ERG+ZSD[NG3B=QB*!Q6(7N]@O(,FGFP_N
M^!';K=V='?%`"+&[VZ9_V]O;]*]Z6D)TMW:[W9W.5K<#7UOMK=T'8N>N$<-G
MDN5N*L0#WTT_W=Q.IME]('2_3P+\'\H<_FEZ=S5&N]7J*GY7\7][!WFN^;^S
M#5_;NYWM!Z)U5PC9SW\X_S<?.>*1T"M`;(A!$/G"%8-42@'OA`L_,QG\)D60
MBT&<BGPDA>>&H4RAYZ;C,(3S49"))(V'J3L65VXFKM(@SV4D^E-Q%G@C-_7%
MSZGK?AJ[D?@)B?W?U]DV@&E&X?,F0Y#"G>0C&"()74]F-&"0CL.I""(:-IGT
MP\`3?CQV@ZAI#\\3:(@\AK]&,A5703X"`("3F^81L$YXH1N,]8Q2&4HWD]0'
ML$40OKR489Q('X`(0"R^TO/)\`UU%TDF)WZ<`Y2QF^4RW<Q"]Q(0<X.4@`"B
M+I#+FZ02X")PP".>Y##@WR=!&D1#F$B<R1+H$8)(XSA'"*X'4\^:0KP;`?5X
M7H1R@3_`#J++^!.@J@CCQ6DJ/>J?P4`R\F0#YR!2("1\C?P@#^(HH[[N91SX
MT!>!(JT`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\I--<^-,QI]OF
M3H,UV=H&T/MOSU^=GCE+HSDK;WSUK)[5LWI6S^I9/:MG]:R>U;-Z5L_J63VK
09_6LGF_C^2=/D#]^`'@`````
`
end


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: